lokeshbhatt
Joined: 16 Mar 2010 Posts: 11
|
18f4331 PWM Dead time |
Posted: Mon Jul 19, 2010 6:19 am |
|
|
Hi,
In 18f4331 how to generate 3phase ac signal? Below is the program
but it is not showing dead time in between complementary output & now we know 3phase AC require 3 different waves so how can we get...
Code: |
#include<18f4431.h>
//#device PIC18f4331*=8 ADC=8 ICD=TRUE
#use delay(clock=4000000)
//#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#int_PWMTB
void PWMTB_isr()
{
setup_power_pwm_pins(PWM_COMPLEMENTARY,PWM_COMPLEMENTARY,PWM_COMPLEMENTARY,PWM_OFF);
set_power_pwm2_duty(100);
set_power_pwm4_duty(100);
clear_interrupt(int_PWMTB);
}
void main()
{
/*********************************************************************************
****** This Program to generate PWM outputs and what are all registers need to
****** be set for that are as follows.......
1.
Parameters :
1. PTCON0 (Timer Control Reg)
Parameters : freerunning, Prescaling 1:1, Postscaling 1:1
2. PTCON1 (Timer Control Reg) 0xC0
Parameters : Count Up,TimeBase ON
3. PWMON0 (PWM ON )
Parameters :PWM ON 0 & 1, Complementary
4. PWMCON1 ()
Parameters :
5. PTPER (Time Period )
Parameters :
*/
enable_interrupts(INT_PWMTB);
enable_interrupts(GLOBAL);
set_power_pwm0_duty(PWM_UPDATE_ENABLE);
set_power_pwm_override(1, true, 1);
setup_power_pwm_pins(PWM_COMPLEMENTARY,PWM_OFF,PWM_OFF,PWM_OFF);
//PPWM channels 0 and 1 are both on and always opposite values
setup_power_pwm(PWM_CLOCK_DIV_4|PWM_FREE_RUN|PWM_DEAD_CLOCK_DIV_4,400,0,500,0,1,200);
//add dead time for reactive loads
set_power_pwm0_duty(400);
set_power_pwm2_duty(400);
set_power_pwm4_duty(400);
while(TRUE);
} |
_________________ Thanks & Regards
Lokesh Bhatt |
|