PDA

View Full Version : Reverse in software PWM4 and PWM5 pins (PIC18F2431)



pxidr84
- 16th June 2012, 10:20
Hi,

I've got a PIC18F2431 (with hardware PWM).

I generate three-phase waveform for an inverter with PWM0-5 outputs (each pair are complementary), so basically PWM0/2/4 generates low-side signals and PWM1/3/5 generates high-side signals.

Unfortunately on my PCB I've reversed PWM4 and PWM5 connections (pins 26 and 25 respectively). So basically I want just to reverse these signals in my program.


' PWM update interrupt (timer 1)
pwmint:


' Timer management
T1CON.0=%0
copy.HIGHBYTE=TMR1H
copy.LOWBYTE=TMR1L
copy=copy+rld
TMR1H=copy.HIGHBYTE
TMR1L=copy.LOWBYTE
T1CON.0=%1

' PWM U phase calculation
uduty=sine[ustep]
uduty=(uduty<<res)**volt


' PWM V phase calculation
vduty=sine[vstep]
vduty=(vduty<<res)**volt


' PWM W phase calculation
wduty=sine[wstep]
wduty=(wduty<<res)**volt


' PWM U, V and W update
PDC0H=uduty.HIGHBYTE
PDC0L=uduty.LOWBYTE
PDC1H=vduty.HIGHBYTE
PDC1L=vduty.LOWBYTE
PDC2H=wduty.HIGHBYTE
PDC2L=wduty.LOWBYTE


' Phase angle calculation
@ decf _ustep,1
@ decf _vstep,1
@ decf _wstep,1


' Phase angle reinitialization
IF ustep=0 THEN ustep=89
IF vstep=0 THEN vstep=89
IF wstep=0 THEN wstep=89


@ INT_RETURN


Thanks

HenrikOlsson
- 16th June 2012, 14:40
Hi,
Well, you have the HPOL and LPOL bits in CONFIG3 (see section 18.11) but they control the polarity of all the "high" and "low" side signals at once. So, as far as I can see there is no way of doing this in software, I think you need to do a little hack on the PCB.

/Henrik.

pxidr84
- 16th June 2012, 14:58
Hi,
Well, you have the HPOL and LPOL bits in CONFIG3 (see section 18.11) but they control the polarity of all the "high" and "low" side signals at once. So, as far as I can see there is no way of doing this in software, I think you need to do a little hack on the PCB.

/Henrik.

Thanks, I see that, so I will do a little modification on the PCB (sadly).