CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

3 phase sinusoidal PWM using 18F4431

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bengun



Joined: 13 Apr 2010
Posts: 1

View user's profile Send private message

3 phase sinusoidal PWM using 18F4431
PostPosted: Thu Apr 15, 2010 12:48 am     Reply with quote

Anybody can help me in programming the power pwm pins?
I write this code example for one phase:
Code:

/*
3 channels power PWM for 3 phase sinewave
*/

#include<18F4431.h> 
#use delay(clock=8M)                 
#define POWER_PWM_PERIOD 3332  // 0.6 KHz pwm freq with 8 MHz osc.
int i=0;

///////////////////////////// SIN table ////////////////////////////////

int16 A[6]={1666,2886,3330,3330,2886,1666};

#int_PWMTB
void PWMTB()
{
///////////////////// power PWM0 for phase 1 ///////////////////////

if(i<6) /////////////////////////////// 1st half period
  set_power_pwm0_duty(4*A[i]);

else  ////////////////////////////////2nd half period
  set_power_pwm0_duty(4*3332-4*A[i-6]);

i++;

if(i==12) i=0; 

clear_interrupt(int_PWMTB);
 
}

void main()
{
  enable_interrupts(GLOBAL);
  enable_interrupts(INT_PWMTB);

  setup_power_pwm_pins(PWM_COMPLEMENTARY ,PWM_OFF,PWM_OFF,PWM_OFF);


 setup_power_pwm(PWM_FREE_RUN, 1, 0, POWER_PWM_PERIOD, 0, 1,0);
  for(;;);
}

My purpose is to complement the pwm signal generated by PWM1 pin in the second period.
In case of second period: I must see the duty cycle at the end of pwm period not in the first (FREE_RUN_MODE generate it at the beginning of PWM pulse).
If I apply this method for 3 phase full bridge inverter, this may cause damage in transistors of the same leg, since for a while they are both ON.
Please if there is a solution in program tell me.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group