;********************************************************************************* ; gpspeed-test-motor GpSpeed test motor's ; Louse@RotaryRacer ;********************************************************************************* ; ; This is a simple test of the motor output PWM totherner with analogue input I0 ; which should be connected to a throttle. It should switch the output MOSFET's ; on and off at 20kHz with a duty cycle matching the analogue input voltage. ; ; GpSpeed pins are: ; B.1 LED ; C.2 Motor PWM ; C.1 Fan PWM ; A.0 Analogue Input 0, I0, throttle ; A.1 Analogue Input 1, I1, misc ; A.2 Analogue Input 2, Voltage measurement ; A.3 Analogue Input 3, Current measurement (Hall effect) ; B.4 Analogue/Digital Input, I2 ; ; B.2 Analogue Input 8, Current measurement (Mosfet) ; B.0 Error, error from Motor PWM ; C.3 I2C Clk ; C.4 I2c Dat ; C.0 User 0, I2c Int ; B.3 User 1 ; C.6 SER1 TX ; C.7 SER1 RX ; ; PWM range at 20kHz: 0 - 400 ; init: let adcsetup = %000000000000111 ; Initialises ADC inputs pwmout C.2, 99, 0 ; Initialises PWM hardware to 20khz gloop: readadc A.0,b1 ; Reads the ADC throttle input. 0 -255 w1 = b1 * 2 ; Scale to 0 to 510 pwmduty C.2, w1 ; Sets the Motor PWM duty cycle. 0 - 400 pause 100 ; 100ms delay goto gloop