;********************************************************************************* ; gpspeed-test-fan GpSpeed test fan ; Louse@RotaryRacer ;********************************************************************************* ; ; This is a simple test of the fan output PWM totherner with analogue input I0 ; which should be connected to a throttle. It should switch the FAN MOSFET ; on and off at 20kHz with a duty cycle matching the analogue input voltage. ; This will result in a DC voltage to the fans (as the FAN MOSFET output is ; filtered). ; ; 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, Votage measurement ; A.3 Analogue Input 3, Current measurement (Hall effect) ; B.4 Analogue/Digital Input, I2 ; ; B.2 Analogue Input 8, Current measurement (Raw) ; 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 ; symbol throttle = w1 ; Set a symbol name for throttle variable flash: let adcsetup = %000000000000111 ; Initialises ADC inputs pwmout C.1, 99, 0 ; Initialises PWM hardware to 20khz, duty cycle 0% gloop: readadc10 A.0, throttle ; Reads the ADC throttle input: 0 - 1023 throttle = throttle / 2 pwmduty C.1, throttle ; Sets the Fan PWM duty cycle to: 0 - 511 (Range is actualy 0 - 400) pause 100 ; 100ms delay goto gloop