Shop OBEX P1 Docs P2 Docs Learn Events
Trying to understand FEQOUT — Parallax Forums

Trying to understand FEQOUT

jsliljslil Posts: 11
edited 2008-03-27 13:19 in Robotics
What exactly does the·PAUSE command after FREQOUT do?· If I am trying to navigate using a bs2 and need to run some switch statements or if/then statements, does that not take time to process and work the same as a pause command?

for example:
check sensors
select/case
move motors

Comments

  • ZootZoot Posts: 2,227
    edited 2008-03-26 19:47
    PAUSE after what kind of FREQOUT? Can you post an example of the code you are talking about?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • jsliljslil Posts: 11
    edited 2008-03-27 03:57
    I apologize.· My question is about the PULSOUT command.· I have gotten the two confused more than once now.blush.gif

    Back to my original question.· In a small snipet it is suggested that a PAUSE command be given after a PULSOUT ie:


    DO

    PULSOUT 12, 750

    PAUSE 20

    LOOP


    Is it possible that the conditions in the program take longer than 20 ms to compute that would make the PAUSE command unnecessary?· For example:


    DO

    GOSUB CheckSensors

    SELECT SensorState

    · CASE SenseRight

    ··· RightSpd =·· 0

    ··· LeftSpd· = 100

    · CASE SenseLeft

    ··· RightSpd = 100

    ··· LeftSpd· =··· 0

    · Case SenseCenter

    ··· RightSpd = 100

    ··· LeftSpd· = 100

    ENDSELECT

    PULSOUT 12, 750 - RightSpd

    PULSOUT 13, 750 + LeftSpd

    LOOP

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-27 04:18
    The PULSOUT / PAUSE combination has to do with how servo motors work. The PULSOUT provides a control pulse for the servo whose width (set by the second expression in the PULSOUT statement) ranges usually from 1000 microseconds to 2000 microseconds. These pulses need to be repeated about 50 times a second, hence the PAUSE of 20 milliseconds.
  • ZootZoot Posts: 2,227
    edited 2008-03-27 05:25
    Somebody said...
    Is it possible that the conditions in the program take longer than 20 ms to compute that would make the PAUSE command unnecessary?

    Yes. The "padding" in your main loop (if any is required) should bring the total time of the main loop to *about* 20ms or so. Sometimes this is a matter of experimentation. Every instruction (Pbasic statement) takes some time. Some programs (like the "Go to and Find Closest Object" program in the Stamps in Class Forum) even change the padding dynamically depending on other parts of the main loop.

    For example, if you PULSIN to measure the sonar distance from a Ping))), the closer the object, the shorter the pulse, so the quicker the next servo pulse out would come around. Go to and Find Closest Object changes the padding of the servo pulse "pause" up and down to match the distance pulse from the sonar. It's not perfect and precise, but it does get the servo out pulses much more consistently coming at around 20ms.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • jsliljslil Posts: 11
    edited 2008-03-27 13:19
    Thank you for your information. And your patience.
Sign In or Register to comment.