Reverse in software PWM4 and PWM5 pins (PIC18F2431)


Closed Thread
Results 1 to 3 of 3
  1. #1

    Question Reverse in software PWM4 and PWM5 pins (PIC18F2431)

    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.

    Code:
    ' 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

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Reverse in software PWM4 and PWM5 pins (PIC18F2431)

    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.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Reverse in software PWM4 and PWM5 pins (PIC18F2431)

    Quote Originally Posted by HenrikOlsson View Post
    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).

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts