Xypher
11-18-2009, 11:23 PM
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?
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.
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.