Cheap way to sense 24VAC?

Go To Last Post
40 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd like to sense the presence of 24VAC in a couple of different places.

I've sensed multiple 5VAC lines before (coming in from current transformers linked to transistors) by just taking the whole port of inputs and ANDing it against a variable that starts as 0xff. I'll do the AND operation 20 or so times with 1ms delays between. Any zeros that come through are captured. That works fine.

24VAC is a little different. I'm not sure how to handle it safely. I've looked up optoisolators on Digikey but there is no input voltage column to sort by and all models I select have very low input voltages.

Does anyone know of a simple and cheap circuit or IC that can at least bring the 24VAC down to 5VAC or does something else that's also useful that I haven't thought of yet?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How about giving it a DC bias then bring it down to 5v via voltage divider?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I guess a voltage divider would work. I was kind of hoping for the protection of an optoisolator.

I suppose I could feed the output of the voltage divider into an optoisolator but I figured somebody might have already made an optoisolator that can take in 24VAC.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You do realize that optoisolators are for logic signals yes? There would be no point in an optoisolator taking AC directly...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not sure I understand your point.

The optoisolator provides protection. That's the main feature about it I like. The thing I don't like about the optoisolators I am finding that you can't put higher than 5V into it without killing the internal LED.

Putting AC into is is fine as I would get a pulsed output which I can sense with the AND logic I mentioned earlier.

Am I off base here?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The optoisolator takes an input voltage and lights a LED internally, then capture the light with a phototransistor and outputs either 1 or 0. It will not translate the AC waveform directly, it will just output 1 on the positive cycle and 0 on the negative cycle.

Some optoisolators will take in AC directly, but as far as I know they all output DC... I might be wrong though...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The typical opto-isolator with a LED input is expecting a voltage applied to the diode high enough to illuminate it (a little more than a volt), but the current through the diode must be kept within the device ratings, too. Use a series resistor to limit the current, and with the typical opto with a single LED, you need to add a diode *across* the led to protect it from excessive reverse voltage if you are sensing AC. You can also get optos with dual LED inputs that will conduct with either input polarity for AC applications, but with your periodic sampling scheme the more common single LED devices are fine. You just need to use the proper resistor value for the voltage range you want to sense. I use them on 480!

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks tpappano, that makes sense.

Unixwhore, appreciate your info too.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just a quick sanity check, I found this cheap opto here: http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=H11L2-MQT-ND

