'''''''''''''''''''''''''''' 'PICAXE-08M E-SCOOTER CODE ' ' 21-6-09 ' '''''''''''''''''''''''''''' FirstPowerUp: 'This is so the scooter doesn't bolt from under you if the throttle is Gosub ReadThrottle 'on when powering up! If W1 > 100 then Goto FirstPowerUp Chopper: Gosub ReadThrottle 'Reads the Hall Effect throttle value. (0 - 1023 in theory! More like 15 to 995) If W1 < 25 then Gosub ZeroThrottle 'Zero out the throttle value if it's already a very low value. Pwmout 2, 250, W1 'This is where it all happens. Poke $12, $06 'Pokes the TCON register to prescale the PWN by 16:1 ratio. Now pulses down to 250Hz. Goto Chopper ReadThrottle: Readadc10 1, W1 'Read the throttle value and put it into word varible "W1" W1 = W1 - 20 'Trying to scale the throttle as these Hall Effect throttles are not perfect! W1 = W1 * 20/19 If W1 > 1023 then Gosub MaxThrottle 'Hold the value to 1023 if it goes over 1023. Return ZeroThrottle: 'Zero out the throttle value to zero. W1 = 0 Return MaxThrottle: 'Maximin throttle value to be held at 1023. W1 = 1023 Return