detecting AC with an optocoupler

Thread Starter

clintonb

Joined Mar 6, 2011
52
I have tried to detect an AC connection using just a diode resistor and a capacitor. I am not trying to detect zero crossing. i would just like to return true or false.

The issue i have is that the LED of the optocoupler remains on. when i measure the voltage coming from the switch it return 33V eventhough the switch is open. removing the switch connection turns the led off.

Not having experience with AC i am inclined to think that i should connect a 10K pull down resistor across the switch output and neutral since there is a large length of cable between the switch and diode +-1m- much in the same way you pull down a mosfet gate.

Is this logic correct and safe?
 

Attachments

mvas

Joined Jun 19, 2017
538
33 Volts when the switch is OPEN but then 0 Volts when the switch is removed?

What type of switch is it ?
Does the switch have some kind of internal illumination circuitry ?
 

cmartinez

Joined Jan 17, 2007
6,600
I have tried to detect an AC connection using just a diode resistor and a capacitor. I am not trying to detect zero crossing. i would just like to return true or false.

The issue i have is that the LED of the optocoupler remains on. when i measure the voltage coming from the switch it return 33V eventhough the switch is open. removing the switch connection turns the led off.

Not having experience with AC i am inclined to think that i should connect a 10K pull down resistor across the switch output and neutral since there is a large length of cable between the switch and diode +-1m- much in the same way you pull down a mosfet gate.

Is this logic correct and safe?
Questions, exactly which LEDs and diode have you been using? Which optocoupler?
 

eetech00

Joined Jun 8, 2013
1,726
I have tried to detect an AC connection using just a diode resistor and a capacitor. I am not trying to detect zero crossing. i would just like to return true or false.

The issue i have is that the LED of the optocoupler remains on. when i measure the voltage coming from the switch it return 33V eventhough the switch is open. removing the switch connection turns the led off.

Not having experience with AC i am inclined to think that i should connect a 10K pull down resistor across the switch output and neutral since there is a large length of cable between the switch and diode +-1m- much in the same way you pull down a mosfet gate.

Is this logic correct and safe?
Hi

instead, use an AC opto isolator (like an H11AA1). The output of the opto would connect to a RC smoothing circuit that would provide the hi/low signal you want.

eT
 

Thread Starter

clintonb

Joined Mar 6, 2011
52
33 Volts when the switch is OPEN but then 0 Volts when the switch is removed?

What type of switch is it ?
Does the switch have some kind of internal illumination circuitry ?
33 Volts when the switch is OPEN but then 0 Volts when the switch is removed?

What type of switch is it ?
Does the switch have some kind of internal illumination circuitry ?
Sorry. that was poorly stated. i mean that the switch connects to the diode over a log wire. if you disconnect this wire from the diode it measures a much lower voltage which no longer lights up the LED
 

BobaMosfet

Joined Jul 1, 2009
839
I think a more pertinent question is- where/how are you measuring your voltage, and please provide a better schematic clearly showing the parts, connections, and the part names/identifying numbers.
 

cmartinez

Joined Jan 17, 2007
6,600
Seems to me you have a leaky switch ... On the other hand, eetech00 has already said it all. You need an RC filter to smooth the output of your circuit so that the opto will steadily remain on.
 

cmartinez

Joined Jan 17, 2007
6,600
The switch is a mechanical switch much like a light switch.
Is it a double-pole, single throw switch? Because I've used single-pole switches for applications similar to this one before, and some of them are of such bad quality that they let a little current flow through them even when open, due to internal capacitance.
 

Thread Starter

clintonb

Joined Mar 6, 2011
52
Is it a double-pole, single throw switch? Because I've used single-pole switches for applications similar to this one before, and some of them are of such bad quality that they let a little current flow through them even when open, due to internal capacitance.

Its a sin
Is it a double-pole, single throw switch? Because I've used single-pole switches for applications similar to this one before, and some of them are of such bad quality that they let a little current flow through them even when open, due to internal capacitance.
It is a spdt switch. i suspected something was giving a small current which is what got me in the direction of a pull down resistor so that it goes to neutral instead of turning on the optocoupler. Were you able to compensate for this?
 

Thread Starter

clintonb

Joined Mar 6, 2011
52
Also woth noting the absolue bonehead mistake. you cant use the moc3041 because its the photo TRIAC i use to switch ac. it wont work on DC.
 

Thread Starter

clintonb

Joined Mar 6, 2011
52
Problem solved and the moc3041 works fine for microcontroller pin grounding even though its for ac switching because once it grounds the pin the voltage i 0 and it goes into the off state.
 
Top