Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/22/10 18:50
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#175286 - so try something safely
Responding to: ???'s previous message
1)Clamp diodes You can add at start and remove after firs success.
I believe that micro will survive. BUT MAKE EVERYTHING FOR YOUR SAFETY. For example - use isolating transformer. Even You do not have such one (1:1 )- You can construct one by 2 transformers connected in "series" - Mains 220V->(T1=220:12) ->(T2= 12V:220V) -> Your dimmer.
This is safe than direct connection to mains for first tests. BUT NOT VERY SAVE, CARE IS NEEDED.

2)1 Mohm ZCD to 8051 will have different behavior than in PIC or some AVR:
a) usually 8xx51 has pull-up circuit
b) input impedance is different.
My expirience is not enough to predict result, You must try.

3) Using Timer instead second ZCD interrupt.
At start -
- wait falling edge on ZCD-pin (disable INT0') .
- clear TL0,TR0 , set Timer in 16 bit mode, external gated , incremented by OSC/12 , enable TR0, clear TF0, disable ET0.
- wait next falling edge on ZCD-pin. Now Timer0 is un-gated , contents X=TH0TL0 shows length of positive half-wave. If Your XTAL=12MHz , then this number is in microseconds . Note - 2*X can be more , less or equal to period.

To measure period You must be very fast (disable interrupts):
- clear timer Tr0=0, th0tl0=0
- wait for high on ZCD-pin
- wait for low
- enable timer with TR0=1 , gate=1 (do not use external gate) .Here You will lose some microseconds.
- wait for high
- enable external gating
- now relax and wait for low.
At falling edge You can read TH0TL0= period.

If You want - repeat some times and average results.


So You can go further - to mainloop.
You will use Int0 on falling edge to detect ZC in (let say) negative direction .
Using any timer You can still track (by controlling timer in INT0 ISR) length of period.

You have Period measured already. On INT0_ISR start Timer1 -
TR1=0 ;TH1TL1=65536-Period , timer mode, TR1=1 enabled,ET1=1 - interrupt enabled.
So After half of period Timer1 ISR will be started - at start of second semi-wave.
Good thinked code will have error (relative to real Zero cross) less than 10 microseconds.


Other way - You do not need to search for second ZeroCross. What i mean:
- On INT0 You detect ZeroCrossing. After some already calculated time AngleTime1 You must fire lamp. So start Timer1=65536 - AngleTime1. Enable TR1, ET1.
- After AngleTime1 Timer1 will invoke ISR_TIMER1. Fire lamp. If You use incandescent lamp and triac - few microseconds fire pulse is enough for triac. You are somewhere in negative semiwave.
Now reload Timer1=65536-HalfPeriod. Clear TF1, keep ET1=1; Unfire triac now. Exit ISR.
- After Half period Timer1 will invoke Timer1_isr. Fire triac again. Wait few microsecond and un-fire .
- And now next INT0 interrupt is coming.


So , i think i should take a beer,
and let You to understand what i mean.
Good luck







List of 86 messages in thread
TopicAuthorDate
External Interrupt on both Falling edge & rising edge            01/01/70 00:00      
   ABORT!, ABORT!, ABORT!            01/01/70 00:00      
      Better circuits exists            01/01/70 00:00      
      one more            01/01/70 00:00      
   DANGER!! Don't Try This At Home!            01/01/70 00:00      
      Its not just Atmel            01/01/70 00:00      
   interrupts on both edges            01/01/70 00:00      
      Thank you All            01/01/70 00:00      
         Read about external Gate for Timer            01/01/70 00:00      
            gate for timer            01/01/70 00:00      
               Jan, will you Shhhhh!!!            01/01/70 00:00      
               Great Idea !            01/01/70 00:00      
                  But i've used up INT0 and INT1 pins            01/01/70 00:00      
                     int0 is gate for timer0            01/01/70 00:00      
                     T1(T0) pin is not use here            01/01/70 00:00      
                        so only one Ext.int pin will do            01/01/70 00:00      
                           i think so            01/01/70 00:00      
                              I haven't tried it yet            01/01/70 00:00      
                                 is a Zener that costly?            01/01/70 00:00      
                                 so try something safely            01/01/70 00:00      
                                    That the most exhaustive reply i got so far !            01/01/70 00:00      
                                       You are wellcome            01/01/70 00:00      
                                          Here's what i have done            01/01/70 00:00      
                                             simulation is partial            01/01/70 00:00      
                                                I'll try writing a sample code            01/01/70 00:00      
                                                   Dimmer            01/01/70 00:00      
                                                      its a dimmer for commercial sale            01/01/70 00:00      
                                                         Dimmer            01/01/70 00:00      
   Its in my Profile            01/01/70 00:00      
      is 8051/2 I/O similar to Zilog Z8            01/01/70 00:00      
         Cease and Desist            01/01/70 00:00      
         It's DANGEROUS - It's not about the IOs!!            01/01/70 00:00      
         Either you are NOT listening...or you don't want to listen            01/01/70 00:00      
            It's worse than that!            01/01/70 00:00      
               Its like openning Pandora's box            01/01/70 00:00      
                  chip A != chip B != chip C            01/01/70 00:00      
                  Consider these points...            01/01/70 00:00      
                     not a newbie to electronics            01/01/70 00:00      
                        What results do you really get from an experiment?            01/01/70 00:00      
                        Reply to Arun Kumar V            01/01/70 00:00      
                  what if the result is death?            01/01/70 00:00      
                     very positive opinion            01/01/70 00:00      
                     Thanks for the pointer            01/01/70 00:00      
   A generic approach to dual edge detection            01/01/70 00:00      
      Here is the method I have been using...            01/01/70 00:00      
      Oh Noes!!!!!!            01/01/70 00:00      
      4 -> 10 nsec Pulse Does Not Work for MCU            01/01/70 00:00      
         No additional logic gates            01/01/70 00:00      
         Modifying design            01/01/70 00:00      
            Yeah But...            01/01/70 00:00      
               If you say so            01/01/70 00:00      
                  Poppycock            01/01/70 00:00      
   Why you should not do this...            01/01/70 00:00      
      Galvanic isolation            01/01/70 00:00      
         Can't we use single AC optocoupler            01/01/70 00:00      
            not 1,8V            01/01/70 00:00      
            can be wrong circuit below            01/01/70 00:00      
               Critical again...            01/01/70 00:00      
                  varistor?            01/01/70 00:00      
                     Yes, but...            01/01/70 00:00      
            You can do a lot of things...            01/01/70 00:00      
               25V is too coarse            01/01/70 00:00      
                  use tha appnote I gave you the link to            01/01/70 00:00      
                  25V is not bad            01/01/70 00:00      
                     You still don't know what my product is?            01/01/70 00:00      
                        sorry            01/01/70 00:00      
                           Its O.K - this thread has crossed 65 replies            01/01/70 00:00      
                              npn            01/01/70 00:00      
                        no, I do not know what your product is            01/01/70 00:00      
                           Answers            01/01/70 00:00      
                              OK, then            01/01/70 00:00      
                                 No headphones            01/01/70 00:00      
                  Then take a better opto!            01/01/70 00:00      
                     he wants to build a Yogo, not a Mercedes            01/01/70 00:00      
                        which makes the lamp flicker when the fridge turns-off            01/01/70 00:00      
                           it (probably) does that anyhow            01/01/70 00:00      
                              No body wants to buy a Mercedez            01/01/70 00:00      
                                 What do you expect??            01/01/70 00:00      
                                    What is there to be ashamed of ?            01/01/70 00:00      
                                       Thread began with ....            01/01/70 00:00      
                                          Dead Horse is Alive and Kicking            01/01/70 00:00      
                                             obviously a comparator is a better solution            01/01/70 00:00      
                                                Oh My God...you having sleepless nights???            01/01/70 00:00      
                                             Then share it with us...            01/01/70 00:00      
                                             to Arun PLEASE get ...            01/01/70 00:00      
                                 what did you expect            01/01/70 00:00      

Back to Subject List