INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Faulty zero crossing detection

Faulty zero crossing detection

(OP)
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.

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.

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

RE: Faulty zero crossing detection

Something funny in the waveform from the inverter?

Maybe try them with clean commercial AC to see if they work better.

RE: Faulty zero crossing detection

(OP)
I Forgot the legend:

blue = utility power
red = inverter

RE: Faulty zero crossing detection

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 - http://www.flaminsystems.com

RE: Faulty zero crossing detection

(OP)
I am using a Particle Core for this and this is my reading code:

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

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?

RE: Faulty zero crossing detection

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

RE: Faulty zero crossing detection

If you can't guarantee what the actual signal looks like when a measurement oddity happens, you may end up chasing your tail.

Scope it and save yourself a shred of sanity.

Dan - Owner
http://www.Hi-TecDesigns.com

RE: Faulty zero crossing detection

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 http://www.circuitstoday.com/zero-crossing-detecto... 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: http://sound.westhost.com/appnotes/an005.htm

TTFN
I can do absolutely anything. I'm an expert!
FAQ731-376: Eng-Tips.com Forum Policies forum1529: Translation Assistance for Engineers

RE: Faulty zero crossing detection

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.

RE: Faulty zero crossing detection

(OP)
@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.

RE: Faulty zero crossing detection

Are there any Maker shops near you? Drag over to one and use their scope.

Keith Cress
kcress - http://www.flaminsystems.com

RE: Faulty zero crossing detection

Sorry for my confusion. I posted in the wrong thread.

Bill
--------------------
"Why not the best?"
Jimmy Carter

RE: Faulty zero crossing detection

(OP)
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:


and the with the pullup on the output side:


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,

RE: Faulty zero crossing detection

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 - http://www.flaminsystems.com

RE: Faulty zero crossing detection

(OP)
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?

RE: Faulty zero crossing detection

[link Digikey Example]http://www.digikey.com/product-search/en/isolators...[/link]

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 - http://www.flaminsystems.com

RE: Faulty zero crossing detection

Binned components are typically not available from suppliers like DigiKey... you need to go direct to the source for that.

Dan - Owner
http://www.Hi-TecDesigns.com

RE: Faulty zero crossing detection

True Dan, but you can find narrower transfer ratio components and just go with
them instead of other choices.

Keith Cress
kcress - http://www.flaminsystems.com

RE: Faulty zero crossing detection

Opto-interrupters can be particularly troublesome when using plastic flags,
which can be opaque to some lots, and transparent to the next lot of the same part number.
I long ago took to using metal flags, or metal foil overlays on the flags.


Mike Halloran
Pembroke Pines, FL, USA

RE: Faulty zero crossing detection

(OP)
Here is a link to a video I made of how I can trigger events from the opto-coupler. Does this hint any problems in the grounding? the laptop is connected via the white cable to the USB port of the micro-controller.

http://solar-trap.com/wp-content/uploads/2016/03/MZFT5156.mov

RE: Faulty zero crossing detection

Your body is a good antenna for 60 Hz from the power grid. Just touch an ungrounded oscilloscope probe and you'll see how good (it won't hurt). So touching the equipment introduces another 60 Hz path to your sensor.

Are you not triggering off 60 Hz from the 110 VAC in the video as you are showing sub-Hertz events?

Are you holding something in your hand? Is that the 'white cable' you refer to?

Does this stop if the laptop is running on battery?

You might want to buy this and read Chapter 10:

http://www.emiguru.com/index.php?option=com_conten...

I still have an original copy from 1994. It's handy!

Z

RE: Faulty zero crossing detection

(OP)
@zappedagain: so the printout is just printing interrupts that fall outside a 16-17ms delay.

I finally got the scope functional! In the new video below I have the serial printout under the scope. The waves in the scope look perfectly fine and I have no explanation why I am getting irregular interrupts. There are 2 waves visible in the scope, the lower is 'city' the upper 'inverter'
Video
here are some values from the serial printout in the video. the first column shows the ms delay between 2 irregular interrupts printouts and the last column is the time measured between two interrupts in the ISR:

3460 city 7
6 city 7
6 city 10
7 city 10

this means:
3460ms nothing irregular happening, then an irregular interrupt within 7ms,
then 6 ms nothing happening, then an irregular interrupt within 7ms
then 6 ms nothing happening, then an irregular interrupt within 10ms
then 7 ms nothing happening, then an irregular interrupt within 10ms

here some more data points:

2456 city 0
6 city 0
6 city 0
7 city 0
6 city 0
6 city 0
3091 city 6
7 city 6
6 city 10
7 city 10
5 city 10
2153 city 0
6 city 0
6 city 0
289 city 0
6 city 0
7 city 0
211 city 7
6 city 10
6 city 10
7 city 10
13261 city 7
6 city 7
6 city 10
7 city 10
6 city 10
26270 inv 0
6 inv 0
6 inv 0
2798 inv 0
6 inv 0
6 inv 0
7993 city 6
6 city 6
6 city 10
6 city 10
7 city 10
5000 city 0
6 city 0
6 city 0
3380 city 7
6 city 7
7 city 10
6 city 10
2507 city 0
7 city 0
6 city 0
2671 city 0
6 city 0
567 city 7
6 city 10
6 city 10
6 city 10
2292 city 0
6 city 0
3481 city 6
6 city 6
7 city 10
6 city 10
2006 city 0
6 city 0
7 city 0
6553 city 0
7 city 0
3123 city 0
7 city 0
6 city 0
596 city 6
6 city 10
7 city 10
6 city 10
37303 inv 0
7 inv 0
6 inv 0
2219 city 0
6 city 0
6 city 0
207 city 0
6 city 0
6 city 0
256 city 0
7 city 0
6 city 0
6 city 0
6 city 0
2772 city 0
6 city 0
6 city 0
3727 inv 0
7 inv 0
6 inv 0
594 city 6
6 city 6
6 city 10
7 city 10
6 city 10
2200 city 0
6 city 0
6 city 0
6335 city 0
9079 inv 0
7 city 0
7 inv 0
7 city 0
208 city 0
6 city 0
131 city 7
6 city 7
7 city 10
6 city 10
1749 inv 0
6 inv 0
6 inv 0
2374 city 0
6 city 0
6 city 0
146 city 7
7 city 10
6 city 10
6 city 10
1385 inv 0
7 inv 0
6 inv 0
395 city 6
6 city 6
7 city 10
6 city 10
415 city 7
6 city 7
6 city 10
7 city 10

RE: Faulty zero crossing detection

As I suspected (and often see). I'd check your interrupt code to make sure it's as short as possible (you should be using no more than 10-15 cycles, just enough to set a flag, reset the interrupt, and get out), along with making sure nothing else can take control.

Dan - Owner
http://www.Hi-TecDesigns.com

RE: Faulty zero crossing detection

(OP)
I added now 0.1uF caps at the input of the micro controller pins connected to the opto-couplers and after running it for a few hours it does not produce false interrupts any longer.
I tried this weeks back directly at the opto-couplers but that did not have the same impact. So maybe the long traces between the opto-coupler and the controller where picking up EMI?

RE: Faulty zero crossing detection

(OP)
They are about 5 inches long. The PCB runs high power DC (up to 50A) and AC thru it.

RE: Faulty zero crossing detection

How close are the AC lines (or the DC lines if they're being switched) to your optocoupler lines?

Dan - Owner
http://www.Hi-TecDesigns.com

RE: Faulty zero crossing detection

(OP)
This is one layer of the PCB: there are 2 thin lines directly above labels Q4 Q2 Q15 Q6 Q13
They connect the opto-coupler to the chip. The big traces are AC lines and above Q4 Q2 Q15 is a big relay.

RE: Faulty zero crossing detection

I'm hung up on the low sense current(s) into and out of the Opto. For your 110 VAC input what "zero-cross" voltage level are you designing for? Say 10 volts. Then, at 10 volts the input current to the opto is 10/33000 = .0003 amps. The CTR at that current level looks to be about .2 so your opto output current = .0003 * .2 = .0000606 amps. Your pull up resistor is 4700 ohms. So your "pull down" volts = 4700 * .0000606 = .28 volts. That's not much for your 3.3 volt pull up voltage.

I'm guessing I'm missing something here? If the currents are really that low then you would be more susceptible to noise I'd think.

RE: Faulty zero crossing detection

This thread helped my problem too. Thanks every one.

RE: Faulty zero crossing detection

Replace BAS32L diode; it had 75V reverse voltage only; in fist moments of voltage applied, diode may see peak voltage of 170V... and initiate a reverse conduction (small cliping) that is "stoped" by 33k resistor.
Or add 0.1microF cap paralel with opto LED.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close