Exp 9
Exp 9
CIRCUIT DIAGRAM:
PROCEDURE:
1. Given: R=5ohm, L=23mH,f=50Hz,vs=220V
2. Connect the components and specify the parameters as shown in Figure 1.
3. Run the simulation and observe the line voltage, phase voltage and load current.
4. Perform FFT analysis and find THD.
OBSERVATIONS:
OBJECTIVE:
To study and model the 180 degree and 120 degree phase conduction mode of a three phase
inverter in MATLAB Simulink
CIRCUIT DIAGRAM:
OBSERVATIONS:
OBJECTIVE:
To operate a three phase inverter with the help of sine wave pulse width modulation scheme
PROGRAM:
First create a new project, as discussed in earlier experiments. The code for DAC followed by
ADC for a sine wave table is given below:
The comments in green have been written by us.
// Included Files
#include "F28x_Project.h"
#include "math.h"
// Globals
volatile struct DAC_REGS* DAC_PTR[4] = {0x0,&DacaRegs,&DacbRegs,&DaccRegs};
Uint32 samplingFreq_hz = 50000;
float fundaFreq_hz = 50;
Uint16 dacOutput;
Uint16 sineEnable = 1;
extern int QuadratureTable[40];
Uint16 dacOffset;
Uint16 resultsIndex;
float ref;
Uint16 ToggleCount = 0;
float Ts = 0.00002;
float W0 = 314.159265;
float Theta0 = 0;
float Theta;
float Ref;
float Ref1;
float Ref2;
#define Result_s 500
#define Result_s2 100
#define Result_s3 100
float a[Result_s];
Uint16 i;
Uint16 j;
Uint16 k;
float b[Result_s2];
float c[Result_s3];
// Defines
#define DACA 1
#define DACB 2
#define DACC 3
#define CPUFREQ_MHZ 200
#define REFERENCE 1
#define RESULTS_BUFFER_SIZE 256
#define EPWM_CMP_UP 1
#define EPWM_CMP_DOWN 0
#define PI 3.14159265
// Function Prototypes
void configureDAC(void);
void InitEPwm1Example(void);
interrupt void cpu_timer0_isr(void);
// Main
void main(void)
{
// Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2837xD_SysCtrl.c file.
//step 1 clocks
InitSysCtrl();
// enable PWM1
CpuSysRegs.PCLKCR2.bit.EPWM1=1;
// For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
// These functions are in the F2837xD_EPwm.c file
InitEPwm1Gpio();
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags are cleared.
// This function is found in the F2837xD_PieCtrl.c file.
DINT;
InitPieCtrl();
// Clear all interrupts and initialize PIE vector table:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Configure DAC
configureDAC();
// Initialize EPWM1
InitEPwm1Example();
EALLOW;
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =1;
EDIS;
EALLOW;
PieVectTable.TIMER0_INT = &cpu_timer0_isr;
EDIS;
CpuTimer0Regs.TCR.all = 0x4000;
// Enable interrupt
IER |= M_INT1;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EINT;
ERTM;
while(1)
{
asm (" NOP");
}
}
void configureDAC()
{
EALLOW;
DAC_PTR[DACA]->DACCTL.bit.DACREFSEL = REFERENCE;
DAC_PTR[DACA]->DACOUTEN.bit.DACOUTEN = 1;
DAC_PTR[DACA]->DACVALS.all = 0;
DAC_PTR[DACB]->DACCTL.bit.DACREFSEL = REFERENCE;
DAC_PTR[DACB]->DACOUTEN.bit.DACOUTEN = 1;
DAC_PTR[DACB]->DACVALS.all = 0;
EDIS;
}
EPwm1Regs.CMPA.bit.CMPA = a[i]*25000;
i++;
b[j] = Ref1;
DacbRegs.DACVALS.all = b[j]/3.3*4096;
EPwm1Regs.CMPA.bit.CMPA = b[j]*25000;
j++;
Ref2= 1 + sin(Theta + 4*3.14159/3); //adding 4pi/3 i.e. 240 degrees phase shift
c[k] = Ref2;
DaccRegs.DACVALS.all = b[j]/3.3*4096;
EPwm1Regs.CMPA.bit.CMPA = c[k]*25000;
k++;
if(Result_s <= i)
{
i = 0;
}
if(Result_s2 <= j)
{
j = 0;
}
if(Result_s3 <= k)
{
k=0;
}
if(Result_s2 <= j)
{
j = 0;
}
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
void InitEPwm1Example()
{
EPwm1Regs.TBPRD = 50000; // Set timer period
EPwm1Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
EPwm1Regs.TBCTR = 0x0000; // Clear counter
// Setup TBCLK
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count mode select
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every
ZERO
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
// Set actions
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // Action when CTR = PRD (EPWM-A)
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR; //Action when CTR=ZRO (EPWM-A)
EPwm1Regs.AQCTLB.bit.CAU = AQ_CLEAR; //Action when CTR=CMPA on UP
Count (EPWM-B)
EPwm1Regs.AQCTLB.bit.CAD = AQ_SET; // Action when CTR = CMPA on DOWN
Count (EPWM-B)
}
// End of file
FLOWCHART:
The following flowchart is for the creation of new project.
The following flowchart is for the generation of sine PWM pulses.