Don_dody
Full Member level 1
The circuit that I've built:
![ZCD.png ZCD.png](https://www.edaboard.com/data/attachments/26/26572-9c905b6898497e4b5180f83b79309019.jpg)
The code:
The simulation result:
![OSC.png OSC.png](https://www.edaboard.com/data/attachments/26/26573-d7b9e99fff9a5fe53e006ebb27f8a23d.jpg)
My questions:
1. Is my code right?
2. What's wrong with green wave in the oscilloscope? Why I didn't get something like this :
![Res.png Res.png](https://www.edaboard.com/data/attachments/26/26597-85a7dc77fc5061d20115909563239eb5.jpg)
![ZCD.png ZCD.png](https://www.edaboard.com/data/attachments/26/26572-9c905b6898497e4b5180f83b79309019.jpg)
The code:
Code:
#include <mega8535.h>
#include <delay.h>
// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
PORTB=0x00;
delay_ms(5); // firing triac 6 ms after zero cross detected
PORTB=0x01;
delay_us(1); // firing pulse width 1 us
PORTB=0x00;
}
void main(void)
{
PORTB=0x00;
DDRB=0x01; // PORTB.0 as output
GICR|=0x40; // INT0
MCUCR=0x01;
MCUCSR=0x00;
GIFR=0x40;
// Global enable interrupts
#asm("sei")
while (1)
{
}
}
The simulation result:
![OSC.png OSC.png](https://www.edaboard.com/data/attachments/26/26573-d7b9e99fff9a5fe53e006ebb27f8a23d.jpg)
My questions:
1. Is my code right?
2. What's wrong with green wave in the oscilloscope? Why I didn't get something like this :
![Res.png Res.png](https://www.edaboard.com/data/attachments/26/26597-85a7dc77fc5061d20115909563239eb5.jpg)
Last edited: