How long does PULSIN take?
Armored Cars
Posts: 172
When in manual mode my car is really jerky, how long does PULSIN take so I can adjust PAUSE accordingly?
MANUAL:
··· DO
····· PULSIN 2, 1, mansteer
····· PULSIN 3, 1, mandrive
····· IF mansteer<400 THEN GOFWD
····· PULSOUT 0, mansteer
····· PULSOUT 1, mandrive
····· PAUSE 20
··· LOOP
MANUAL:
··· DO
····· PULSIN 2, 1, mansteer
····· PULSIN 3, 1, mandrive
····· IF mansteer<400 THEN GOFWD
····· PULSOUT 0, mansteer
····· PULSOUT 1, mandrive
····· PAUSE 20
··· LOOP
Comments
If you are running Pbasic...hit F1 and look up PULSIN.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
http://www.geocities.com/paulsopenstage
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
And 140 mSec is like 1/10 second. I believe you can 'percieve' that short a time -- but not enough to say "is much longer than how fast my car was jerking".
One way to minimize this would be to only do a single PULSIN per loop. Thus:
CheckMan VAR BIT
MANUAL:
· DO
··· CheckMan = ~CheckMan
··· IF CheckMan THEN
····· PULSIN 2, 1, mansteer
····· PULSIN 2, 1, mansteer
··· ELSE
····· PULSIN 3, 1, mandrive
····· PULSIN 3, 1, mandrive
··· ENDIF
··· IF mansteer<400 THEN GOFWD
··· PULSOUT 0, mansteer
··· PULSOUT 1, mandrive
···' ·PAUSE 20
· LOOP
Now, if you are driving pins 2 and 3 with the output of a Servo reciever, it is probably repeating at a 20 mSec rate -- but you don't know when you start to sample it.· It could be 40 mSec worst case.· If the Servo pulse has already started before you start to sample it, you may read it as 'too short'.· Outputting a 'too short' servo pulse could make you jerky.
One solution could be to read the servo signal twice, and take the second signal as the one you'll keep.· That should·guarantee that the second signal gets both the start·AND end of the pulse.· Then you probably don't need a 'pause' at all, because reading the servo signal will take that much time.
OK, I've now updated the code above to do the 'read servo input signal twice'.· You still want to read only steering, or only drive, each time through the loop, but you can update both servos each time through the loop.· This should work.
Post Edited (allanlane5) : 12/14/2004 8:36:46 PM GMT
Shawn Lowe
After about a minute of using the code
MANUAL:
DO
PULSIN 2, 1, mansteer
PULSIN 3, 1, mandrive
IF mansteer<400 THEN GOFWD
PULSOUT 0, mansteer
PULSOUT 1, mandrive
LOOP
mandrive will start to equal mansteer. I didn t have enough wires to run anything to pin 3, but after awhile it starts copying pin 2.
What this code is doing is taking the pulse from an RC reciever and sending it to the servos.
And WHAT DO YOU MEAN you are doing a 'pulsin' on a pin with nothing connected? That's going to time-out every time! That's a 131 mSec delay in your program every loop. If you HAVE no input signal, don't try to READ an input signal.
At least tie the pin to ground with a 22 Kohm resistor, to give yourself a 'soft' ground signal.