- Joined
- Jan 22, 2008
- Messages
- 53,346
- Helped
- 14,796
- Reputation
- 29,879
- Reaction score
- 14,331
- Trophy points
- 1,393
- Location
- Bochum, Germany
- Activity points
- 302,063
There is a parallel diode, so surely no AC opto-coupler. Simply assume that the circuit is triggering with halfwave zero-crossing signal on both edges.AC type opto ? There is no diode or bridge then how he get ZC pulses.
Probably. Anything goes.Is it 1N4148 ?
Don't use 220V for Vsin rather use 50V as earlier.The negative half cycle is not controlling
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 unsigned char milliSec = 0, i = 0; //Timer0 //Prescaler 1:4; TMR0 Preload = 6; Actual Interrupt Time : 1 ms //Place/Copy this part in declaration section void InitTimer0() { OPTION_REG = 0x81; TMR0 = 6; INTCON |= 0x20; } void interrupt() { if(INTF_bit) { //ZC occurs once every 10 ms INTF_bit = 0; i = 0; if(milliSec == 0) { GP5_bit = 1; Delay_us(50); //INTF occurs once every 10 ms. So, it is safe to use 50 us delay GP5_bit = 0; } else InitTimer0(); } if(T0IF_bit) { //Timer interrupt occurs every 1 ms T0IF_bit = 0; TMR0 = 6; //Enter your code here if(i++ == milliSec) { GP5_bit = 1; T0IE_bit = 0; Delay_us(80); // 50 us delay in a 1 ms timer interrupt is not a problem GP5_bit = 0; } } } void initialize() { INTEDG_bit = 0; INTF_bit = 0; INTE_bit = 1; PEIE_bit = 1; GIE_bit = ~GIE_bit; //milliSec = EEPROM_Read(0); //There is no option to load eeprom file in Proteus for 12F683, So, uncomment this code while testing in hardware //Delay_ms(20); } void main() { ANSEL = 0x00; CMCON0 = 0x07; TRISIO = 0x07; GPIO = 0x00; IOC = 0x00; while (1) { if(GP0_bit) { Delay_ms(50); while(GP0_bit); if(milliSec < 9)++milliSec; //EEPROM_Write(0, milliSec); //There is no option to load eeprom file in Proteus for 12F683, So, uncomment this code while testing in hardware //Delay_ms(20); } else if(GP1_bit) { Delay_ms(50); while(GP1_bit); if(milliSec > 0)--milliSec; //EEPROM_Write(0, milliSec); //There is no option to load eeprom file in Proteus for 12F683, So, uncomment this code while testing in hardware //Delay_ms(20); } else if(GP3_bit) { Delay_ms(50); while(GP3_bit); initialize(); } } }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?