PDA

View Full Version : HELPP i need this by tomorrow? 100% BEGINNER?

illuminatedsparks
01-17-2012, 09:40 PM
okay so we're doing some parallax robotics thing for school. I am TOTALLY unexperienced in robotics. We're using a boe-bot. What do I write in the program to make the boebot run straight for 36 seconds, and then stop? I need help finding out the duration of the FOR counter thingy. It only works sometimes, and sometimes it doesn't stop.

So the main problem is, is that whatever I write in the boebot doesn't stop at ALL. THis is what I write (ot including the other stuff). This is slightly unaaccurate

FOR counter = 1 to 1500 <<THIS PART i have no idea what to type for it to run 36 seconds

And for p12 and p13 i write in the numbers that make my boebot go straight, and at the end I write "PAUSE 20".
My main concern is what duration I put in for the FOR counter to make my boebot run for 36 seconds, and then STOP

I'm really unexperienced so sorry if i don't make sense.

stamptrol
01-17-2012, 09:49 PM
You'll have to give us more details in order to help you. Also, we're not going to do your homework for you.

Its hard to believe this assignment was just dumped on you with one days notice.

So, you want it to run for 36 seconds. First tell us how long it runs with your existing program. After that, its simple ratio to adjust it for 36 seconds.

You can also look in the Help file of the programming environment to read up on the FOR-NEXT and PAUSE command.

Good luck.

illuminatedsparks
01-17-2012, 10:11 PM
I don't know what you mean by how long it runs for my existing program.
But if you mean this, when I put if on FOR counter = 1 to 122, it runs for 3 seconds and then stops,if that makes any sense.

Duane Degn
01-17-2012, 10:14 PM
Here's a hint. The "PAUSE 20" command pauses the stamp for 20 milliseconds. That's 0.02 seconds or 1/50 of a second.

You can use these numbers to get close to the number you need. As Tom said, you could time how long it runs with your current code (which looks like it shouldn't be too far off) and then compensate for the difference in actual time taken and your target time.

There might be a problem somewhere else in your code. Use this link to learn how to post code in the forum.

illuminatedsparks
01-17-2012, 10:23 PM
I would post code, but all of my stuff is at school unfortuantely
But I tried FOR counter = 1 to 122, and I think it ran for like 3 seconds, if that helps?

Duane Degn
01-17-2012, 10:28 PM
It looks like you're on the right track.

Have you done the math yet to get an estimate of how many loops it will take?

Don't let school take the fun out of learning.

Franklin
01-17-2012, 11:28 PM
122 = 3; x = 36

Duane Degn
01-17-2012, 11:37 PM
122 = 3; x = 36

If the 3 seconds was accurate you'd use two equations and two unknowns.

122 * z = 3
and
x * z = 36

SRLM
01-18-2012, 03:39 AM
As for the not stopping part, be sure to take a look at the difference between BYTE and WORD variable types.

illuminatedsparks
01-19-2012, 11:45 PM
If the 3 seconds was accurate you'd use two equations and two unknowns.

122 * z = 3
and
x * z = 36

thanks but i'm presenting tomorrow and with a help of a friend and some cheating, i'll probably get a 3 :)

mindrobots
01-20-2012, 12:18 AM
thanks but i'm presenting tomorrow and with a help of a friend and some cheating, i'll probably get a 3 :)

That 3 ought to make everyone so proud!!

Beau Schwabe (Parallax)
01-20-2012, 02:10 PM
3 seconds is about right ... it's already been said, but I'll state the obvious again.

20ms x 122 loops = 2.44 seconds ... with a little over head that could be close to 3 seconds.

without looking at your program though it is difficult to tell.

in reality that 20ms is likely to range from 21ms to 23ms plus some overhead depending on the value of the pulse you are sending to the servo.

20ms Pause + (1ms to 2ms servo pulse) + program overhead

So... 2.56 seconds to 2.81 seconds plus any amount of overhead.... best thing to do is actually time it to figure out the unknown time of overhead so you can factor that back in. For better accuracy, set your loop grossly high.... example: 2440 for about 1 minute or 12200 for about 5 minutes and keep track of the value down to a second with a stopwatch.

Then take your loop value (2440 or 12200 or whatever you decide to use) and divide that by the number of seconds you determined with a stop watch. That will give you a better representation of how many loops per second you have. Finally, take your loops per second and multiply that by your 36 seconds you wish to run the servo for.