Go Down

Topic: 24 volts AC to arduino input (Read 4967 times) previous topic - next topic

kevinsa5

I'm working on a project to monitor a heat pump and log when it's on and off. They way I plan to do this is to send a line from the heat pump up to a digital in on the arduino and have "if (digitalRead(pin) == HIGH), log to flash drive" running. However, the heat pump uses 24v AC and I'm using wall warts for the other bits of my project. I have a couple of questions:

1- can a wall wart (ie cell phone charger) take in 24v? on all of mine it says something like 110-240. I mostly just want it to make DC, I can make a voltage divider really easily to step it down from there.

2- I could use a rectifier, but to my understanding it doesn't make a constant voltage, it bumps up and down. I've heard of using a voltage regulator to fix this, but would a capacitor connected to ground do the same? forgive me if this is stupid, I'm somewhat new to the AC field.  :-/

I'd rather use a wall wart just because I have a bunch laying around and I don't have many free diodes.

If there's another easy solution, please let me know. I'm open to any and all suggestions.

Thanks!

sxdemon

#1
Jul 22, 2010, 03:35 am Last Edit: Jul 22, 2010, 03:41 am by kraig Reason: 1
Until the real expert come back and help you...

1-Walmart will probably blow up
2-????? (I don't know about rectifier)
3-Plug the Heat pump with his respective power suply, separate from the Arduino.

4-I do believe the arduino Pins only take DC or it would blow up(I like that word) (the reason why you want to convert AC to DC) From my very tiny knowledge base, you should probably use an external device (detector) wired to the Arduino to register if the pump is On or OFF.

And btw, if your heat pump require AC, use AC, not DC.

I don't know how your heat pump is or work, but if I was trying to do that I would try to detect the Heat exchange using a electronic Heat sensor or something similar, but it's probably not the best way to do that and might be unreliable as you will need to do some qualibration...maybe using one sensor to detect the ambiant temperature and the other one beside your heat pump.

dilbert98122

#2
Jul 22, 2010, 03:44 am Last Edit: Jul 22, 2010, 03:45 am by spday Reason: 1
This sounds like you're asking two questions:
1) 24V AC to an Arduino digital input
2) 24V AC to provide power to the Arduino

1) Do not put 24VAC directly to an input pin.  It will fry the input.  You have a few options:
a) opto-isolator (plus a couple resistors, small diode, and a capacitor)
b) input protection/level shifting with a diode, resistors, small capacitor, maybe also a zener diode.

I include a capacitor on both of the above because either option will give you a series of pulses when the AC is on.  The a capacitor can hold the input high between the pulses, otherwise you'd randomly get a false "off" or would have to deal with that in software.

2) No, most wall warts will not give you the voltage you need to power the Arduino with only 24VAC input.  You can fairly easily build a small power supply with a bridge rectifier, a few capacitors, and a small voltage regulator.  All of which are fairly inexpensive.  The 24Vac may push the limits for input voltage on many small regulators though.

A voltage regulator and a capacitor are not the same.  You really would want both.  The output of a rectifier is either just the positive halves of the sine wave (half-wave rectifier) or the positive half and the negative half flipped over (full-wave rectifier).  But both will be a series of pulses.  The capacitor fills in the gaps, but not perfectly.

The voltage regulator knocks the voltage down further to the value you really want and further smooths out the imperfect output of the capacitor.  Normally, you'd also have a second capacitor after the regulator to further smooth out the ripple.

Here is some info on power supply design that google turned up.  You would be interested in Fig 16.  
http://www.st.com/stonline/books/pdf/docs/1707.pdf

kevinsa5

Thanks for the reply!

The heat pump is already in place and functioning, I'm just trying to leech a small amount of power out to indicate whether the pump is on or off.

You're right about not sending AC through an Arduino pin, that would not be good.  :o  That's why I'm converting it to DC.

As for using an external sensor, I'm just trying to step down the 24V AC to <5V DC so a digital in can read it. I'd have to use a digital pin anyway to detect the external sensor, so I don't really see the point in using an extra component? :-?

