Trying to understand FEQOUT
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
for example:
check sensors
select/case
move motors
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
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
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