Wild Results for Zero Cross Timer

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Hello,

   

  I am working on my final project for a PLD course using the CY8CKIT-050BU board. I am trying to create an AC light dimming circuit controlled by the PSoC.  The concept is simple and I've got the zero cross detector interrupt working and stable, but every timer/counter combination I've tried to count the wait time before firing the trigger interrupt has had inconsistent timing, resulting in a light blinking in varying intensity.  I am testing it with an LED and trigger it on with the Zero Cross interrupt and shut it off with the end of count interrupt.  The oscilloscope show that the zero cross is ok, but the wait timer is sporadic, what am I missing?  Attached is the latest version of this trouble.

0 Likes
9 Replies
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Here is a screenshot of the Results.     

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

All signals into PSOC are basically constrained as follows -

   

 

   

Vdd >= Vinx >= Vss. So generally speaking you have to offset

   

signals in order for PSOC to work correctly. Otherwise you will

   

get very erratic results. For some OpAmps, Comparators, signals

   

below ground will actuall create phase reversal, or trigger the

   

parasitic SCR mechanism in all CMOS and latch the part up,

   

blow it up.

   

 

   

If you are using a comparator you should use it with Hysterisis.

   

Also if you are looking at AC line consider a LPF to get rid of

   

transient noise from motor starting as an example.

   

 

   

Some methods of offsetting signals -

   

 

   

www.dropbox.com/s/k1yn4m7heaixvmg/ADinput%20negative%20inputs.zip

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Consider using a comparator based circuit and an analog pin into the

   

comparator.

   

 

   

Note its tempting to just use a R divider from the neutral to the hot line

   

side to limit V into PSOC, google "AC line interface zero cross", there

   

are a number of threads on how to do this. Note high value R's cause

   

offsets, and you need to calc their Pdiss to insure they won't smoke.

   

 

   

I have seen some use a high value R with clamp diodes at input of UP,

   

so that current is limited on negative cycle, and also for positive cycle

   

above Vdd. Not sure if this would pass UL safety though.

   

 

   

Regards, Dana.

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

One approach -

   

 

   

Net_sync.JPG

   

 

   

Basically you are working with low V and isolation due to transformer.

   

 

   

Another approach (circuit to right, you would have to debounce it) -

   

 

   

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable
        I am sorry I didn't explain myself so well. I think am using an h11aa1 zero cross detector with a moc 3020 photo triac to trigger the main triac. So my zero cross signal is sent as a rising edge 5v positive voltage to the board. I have an interrupt attached to this rising edge that works great, and does what it is supposed to. I have a timer started by this interrupt that counts down and fires a second interrupt when it is finished. I planned to just change the period of this timer with a variable, maybe hooked up to the capsense slider. It is this second interrupt that I cannot figure out. The First runs as it should, but the counter finishes its count at different points in time from the zero crossing. It isn't consistant, it has a range of finishing times making the light flicker at different brightnesses. The Zero Cross circuit works great with my Arduino, I got it fading beautifully smooth within a few hours (thanks to author "lex talionus"), so the circuit works, it is just the timer interrupts I can't figure out. I appreciate the replies and schematics I will look through later as I'm in a hurry. Thanks to all.   
0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The h11aa1 is not  a zero cross detector per se, just an opto isolator.

   

As such any power line noise will be coupled and trip the output driver

   

at different phase angles in the AC cycle. Aditionally it has no hysterisis,

   

so that in turn will cause "bounce" in the trigger signal.

   

 

   

You have the edge detector being clocked at 1 Khz, so that in turn could

   

be generating multiple triggers as the optoisolator "hangs" in its threshold

   

region. You might consider the pulse converter component or set a D then

   

clear it thru software.

   

 

   

Use PSOC to set up a test bed where you create noise and a sine with Wavedac

   

and test the robustness of the zero cross solution.

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Sorry, bad post

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 OK, I have solved the problem.  After unhooking my AC source yesterday I noticed that the Trigger Timer was still running, it should have stopped after each cycle, which I figured it being configured as a one shot would take care of.  It did not and so I had to manually stop it in the interrupt function triggered by it's completion. This solved the problem.  Oddly enough the Zero Cross detector works better without the debouncer, I am new at this and maybe didin't configure it right, but with the debouncer component hooked up to the same clock and the zero in pin it actually missed triggers.  It does not miss without the debouncer and makes a beautifully smooth light.(On the LED, haven't tested it in the full circuit yet).  Thanks for the stimulation of thought Dana, attached is the working circuit for the test.  In the actual circuit the zero cross will turn on the Trigger Timer/counter and then at the second interrupt turn on the triac with a short pulse of 55.6 microseconds.  (I hope)

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Right now your timer only allows 1/2 the line waveform control,

   

no reason not to set it up so that you can control into the other 1/2

   

of the sine.

   

 

   

Food for thought.

   

 

   

Regards, Dana.

0 Likes