I have the circuit built and running but I need to shorten the pulse width of the SCR. I am using a PIC16F884 running at 16MHz. I am using a half wave to control a device. When I use a for next loop, my on and off time is around 660uS, and if I try to reduce the number, I will have missing firing pulse. The following code has the for next loop in it.
void init_int(void) {
INTEDG = 0; //1; // Interrupt is on falling edge of int pin
TRISB0 = 1; // Set RB0 as input
ANS12 = 0; // Set RB0 as digital
IOCB0 = 1; // 0; // Interrupt on change
WPUB0 = 0; // Pull-up disable
nRBPU = 1; // Port b pull-up are disable
GIE = 1; // enable global interrupts
PEIE = 1; // Enable Peripheral Interrupt
INTE = 1; // enable interrupt flag
INTF = 0; // Clear external interrupt flag
T0IE = 0; // Disables the Timer0 interrupt
ei(); // enable global interrupt
}
void __interrupt() HardW() {
if (INTCONbits.INTF == 1) {
for (x = 0; x < speed_val; x++) { // phase angle
}
INTCONbits.INTF = 0;
Gate = 1; // turn SCR on
for (x = 0; x < 165; x++) { // 165 = 660uS Positive pulse width
}
Gate = 0; // turn Scr off
} else
INTCONbits.INTF = 0;
}
if I use the following code with TMR0 I will not get 60 hz firing pulse.
void __interrupt() HardW() {
T0IE = 1;
if (INTCONbits.INTF == 1) {
for (x = 0; x < speed_val; x++) { // phase angle
}
INTCONbits.INTF = 0;
Gate = 1; // turn SCR on
while (T0IE = T0IF) {
T0IF = 0;
T0IE = 0;
}
Gate = 0; // turn Scr off
} else
INTCONbits.INTF = 0;
}
Any suggestions would be helpful.
while (T0IE = T0IF)
. Do you meanwhile (T0IE == T0IF)
instead? (==
instead of=
). \$\endgroup\$