View previous topic :: View next topic |
Author |
Message |
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
invert PWM output (18F4431) |
Posted: Sat Nov 26, 2011 11:56 am |
|
|
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!
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);
|
|
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sat Nov 26, 2011 4:50 pm |
|
|
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 ;-)) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19346
|
|
Posted: Sun Nov 27, 2011 3:15 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
freesat
Joined: 08 Feb 2011 Posts: 32
|
|
Posted: Mon Nov 28, 2011 6:40 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19346
|
|
Posted: Mon Nov 28, 2011 8:12 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
|
Posted: Tue Nov 29, 2011 12:25 pm |
|
|
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! |
|
![](templates/subSilver/images/spacer.gif) |
|