#include <TimerOne.h>
const int pwmPin1 = 9; // PWM output for signal 1
const int pwmPin2 = 10; // PWM output for signal 2
const long frequency = 50; // Frequency in Hz
const long period = 1000000 / frequency; // Period in microseconds
const long deadTime = 2; // Dead time in microseconds
void setup() {
pinMode(pwmPin1, OUTPUT);
pinMode(pwmPin2, OUTPUT);
// Initialize Timer1
Timer1.initialize(period);
// Set up PWM outputs with complementary signals and dead time
Timer1.pwm(pwmPin1, 0); // Initialize with 0% duty cycle
Timer1.setPwmDuty(pwmPin2, 0);
// Set up the ISR to control the PWM signals and add dead time
Timer1.attachInterrupt(updatePWM);
}
void updatePWM() {
static bool toggleState = false;
// First half of the period (signal 1 is HIGH, signal 2 is LOW)
if (!toggleState) {
Timer1.setPwmDuty(pwmPin1, 511); // 50% duty cycle for signal 1
delayMicroseconds(deadTime); // Dead time
Timer1.setPwmDuty(pwmPin2, 511); // 50% duty cycle for signal 2
}
// Second half of the period (signal 2 is HIGH, signal 1 is LOW)
else {
Timer1.setPwmDuty(pwmPin2, 511); // 50% duty cycle for signal 2
delayMicroseconds(deadTime); // Dead time
Timer1.setPwmDuty(pwmPin1, 511); // 50% duty cycle for signal 1
}
toggleState = !toggleState; // Toggle between signal 1 and signal 2
}
void loop() {
// No logic in the loop. PWM signals are handled in the ISR.
}
Look it up in the datasheet?
I think this will work, what do you recon?
C:#include <TimerOne.h> const int pwmPin1 = 9; // PWM output for signal 1 const int pwmPin2 = 10; // PWM output for signal 2 const long frequency = 50; // Frequency in Hz const long period = 1000000 / frequency; // Period in microseconds const long deadTime = 2; // Dead time in microseconds void setup() { pinMode(pwmPin1, OUTPUT); pinMode(pwmPin2, OUTPUT); // Initialize Timer1 Timer1.initialize(period); // Set up PWM outputs with complementary signals and dead time Timer1.pwm(pwmPin1, 0); // Initialize with 0% duty cycle Timer1.setPwmDuty(pwmPin2, 0); // Set up the ISR to control the PWM signals and add dead time Timer1.attachInterrupt(updatePWM); } void updatePWM() { static bool toggleState = false; // First half of the period (signal 1 is HIGH, signal 2 is LOW) if (!toggleState) { Timer1.setPwmDuty(pwmPin1, 511); // 50% duty cycle for signal 1 delayMicroseconds(deadTime); // Dead time Timer1.setPwmDuty(pwmPin2, 511); // 50% duty cycle for signal 2 } // Second half of the period (signal 2 is HIGH, signal 1 is LOW) else { Timer1.setPwmDuty(pwmPin2, 511); // 50% duty cycle for signal 2 delayMicroseconds(deadTime); // Dead time Timer1.setPwmDuty(pwmPin1, 511); // 50% duty cycle for signal 1 } toggleState = !toggleState; // Toggle between signal 1 and signal 2 } void loop() { // No logic in the loop. PWM signals are handled in the ISR. }
Is it even possible/practical to define a 1nS delay with an Arduino?I'm now programming the IR2110 pulses with arduino, and can't remember the dead time if it's 1 nano-second or micro-second
No.Is it even possible/practical to define a 1nS delay with an Arduino?
They need to connect to the same ground.also do I ground the arduino with the IR2110 circuit setup
Hi there! Do you know how to invert the positive and negative with an op amp?I don't know the order, but if I would be inclined to ensure the Arduino was running first, so that the FETs are controlled correctly.