kevinsa5

I'm trying to send 24V AC to an Arduino digital in. I have a separate power source, sorry for the confusion.

My question about the wall warts was whether the output was just a function of the input or if it was only a specific voltage. If input is 120V AC and output is 6V DC, would 60V AC yield 3V DC? if that's the case, 24V AC would yield a little over 1V DC.

I think I'm actually going to go with the rectifier + capacitors. Do I need the voltage regulator if I use a voltage divider? I guess it would protect from spikes... if there are any? Would there be?

Thanks for the link, too.

sxdemon

Quote
I'd have to use a digital pin anyway to detect the external sensor, so I don't really see the point in using an extra component?  

Me either. I like doing simple things complicate.  ::)

retrolefty

Until you are experienced enough to answer your own question of methods to convert 24vac to be Arduino digital I/O compatible, might I suggest a method that is simple and safe. Just get a 24vac relay and let the heat pump power the relay coil and wire the relay contacts (one grounded, one to a input pin) to the Arduino.

Lefty

kevinsa5

Hmm. I think I'll revise my main question: Can I use a wall wart rated for 110-240 V AC for changing 24V AC to DC?

I'd rather not get a relay just because I'd have to go out and get one. If I can use something I already have, it'd be simpler.

"Until you are experienced enough to answer your own question of methods"  ;D right now the only way to get experience in this is to plug it in and hope it doesn't start smoking

cr0sh

#8
Jul 22, 2010, 04:28 am Last Edit: Jul 22, 2010, 04:29 am by keeper63@cox.net Reason: 1
Quote
I'm trying to send 24V AC to an Arduino digital in. I have a separate power source, sorry for the confusion.


As stated before, you can't do this directly. You know this.

Quote
My question about the wall warts was whether the output was just a function of the input or if it was only a specific voltage. If input is 120V AC and output is 6V DC, would 60V AC yield 3V DC? if that's the case, 24V AC would yield a little over 1V DC.


It really depends on how the wall-wart is designed; if its one of the newer switched-mode supply wall-warts, then no, it won't work. If it is a linear-regulated wall-wart, then it probably wouldn't work, either. If it is a linear un-regulated wall-wart, it may work, depending on its design.

What would be better would be to remove the transformer from such an unregulated wall-wart, then build your own step-down rectification system, then place a small regulator after that (with appropriate capacitors and such - they -are- needed). The regulator would need to be matched to the output of the transformer, so that it will work (for instance, if you were using a 7805 for the regulator, then your output of the rectification would have to be 7 volts or greater, because the 7805 has something like a 2 volt dropout, IIRC).

Something you could try, though, would be to detect voltage indirectly by a coil around one of the 24 VAC wires. Make a small coil on a form (like a soda straw or a piece of a plastic ball-point pen body), wrapping say 100-200 turns of 20-24 gauge wire around it. Laquer it up or otherwise seal it. Pass one leg of the 24 VAC line through the coil. When it is "on", the coil should generate a low voltage that you can measure. This voltage will be AC, too, so you'll want to rectify and filter it with caps, depending on its amount, you might need to rectify it, but it should be detectable - you would have to experiment with it.

Quote
I think I'm actually going to go with the rectifier + capacitors. Do I need the voltage regulator if I use a voltage divider?


If you are going to use a rectifier, try to find a 2:1 step-down transformer to place before the rectifier, so that you turn the 24 VAC into approximately 12 VAC, then into 12 VDC - then use a 7809 regulator (with appropriate caps) to regulate that down to 9 VDC, then a 7805 regulator (with caps) to take it down to 5 VDC; I would then use that to drive a small 4N26 optocoupler (put a resistor in place to limit current to the LED), and the output of the optocoupler to signal the Arduino (don't couple the grounds - this will isolate the Arduino from the AC side completely).

You want to take these steps (12 VDC->7809->7805) because if you just went with 12 VDC to a 7805, the excess voltage (7 volts) is dumped as heat from the regulator, and you would need a large heatsink to keep from frying the regulator. By doing it in stages, you don't have this heat issue.

If you wanted to spend the money, there also exist miniature switched-mode regulators to replace a 7805, that can easily take high voltages and convert them down to 5VDC (they also come in other values) - they aren't cheap, though; a 7805 replacement device costs around $15.00.

Another possibility would be to hook up a 24 VAC SPST relay in parallel with the output you want to monitor, then use the contacts of that relay to switch an input on the Arduino to ground (activate the internal pull-up first). That would be simple and fairly cheap (if you can get the relay).

:)
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

