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 support@ccsinfo.com

invert PWM output (18F4431)

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



Joined: 02 Oct 2009
Posts: 123
Location: Denmark

View user's profile Send private message

invert PWM output (18F4431)
PostPosted: Sat Nov 26, 2011 11:56 am     Reply with quote

Hi,
I use a 18F4431 to make a PWM on a six pulse two levels converter, using set_power_pwm_duty().
The gate driver works that when the output of the PIC is high, the switch is open.

Example of a transition:
-PWM1 is 1 and PWM2 is 0.
-PWM1 goes low
-dead time 500ns
-PWM2 goes up

Which in the power side became:
-IGBT1 is open, IGBT2 is close
-IGBT1 close
-dead time 500ns
-IGBT2 open

So...there is a short circuit! Exclamation
I would like to have the opposite of the signal which is actually generated in the pins PWM1 and PWM2. How can I do?
Code:

setup_power_pwm(PWM_CLOCK_DIV_4|PWM_FREE_RUN,1,0,period,0,1,4);
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sat Nov 26, 2011 4:50 pm     Reply with quote

i can't comment on the logic of of you program

but what you want is easy with 1/3 of a 74HCT04 connected between the PIC and your drive line ;-))
Ttelmah



Joined: 11 Mar 2010
Posts: 19346

View user's profile Send private message

PostPosted: Sun Nov 27, 2011 3:15 am     Reply with quote

Inversion is directly available in the chip.
It is controlled by the HPOL, and LPOL fuses. These control an inverter available for the high, and low output bits respectively. Section 17.11.2 in the data sheet. For CCS, these are:
Code:

3.03   LPOL_LOW   Low-Side Transistors Polarity is Active-Low (PWM 0,2,4 and 6)
3.03   LPOL_HIGH   Low-Side Transistors Polarity is Active-High (PWM 0,2,4 and 6)
3.04   HPOL_LOW   High-Side Transistors Polarity is Active-Low (PWM 1,3,5 and 7)
3.04   HPOL_HIGH   High-Side Transistors Polarity is Active-High (PWM 1,3,5 and 7)

So you need to select the drivers you want, to be configured as 'active low', which then gives the inversion needed.
Looks like LPOL_LOW, AND HPOL_LOW, will give what you want. But test first.....

Best Wishes
freesat



Joined: 08 Feb 2011
Posts: 32

View user's profile Send private message

PostPosted: Mon Nov 28, 2011 6:40 am     Reply with quote

u can use xor with (
0xFF if 8 bit res
0x3FF if 10 bit res
0xFFF if 12 bit res

this way u dont need external components to invert.
Ttelmah



Joined: 11 Mar 2010
Posts: 19346

View user's profile Send private message

PostPosted: Mon Nov 28, 2011 8:12 am     Reply with quote

Er. No.
The original poster is talking about a hardware PWM output. You can't use XOR with this. Normally you would have to use an external inverter, as asmboy says.
However in the particular case involved of the ECCP, there are hardware inverters available inside the chip.

Best Wishes
webgiorgio



Joined: 02 Oct 2009
Posts: 123
Location: Denmark

View user's profile Send private message

PostPosted: Tue Nov 29, 2011 12:25 pm     Reply with quote

Code:
#fuses LPOL_LOW, HPOL_LOW
together with the others fuses worked well!
I also saw in the PIC datasheet the selectable NOT port before the PWM pin.

thank you!
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