PC Fans: Difference between revisions
| Line 130: | Line 130: | ||
** or, fed 3.3V: 680Ω (4.9mA) | ** or, fed 3.3V: 680Ω (4.9mA) | ||
* 24V: 3KΩ (6V, 2mA) | * 24V: 3KΩ (6V, 2mA) | ||
Arduino 5V internal pullup resistors are several tens of thousands of ohms, so they can be used to simplify the circuit (on a 3.3V MCU, you'll need hook up the tachometers to at least a 5V V<sub>CC</sub>, so this won't help you there). You'll then want an RC circuit going to ground, | Arduino 5V internal pullup resistors are several tens of thousands of ohms, so they can be used to simplify the circuit (on a 3.3V MCU, you'll need hook up the tachometers to at least a 5V V<sub>CC</sub>, so this won't help you there). You'll then want an RC circuit going to ground, yielding a [https://en.wikipedia.org/wiki/Low-pass_filter#RC_filter low-pass filter]. Given a time constant RC, a low-pass filter blocks signals over 1/2πRC. Pick something a fair amount above your expected frequency. Let's say your fan maxes out at 3000 RPM. That's 3000 / 60 = 50 RPS. The Hall sensor triggers twice per revolution so you're expecting 100 transitions per second. If you're using a 680Ω resistor on input, and want to pass signals below 500 Hz, a 470 nF capacitor will do the trick: 1/2πRC == 1/2π(.0003196) == 497.98 Hz. The tach will pull the signal low. It's best to detect this via hardware interrupts: | ||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
static _Atomic(uint32_t) LowerFanPulses, UpperFanPulses; | static _Atomic(uint32_t) LowerFanPulses, UpperFanPulses; | ||