Browse over 10,000 Electronics Projects

# AC Power Control with Thyristor – Pulse Skipping using triac with PIC16F877A BROWSE

//———————————————————————————————————
//Programmer: Syed Tahmid Mahbub
//Compiler: mikroC PRO for PIC v4.60
//Target PIC: PIC16F877A
//Program for pulse skipping modulation or cycle control
//———————————————————————————————————
unsigned char FlagReg;
unsigned char Count;
unsigned char TotalCount;
unsigned char nCount;
unsigned char nTotalCount;
sbit ZC at FlagReg.B0;
void interrupt(){
if (INTCON.INTF){          //INTF flag raised, so external interrupt occured
ZC = 1;
INTCON.INTF = 0;
}
}
void main() {
PORTB = 0;
TRISB = 0x01;              //RB0 input for interrupt
PORTA = 0;
TRISA = 0xFF;
PORTD = 0;
TRISD = 0;                 //PORTD all output
OPTION_REG.INTEDG = 0;      //interrupt on falling edge
INTCON.INTF = 0;           //clear interrupt flag
INTCON.INTE = 1;           //enable external interrupt
INTCON.GIE = 1;            //enable global interrupt

Count = 6;                 //number of half-cycles to be on
TotalCount = 10;           //total number of half-cycles control
nCount = Count;
nTotalCount = TotalCount;
while (1){
if (ZC){ //zero crossing occurred
if (nCount > 0){
PORTD.B0 = 1;
delay_us(250);
PORTD.B0 = 0;
nCount–;
}
nTotalCount–;
if (nTotalCount == 0){ //number of required half-cycles elapsed
nTotalCount = TotalCount;
nCount = Count;
}
ZC = 0;
}
}
}
The total number of half-cycles I want to control is stored in the register TotalCount. Count holds the number of half-cycles I want voltage supplied to the load. So, the ratio of Count to TotalCount equals the duty cycle.
Each time the triac is fired, the value of nCount is decremented, until it reaches zero. When nCount equals zero, the triac is no longer fired. At the same time, the register nTotalCount is decremented each zero-crossing. So it keeps track of the number of half-cycles elapsed. Initially nTotalCount is loaded with the value of TotalCount so that nTotalCount keeps track of the number of half-cycles we want to control. After that number of half-cycles elapses, nTotalCount is reloaded with the value of TotalCount and nCount is reloaded with the value of Count. Pulse skipping modulation starts over again.
In our code, we want to control 10 half-cycles, which means 5 cycles. We want voltage to be supplied to the load for 3 cycles and off for 2 cycles. This is done, as nCount counts down from 6 to 0 while firing the triac, firing the triac 6 consecutive half-cycles. For the next 4 half-cycles, while nTotalCount is still counting down to zero, the triac is off. So, voltage is not supplied to the load. The duty cycle is 60%.
The triac is fired right after zero-crossing occurs. One advantage of this is that very little radio frequency interference is produced. However, care must be taken that an unequal number of positive and negative half-cycles must not be present. This will introduce a DC component that can damage motors and other devices. Cycle control also cannot be used with incandescent bulbs because of high unacceptable flickering.
This problem with the DC component is avoided by ensuring that equal numbers of positive and negative half-cycles are present. This is done by ensuring that the Count and TotalCount (in the code above) are both even numbers.

Now let’s take a look at my circuit setup and then the output waveform using this code:

BROWSE

Top
{"ft_lang_label":"__label__en","ft_lang_prob":0.8862856,"math_prob":0.9456234,"size":3188,"snap":"2021-04-2021-17","text_gpt3_token_len":832,"char_repetition_ratio":0.17933416,"word_repetition_ratio":0.030828517,"special_character_ratio":0.26286072,"punctuation_ratio":0.13856427,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9771279,"pos_list":[0,1,2],"im_url_duplicate_count":[null,9,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-16T12:08:07Z\",\"WARC-Record-ID\":\"<urn:uuid:d6d5b7bf-980a-4680-a805-73e29e047e0a>\",\"Content-Length\":\"48426\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:875ce069-7989-44a3-8733-bf2f1221cad4>\",\"WARC-Concurrent-To\":\"<urn:uuid:654583cd-189a-45f5-8696-3588d2164ab7>\",\"WARC-IP-Address\":\"104.21.77.243\",\"WARC-Target-URI\":\"https://electronicsinfoline.com/pin/38326/2/\",\"WARC-Payload-Digest\":\"sha1:FCAJTFW54REFE7AAGCJTDF36NKJ4OW3M\",\"WARC-Block-Digest\":\"sha1:HJEJ3CSLFU2AIM6TBVTHL52MNYVPQJU7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703506640.22_warc_CC-MAIN-20210116104719-20210116134719-00007.warc.gz\"}"}