Shop OBEX P1 Docs P2 Docs Learn Events
counting the number of pulsout command — Parallax Forums

counting the number of pulsout command

ktkootaktkoota Posts: 3
edited 2009-12-22 06:46 in Robotics
hello,
how can I count the number of pulseout command?
for example:
FOR counter· = 1 TO 570
··· PULSOUT 13,850
··· PULSOUT 12,650
··· PAUSE 20
NEXT

check how many times did the pulseout command
got executed in 10 second , Iam trying to find the rpm

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-20 17:44
    You can't directly time things. The PULSOUT statements take roughly 2us*850 + 2us*650 = 3ms. The PAUSE takes 20ms. There's a few hundred microseconds of overhead for the FOR / NEXT, PULSOUT, and PAUSE. You can find a discussion of this on www.emesystems.com. Click on the "app-notes" link near the bottom of the page. Each time through your loop (FOR/NEXT), your program will take roughly 23-24ms.

    Note that this won't give you RPM. For that you'll have to use something like the BoeBot wheel encoder (www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/80/Default.aspx?txtSearch=wheel+encoder). The pulse width only roughly controls the servo motor speed. It's not calibrated in any way and the speed depends on the mechanical load on the motor and the voltage supplied by the motor's power source.
  • ktkootaktkoota Posts: 3
    edited 2009-12-20 19:51
    ok,
    how can I find the ditance that it has moved forword.. how can I map the pulsouts to the distance?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-20 20:07
    You can't do it accurately without the wheel encoder I mentioned. You can approximate the distance by using the number of loops (FOR/NEXT) that your program has done and by calibrating you program and BoeBot. For example, you could set the number of loops that your program does to 100, run the program, and measure the distance that each wheel has gone. That would be your distance per counts of 100. If you used a count of 200, the BoeBot should go roughly twice as far. There'll be some inaccuracies and slippage and you should repeat your measuring "experiment" several times to see how much the distance estimate varies.
  • ktkootaktkoota Posts: 3
    edited 2009-12-22 06:46
    thanks alot ,what I need is just estimation for the distance,
    can you please explain your words in terms of code..

    another question: can I measur the distance using estimating·rpm.. let me tell you my estimation:·keep the wheel moving and count the number of turns it made in (say) 10 seconds;·let the result be x... during that same time, check how many times did the pulseout command got executed; let the result be y...hence actual rpm would be a=x*6 and actual number of pulseouts will be b=y*6...·hence for any number of pulseouts (c) the rpm would be (a/b)*c...

    Post Edited (ktkoota) : 12/22/2009 6:56:59 AM GMT
Sign In or Register to comment.