CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC Phase Angle Dimmer - Best Way to sync to zero cross ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nurquhar



Joined: 05 Aug 2006
Posts: 149
Location: Redditch, UK

View user's profile Send private message Visit poster's website

PIC Phase Angle Dimmer - Best Way to sync to zero cross ?
PostPosted: Thu Oct 02, 2008 10:21 am     Reply with quote

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. Smile 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 Exclamation

To get to the question 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 Idea

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

View user's profile Send private message

Re: PIC Phase Angle Dimmer - Best Way to sync to zero cross
PostPosted: Thu Oct 02, 2008 11:51 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 02, 2008 12:57 pm     Reply with quote

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

View user's profile Send private message

Re: PIC Phase Angle Dimmer - Best Way to sync to zero cross
PostPosted: Thu Oct 02, 2008 1:02 pm     Reply with quote

nurquhar wrote:
..I had also included on the board an input into RB0 from the 6v secondary of transformer used for the circuits PSU. Smile 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

View user's profile Send private message

PostPosted: Thu Oct 02, 2008 1:46 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 02, 2008 1:47 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 02, 2008 2:03 pm     Reply with quote

hey have a look at this. it is really quite good and has circuit diagrams and code for triac and igbt methods

http://www.microchipc.com/sourcecode/#triac

search the page for : PIC16F84 based TRIAC / IGBT phase controller for 50/60Hz brightness control by Mike Pearce

or download zip file straight form : http://www.microchipc.com/sourcecode/PIC_Hi-Tech_C_Mike_Pearces_phase_controller_TRIAC_or_IGBT_50-60Hz.zip
nurquhar



Joined: 05 Aug 2006
Posts: 149
Location: Redditch, UK

View user's profile Send private message Visit poster's website

PostPosted: Fri Oct 03, 2008 2:24 am     Reply with quote

WOW Exclamation 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 Very Happy
Ttelmah
Guest







PostPosted: Fri Oct 03, 2008 3:05 am     Reply with quote

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
PostPosted: Thu Feb 26, 2009 5:08 am     Reply with quote

I like to have seen discussion of this topic in this forum
JackPols
Guest







cosmetics, cosmetics beauty, make up cosmetics
PostPosted: Thu Feb 26, 2009 5:10 am     Reply with quote

+1
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

about dimming gas tubes
PostPosted: Thu Feb 26, 2009 8:24 am     Reply with quote

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 ?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group