9 Replies Latest reply on May 1, 2015 3:21 PM by user_14586677

    Wild Results for Zero Cross Timer

    nathan.spackman

       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.

        • 1. Re: Wild Results for Zero Cross Timer
          nathan.spackman

           Here is a screenshot of the Results.     

          • 2. Re: Wild Results for Zero Cross Timer
            user_14586677

            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.

            • 3. Re: Wild Results for Zero Cross Timer
              user_14586677

              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.

              • 4. Re: Wild Results for Zero Cross Timer
                user_14586677

                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.

                • 5. Re: Wild Results for Zero Cross Timer
                  nathan.spackman
                          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.   
                  • 6. Re: Wild Results for Zero Cross Timer
                    user_14586677

                    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.

                    • 7. Re: Wild Results for Zero Cross Timer
                      user_1377889

                      Sorry, bad post

                         

                       

                         

                      Bob

                      • 8. Re: Wild Results for Zero Cross Timer
                        nathan.spackman

                         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)

                        • 9. Re: Wild Results for Zero Cross Timer
                          user_14586677

                          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.