'Radio control servo slowdown using PICAXE-08M 'Kevin Goom, 17 October 2005 ' 'PICAXE-08M connections are: ' Leg 1 +5V ' Leg 2 (Serial in) Tie to Ground through 10K resistor ' Leg 3 (In4/Out4) Wiper of 10K potentiometer connected to +5V and ground ' Leg 4 (In3) Pulse input from radio receiver ' Leg 5 (In2/Out2) Pulse output to servo ' Leg 6 (In1/Out1) Mode indicator output '1/2 second flash = no valid signal 'Steady on = pass-through (no servo slowdown) 'Flicker = servo slowdown mode ' Leg 7 (Out0/Serial Out) NC ' Leg 8 Ground symbol Delay=b8 'Name the delay factor symbol PWin=w0 'Name the input pulse length symbol PWout=b2 'Name the output pulse length symbol PWinPrev=b3 'Name the length of the prior input pulse length symbol PWinErr=b6 'Name the difference between input and output pulse lengths symbol skip=b4 'Name the counter for skipping "Delay" times restart: Skip=0 high 1 servo 2,135 'Center the servo initially and on input pulse loss Pause 500 'Wait 1/2 second initially toggle 1 readadc 4,Delay 'Read the voltage from the delay potentiometer pulsin 3,1,PWin 'Measure the input pulse width initially if PWin<75 or PWin>225 then restart 'Go back if no valid input detected high 1 low 2 'Stop the sevo command if valid input detected PWinPrev=PWin 'Initially set the prior pulse width to current pulse width if Delay<5 then StraightThru 'If delay pot set near zero skip slowdown routines Delay=Delay/21 'Set delay to 0 (1.5s stop-to-stop) to 12 (20s stop-to-stop) PWout=PWin 'Set output pulse to input pulse initially loop: toggle 1 PWinPrev=PWin 'Reset the prior pulse width pulsin 3,1,PWin 'Measure the input pulse if PWin<75 or PWin>225 then restart 'Go back if no valid input detected PwinErr=PWin-PWOut if PWinErr<2 or PWinErr>254 then StayPut 'Add 2 units of hysteresis if PWoutPWin then MoveDown MoveDown: 'Routine to decrease the output pulse width if skip>=Delay then Skip1 'Loop to delay change to Delay x 20ms input periods Skip=Skip+1 goto Skip2 Skip1: Skip=0 PWout=PWout-1 Skip2: pulsout 2,PWout 'Send the output pulse to the servo goto loop 'Return to re-measure the input pulse MoveUp: 'Routine to increase the output pulse width if skip>=Delay then Skip3 'Loop to delay change to Delay x 20ms input periods Skip=Skip+1 goto Skip4 Skip3: Skip=0 PWout=PWout+1 Skip4: pulsout 2,PWout 'Send the output pulse to the servo goto loop 'Return to re-measure the input pulse StayPut: 'Routine to send the same output pulse pulsout 2,PWout goto loop 'Return to re-measure the input pulse StraightThru: pulsin 3,1,PWin if PWin<75 or PWin>225 then restart 'Go back if no valid input detected PwinErr=PWin-PWinPrev if PWinErr<2 or PWinErr>254 then Stay 'Add 2 units of hysteresis pulsout 2,PWin PWinPrev=PWin goto StraightThru: 'Return to re-measure the input pulse Stay: pulsout 2,PWinPrev 'Set output pulse to input pulse goto StraightThru: 'Return to re-measure the input pulse