0% found this document useful (0 votes)
129 views4 pages

SPWM Inverterwd

This project summary describes a DC-AC inverter that uses a timer interrupt to generate a sine wave PWM signal: - The project generates a sine wave PWM using timer0 interrupts to control an inverter driver circuit. - It defines a sine wave lookup table and variables to control the index and duty cycle. - In the interrupt service routine, it loads the timer, toggles ports to drive the inverter, and increments the sine wave index.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views4 pages

SPWM Inverterwd

This project summary describes a DC-AC inverter that uses a timer interrupt to generate a sine wave PWM signal: - The project generates a sine wave PWM using timer0 interrupts to control an inverter driver circuit. - It defines a sine wave lookup table and variables to control the index and duty cycle. - In the interrupt service routine, it loads the timer, toggles ports to drive the inverter, and increments the sine wave index.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

/* Project name: DC-AC Inverter

* Author: BABALOLA
* Description:
This project generate sine-wave PWM in an open loop
using timer0 to generate interupt.
* Test configuration:
MCU: P18F452
Oscillator: HS, 20.0000 MHz
SW: mikroC v8.2
24/03/2010
* NOTES:
*/

unsigned char const sine_wave[32]= {20,41,60,80,98,116,132,147,161,173,183,


192,199,204,207,208,207,204,199,192,183,173,161,147,132,116,98,80,60,41,20,0};

//unsigned char const sine_wave[32]={20,40,59,78,96,113,129,144,158,170,180,188,


//195,200,203,204,203,200,195,188,180,170,158,144,129,113,96,78,59,40,20,0};

//unsigned int const sine_wave[32]=


{37,74,110,145,179,211,241,269,294,316,335,351,364,
//373,378,380,378,373,364,351,335,316,294,269,241,211,179,145,110,74,37,0};

// variable/function definitions
unsigned char index;
int duty;

// TIMER INTERRUPT SERVIVE ROUTINE


//Inverter run in close-loop mode

void Interrupt( )
{
INTCON.TMR0IF = 0; // clear TMR0IF(interupt flag that brought us here)
//T0CON.TMR0ON = 0; // STOP TIMER0
TMR0H = 0xF9; // Reload Timer0 register
TMR0L = 0xE5;

PORTC.F0 =0; //enable inverter

CCPR1L = sine_wave[index];

if (!index)

PORTC.F1 = ~PORTC.F1;

++index;
if (index == 32)
index = 0;

void main( )
{
//Prepare PIC for operation,intialise variables and the controller hardware
INTCON.F7 = 0; //diable all interrupt now
TRISC = 0X90; //set portc direction
PORTC.F0 = 1; //disable inverter driver
TRISB = 0XC9; //portb direction
//PORTB.F1 = 1; //hold power supply

PORTB.F4 = 1; // TEST LEDS


PORTB.F5 = 0;
delay_ms(1000);
PORTB.F4 = 0;
PORTB.F5 = 1;
delay_ms(1000);
PORTB.F5 = 0;
index = 0;
// pwm setup
PR2 = 0XFF; // 20 MHz clock - > 19.53kHz PWM frequency
T2CON =0X04; // timer2 on , NO pre/postscale
CCPR1L = 0; // Initial Duty
CCP1CON =0X0C; // configure and start as pwm

// Timer0 Setup

T0CON = 0X08; // Timer0 settings,no presc,timer start now


TMR0H = 0xF9;
TMR0L = 0xE5; // Initialize Timer0 register

//set up the interrupts, enable it and start timer0


INTCON =0X20; //SETUP GLOBAL INT.

T0CON.F7 = 1; // enable Timer0 interrupt


INTCON.F7 = 1; //enable global interrupt

PORTB.F4 = 1; //GET READY (green led on)

while( 1 ); //loop forever, execute in INTERRUPT

Below is my basic schematic with information about the transformer. My output target is
500WATT.
INFORMATION ON TRANSFORMER:
RATIO IS 1:17
LEAKAGE INDUCTANCE IS 2.76mh which is used with the output capacitor to form the
output filter.
With the accompanied code, I’ am getting 246vac without load at 24 battery voltage.
REGARDS,
BABALOLA.

You might also like