Hi all..
schematic in my attachments.
I want to design an automatic transfer switch that switches between 2 AC sources. I used MOC driver and a triac for each source.
now, the 2 sources must be connected to the same load... but when I run the simulation in Proteus, I have a voltage signal at the load between the value of the 2 sources... which means they are not connected/disconnected properly... maybe the 2 of them are fired together though software don't do that.
in my attached schematic I used a clock (one clock is active, the other is not) for firing the 2 of them and it works nicely!!! but when I connect the PIC16F877A and run the code.... that problem happens.
so, I figured that I should put the code too.
Code:
if ( adc1 < adc_rms_min ) { // if source_1 is not active:
if ( adc2 >= adc_rms_min ) { // if source_2 is active:
source_1 = 0; // deactivate source_1
delay_ms(10); // wait 5ms
source_2 = 1; // activate source_2
source_1_on = 0; // source_1_on LED is OFF
source_2_on = 1; // source_2_on LED is ON
no_active_source = 0; // no_active_source LED is OFF
}
else {
source_1 = 0; // source_1 off
source_2 = 0; // source_2 off
no_active_source = 1; // no_active_source LED is ON
source_1_on = 0; // source_1_on LED is OFF
source_2_on = 0; // source_2_on LED is OFF
}
}
if ( adc1 >= adc_rms_min ) { // if source_1 is active:
source_2 = 0; // source_2 off
delay_ms(10); // wait 5ms
source_1 = 1; // source_1 on
no_active_source = 0; // no_active_source LED is OFF
source_1_on = 1; // source_1_on LED is ON
source_2_on = 0; // source_2_on LED is OFF
}
this is the part needed to understand what I want... as you see adc1 and adc2 are for measuring sources' voltage to decide which one to enable... if it's adc above a certain level, connect it.
source1 is the primary one so if it's voltage is good it will be connect even if source2 was active, and here it will disconnect source2 then activate source1.
so, what wrong thing does this kinda code do?!
in the case of using clocks... I used a 1Hz clock for each source, clock1 is low-to-high and clock2 is high-to-low... so each source is active for 0.5s AND it worked perfectly!!! no problems in zero-crossing thing (because the MOC supports it).
that means the code have something, right?
looking forward to your answers.
thanks