I am new to the world of arduino so I apologise if I ask some silly questions :P
I am looking at interfacing an arduino with my A/C but need some help on the hardware side of things. The A/C has a heap of control lines going from the unit on the wall up to the unit in the roof, these lines change voltage based on what mode for the A/C is in (all lines are 18.1v when the unit is "off") The fan speed controller line then drops between 11.14V and 5.77V depending on the speed of the fan, the higher the voltage the slower the fan.
So firstly I want to create a circuit (voltage divider) to take the line and reduce it to a voltage that wont blow up my arduino. I can use a 1k and 330 ohm resistor to do this, however this will change the voltage on the fan speed line and cause the fan to go faster (which is not what i want to do). So I started looking at adding an op-amp as a voltage follower but being so green in this area I though I would hit the forums for some help.
Below is my Circuit Diagram any help would be great.
Something to keep in mind is that it's likely the power supply for that module isn't regulated, and the fand speed controller isn't dependent on a very precise voltage. You may be seeing 18.1V today, but it could be 17V, or 20V, next week or next year. So trying to simply divide down that voltage could wind up producing an excessive input to the Arduino.
To avoid affecting the control voltage in the equipment, you should monitor it with a high-impedance input, like an op-amp. That way, the current drawn out of it by the monitoring circuitry will be so tiny it's negligible (this is why you see see specs for multimeters that brag about input impedances of gazillions of Ohms). Once you have a buffered "copy" of the signal, you can do whatever you want with it without affecting the original.
You could run an op-amp off a 24V supply (which can be made very cheaply with a 7824 regulator and a surplus wall-wart, because it only needs to supply a few mA), and put a low-resistance voltage divider on its output.
With a really high input impedance op-amp running off 5V, you could use a high-resistance (tens of K) voltage divider on the input, and monitor the circuit without affecting it. Probably: the input impedances inside the controller circuitry could be high, too, so there's a chance your voltage divider could be too much load. The circuit going through the cable to the roof should be low-impedance, for good noise immunity, but you know what they say about "assuming" ;)
The circuit you posted earlier is actually pretty much what I had in mind, except that I recommend going with my 24V power suggestion: most ICs get really unhappy, and may even be damaged, when the input significantly exceeds one of the supply rails. That's why you'll often see people including protective networks, with diodes that appear to be "backwards", when designing input circuits that connect to the dangerous outside world: if the input swings too far, the diode will divert most of the energy to the power supply.
So just a quick update, I have found out that the Fan speed controller uses PWM this is from the manufacturer
"The only control line which uses Pulse Width Modulation is the Speed line (Pin 2 of the 7 Pin Header). It is a 0 - 17V signal at a frequency of 62.5Hz. At minimum speed the duty cycle is approximately 50%, while at 90% of full speed the duty cycle is approximately 15% (Note however that if speed control is not required, pin 2 can be connected to 0V and the Fan will run at full speed.)"
I have built my op-amp + voltage divider circuit and using a multimeter it appears to work, but I am wondering given that this line is PWM, should I be doing something different?
I have found out that the Fan speed controller uses PWM
Oh, that changes everything. You don't need to find out what the exact voltage is.
It's safest to assume that "17V" is a nominal value, that might go a little higher, or might not reach that high. So divide it down by about 4-to-1, with a total resistance in the divider on the order of 20-30K. That'll give you a good (and safe) logic high as long as the PWM is anywhere in the range of about 14-20V.
You can find examples in the forums (and probably the Playground) of people decoding PWM signals from other fan controllers, RC servos, etc.
Here is the code I am using (just quickly knocked it up using examples found on the forum)
int pin = 8;
float DutyCycle = 0; //DutyCycle that need to calculate
unsigned long SquareWaveHighTime = 0; //High time for the square wave
unsigned long SquareWaveLowTime = 0; //Low time for the square wave
unsigned long Speed = 0; //Trying to figure out the speed!
void setup()
{
pinMode(pin, INPUT);
Serial.begin(38400);
}
void loop()
{
DutyCycle = 0; //Initialize to zero to avoid wrong reading
Speed = 0; //due to incorrect sampling etc
SquareWaveHighTime = pulseIn(pin, HIGH);
Serial.println(SquareWaveHighTime);
SquareWaveLowTime = pulseIn(pin, LOW);
Serial.println(SquareWaveLowTime);
DutyCycle = SquareWaveHighTime; //Calculate Duty Cycle for the square wave
DutyCycle /= (SquareWaveHighTime + SquareWaveLowTime);
Serial.print("DutyCycle = ");
Serial.println(DutyCycle, 4);
delay(1000);
}
Assuming the above is right below are the values that come out
It doesn't have to be that accurate the fan control speed is 1 -100 my project is basically to intercept that line as well as the pump line to determine if the a/c is off/cool/or fan only and at what speed the fan is set to. I guess my next step is to look at Timer Input Capture Interrupt?
I plan to add a couple of reed relays to be able to turn the system on and off also, I guess I can use pulsein however that will mean I have to wait for it to complete before I can do anything else (read temp, turn the system on/off change fan speed etc). Though I guess that isn’t really a problem.
You should be able to take the two pulseIn readings to get the duty cycle in well under a tenth of a second. In your application that should be more than fast enough.