??? 11/24/04 03:06 Read: times |
#81794 - Thyristor output flickering. |
Hi Forum Members,
I am using my controller for firing a thyristor. In my application I need to fire thyristor at an appropriate angle to get the desired output voltage. I am using a zero cross detector built around LM311 comparator for zero cross reference. The zero cross output from comparator is fed to INT0 pin of the micro. with interrupt 0 enabled. Here is figure illustrating this. ![]() Since I need to fire thyristor both the half cycles but I get only one interrupt due to being low only during low half cycle thus to get away with this problem and to fire at appropriate angle I am using Timer 1 in 8 bit reload mode set to tick at every 133 machine cycles i.e. 100us with my setup. The timer 1 interrupt is used for positive going zero cross determination as well as for timing the thyristor firing delay with an accuracy of 100us. Here are my EX0 and T1 interrupt service routines. //*********External Interrupt [zero cross]*************** void ex1_isr(void) interrupt 0 using 3 { uchar ii, itestroot=0, ibackroot, iorer=0x80; uint itestsqr; SYSTIME=0; //reset SYSTIME variable. EX0=0; //disable interrupt ex0 to avoid immediate next intrpt. sysset=0; //reset syset variable. if (onfire) //if fire is enabled set fire counter 20 to get 10 pulses. firecount=20; cycles++; //Increament the number of cycles variable MSSUM=MSSUM/samples; //divide squre sum by samples to get mean sqare. for(ii=0; ii<8; ii++) //Square root calculation { ibackroot=itestroot; itestroot|=iorer; itestsqr=itestroot*itestroot; if(itestsqr>MSSUM) itestroot=ibackroot; iorer=_cror_(iorer,1); } if (ARMS) ARMS=(ARMS+itestroot)/2; //Add it into previous value and divide by 2 else //to get Average RMS. ARMS=itestroot; MSSUM=0; //clear the square sum variable and samples. samples=0; //clear the samples variable. } /*********Interrupt function for timer 1**************** This interrupt is always on and is 100us*/ void t1_isr(void) interrupt 3 using 2 { SYSTIME++; //increament the SYSTIME variable used for fire timing. if (SYSTIME>99 && !sysset ) //if systime=100 there is a zero cross since . { //10ms elapsed past last EX0 interrupt. SYSTIME=0; //Reset systime upon zero cross. sysset=1; //Set sysset variable to take a not of this reset. if (onfire) //If fire is enabled set pulse count as 20. firecount=20; //to give 10 pulses to thryistor. } if (onfire && SYSTIME>firedly && firecount) //If firing is enable //and required firing delay has elapsed and pulse down count is not 0. { FIREPORT=!FIREPORT; //Togle Firing output pin firecount--; //Reduce fire count variable by 1. } if (sysset && (SYSTIME>50)) EX0=1; //Enable external interrupt 0 to detect next low //for zero cross detection } 1. The SYSTIME is a gloabal unsigned char. and is used to keep track of X100us elapsed since last zero cross. 2. The firedly is also a global unsigned char its value is set by main propgram to set the firing angle. 3. firecount is a global unsigned char varibles used for keeping track of number of pulses sent and send exactly ten pulses. 4. onfire is a global bit variable set/cleared by main program to enable or disable firing. 5. sbit FIREPORT=P1^2; 6. Interrupt priority is set for timer 1 PT1=1; 7. samples are global unsigned char variables. 8. MSSUM, ARMS is a global unsigned char. The thyristor is made to drive a 100W bulb to test the program and the problem the bulb appears flickering. I have tried a lot tracking the cause but couldn't succeed. Please have a look at the ISR and tell me what's wrong. It seems I am biased with the code and thus can't find whats wrong. Please note that this thread is in relation to the same project for which I had posted http://www.8052.com/forum/read.phtml?id=81609 I have completely changed my ISR and some part of my software but this flickering is making my head bang with the walls but no help?? If you find this post confusion and/or more information is needed tell me I will post it immediately. Thanks a lot for reading my post. Waiting desperately for your suggestions/ comments. Thanks & Regards, Prahlad Purohit |