View previous topic :: View next topic |
Author |
Message |
nurquhar
Joined: 05 Aug 2006 Posts: 149 Location: Redditch, UK
|
PIC Phase Angle Dimmer - Best Way to sync to zero cross ? |
Posted: Thu Oct 02, 2008 10:21 am |
|
|
I am going to be doing new PIC project which involves dimming some Neon Transformers (inductive loads).
I already have an 'On-Off' circuit design (and spare PCB's) that uses a 16F876 to switch some Crydom 5A SSR's. The SSR's had inbuilt zero-cross so when they switched the neon tx's there was'nt lots of mains noise.
Now fortunatly I had also included on the board an input into RB0 from the 6v secondary of transformer used for the circuits PSU. The tap is taken before the bridge rect and is voltage limited by a 10k and diode clamp.
So by swapping in some non-zero-cross SSR's I should have a circuit capable of also being a Dimmer. With the right software
To get to the question For accurate control of the triac's in the SSR's I need to sync to the zero-cross point on the mains. Although I have the RB0 input that could simply trigger an interrupt I am thinking this may be too crude for two reasons :
1) lead/lag in the input signal because the input will read as Zero before just before the AC voltage has dropped to zero.
2) Noise on the AC line may cause false interrupts.
Does anyone have an idea on how to use the zero-cross input and "filter" out any rubbish and accuractly sync to the true zero cross point
I was thinking of something like a 100hz timer interrupt that the software "tunes" until it syncs with the true zero cross point.
Any thoughts would be welcome ..........
Regards
Neil |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
Re: PIC Phase Angle Dimmer - Best Way to sync to zero cross |
Posted: Thu Oct 02, 2008 11:51 am |
|
|
nurquhar wrote: | I was thinking of something like a 100hz timer interrupt that the software "tunes" until it syncs with the true zero cross point. |
Good idea. This will be a kind of a software PLL (phase-locked loop). You just need to limit the phase-error value's range to smoothen out any noise or false zero-cross signals caused by spikes. Limiting the 100 Hz timers range to let's say 95-105 Hz will also filter out wrong operation. However this solution would need some tune-up time after turn-on, during this you might need to block operating the SSR based upon untuned values.
Regarding the lag/delay it is a fairly constant value, I suggest to visualize it on a two-channel oscilloscope (if you have one around) one channel would be the mains input (divide it to low voltage), the other would be the PIC's signal of the zero-cross point (what it thinks to be) on a port. Adding a constant value will solve this problem. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Oct 02, 2008 12:57 pm |
|
|
This app note on zero crossing detection is old but still worth reading.
http://ww1.microchip.com/downloads/en/AppNotes/00521c.pdf
Sampling a higher voltage input makes the zero crossing faster and therefor more precise and noise resistant. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
RLScott
Joined: 10 Jul 2007 Posts: 465
|
Re: PIC Phase Angle Dimmer - Best Way to sync to zero cross |
Posted: Thu Oct 02, 2008 1:02 pm |
|
|
nurquhar wrote: | ..I had also included on the board an input into RB0 from the 6v secondary of transformer used for the circuits PSU. The tap is taken before the bridge rect and is voltage limited by a 10k and diode clamp...
Neil |
I think 6v may be too low to give accurate timing. Maybe that's what you meant when you mentioned the lead/lag problem? The switch point of the RB0 input is nominally half the Vdd, but is could be anywhere from .2 Vdd to .8 Vdd. This will give you a lot of uncertainty as to where the zero crossing is. Can you use a 110 v feed instead? You may need to raise the current-limiting resistor, but at least you would get a logic trigger that was pretty close to the zero-crossing of the sine wave. _________________ Robert Scott
Real-Time Specialties
Embedded Systems Consulting |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Thu Oct 02, 2008 1:46 pm |
|
|
I would suggest the following circuit connected to the mains:
series resistor (about 22k - 33k 2W) ---> rectifying diode brigde. A 11 V Zener in series with the DC ---> optocoupler's diode. + a diode added in parallel with the optocoupler's led.
and connect the optocoupler's output to the B0 pin with a pull-up resistor.
The zener will cut of everything above 10 V, but you still get the sharp resolution. and also a galvanic isolation for safety.
Last edited by libor on Thu Oct 02, 2008 1:49 pm; edited 3 times in total |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Oct 02, 2008 1:47 pm |
|
|
Hello,
You didn't tell the exact circuit. If you evaluate the voltage difference between an AC terminal before a bridge rectifier and your circuit ground, please consider that with a single transformer winding the AC voltage is floating most of the time. Very bad for a precise ZCD. It would be different in case of a dual voltage supply and a ground connected transformer center tap.
You can break the floating transformer state by connecting a resistor from the opposite AC terminal to ground. To get the ZCD work nearer to the real zero crossing, you can use a NPN transistor (with an antiparallel protection diode) as level converter. It's 0.6 V threshold is equivalent to only 4° phase angle with 6V AC, that's acceptable.
The said software PLL shouldn't be necessary in typical applications. However, in some cases, the power switch may cause a second, false ZC signal shortly behind the real one. Thus a holdoff of a few ms after the ZC trigger may be helpful.
Regards,
Frank |
|
|
umka
Joined: 28 Aug 2007 Posts: 99 Location: New Zealand
|
|
|
nurquhar
Joined: 05 Aug 2006 Posts: 149 Location: Redditch, UK
|
|
Posted: Fri Oct 03, 2008 2:24 am |
|
|
WOW Thanks for all the useful suggestions.
On balance I think I'll work in an AC Input opto-iso (TCLT1600) with a couple of 47k's connecting it to the 240v live and neutral. The transistor op connected to RB0.
Although the high value resistor connected to the 240v live is probably the simplest it also makes me the most nervous. I assume for it to work I would need to also reference the gnd to the neutral line. I don't want to kill myself, my Digital Scope or ICD if something goes wrong with the resistor. For the small cost I will keep the galvanic isolation.
As for the software then it seems to make sense to try the simple things first, ie just use the ZC RB0 interrupt to sync the code as most people seem to work with. Then if there are false triggers use the code to turn of the interrupt until it s expected. Then if that don't work do the PLL type of thing.
Yet again thanks for the input |
|
|
Ttelmah Guest
|
|
Posted: Fri Oct 03, 2008 3:05 am |
|
|
I have in the past, used the output from a low voltage transformer to detect zero crossing OK. The solution, is not to couple it directly to a PIC, but instead use a comparator, with the second input, fed from a massively integrated copy of the waveform. So one input of the comparator receives the AC signal, while the other receives a near DC level, corresponding to the 'average' value of the waveform. This gives a square wave, with transitions at the 'half way' point. Provided there are not any really nasty asymmetries on the waveform, the signal changes are 'close', to the zero points, and don't involve dealing with high voltages. The output of the square wave, is then fed into one input of an XOR gate, while the other input is fed from the output of the XOR gate, via a other gates, to give a tiny delay (and an inversion). This then gives a narrow pulse (depending on the delay time of the gates), whenever the square wave changes level.
Best Wishes |
|
|
JackPols Guest
|
cosmetics, cosmetics beauty, make up cosmetics |
Posted: Thu Feb 26, 2009 5:08 am |
|
|
I like to have seen discussion of this topic in this forum |
|
|
JackPols Guest
|
cosmetics, cosmetics beauty, make up cosmetics |
Posted: Thu Feb 26, 2009 5:10 am |
|
|
+1 |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
about dimming gas tubes |
Posted: Thu Feb 26, 2009 8:24 am |
|
|
not to sound too dim - but is everybody CERTAIN that this approach CAN actually dim a neon tube?
i was under the persistent impression that such gas tube illumination was basically resistant / intolerant to phase angle modulation.
has the concept been tested successfully with an off- the shelf - $20 dimmer module ? and is it KNOWN to work ? |
|
|
|