Go Down

Topic: Direct zero cross detect - filter capacitor (Read 365 times) previous topic - next topic

lefstin

Oct 09, 2018, 05:01 am Last Edit: Oct 09, 2018, 05:40 am by lefstin
I'm playing around with triac phase control of a model railroad that runs on 18V AC power.

To detect the zero cross of the track power, I connected one leg of the AC supply to an input pin via a 220k resistor (similar to the scheme shown in this application note). This relies on the internal clamping diodes on the I/O pins. With a 220k resistor, the peak current through the clamping diodes should be about 0.12 mA, well within the 1mA limit described in the note.

This worked, but was picking up a fair amount of noise (the AC coming off the railroad track is messy to start with, and the triac probably doesn't help). While I might handle the noise in software as described in the Atmel note, I was curious if a 100 pF capacitor on the input (as described in Figure 6 of this note) could clean up the noise. So I added one after the 220k resistor.

This eliminated the noise, but shortly afterwards the Arduino (a Pro Mini-type board) let out its magic smoke (nothing visible burned, but I heard a pop, smelled the burn, and the board is dead).

Now I'm not sure if the capacitor was to blame - I have a rat's nest of alligator clips and something else could have shorted.

So, QUESTION: could adding the filter capacitor have overloaded the clamping diodes?  Would the capacitor charge to about 25V and dump that charge straight into the protection diodes?

The circuit in Figure 6 of the ON Semi note has clamping diodes BEFORE the filter capacitor, so I assume the capacitor in that circuit would only charge to 3.3v.

wvmarle

I don't see anything wrong with the circuit as in the application note, but don't know yours: you say "similar to", but don't post your actual circuit, and the differences may be key.

220k/18V should be safe indeed.

The cap should not cause any issues: when the voltage swings to the other side, the 5V potential of the cap may want to discharge in one go through the clamping diodes, but as the RC of this circuit is about 22 ┬Ás the swing through zero should be slow enough for the cap to follow the voltage as the input goes from +5V to -0.5V (I suppose you use 50 Hz or 60 Hz AC).
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

lefstin

#2
Oct 09, 2018, 05:45 am Last Edit: Oct 09, 2018, 05:45 am by lefstin
The difference is that my circuit didn't have the external clamping Schottky diodes shown in Figure 6 of the ON Semi application note.  Rather,:

18v AC  -- 220k ---- GPIO
                               |
                               |
                              100 pF
                               |
                            GND (common with other half of AC line)

So I'm wondering if my capacitor would charge to the peak voltage of 25V, and if that would be a Bad Thing.

wvmarle

#3
Oct 09, 2018, 06:11 am Last Edit: Oct 09, 2018, 06:11 am by wvmarle
The Atmel AN also shows a resistor between Arduino GND and the other AC wire.

I can imagine a ground loop on that side, depending on how the power supplies are ultimately connected. You may have to use 2x100k instead - one for each AC wire.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

lefstin

The Arduino is also powered from the 18V AC supply (via a buck module), so I don't know how the grounds would be separated.


No one knows if the filter capacitor would charge to 25V, or if that would be a problem?

Southpark

#5
Oct 09, 2018, 06:58 pm Last Edit: Oct 09, 2018, 11:07 pm by Southpark
No one knows if the filter capacitor would charge to 25V, or if that would be a problem?
You could certainly try it again. But this time..... avoid possible issues like short circuits. Eg. do something that avoids bare wires or clips from shorting to other wires or components. That's what can happen if you have rats nests - as you correctly predicted. The rats nest itself is not uncommon .... but has thrown in a fair bit of uncertainty due to various bare metal bits floating around.

outsider


wvmarle

That filter cap can't charge beyond +5.5V or -0.5V thanks to the clamping diodes of the Arduino.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

lefstin

Where is the Arduino GND connected?
To the other half of the AC supply, as shown in reply #2.  The Arduino receives its power from the 18v line, half-wave rectified and fed into a buck module.

lefstin

That filter cap can't charge beyond +5.5V or -0.5V thanks to the clamping diodes of the Arduino.
Ok, that makes sense when you put it that way.  So it doesn't seem like the capacitor could be a source of current that would overload the clamping diodes.

I may nonetheless use some external clamping diodes or give up and put in an optocoupler.  This is the third or fourth chip I've smoked with this project, even though the circuit works, so something isn't right.

Southpark

This is the third or fourth chip I've smoked with this project, even though the circuit works, so something isn't right.
What is the value of supply voltage for this arduino? How many volts?

lefstin

What is the value of supply voltage for this arduino? How many volts?
5V, via a Pololu buck module hooked to Vcc.

The noise issue is proving tricky.  My zero cross interrupt routine samples the input 4 additional times and reports whether the readings are consistent.  Sometimes there's a fair amount of noise, particularly when the triac is firing at certain points in the cycle. But sometimes there's none.  When there's noise sometimes just putting the oscilloscope probe at the input pin cleans it up. But without the noise appearing consistently it's hard to experiment with noise control measures.

I don't have a pullup enabled on the input line; I could try that.




JohnRob

You could use a circuit like this:    Zero Cross opto

It would allow you to full wave rectify the 18VAC to the buck converter.  I don't know your load current so I can't say if this would actually be beneficial.


Or you could do the same with a regular transistor.  Why might it be better?  Lower impedance = less noise pickup.




Not directly to your question / problem but an alternative might be:

Use an opto-isolated zero crossover driver for your triac.   To dim simply drop cycles.  Of course on really low "dim" settings you would run into noticeable pulsing.



Please do not PM me with thread based messages.  If your thoughts are worth responding,  the group should benefit from your insight.

wvmarle

You could use a circuit like this:    Zero Cross opto
Circuit #4 is a peak detector, not zero crossing. Needs a bit more magic with the timers to make that work, but the great advantage is no hot resistors.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

JohnRob

Circuit #4 is a peak detector, not zero crossing. Needs a bit more magic with the timers to make that work, but the great advantage is no hot resistors.
I'm not sure I follow.  For me the link shows a number of Zero Crossing detectors, Figure 4 is an Arduino based lamp dimmer with Zero Crossover detection.

I would think at 18Vac the resistor required would not require too much power.
Please do not PM me with thread based messages.  If your thoughts are worth responding,  the group should benefit from your insight.

Go Up