It has a continuous forward max current of 60mA. I think 30mA ought to do it. Since 24VAC has a peak of 34 volts, I need to use a 1133-ohm resistor (I'll round to 1k). I then put a diode that points the opposite way as the internal LED of the optoisolator and I'm good.

Does that sound about right?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would personally just simply use the resistor divider mentioned above and place a diode on the tap point with a small cap to filter the dc. then connect the circuit to the pin of the avr. Simple and cheap.

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is isolation overated? Am I too paranoid?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Isolation is probably not needed if your 24v system and your 5v system share a common ground, or some other common reference point. Isolation is usually only needed for safety from line voltage and/or if the two systems have an uncertain electrical relationship to each other.

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some info about optoisolators:

At heart they are analog devices. But, and that is a big "but", unfortunately, the transfer function of the bog-standard, low-end ones (CNY17, 4N35 etc.) is so non-linear that using them for analog signal is inconvenient. You need to compensate the non-linearity with a second, paired (selected), one. Even with thorough paring you don't get great linearity.

Then there are high-end analog optocouplers. For example, HP used to make some. They have sold/outsourced/spinned-off/licensed that business to some other company. I don't remember the name of that company. These optocouplers are in fact 1 1/2 couplers in one package. One LED, two phototransistors. Similar to using two separate, paired couplers you use the second phototransistor for compensating the non-linearity of the system. The phototransistors are well paired and you get good linearity, at a much higher cost per optocoupler compared to the low-end stuff.

Now to digital transmission. You can use the low-end ones for this to a certain point. For higher speed there are special digital optocouplers. In particular the receiving side has addition build-in circuitry to regenerate the digital signal. They are also more expensive than the low-end ones.

There are also completely different technologies, like isolation barriers and I think some manufacturer also offers some kind of mini transformers in a chip.

Back to the cheap optocouplers. They have one very weak point. The maximum allowed reverse voltage over the LED is typically rather low. They just don't like reverse voltage. Just connecting some AC to it, even with a proper resistor for limiting the forward current is likely to kill most of the cheap couplers. You do want an additional protection diode.

Stealing Proteus doesn't make you an engineer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Does that sound about right?

Yes, but don't forget the extra diode.

Also, I'd round the resistor UP, not down.

You did not discuss the output from the opto. I assume this means you are familiar with it. But just in case: The output would typically be tied to your uC V+ via a resistor, and the other lead to ground. The junction of the resistor and the opto can go to a digital input. More elaborate systems exist, (as always), but this is the basic setup and without further info will probably do what you need.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depending on the exact requirements, you could just have a diode in series (half wave rect) along with a current limit resistor and a capacitor so you get either on or off rather than pulses out of the opto. You want want a zener in series also so that you can sense the voltage is above a certain value.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

fizgig wrote:
Just a quick sanity check, I found this cheap opto here: http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=H11L2-MQT-ND

It has a continuous forward max current of 60mA. I think 30mA ought to do it. Since 24VAC has a peak of 34 volts, I need to use a 1133-ohm resistor (I'll round to 1k). I then put a diode that points the opposite way as the internal LED of the optoisolator and I'm good.

Does that sound about right?

Hi,

That opto is quite happy with an input (LED) current of between 0.3 mA and 10 mA. I cannot see the point in draining 30 mA from your 24VAC line. So I would use a bog-standard 1N400X diode in series with your line plus a 3K3 resistor to the anode of the opto. If as Kartman suggests you need to detect a particular level you could add a zener and lower the resistor value.

Cheers,

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Isolation is a good thing.

Something simple like this will do the job- just use some software to figure out if AC is there or not. (R1 and R2 both 10k will probably work first try). 1 Thing to watch is the power dissipation in the diode biasing resistor - the numbers can add up quickly.

Bias the opto according to the CTR and add some headroom.

oddbudman

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Isolation is a good thing.

When needed 8-)

You have the left side of your opto connected through ground to the right side. Not much isolation there!

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tpappano wrote:
Quote:
Isolation is a good thing.

When needed 8-)

You have the left side of your opto connected through ground to the right side. Not much isolation there!


:lol: Yes, you need to lose that GND connection. Otherwise, that is a very good circuit. By changing R1 to a fat, high voltage type you can even use it to monitor the AC mains voltage.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i'll put the other triangle next time. lol

Just a side note (sorry if a little offtopic) - here is a nice way to isolate an analog input signal. http://www.irf.com/technical-info/designtp/dt02-1.pdf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Jeeeeeez loueeeezzzz,

Why is this thread becoming so friggin complicated? :o

The OP wants to simply sense the presence of 24vac. Why make up these sophisticated circuits? We are not talking about 115/230vac so there is no reason to get into the circuits presented.

A simple resistor/divider/diode/capacitor will suffice. End of story. The OP has not asked for anything other than a on/off let-you-know.

Jim

Edit:
I am gonna catch hell for this one :wink:

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've shown this before...

For truly isolated inputs, and with an operating range of 4 to 36VDC, the attached circuit works very well.

The attached circuit has been operating at 100% reliability for over 3 years in a very electrically noisy industrial environment.

Complicated or not, it works very well.

Use it if you wish.

Attachment(s): 

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I've shown this before...

But is it any better than just a resistor, diode and opto? Actually, your circuit appears vulnerable to excessive input voltages and adds potential points of failure. I may be cranky because I haven't had dinner yet 8-)

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

A simple resistor/divider/diode/capacitor will suffice. End of story. The OP has not asked for anything other than a on/off let-you-know.

Just erring on the side of caution. ;) It has been my experience that the presence of several different 24V AC sources in a system suggests that there is need for isolation (else everything would be running off a single 24V AC supply). I once had to repair a sub-system for an MRI that had 11 different AC voltages. :o

If the OP can confirm that the various 24V AC voltages that need to be monitored are tied to a common ground, then of course your solution is all that's needed. :D One diode, one capacitor and a couple of resistors per input.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tpappano wrote:
Quote:
I've shown this before...

But is it any better than just a resistor, diode and opto? Actually, your circuit appears vulnerable to excessive input voltages and adds potential points of failure. I may be cranky because I haven't had dinner yet 8-)

