Hi everybody.
I am new to Arduino programming.
I'm trying to get a square wave signal with a variable frequency of 1-200Hz on pin OC1A with Timer1.
I found several threads here on the forum and blogs on the Internet, but the device does not work.
The device is a PWM fan emulator. And I want to send a RPM sensor signal to the motherboard.
I doesn't have oscilloscopes.
I wrote the following example code for setting the timer and pin out.
I ask knowledgeable people to look at this and check where I went wrong.
I myself can not do it yet, I do not understand how it is.
The rest of the code for this question is not important and was not written here.
Characteristics: (1) Frequency range is determined by the following equation:
fOC1A = clckSys/2N(1+OCR1A)
clkSys = 16 MHz
N = Clock division factor: 1, 8, 64, 256, 1024
OCR1A = 16-bit Input Output Compare Register of TC1 for Ch-A
fOC1A = 0.20 Hz to 8 MHz
(2) Parameters for 5 Hz PWM Signal (For example, Fig-2):
N = 256
OCR1A = 6249
Why?
You can use compare match toogle mode with MAX counter value = OCR1A or ICR1 (modes 4 and 8-14), that give you gradual change in frequency with square output.
The duty will always 50% because the state of the pin will be TOOGLED once on the period - from HIGH to LOW in first cycle and than from LOW to HIGH in the next cycle.
So the duration between the toogles will be always equal to full timer cycle and freq of signal will be half of timer freq independent from OCR1A value.
Also, FYI, your frequency is going to have to be twice the frequency you are trying to mimic. PWM fans send a signal twice per revolution on the tachometer line. So, if you are trying to mimic a 1000RPM fan, you would need a signal that is 2000Hz. You'll also want to be careful because the motherboard is going to have a pull-up to 12v on the Tach line of a 4 wire PWM fan.
There's a spec for those fans you might want to look at.
The fan is actually an open drain collector. That means it's an inverted PWM signal or an inverse square wave. You don't need to bring the voltage up to simulate a pulse. You need to bring it down.
Then I am confused to interpret the meaning of "Update of OCR1x at" of Fig-1 in Mode-12 (CTC). When ICR1 sets the frequency, then what is the use of OCR1A Register.
I have a 6000 rpm / 5V power fan.
And my calculations are: 6000 * 2 = 12000 pulses / min = 12000 / 60 pulses / second = 200 pulses / second = 200Hz.
Am I wrong in these calculations?
The background to the creation of this emulator is as follows: I bought a new Dell Optiplex Micro computer, and unfortunately the BIOS does not have a fan speed setting. And this CPU fan often picks up high speed and makes a lot of noise. At the same time, the processor temperature never rises above 65 degrees Celsius, and most often 45-55. I want to deceive the BIOS with the help of Arduino, and lower the cooler speed. Even if the processor heats up to 80-85 degrees, then this will suit me.
The electrical connections have already been made by me. With a simple repetition of the signals, the fan operates normally with the following code: