sam781
Full Member level 4
- Joined
- Oct 22, 2011
- Messages
- 212
- Helped
- 7
- Reputation
- 14
- Reaction score
- 7
- Trophy points
- 1,298
- Activity points
- 2,757
I'm trying to learn AVR again. This time wanted to start with Arduino. Normal PORT in/out, delay etc. are okay. Facing problem with making PWM signal for H bridge converter configuration.
For H-Bridge (or even half bridge), at least two PWM output is required. I've chosen Timer2 for this purposes.
I wanted to make 50kHz pwm signal. As Arduino uno has 16MHz Xtal, it is possible to create 62.5kHz pwm (OC2A & OC2B) using no prescaler.
But not getting any idea to create the pwm to drive H bridge considering dead zone.
For H-Bridge (or even half bridge), at least two PWM output is required. I've chosen Timer2 for this purposes.
I wanted to make 50kHz pwm signal. As Arduino uno has 16MHz Xtal, it is possible to create 62.5kHz pwm (OC2A & OC2B) using no prescaler.
Code:
void setup()
{
int pin3=PIND3;
int pin11=PINB3;
DDRB=(1<<pin3);
DDRD=(1<<pin11);
TCCR2A=(1<<COM2A1) |(1<<COM2B1) | (1<<WGM21) |(1<<WGM20);
OCR2A=102;
OCR2B=102;
TCCR2B=(1<<CS20);
}
But not getting any idea to create the pwm to drive H bridge considering dead zone.