I want to make a three phase inverter (DC to AC) bridge type using Arduino. For that I want to generate three square wave each is 120° phase shifted and other three waves of main three wave forms inverted for opposite switch.
Can anyone please help me out? I am new to programing in Arduino.
Code:
void setup() {
pinMode( 9 , OUTPUT );
pinMode( 10 , OUTPUT );
TCCR1A = _BV( COM1A0 ) |_BV( COM1B0 );
TCCR1B = _BV( WGM13) | _BV( WGM12);
OCR1A = 0;
}
#define PRESCALER 1
#define PRESCALER_BITS 0x01
#define CLK 16000000UL
int setWaveforms( unsigned long freq , int shift ) {
unsigned long clocks_per_toggle = (CLK / freq) / 2;
ICR1 = clocks_per_toggle;
unsigned long offset_clocks = (clocks_per_toggle * shift) / 180UL;
OCR1B= offset_clocks;
TCCR1B |= _BV( CS10 );
}
void loop() {
setWaveforms( 50000 , 120 );
delay(1000);
setWaveforms( 50000 , 120 );
delay(1000);
setWaveforms( 50000 , 120 );
delay(1000);
}
I had get 2 waves only but I want to get 6. I am new to Stack Exchange.