Saturday, January 30, 2016

Arduino - Fan RPM measurement using internal hall effect sensor (Hardware Interrupts and LCD)

I needed to measure rotational speed in RPM for one modified computer 3 pin fan with inbuilt Hall effect sensor.

This project gives quick intro to-

1) Using Interrupts of arduino boards (here arduino Due)
2) Interfacing Hall effect sensor of fan
3) Interfacing and displaying real time information on LCD display (here 16 x 2)
4) Implement basic logic in programming

There are many ways of measuring speed, using IR sensor, Photo diode, HES etc. 
The computer fans have internal hall effect sensor (HES) that can be used to pick up the ticks per revolution of rotor. The measurement algorithm can be also varied depending upon the required accuracy and response time. I am measuring fan speed approx in 1 sec interval using basic microcontroller interrupt driven algorithm, giving acurracy of few 10s or RPM, something I needed for my other project.

Hall effect sensor working principle (Source of image)

Hall effect sensor (HES) works on the principle of interaction of magnetic field with electrons flowing in the conductor and subsequent generation of secondary voltage known as Hall voltage. Read more here.

In three pin fans with internal hall effect sensor, generally yellow colored wire is output of HES. Most of the time it requires external pull-up resistor of few kohm values depending on supply voltage. Instead of external resistor, internal pull-up resistor of our arduino board pins can be used. digitalWrite(pinno, HIGH); in setup() function enables this internal pull-up resistor. With this HES output wire can be directly connected to interrupt pin (here pin 12) without using an external 10kohm pull-up resistor. I have used external pull-up resistor.

With every rotation of rotor, depending on type of fan and number of magnets attached to rotor, with every rotation of rotor, we get 1, 2 or 4 ticks as output signal from HES. We will pick up these ticks by interrupting our arduino program using "hardware interrupts". Interrupts help in letting our arduino do its regular job until some signal is received at interrupt pins. This lets us use arduino perform other tasks while waiting for signal at interrupt pins. 

I have used a RGB LED to provide quick idea about speed range, the LCD displays actual speed in RPM, values updated every second.

Code/Sketch is shown at the end of video or on github page here

Bill of materials:-

1) Arduino due board from Ali-express
2) Resistors - 10k and 470 ohm  (you can use any other resistors in similar ranges)
3) PC fan or any other motor with inbuilt hall effect sensor
4) LCD display with I2C interface  ( you can use parallel LCDs too, but pinout and code needs to be slightly modified)
About installing I2CLibrary and getting I2C address, check my video - 
5) Power supply as per used fan/motor  (here it is 12V DC)
6) 3 LEDs or single RGB LED, to use as optical indicator of fan RPM range

In next project i will interface OLED display instead of LCD and try to modify code for faster update and higher accuracy of RPM....

Thanks to -  for starting code