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
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;
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
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