I am making a board that is using the ATmega32U4 is based of the Leonardo.
The board will control some leds (PWM) and read some fan RPM (hall sensor).
Wanted to confirm there are no problems with connecting the FAN_A, FAN_B & FAN_C lines in the following picture. You can see the full picture here: http://i.imgur.com/YQvoh.png. I intend to use timer 0, 1 & 2 to count the pulses coming from the hall sensor.
The pull-up in the HWB is ‘do not stuff’. I just put it there just so I can have a pad for debugging.
Thanks in advance!
http://i.imgur.com/YQvoh.png
What voltage are the fans running on? I’ve forgotten what type of output fans provide for RPM (open collector, 0 to +5V etc.), but you need to make sure your micro won’t be damaged.
EDIT: it seems that many fans have open-collector outputs for tach, so you should probably include some pullup resistors on the board, unless you’re happy to use the weak pullups in the micro.
Whenever I connect a microcontroller pin to the “outside world” (i.e., anything not on the same PCB), I like to provide some protection against damage from ESD & misconnection. At the very least, this could be an inline resistor (say 10K), which relies on the internal protection diodes in the microcontroller to clamp any nasties. Better still, use a “back to back” Schottky diode on the input (e.g. BAT54S) to do the work instead of the internal diodes.
Thanks for the reply MichaelN:
My fans are running on 12V, and I am OK with the weak pull ups on the uC. The BAT54S is a good idea - thanks.
Will the pins that can connected to the fans have any problem with counting pulses? There is timer 1 & timer 2 that I plan on using, but I am not sure if I can use timer 0. If the timers do not work, I plan on using interrupts. I am mostly concerned about this, and would like another set of eyes on it.
I don’t think the connection to PD7 will do what you want, but this would take a more detailed read of the datasheet to confirm. Also, do you really want to use 3 timers just to measure these fan pulses? Normally you’d dedicate (at most) one timer for this, and connect the fans to pin-change interrupt pins. The ISR to deal with these interrupts will be very simple.
Since you have some spare pins, I’d suggest connecting each fans to BOTH a pin change pin and timer input, so you can chose later in software how you want to handle it. You might need to move some pin functions around (I’m guessing the LED outputs don’t need to use interrupt pins, for example).