PWM: Timer0 Fast PWM Mode 7

Reference: http://darcy.rsgc.on.ca/ACES/Datasheets/ATMEGA328P.pdf#page=93
Purpose: A low-level PWM replacement for the analogWrite() function is required to control the fan speed.

Filename: FastPWMFan.S

Just like servo motors, many 12VDC desktop computer fans require a specific PWM signal to operate successfully. The datasheet for the Sunon unit ACES have used in the past indicates at frequency of 25 kHz.

If Timer/Counter1 is used as a scheduler, Timer/Counter 0 can be used to generate this required PWM signal.

As trials will reveal, duplicating the PWM characteristics of the simple Arduino analogWrite function on pins 5 and 6 (OC0A and OC0B) will not work as they offer only 978 Hz signal. See capture below, left. We need to dig deeper.

Of the 8 Timer/Counter0 Waveform Generation Modes presented in the Register Summary datasheet, there IS a Fast PWM Mode that can be configured to deliver the 25 kHz signal. The capture below right reflects the signal required.

This signal will be placed on the PWM wire (almost always blue) of the DC Computer fan.

980 Hz (AnalogWrite: No good) 25 kHz (Timer/Counter0 Mode 7)

Example: Sunon MFC0251V2-1Q02U-S99