Here is my circuit:
When I start on phase 1 by PWMing LIN & HIN of U2 and send a HIGH signal to LIN of U1, then the circuit works perfectly and only one LED lights up.
When I try to switch to phase 0 (after starting on phase 1) by PWMing LIN & HIN of U1, and send a HIGH signal to LIN of U2, then the MOSFET bridge suddenly shorts and breaks both of my IR2110 ICs.
BUT if I turn my DC power supply down to 0 V, reset the Arduino to start on phase 1, and turn the DC power supply back up to 13 V then the other LED lights up without a problem.
For some reason my MOSFETs are only shorting when I try to switch phases; if I start on either phase 1 or phase 0 then it works perfectly.
Does anyone know why this would happen? I am implementing 10 μs of dead time between switching phases so I don't think shoot-through would be the problem.
Here is the code I am running:
byte preg = 2;
byte sec = 0;
byte pres = 0;
void setup() {
pinMode(D7, OUTPUT);
pinMode(D6, OUTPUT);
pinMode(D12, OUTPUT);
pinMode(D11, OUTPUT);
digitalWrite(D7, LOW);
digitalWrite(D6, LOW);
digitalWrite(D12, LOW);
digitalWrite(D11, LOW);
// A5 is connect to a button so I can switch phases when
// pressing the button
pinMode(A5, INPUT);
// I have an LED attached to A0 to help me keep track of
// button presses
pinMode(A0, OUTPUT);
digitalWrite(A0, LOW);
}
void loop() {
// This code is to debounce a button press when for switching
// phases
sec = digitalRead(A5);
if (sec == 0) {
// Wait 1 second to check if button is still pressed
delay(1000);
sec = digitalRead(A5);
if (sec == 0) {
pres = digitalRead(A0);
if (pres == 1) {
// Set phase 0
preg = 0;
} else if (pres == 0) {
// Set phase 1
preg = 1;
}
}
}
// Switch to the new phase when button is pressed
switch(preg) {
// Phase 0
case 0:
digitalWrite(D7, LOW);
digitalWrite(D6, LOW);
digitalWrite(D12, LOW);
digitalWrite(D11, LOW);
digitalWrite(A0, LOW);
delayMicroseconds(10);
analogWrite(6, 100);
for (int i = 0; i < 10000; i++) {
phase0();
}
break;
// Phase 1
case 1:
digitalWrite(D7, LOW);
digitalWrite(D6, LOW);
digitalWrite(D12, LOW);
digitalWrite(D11, LOW);
digitalWrite(A0, HIGH);
delayMicroseconds(10);
analogWrite(11, 100);
for (int x = 0; x < 10000; x++) {
phase1();
}
break;
}
}
// PWM U1 LIN & HIN alternatively to charge C4 & C5
void phase0() {
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
delayMicroseconds(10);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
delayMicroseconds(1);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
delayMicroseconds(150);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
delayMicroseconds(1);
}
// PWM U2 LIN & HIN alternatively to charge C2 & C3
void phase1() {
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
delayMicroseconds(10);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delayMicroseconds(1);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delayMicroseconds(150);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delayMicroseconds(1);
}
phase0()
andphase1()
functions, the LIN and HIN pins should never be on at the same time because I have added a 1us delay between each PWM & I turn one of them off while the other one is on. \$\endgroup\$