kevinsa5

#9
Jul 22, 2010, 04:42 am Last Edit: Jul 22, 2010, 04:46 am by kevinsa5 Reason: 1
Wow, cr0sh, I'm impressed with the thought behind your answer. Thanks! However, I was hoping for something much simpler, like Richard Crowley's. I do kind of like the coil idea, just for bonus cool points   8-)

Richard's idea sounds well and good, but I was under the impression that under no circumstances may one send more than 5V into an arduino pin. 18V is a lot more than 5. It would make things a lot better if I was wrong on this point, though.  ;)

EDIT: re capacitors, if a circuit calls for a capacitor rated at 10V, will any cap rated at or above 10V work, as long as the capacitance is sufficient? Also, does a simple two resistor voltage divider work on AC?

dilbert98122

Ok, so if I understand correctly now, you already have power for the Arduino and just wanted to use a wall wart as a pre-made method of converting 24VAC to 5VDC for the digital input....

As other posters have mentioned, that depends on the design of the wall wart, so without a good bit of detailed info about it, I'd have to give the easy answer: no.   (Although I've done this with sensing 120VAC on/off.)

You can however build a fairly simple input circuit quite easily:

Get:  any typical diode with at least 50V PIV (peak inverse voltage), a good example is 1N4001; a 5.0 V Zener diode (5.1 should be ok); small electrolytic capacitor rated at least 35V (say 10 uF), and a resistor 10Kohm to 47kohm, 1/4W.  All are inexpensive and can probably find at the nearest Radio Shack (do they still have components?)


24VAC --->|----*-----/\/\/\-----*-------  Digital In
                    |                 |
                    C                Z
                     |                 |
24VAC(gnd)----*----------------*------- Ard Gnd


Ok, pardon the horrible ascii sketch....  
C = capacitor (+ pin on top)
Z = zener diode (cathode at top... arrow symbol pointing up)
-->|-- = rectifier diode (cathode at right)
--/\/\/\---  = resistor

The capacitor will smooth out the pulses from the rectifier diode, and the resistor and zener diode will limit the voltage to 5VDC to the Arduino input.

Your other options are as mentioned: a relay with 24VAC rated coil, or an opto-isolator such as 1N26 or equiv.  

For the opto-isolator though, you would still need a diode and two resistors at minimum, and I'd recommend a capacitor so you don't end up with a pulse train.

dilbert98122

Whoops.... that ascii sketch didn't work out very well....  the "*" was supposed to be junctions to the vertical components.

dilbert98122

Yes to both...  a simple two resistor divider works with AC.  Its output of course will still be AC.  Keep in mind when you rectify AC to DC that you need to multiply the AC voltage by 1.414 to get the peak voltage.

And, yes a capacitor with higher voltage rating is fine.  The voltage rating is the maximum voltage the the capacitor can withstand (see note about peak voltage above).

dilbert98122

Richard:  nice example.  I just don't like to trust things like AC or high voltage directly to a pin.

kevinsa5

okay, cool. the radioshack near my house has a limited selection of components, but more often than not I can find what I'm looking for, or a replacement, there.

I do like dilbert's sketch. I know I have a 1n4003 laying around somewhere, radioshack.com says its PIV is 200 V. as I understand it, zener diodes let current through when the reverse-biased voltage is greater than the zener diode's rating? that doesn't make sense with your explanation, though.

Go Up