Shop OBEX P1 Docs P2 Docs Learn Events
HELPP i need this by tomorrow? 100% BEGINNER? — Parallax Forums

HELPP i need this by tomorrow? 100% BEGINNER?

edited 2012-01-20 07:10 in General Discussion
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.

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2012-01-17 14:49
    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.
  • edited 2012-01-17 15:11
    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 DegnDuane Degn Posts: 10,588
    edited 2012-01-17 15:14
    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.

    attachment.php?attachmentid=78421&d=1297987572
  • edited 2012-01-17 15:23
    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 DegnDuane Degn Posts: 10,588
    edited 2012-01-17 15:28
    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.
  • FranklinFranklin Posts: 4,747
    edited 2012-01-17 16:28
    122 = 3; x = 36
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-17 16:37
    Franklin wrote: »
    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
  • SRLMSRLM Posts: 5,045
    edited 2012-01-17 20:39
    As for the not stopping part, be sure to take a look at the difference between BYTE and WORD variable types.
  • edited 2012-01-19 16:45
    Duane Degn wrote: »
    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 :)
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-01-19 17:18
    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 SchwabeBeau Schwabe Posts: 6,569
    edited 2012-01-20 07:10
    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.
Sign In or Register to comment.