and here is the code i am using, its pretty simple. im using a teensy++2.0 board. im setting one pwm output to feed my boost converter, the voltage regulation is handled in hardware. the other 2 pwm outputs feed the h-bridge. and while i realize this code could use a ton of optimization (like taking the sine table out of ram, and cutting it in half), its just a basic program for testing.
byte sine[181] = {0,4,8,13,17,22,26,31,35,39,44,48,53,57,61,65,70,74,78,83,87,91,95,99,103,107,111,115,119,123,127,131,135,138,142,146,149,153,156,160,163,167,170,173,177,180,183,186,189,192,195,198,200,203,206,208,211,213,216,218,220,223,225,227,229,231,232,234,236,238,239,241,242,243,245,246,247,248,249,250,251,251,252,253,253,254,254,254,254,254,255,254,254,254,254,254,253,253,252,251,251,250,249,248,247,246,245,243,242,241,239,238,236,234,232,231,229,227,225,223,220,218,216,213,211,208,206,203,200,198,195,192,189,186,183,180,177,173,170,167,163,160,156,153,149,146,142,138,135,131,127,123,119,115,111,107,103,99,95,91,87,83,78,74,70,65,61,57,53,48,44,39,35,31,26,22,17,13,8,4,0};
int i = 0;
int dly = 44;
void setup()
{
TCCR0B = TCCR0B & 0b11111000 | 0x03; //pwm pin 0 messes with delay?
TCCR3B = TCCR3B & 0b11111000 | 0x02; //pwm pin 14 15 16
analogWrite(0,200); //driving frequency for the boost converter
pinMode(15,OUTPUT);
pinMode(14,OUTPUT);
// the two opposite legs of the h-bridge are connected to the same control line. a low on one side give -170 volts, a low on the other gives +170 volts.
digitalWrite(14,HIGH); //h-bridge is active low, so this grounds both sides and shuts the output off.
digitalWrite(15,HIGH);
}
void loop()
{
/*
digitalWrite(14,LOW);
delay(30);
digitalWrite(14,HIGH);
delay(70);
digitalWrite(15,LOW);
delay(30);
digitalWrite(15,HIGH);
delay(70);
*/
i = 0;
while (i < 182)
{
analogWrite(14,255-sine[i]);
delayMicroseconds(dly);
i++;
}
digitalWrite(14,HIGH);
delayMicroseconds(100);
i = 0;
while(i < 182)
{
analogWrite(15,255-sine[i]);
delayMicroseconds(dly);
i++;
}
digitalWrite(15,HIGH);
delayMicroseconds(100);
}