CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

phase control

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chava



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message Send e-mail

phase control
PostPosted: Sun Feb 15, 2004 3:52 am     Reply with quote

hello
I have a pic 12c508a and I have to control the ligth intensity of a lamp using a triack and a phase control methode.
what I did is that i sampled the phase input (220VAC) .
I know that when phase input voltage<0 I will get "o" in the pic pin and when the phase input voltage>0 I will get "1".
I made a little program to ligth the triack at "t" sec after zero cros was detected.(t is a time ofcourse)
the problem is that for some reasone the point in which the pic ligth the triack changes in a cyclic form, as if every phase-cycle the pic calculate "t" differently

here is the code- main procedure:

while (1){
//the loop condition detect phase direction change
while(input(pin_phase)==mystatus.current_phase){

TMR0=0;
wait_for_pulse+=1;
if (wait_for_pulse==level) output_high(pin_out);
else output_low(pin_out);
while (TMR0<100);//wait 200 usec
}

//phase_direction_changed:
if (input(pin_phase)==1) mystatus.current_phase=1;
else mystatus1.current_phase=0;
wait_for_pulse=0;

}
Code:


the program gives a single short pulse when "wait_for_phase==level"

"mystatus" is a byte variable of bit flags,
"current_phase" is a bit in mystatus.
"wait_for_pulse" count time since last time that the phase direction changed
""level" is the requiered point in time that the program should give a single pulse to the triack
when
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Sun Feb 15, 2004 8:19 pm     Reply with quote

Here is something really basic.


While(1)
{
While(input(pin_phase));
Delay_ms(x);
output_high(pin_out);
output_low(pin_out);
While(!input(pin_phase));
Delay_ms(x);
output_high(pin_out);
output_low(pin_out);
}

The value for x has to be in the range of 1/2 of the period and less. That gives you from 0 to ~8mS at 60hZ. Thats not a lot of resolution but the method used for delay can be something different. This method requires a timer that counts for longer than 1/2 the period;

While(1)
{
While(input(pin_phase));
set_timer1(0);
while ( get_timer1() < x) ;
output_high(pin_out);
output_low(pin_out);
While(!input(pin_phase));
set_timer1(0);
while ( get_timer1() < x) ;
output_high(pin_out);
output_low(pin_out);
}
chava



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message Send e-mail

I tryed that
PostPosted: Mon Feb 16, 2004 7:52 am     Reply with quote

hi
well I tryed that methode but the result was a blinking ligth. the ligth was not stable and a sence of blinking was in it.
tank you anyway,
by the way i succeeded , I did it by minimizing the period of the loop so that there is no delay between the point-in-time is which a phase-dierection-change was detected to the point-in-time when the pic respond to that detection.
thanks
chava
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group