Lost treasures
Disassembling old electronics pieces can be lot of fun. Sometimes one can find small treasures. I will start a series of posts with my findings. This time is the turn of a PC cooling fan. On the case I've found the model code: HY45J-05A-831. The manufacturer is SEPA. The are also minimal specs:
DC 5V
0.16A
Here is a picture of the fan.
Surfing a little bit over the internet I've found a possible the pin-out:
RED | = +5V |
BLACK | = GND |
YELLOW | = Rotation sense |
I've tested it and it is correct. Test circuit and program are below.
The test circuit
In the library of components coming with Fritzing I couldn't find a fan cooler. Hence in the picture of the circuit I inserted a generic servo motor. Cables colors are:
red = +5V
black = GND
yellow = connection between yellow cable on fan and resistor.
The test program
Here is a small test program that I modified from one found over the internet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /********************************************************************************* AUTHOR : Enrico Formenti LICENCE : MIT Licence REV: 9/11/2013 *********************************************************************************/ uint8_t _RotationSensePin = 2; // digital pin to which sense cable is // connected uint32_t pulsesNumber; uint32_t lastRPM; uint32_t rpm; void senseRotation(void) { ++pulsesNumber; } void setup(void) { pulsesNumber=0; lastRPM=0; Serial.begin(57600); pinMode(_RotationSensePin, INPUT); digitalWrite(_RotationSensePin, HIGH); // activate pull-up resistors attachInterrupt(0, senseRotation, RISING); } void loop(void) { pulsesNumber=0; sei(); delay(600); cli(); // formula (measure interval in millisec)/pulses=1000*60/rpm rpm = 10*pulsesNumber; rpm = (rpm+lastRPM)>>1; // sum divided by 2 lastRPM = rpm; Serial.print("RPM = "); Serial.println(rpm, DEC); } |
How the program works
The "Rotation Sense" pin of the fan is attached to Arduino's digital pin 2. To this pin it is also attached Arduino's interrupt routine 0. As all Arduino's interrupts, the interrupt occurs when the current is either RAISING (going from 0V to +5V) or FALLING (going from +5V to 0V).
Therefore the idea is to attach to the interrupt 0 routine a procedure that performs updates of a pulse counter. Main loop computes RPM (rotations per minute) and print them on the serial monitor of Arduino. Pay attention that the communication speed is set at 57600 bauds.
The formula for computing RPM is easy:
RPM = 60 * 1000 * pulses/ interval
where "interval" is the length of the interval during which the pulses are counted, expressed in milli-seconds. Remark that due to "interferences" with other internal operations with Arduino the raise of interrupt 0 is inaccurate. Hence, RPM computations are also inaccurate. In order to partially overcome these inaccuracies, the current value of RPM is smoothed using the last measurement of RPM (aka we take the mean of the two values).
Enjoy!
Enjoy!
No comments :
Post a Comment