I'm not sure why that would be, Tom. It is bi-directional, uses a current source set to 1.5mA, has 1,500 volt galvanic isolation, and has an operating range from 4 to 35 VDC or VAC. It has performed with out failure or interruption for several years. And that is 24/7, 52 weeks a year.

I guess I'll let you get some dinner. But I would like to hear where, specifically you see vulnerabilities.

Sure, a current limiting resistor and a filter capacitor would work. But if you'll really look, this circuit provides for complete isolation - not only between the real world and the controller, but also from input channel to input channel.

The analog speed control does not enter into the discussion, as it's only in the picture because I was too lazy to go through all of the conversion getting from HiWire II and a suitable picture to post. Even still, the resolution of the picture really sucks.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

has an operating range from 4 to 35 VDC or VAC

Pardon me for nitpicking, but 35V AC would produce nearly 50V peak which will probably kill the LM317.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

emuler wrote:
Quote:

has an operating range from 4 to 35 VDC or VAC

Pardon me for nitpicking, but 35V AC would produce nearly 50V peak which will probably kill the LM317.

Yes, that is true... I was thinking of DC voltage at the 35VDC maximum.

The maximum AC input would be 24.745 VAC, RMS.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How about winding some small toroidal pulse transformers? Back to back zeners on the primary set the sense voltage, the secondary can tie directly to a port pin to interrupt on rising edge or through a capacitor for falling edge. Good isolation, low impedance and power consumption, sensitive to AC only, and programmable time response. I've not tried it with AVR but 5mm toroids with a few turns work for TTL.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I guess I'll let you get some dinner. But I would like to hear where, specifically you see vulnerabilities.

Hi Carl,

I mainly was noticing that the 317 could fail from an excessive input voltage. With no capacitance on the bridge, you do not have any transient protection at all. With an AC input you still would be getting pulses at the opto's output, so I don't see what the practical advantage would be over a simple resistor and shunt diode driving the opto. These days I seem to be obsessive about performance vs. pcb real estate as much as reliability and cost 8-)

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've used a bridge rectifier and opto-isolator for detecting when an AC signal is present. It was used to detect when the "Green Man" was displayed at a pedestrian crossing for a prototype people counter that was installed at the crossing, for a local authority. We needed to count the people waiting at the crossing after the button was pressed.

Leon.

Leon Heller G1HSM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tpappano wrote:
Quote:
I guess I'll let you get some dinner. But I would like to hear where, specifically you see vulnerabilities.

Hi Carl,

I mainly was noticing that the 317 could fail from an excessive input voltage. With no capacitance on the bridge, you do not have any transient protection at all. With an AC input you still would be getting pulses at the opto's output, so I don't see what the practical advantage would be over a simple resistor and shunt diode driving the opto. These days I seem to be obsessive about performance vs. pcb real estate as much as reliability and cost 8-)

What the schematic shows, is what the schematic is. I've got provision for filtering capacitors, but they aren't populated on the PCB. As the installation used 24VDC, there was no problem with AV ripple. And as the isolated signals were transitions with frequencies ranging from 10 of seconds to the duration of the lines run time without interruption, there wasn't much need for concern about how fast things moved.

And while it's a matter of simply soldering down a filter cap at the output of the bridge rectifier, there has filtering in the firmware that basically acts like extended debouncing. So for an input to be recognized as a logic low, it would need to change (go away) state, and hold that state for about 1/4 second before it was recognized. A logic zero to a logic one transition has be a solid (or repetitive) high for about a 1/2 second before it is recognized as a valid high.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

leon_heller wrote:
We needed to count the people waiting at the crossing after the button was pressed

Man, that must have been a hard assignment...
What sort of sensor did you use to count the people?
How did you eliminate false readings from the sensor?

In Australia we use a much simpler method.
A uni-student with a clip-board ;)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was working for Irisys at the time:

http://www.irisys.co.uk

They use their own 16x16 element IR sensor array and ASIC. The software uses Kalman tracking techniques and was developed on a PC. I ported the software to my hardware which included an FPGA and DSP. It wasn't easy!

I don't think that a student standing by every crossing in the country and operating the traffic lights is viable, even in Australia. 8-)

Leon

Leon Heller G1HSM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am facing a similar situation. In my case I just want to monitor and log when the signal (24 VAC) is on or off.

I am thinking that perhaps a small AC relay could do the job (?)

The 24 VAC is the thermostat on/off control for an air conditioner. If I understand , the 24 VAC may be able to handle some current in the circuit and not effect the

air conditioner.

I'll believe corporations
are people when Texas executes one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

A relay would, indeed, work.

 

An opto-isolator is smaller and less expensive and takes less power. Just put a series resistor between the 24VAC and the isolator's LED. Put an ordinary diode in parallel with the opto's LED, but in reverse; this prevents damaging high reverse voltages across the LED. Size the resistor so that the opto's LED current is less than maximum at peak line voltage which is 24V * 1.4 = 34V, So, if the peak forward current is to be 10mA, you would use about 3.3K.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:

A relay would, indeed, work.

 

An opto-isolator is smaller and less expensive and takes less power. Just put a series resistor between the 24VAC and the isolator's LED. Put an ordinary diode in parallel with the opto's LED, but in reverse; this prevents damaging high reverse voltages across the LED. Size the resistor so that the opto's LED current is less than maximum at peak line voltage which is 24V * 1.4 = 34V, So, if the peak forward current is to be 10mA, you would use about 3.3K.

 

Jim

Note this will produce pulses at 50/60 Hz when the AC is present, and high when not AC is present, (as output of opto will have a pull up).  You could filter this input via software if needed.

 

Flyover Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
stack gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:
Note this will produce pulses at 50/60 Hz when the AC is present, and high when not AC is present, (as output of opto will have a pull up).  You could filter this input via software if needed.

or put a full wave bridge in front to get 100/120 Hz pulses allowing for a faster filter (and eliminating the need for a reverse protection diode) if speed of response is important.

Letting the smoke out since 1978

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tubecut wrote:

I am facing a similar situation. In my case I just want to monitor and log when the signal (24 VAC) is on or off.

I am thinking that perhaps a small AC relay could do the job (?)

The 24 VAC is the thermostat on/off control for an air conditioner. If I understand , the 24 VAC may be able to handle some current in the circuit and not effect the

air conditioner.

 

Yes, a small AC relay could do the job.

You may need a transient catch transorb across the relay, depending on what is driving it.

24VAC relays are not so common, and a quick check of an example reveals the AC coil is 24VAC, 350 Ohms, 0.76W, whilst DC24 is   1440 Ohms and 0.400W

That 24VAC relay example adds 68mA load to the switch.

 

Cheaper/smaller may be a Optocoupler, with an AC input and Series R. Many optocouplers are now spec'd at 0.5mA in, so you can design say a 1mA load.

A Cap across the optocoupler will remove the zero crossing ripple, when used with a MCU logic pin.

 

Interesting to spot liteOn offer a high input current  AC In optocoupler :   LTV-814HS-TA1   150mA MAX

Strange I thought, why would anyone want a high input current opto - then it occurs this could be series-inserted into almost any 24V control line, and used to confirm current flow. That will catch open circuits.

It costs voltage drop about 1.4V 

 

 

Last Edited: Mon. Aug 5, 2019 - 11:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If i was asked to quickly interface into the aircon system, i would use a relay. Something like an omron g2r series with a din rail mount socket. You have the option of a led and test pushbutton. Not super cheap, but near zero engineering time involved. Mounting, termination, safety and electrical requirements solved with a minimum of engineering skill involved. Whereas if i was designing a pcb and writing code, i would go the opto coupler route.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

Note this will produce pulses at 50/60 Hz when the AC is present, and high when not AC is present, (as output of opto will have a pull up).  You could filter this input via software if needed.

 

Flyover Jim

 

 

I was wondering when someone was going to mention the frequency.  While we're assuming typical house line power (50-60Hz) it does make a difference if he's looking at 50-60kHz... *

 

More helpfully, if you do use a filter cap, you'll want to put a drain resistor across it.  If your voltage divider is downstream of the diode, the low side resistor can be that resistor, but you might want to take note of your diode's voltage ratings if you go that way around.  A single diode will do - no need for a full bridge.  S.

 

* If you're looking at kilohertz, a capacitor is an excellent way to drop voltage.  At line frequencies, it's more of a pain.  Look up 'transformerless power supply' (and you might get electrocuted if you put your fingers where you shouldn't have).   S.