Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Faulty zero crossing detection 1

Status
Not open for further replies.

SolarTrap

Computer
May 5, 2014
89
0
0
DE
Hello,

below is my circuit for zero cross detection at 110VAC.
My pcb has 2 of these and they are connected to 2 independent AC sources.
URL]

I get a lot of faulty zero crossing events from the interrupt of the Arduino.
Below is the sampled input for 100ms.
At 19ms there is the problem. Vertical axis is 12bit ADC, horizontal time in ms.
URL]

It's a very simple circuit and I don't know why these values are not up to 4095 and down to 0:

12 168 178
13 177 189
14 218 245
15 4011 4060
16 4076 4075
17 4079 4079
19 4067 4080
20 4081 4083
21 4080 4082
22 4081 4081
23 4082 4081
24 1169 237
25 202 185
26 170 170
27 165 177
28 170 174

Any suggestions what might be the problem? Markus
 
Replies continue below

Recommended for you

You may not be driving the opto hard enough.

Could be you are violating the A2D set-up times on your readings. You don't make it clear but I am
supposing that the graph above is via your Arduino. If so, can you look at it with a stand-alone
scope to confirm where the issue is?

Keith Cress
kcress -
 
I am using a Particle Core for this and this is my reading code:

[pre]void record()
{
unsigned long ms = millis();
for(int i =0 ; i < MAX_RECORD; i++)
{
inT = millis() - ms;
inA = analogRead(cityACPin);
inB = analogRead(inverterACPin);
inV = analogRead(battVPin);
delay(1);
}
}[/pre]

I assume the signal is a real sine wave but I cannot measure all at the same time.
If the circuit is correct then I don't know what the problem is. Maybe the supply voltage?
 
Put your scope on the input of the opto and then on the output of the opto while the shaft is enabled but motionless and see what you get.
re you sure that you are not just counting the cycles of the 110 Volts, AC?

Bill
--------------------
"Why not the best?"
Jimmy Carter
 
Aren't those things really academically interesting relative to your purported requirement for zero-crossing detection? Can you even tell where the true zero-crossing is? What is your performance requirement?

Many diode-based circuits are based on full-wave rectification, rather than half-wave. This makes the zero crossing time window much clearer, and the actual zero-crossing can be more accurately inferred. An alternate solution is which is op-amp based. While there are diodes in the circuit, their purpose is clamping, rather than rectification. There are a bunch of circuits here:
TTFN
I can do absolutely anything. I'm an expert!
faq731-376 forum1529
 
I agree with Keith. Take a look at the current gain in the opto, the input current to it and the output current from it. My guess is that you're not pulling your output down.
 
@waross:

I don't own a scope but I think I can build one with another arduino.
I am not sure I understand the question "re you sure that you are not just counting the cycles of the 110 Volts, AC?"

@MacGyverS2000:
@BrianE22:

Will try to scope them as mentioned above. I also ordered fresh parts from Mouser to make a 'clean' detector on a breadboard with the same configuration as on the PCB.

@IRstuff:

I am trying to detect 2 things:
1) is there an AC signal on one or on both of my inputs
2) are the 2 AC signals in sync

The PC817 is half wave so the detection should be easy.
 
OK, so if the circuit is designed correctly, then there's not much point in #2. #1 does not specifically require a zero-crossing detection, just that the signal shows an amplitude modulation with the appropriate time behavior.

TTFN
I can do absolutely anything. I'm an expert!
faq731-376 forum1529
 
So it looks like I will get access to a scope tonight - keeping fingers crossed.

Besides that I got the fresh parts and did setup a testbed on a breadboard and was playing with the resistors. First playing with the input side:
URL]


and the with the pullup on the output side:
URL]


What I notice is that beginning with 4.7k I am no longer getting a straight line at the top. If that is all then it would be a cheap fix,
 
You may not realize that optos have one of the worst quality issues of any
electronic device. Their gain can be range over hundreds of percent between devices.

You can dial in the resistor(s) for one and have those same resistors be completely
wrong for the next.

Often there are 'screened bins' of devices that are measured and put in lots.
Depending on what you need it may behoove you to pay the extra to get screened
parts that are all more closely matched.

Keith Cress
kcress -
 
That sounds concerning. I looked around for 'screened bins' on Mouser and Digikey but that did not bring up anything. Any other advice on how to deal with opto coupler for my 120VAC use case?
 
[link Digikey Example][/url]

Notice the two columns "Current Transfer Ratio"?

Min and Max?
(compare at the same 1mA)

Notice how some part numbers have a minimum of 20%
and a maximum of 300%. Those can freak your resistor
values. You often want to spec a part that has the narrowest range.

That's just an example parts, that of course, DKY has no stock of
but it demonstrates my point.



Keith Cress
kcress -
 
Status
Not open for further replies.
Back
Top