Jump to content

small solution for detecting 120V AC as a digital input

Recommended Posts

I posted this on a different forum and got some help but wanted to run it past you guys to see if anyother ideas shook out of the tree.


[this is a repost from a different forum combining a few of my posts]

hey guys the project I am working on requires me to sense the presence of 120v on 15 different lines back to my microcontroller, trying to do it with optocouplers means i have to drop 120v across resistors to provide 20mA to the opto LED means i am dissipating 2.5W on 15 different resistor sets... 30W in a relatively small plastic box is gonna get very hot.

there has to be a simple way to detect, hey there is voltage here. no power is required eventually just driving the input to the micro through an opto for isolation. I can't find any microtransformer on digikey, although I may not be looking in the right place.

the end goal is just verifying the SSR relays are actually "closing" to verify that voltage is being sent out to the control relays. they are 100-c09d10 allen bradley relays on the equipment I am building this for so I have to work with them. they only draw about 80mA when once they are closed so i don't think there is enough for a current sense solution... but I am open to whatever ideas people have.

thanks for helping me with this, ac stuff is still new to me, my projects are usually just 3.6-5V dc stuff.


 well this is how this ended up

the simulator predicted 30mA through the opto-coupler, and the physical circuit hit around 36mA if you discount an oscillation (which happens each time and I'm not sure why but i don't think its a problem) the part is rated for a max of 150mA input current so i don't think 30-40 is gonna hurt it. i think i can write off the difference to the simulator using "generic" LEDs and also the resistor being 5% and the cap being 10% tolerance. ah well close enough

I am using the input pullup resistor in the micro controller to pull up the open collector on the output transistor, so it goes low when voltage is present, and high when not... and as a nice side effect there is a short timing pulse when the current is 0 (changing directions) at the top and bottom of the sine wave that gives me a short timing pulse i can time the operation to for a zero crossing switching of the SSRs

all in all this worked out very well, thank you guys for the help. there is a small oscillation (at around 1MHz but it is very small around 2mA) but I'm not worried.



how I ended up hooking it up.



The optocoupler does in fact pull the line low, and even gives me a timing pulse incidentally



here is the oscillation at the peak current draw



here is the current draw plot in general (across a 100 ohm resistor) more of a triangular wave rather than a sine that the simulator predicted, but i guess thats real world components



any thoughts on better or simpler ways to do it?

Link to post
Share on other sites

If you're trying to minimise power draw, how about having a voltage divider with a high resistance and detect this lower voltage with a high impedance amplifier? A more complicated circuit, but less power dissipation. It depends what is the priority.


After a quick Google throws up TI's AMC1100 Isolation Amplifier (or maybe other alternative products on the page). http://www.ti.com/product/amc1100 I haven't looked at it in detail but that's the sort of thing I was thinking of.


Also, does the opto really need 20mA? A few mA are not worth worrying about at normal driving voltages, but if you could get away with 5mA that might make a significant difference in this case.

Link to post
Share on other sites

the power for this is coming from a 840KW 4160V generator, so power is pretty much unlimited,  my primary concerns are isolation, footprint, cost, and excessive heat dissipation.


I like that sensor chip, but at 3.75 a piece they will get expensive, and sensing current would require the relay at the far end to be working. the second concern is the need for 15 copies of this on the board and those SOT8's will take up too much space i think.

Thanks for the suggestion, I may use those for a different function i need though :)


in studying the charts in the datasheet, I only have to overcome the current flowing from the pullup resistor on the input pin to drag the line negative, so about 0.072 mA so based on the current transfer ratio it looks like 1 to 2 mA would be the actual minimum to be safe, but since the capacitor doesn't disipate heat I'm not all that concerned, I will play with smaller currents and see if it improves the timing pulse action.





Link to post
Share on other sites

I read somewhere one thing to keep in mind with voltage dividers and other circuits for conditioning HV is redundancy--think hard about the choice of components and design, e.g. in a voltage divider, if the GND side resistor blew or wasn't soldered right, would anyone get hurt and/or is a total loss of the board acceptable? Probably also surges/spikes to consider...


Sent from my Galaxy Note II with Tapatalk 4

Link to post
Share on other sites

Why not use low input current optos like 6N138/6N139 or dual channel HCPL2730/HCPL2731?

I am using them for MIDI apps, which use 5mA current loop, but you could go as low as 0.5mA.
I would probably settle on 1.5mA

Ping me if you decide to use them.

Link to post
Share on other sites

unfortunately i have to detect 16 different lines (these are output verification on a relay control module, so i gotta do 15 copies of this circuit, and don't have the room to implement alot of these suggestions.)


the msp430  talks to an open drain constant current led driver, driving the LEDs inside some SSR relays to switch the AC signal to control the 120v relays on the target piece of equipment)  each of these outputs is what I am sensing and feeding into the sensing optocouplers, all acting as open drains on on a common sensing bus, so when i put it through self test, it turns each one on and off seperately looking for that sense buss to be pulled low.



here is what the board layout looks right now (with the capacitor driven optos) looks like


for those playing at home...

the LED driver is a Texas Instrument TLC5926

the SSRs are Panasonic AQH3213A

the Optocouplers are Lite-On LTV-814HS, and LTV-844HS  (single, and 4 channel units)

and the 3.6v regulator is a Texas Instrument TPS54336 switcher


this PCB actually serves 3 functions.  the wall mounted box has this board to drive the primary 15 relays, if I cut along the 120v line, and mount a second version via standoffs with the JP points and close the solder jumper on the back, it will act as a second relay board with its LED driver serial input coming from the output of the main LED driver, so it is a second set of 15 relays as an optional expansion for them.  neither of these have the MSP430 mounted on them though, the hand held box has this board in the base with the MSP430 mounted and none of the 120v stuff populated, and going out the PB_IO header, and the OLED_IO header to the frint panel of the handheld unit to the switch board that has the user push buttons and OLED on it for the interface, so this same PCB has 3 different jobs built into it. :)


Link to post
Share on other sites

what is the current draw? The other option, if the current draw is sufficient, would be an inductive pickup, or a hall effect pickup like the Allegro ACS710 or 712 series. Both the inductive and the current sensor IC are isolated. The IC is cheaper. The 5A version of the 712 is a couple bucks. Advantage to these is current measurement.


Edit: just reread the intro. At 80mA, you should be able to go with current sense. A 5A sensor has resolution of 10mA at 10 bits(bipolar), which is about ok for 80mA (look for the periodic change). An inductive pickup with the appropriate ballast resistor is more than good, but will need extra components to protect against overcurrent and bias to positive.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...