Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Disclaimer:
- Use it as it is, completely and entirely at YOUR OWN RISK.
- YOU CAN DAMAGE YOUR HARDWARE WITHOUT PROPER COOLING, LEAVE THE THERMAL SHUTDOWN ON!
- Generic CPU fan tachometer signal emulator for 4 wire pwm fans.
- Tuned for Delta AFB1212SH, 0 - 3400 RPM (found in HP Microserver Gen 8)
- The fan will send 2 pulses per revolution, with a duration of 1/4 rev.
- -> 1 RPM -> 1 rotation / 60 seconds -> 1 Hz
- 2 pulses per rotation -> 2 Hz signal freq. -> 500 miliseconds per pulse ( 250ms UP and 250ms DOWN )
- -> 3400 RPN -> 3400 rotations / 60 seconds -> ~56.7 Hz
- 2 pulses per rotation -> 2x56.7 -> ~113.4 Hz -> ~8.8 miliseconds per pulse (4.4ms UP and 4.4ms DOWN )
- -> 1000 RPM -> 1000 rotations / 60 seconds -> 16.7 Hz
- 4 pulses per rotation -> 4x16.7 -> ~66.7 Hz -> ~15 milliseconds per pulse(7.5 UP and 7.5 DOWN)
- -> 14000RPM -> 14000 rotations / 60 seconds -> ~233.3 Hz
- 4 pulses per rotation -> 4x233.3 -> ~933.2 Hz -> 1.1 milliseconds per pulse( 0.55 UP and 0.55 DOWN )
- After computing the above ( min, max rpm ) put them in the voltage to pulse duration mapping in the loop() function
- pFreq = map(Voltage, 0, 1023, 500.0, 8.8235);
- Volatage = voltage read from the motherboard pwm driving pin by the ADC
- (10 bit resolution, means 0-5V will return 0-1023)
- Voltage range - 0, 1023
- Ms pulse range - 500.0 - 8.8235
- Hardware:
- Tested on Arduino Pro Mini 5V/16Mhz - ( ~10$)
- Programmer - FTDI Basic Breakout - 5V - ( ~15$)
- Software:
- Adruino IDE 1.0.5-r2
- Arduino Timer Library - http://playground.arduino.cc/Code/Timer#.UxdUPfS1a7M
- Pin A0 connected to the motherboard PWM pin
- Pin 3 connected to the tach. signal on the motherboard
- GND to GNDs (see fan connector gnd loop)
- */
- // Timer lib
- #include "Timer.h";
- // Timer
- Timer t;
- // Pulse output pin
- int pPin = 3;
- // Pulse freq.
- float pFreq;
- // Voltage measure pin
- int iPin = A0;
- // Voltage
- int Voltage;
- // Led pin - alive blink
- int ledPin = 13;
- void setup()
- {
- //Initial config
- //IO Pins
- pinMode(ledPin, OUTPUT);
- pinMode(pPin, OUTPUT);
- digitalWrite(pPin, LOW);
- pinMode(iPin, INPUT);
- //Timers
- t.every(pFreq, sendPulse);
- t.every(100, readIV);
- t.oscillate(ledPin,1500,HIGH);
- }
- void loop()
- {
- // Map V to Pulse Freq
- //pFreq = map(Voltage, 0, 1023, 500.0, 8.8235);
- pFreq = map(Voltage, 0, 1023, 16.7, 1.1);
- // Update timers
- t.update();
- }
- void sendPulse()
- {
- // Half period on
- digitalWrite(pPin, HIGH);
- delay(pFreq/2);
- // Half period off
- digitalWrite(pPin, LOW);
- delay(pFreq/2);
- }
- void readIV()
- {
- //Analog voltage read - little bit imprecise but works
- Voltage = analogRead(iPin);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement