Following from the previous log, the initial schematic layout for a 'missing pulse detector' based circuit for determining the power state of the Compute Module 5 to enable/disable the fan is shown below:

Note: in the below description, 'tachometer line' is used to refer to the TACH_PI signal, which is the tachometer input to the Raspberry Pi. The TACH_FAN signal is the open collector tachometer output of the fan, which I try to refer to as such (e.g. Fan tachometer output)
The circuit is a fairly simple one, relying on an LM393 comparator to monitor the voltage across capacitor C2. A resistor network slowly charges this capacitor, however it is rapidly discharged by MOSFET Q2 whenever the tachometer line is high. While the Pi is running, the fan produces a square wave on the tachometer line, which regularly discharges C2 so the threshold to disable the fan is never reached.
After shutting the Pi down the tachometer line is no longer being pulled up, and hence Q2 cannot discharge the timing capacitor C2. After reaching a threshold of 60% of VCC (set by R11 and R12), the comparator U1B disables the output MOSFET Q1, turning the fan off.
MOSFET Q3 acts to buffer and invert the fan tachometer output before it is fed back to the Compute Module 5. This is required as some fans may have a built-in pull-up resistor on their tachometer output, which could interfere with measuring whether the tachometer line is being pulled up by the Pi. Since the tachometer signal is a simple square wave and fan speed is measured proportional to its frequency, the fact that Q3 inverts the signal should not matter.
As the fan being controlled is of PWM type, it is possible for the Raspberry Pi to stop the fan completely by driving the PWM signal low, and as a result the tachometer signal produced by the fan becomes a constant voltage. This causes a problem should the fan stop in a position where the tachometer is high, as Q3 would be stuck 'on', driving the tachometer line to ground. With the tachometer signal stuck low, C2 will be allowed to charge up until the module disables the fan, even through the Compute Module hasn't been shutdown.
To solve this, a second timing capacitor and comparator, C1 and U1A are used. C1 is discharged when the fan tachometer output is low (and hence Q3 is 'off') through diode D1. If the fan is stuck with its tachometer output high, C1 will begin to charge up. Once C1 reaches 60% of VCC, comparator U1A disables its open collector output, preventing Q3 from driving the tachometer line low, so that it may be pulled high by the Compute Modules pull-up, should it still be running. This additional timing capacitor is charged at a faster rate than capacitor C2, so should the fan become locked, the tachometer line will be prevented from being driven low before the power to the fan is disabled, ensuring the fan remains powered throughout.
The discharge and gate resistor values of 6.8k were chosen based on the Noctua fan whitepaper, which suggests a maximum pull-up current of 5mA connected to the fan tachometer output for 5V and 12V fans (p.3). In this case, the peak current occurs as a combination of R6 and R10 (6.8k) and R2 and R3 (100k). Assuming the module is being powered at 12V (instead of the 5V provided by the CM5 IO Board), the maximum collector current drawn through the fan tachometer is ~3.77mA.
A couple of additional features in the circuit include diode D2, which acts as a flyback diode if you want to use the module to drive any reactive loads other than a brushless PC fan, such as DC motors, solenoids, or relays; and (unpopulated) pin header J3, which conforms to the common 4-pin desktop fan pinout (Noctua fan whitepaper, p.3), allowing regular PC fan to be used with the module instead.
Finally, if you looked closely at the schematic, you might have noticed a very simple mistake that means this version won't work as expected - The output transistor Q1 is the wrong way around, so even when the fan is 'off', current will still be allowed to flow through the body diode!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.