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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/25/04 12:42
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#81923 - ideas
Responding to: ???'s previous message
hi,

Prahlad, I looking at code and see some not good coding. Let me cut next part of code:
	if (onfire && SYSTIME>firedly && firecount  && fwbit)
	{
		FIREPORT=!FIREPORT;	//Put the fire pulse	
		firecount--;		//Reduce remining pulse counter.
	}
	else
		FIREPORT=1;		//Make fire pin 1 to keep transistor off.
	fwbit=!fwbit;			//fwbit to make firing pulse 200us
	ioport=OPSTATUS;
}
First of all, I need to say that you toggle fwbit at each interrupt even if firing is not required. As result, you never be sure that at time when zero cross has been detected this bit is at state 1. As result, first firing pulse delay is not fixed and varies as (firedly + [0 or 100us]). I may suggest you to set this bit manually inside both cases:
if (IE0) {... fwbit=1 ...}
if (SYSTIME>99) {... fwbit=1 ...}
...but read below.

Secondly, your comment says:
fwbit=!fwbit; //fwbit to make firing pulse 200us

If you mean low level pulse duration time then it does not. The duration is 100us because next line:

else FIREPORT=1;

Let explain:
	if (IE0)		//If zero cross detected.
	{
		SYSTIME=0;	//increase systimer.
		cycles++;
		IE0=0;		//Clear zero cross flag.
		firecount=4;	//set fire couter.
	}
1. zero cross or SYSTIME detects that it needs firing. It loads number of pulses (firecount) and resets SYSTIME to count delay before actual firing (SYSTIME>firedly).
2. SYSTIME>firedly happens. Assume that fwbit is set at this time. So condition FIREPORT=!FIREPORT; makes first pulse (low level) and decreases firecount. fwbit inverts at the end of ISR.
3. Next interrupt (100us) comes on and so condition if (onfire && SYSTIME>firedly && firecount && fwbit) fails. Instead program does else FIREPORT=1;. By this, output comes to high level. As result, low level pulse duration time is 100us.

What is about next code:
	SYSTIME++;		//increament the SYSTIME variable used for fire timing
	if (IE0)		//If zero cross detected.
	{
		SYSTIME=0;	//increase systimer.
		cycles++;
		IE0=0;		//Clear zero cross flag.
		firecount=4;	//set fire couter.
	}
	if (SYSTIME>99)		//If SYSTIME exceeding 100 it is a zero cross.
	{
		SYSTIME=0;	//reset system timer.
		firecount=4;	//set fire counter.
	}
	if (onfire && SYSTIME>firedly && firecount)
	{
		FIREPORT=(firecount & 1);	//Put the fire pulse	
		firecount--;	//Reduce remining pulse counter.
	}
	else
		FIREPORT=1;	//Make fire pin 1 to keep transistor off.
	ioport=OPSTATUS;
}
Here I have fwbit deleted (its function is done with bit 0 of firecount).

Regards,
Oleg

List of 42 messages in thread
TopicAuthorDate
Thyristor output flickering.            01/01/70 00:00      
   Thyristor problem            01/01/70 00:00      
      No Hardware problem            01/01/70 00:00      
      Please Elaborate more.            01/01/70 00:00      
   Thyristor problem            01/01/70 00:00      
      Re: Thyristor Problem.            01/01/70 00:00      
      Mains looks seldom like pure sinus            01/01/70 00:00      
         Thanks Kai But problem seems diffrent            01/01/70 00:00      
   Did the changes but still flickering.            01/01/70 00:00      
      Did the changes ....            01/01/70 00:00      
         Russell- Where can I get DSO software            01/01/70 00:00      
   More thoughts on filtering            01/01/70 00:00      
   Flickering is not minor.            01/01/70 00:00      
      Cool Edit            01/01/70 00:00      
         Cool Edit - no more :-(            01/01/70 00:00      
         Loading is enough.            01/01/70 00:00      
      interrupt configuration            01/01/70 00:00      
         I am not using External Interrupts.            01/01/70 00:00      
            external interrupt            01/01/70 00:00      
               I am reading only the edge detect flag.            01/01/70 00:00      
                  configuration again            01/01/70 00:00      
                     Here is the configuration.            01/01/70 00:00      
   Is it Int. prioprity setting proble?            01/01/70 00:00      
      Why not use the PCA?            01/01/70 00:00      
         It's too late to change the design.            01/01/70 00:00      
   Its not a interrupt priority problem.            01/01/70 00:00      
      Real -time problems            01/01/70 00:00      
   Tried PCA!            01/01/70 00:00      
      Firing circuit            01/01/70 00:00      
      hardware modification            01/01/70 00:00      
         Already modified with PCA SYSTIME>99            01/01/70 00:00      
      Sorry I small typpo in earlier post.            01/01/70 00:00      
   ideas            01/01/70 00:00      
      Problem Solving Great Idea            01/01/70 00:00      
   Assymetry            01/01/70 00:00      
   back to root            01/01/70 00:00      
      It is for power control.            01/01/70 00:00      
   Hey Friends Problem Solved.            01/01/70 00:00      
   Happiness is...            01/01/70 00:00      
      Oh sure....            01/01/70 00:00      
   here i am?            01/01/70 00:00      
      Thanks Kuldeep.            01/01/70 00:00      

Back to Subject List