/*********************************************************** Fadhel Ali 201102569 * * DC to AC Inverter ***********************************************************/#include "mbed.h"#include "QEI.h"#define size 512#define ph50Hz 4400#define pi 3.14159265
PwmOut out(p21);
PwmOut out1(p22);
PwmOut out2(p23);
PwmOut out3(p24);
QEI wheel (p15, p16, NC,16);
DigitalIn switch1 (p19);
DigitalOut base(p30);int main(){
out.period_us(50);float sin1[size],sin2[size],sin3[size],sin4[size];float omega;int x=0;int y;int n, z=0;
base =0;for(int i=0; i<size; i++){//fill the arrays with the sine wave's amplitude values
omega=2*pi*i/float(size);
sin1[i]=(sin(omega));//half-wave rectified signal
sin2[i]=(sin(omega+pi));//180 deg phase so each phase will not work togother
sin3[i]=(sin(omega));
sin4[i]=(sin(omega+pi));}
wheel.reset();
n=ph50Hz;while(1){
z=wheel.getPulses()*100;//read the state of the shaft encoder
x+=n+z;
y=(x>>14)&(size-1);//controls the frequency//call the sine wave arrays
out=sin1[y];
out1=sin2[y];
out2=sin3[y];
out3=sin4[y];}}
yes in the DC to DC converter, there are some ripples. but I checked the dc to dc converter seperatly and it was fine withoud any voltage drop or regulation but only when it is connected to the h-bridge the voltage drops.