Help needed to "shorten" time between pulses
Xypher
Posts: 10
I am writing a program to control a 4 Channel r/c toy.
However, the time taken for each cycle of 4 channels is too slow. The receiver needs to be updated every 20ms. 50 times a second. However each full PPM output takes 75-100ms at least. Partly due to RCTIME function. Is there anyway to control it more effectively? At the current level, its impossible to control any r/c toy I think.
Would PWMPAL be the best tool for this job?
Thanks.
However, the time taken for each cycle of 4 channels is too slow. The receiver needs to be updated every 20ms. 50 times a second. However each full PPM output takes 75-100ms at least. Partly due to RCTIME function. Is there anyway to control it more effectively? At the current level, its impossible to control any r/c toy I think.
Would PWMPAL be the best tool for this job?
Somebody said...
' {$STAMP BS2}
' {$PBASIC 2.5}
' Control servos with accelerometer
rawx VAR Word
rawy VAR Word
x VAR Word
y VAR Word
time VAR Word
throttle VAR Word
header VAR Word
DO
PULSIN 8, 1, rawx 'data from accelerometer
PULSIN 9, 1, rawy 'data from accelerometer
y =5 * rawy / 12 - 290 'formula to convert raw data to pulse to control servos
x =5 * rawx / 12 - 290 'formula to convert raw data to pulse to control servos
HIGH 8 'receive data from potentiometer to control motor
RCTIME 8, 1, time
throttle = 10 * time + 490 'convert data to pulse
PULSOUT 7, x
PULSOUT 7, x
PULSOUT 7, throttle
PULSOUT 7, y
header = 10000 - x - x - y - throttle 'calculate the pulse require to fill up remaining 20ms
PULSOUT 7, header 'pulse to reset
LOOP
Thanks.
Comments
header = 10000 -x - x - throttle - y - rawx - rawy - time
You also need to check for no time left like:
IF header > 0 THEN PULSOUT 7, 2*header
Is there any reason you need to read all three sensor outputs in every transmit cycle? Perhaps you could save time by rotating through them, reading just one per cycle.
-Phil
Phil's suggestion is the way to do it in a single threaded environment. Basically you have an Index counter set to count to "N" and recycle...
Pseudo Code
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
However, due to RC TIME, the pulse is still too long for my receiver. Is there any other way to control the motor without RC TIME?
May I know why this kind of waveform appears instead of the usual pulsout waveform?
I used this program to test the waveform but it still looks wrong.
Thanks!
-Phil