bagusdj
Member level 3
- Joined
- Nov 25, 2012
- Messages
- 67
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 1,766
hey guys, im trying to make my phase angle control code using Keil C51.
i try to get half power delivered to my load. i also tried to use this program but it is not even close to correct
Code:
#include<reg52.h>
sbit triac=P3^0;
void cct_init(void);
void initint0(void);
unsigned char wek;
void cct_init(void)
{
P3=0x01; //my triac configuration toward mcu is active low.
}
void delay(unsigned int count) // Function to provide time delay in msec.
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1275;j++);
}
void initint0(void)
{
IT0=1;
EX0=1;
EA=1;
}
void external0_isr(void) interrupt 0
{wek=1;
}
void main(void)
{
cct_init();
initint0();
if(wek==0)
{triac=1;}
else
{delay(5);
TMOD = 0x01; //Timer 1, mode 1 (16-bit)
TL0=0xff; // load TL with 0x00
TH0=0xff; //load TH with 0xDC
TR0=1; //start Timer1
while(!TF0){;} //wait for timer1 overflow
TR0=0; //stop timer1
triac = 0; //complement P3.0
TF0=0; //clear timer1 flag
triac=1;
}
}
i try to get half power delivered to my load. i also tried to use this program but it is not even close to correct
Code:
#include<reg52.h>
sbit triac=P3^0;
void cct_init(void);
void initint0(void);
void cct_init(void)
{
P3=0x01;
}
void delay(unsigned int count) // Function to provide time delay in msec.
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1275;j++);
}
void initint0(void)
{
IT0=1;
EX0=1;
EA=1;
}
void external0_isr(void) interrupt 0
{
triac=0;
delay(5);
triac=1;
}
void main(void)
{
cct_init();
initint0();
while(1)
{}
}