Sajjadkhan
Full Member level 5
- Joined
- Sep 25, 2010
- Messages
- 307
- Helped
- 17
- Reputation
- 34
- Reaction score
- 16
- Trophy points
- 1,298
- Location
- Rawalpindi,Pakistan
- Activity points
- 4,199
Hi guys. I am a bit stuck for few days. Actually i have built this circuit and everything for me seems to be ok but my bad the triac is not working. here is the schematic ( fig 1 ) interfaced with pic controller. 330 ohms is connected to RA1 pin. pic16f688 used. U1 is moc3062.
In fig 2 yellow signal is the AC rectified signal which is fed to a transistor base via 1k resistor. 10k resistor is connected to 5v and transistor collector and fed to the controller interrupt pin for detecting zero crossing. Blue signal shows the interrupt.
In fig 3 same as before yellow signal is the ac wave but this time blue signal is my firing angle signal.
and here is my code which is working as you can see in the pictures.
-----------------------------------------------------------------
short int state;
void main() {
ANSEL = 0;
cmcon0 =7;
TRISA = 0B00000100;
TRISC = 0B00000000;
INTCON = 0b11010000;
OPTION_REG = 0b10000000;
RA1_BIT = 0;
state = 0;
while (1)
{
if ( state == 1 )
{
delay_ms(5);
RA1_BIT = 1;
delay_us(500);
RA1_BIT = 0; //RA1_BIT = 1; makes the bulb glow on full sine wave
state = 0;
}
}
}
void interrupt ()
{
if( INTF_BIT )
{
state = 1;
INTF_BIT = 0;
}
}
--------------------------------------------------------------------------------
if i write a simple program to toggle RA1 pin, then bulb off and on's. but why it is not being phase controlled?
In fig 2 yellow signal is the AC rectified signal which is fed to a transistor base via 1k resistor. 10k resistor is connected to 5v and transistor collector and fed to the controller interrupt pin for detecting zero crossing. Blue signal shows the interrupt.
In fig 3 same as before yellow signal is the ac wave but this time blue signal is my firing angle signal.
and here is my code which is working as you can see in the pictures.
-----------------------------------------------------------------
short int state;
void main() {
ANSEL = 0;
cmcon0 =7;
TRISA = 0B00000100;
TRISC = 0B00000000;
INTCON = 0b11010000;
OPTION_REG = 0b10000000;
RA1_BIT = 0;
state = 0;
while (1)
{
if ( state == 1 )
{
delay_ms(5);
RA1_BIT = 1;
delay_us(500);
RA1_BIT = 0; //RA1_BIT = 1; makes the bulb glow on full sine wave
state = 0;
}
}
}
void interrupt ()
{
if( INTF_BIT )
{
state = 1;
INTF_BIT = 0;
}
}
--------------------------------------------------------------------------------
if i write a simple program to toggle RA1 pin, then bulb off and on's. but why it is not being phase controlled?