6 HPWM signal generation with PIC18F4431


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 6 HPWM signal generation with PIC18F4431

    Hi,
    I'm not using a simulator, I just sent the values to the PC and plotted them with EXCEL. Here's the exact code I used to test with:
    Code:
    DEFINE LOADER_USED 1
    DEFINE OSC 20
    DEFINE HSER_BAUD 19200
     
    i VAR BYTE
    T VAR BYTE
    uDuty VAR WORD
    vDuty VAR WORD
    wDuty VAR WORD
     
    Main:
    For i = 0 to 2   'Make three periods
      T=0
        
       for T=0 to 255
       ' PWM U phase calculation
       uduty=((sin(t)+128)*4)  
          
       ' PWM V phase calculation
       vduty=((sin(t+85)+128)*4)
        
       ' PWM W phase calculation
       wduty=((sin(t+170)+128)*4)
       
       HSEROUT [DEC uDUTY, ",", dec vDUTY, ",", dec wDUTY, 13]
      next
    NEXT
    WereDone:
    Goto WereDone
    Try removing C3, C6 and C8 to start with.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: 6 HPWM signal generation with PIC18F4431

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    I'm not using a simulator, I just sent the values to the PC and plotted them with EXCEL. Here's the exact code I used to test with:
    Code:
    DEFINE LOADER_USED 1
    DEFINE OSC 20
    DEFINE HSER_BAUD 19200
     
    i VAR BYTE
    T VAR BYTE
    uDuty VAR WORD
    vDuty VAR WORD
    wDuty VAR WORD
     
    Main:
    For i = 0 to 2   'Make three periods
      T=0
        
       for T=0 to 255
       ' PWM U phase calculation
       uduty=((sin(t)+128)*4)  
          
       ' PWM V phase calculation
       vduty=((sin(t+85)+128)*4)
        
       ' PWM W phase calculation
       wduty=((sin(t+170)+128)*4)
       
       HSEROUT [DEC uDUTY, ",", dec vDUTY, ",", dec wDUTY, 13]
      next
    NEXT
    WereDone:
    Goto WereDone
    Try removing C3, C6 and C8 to start with.
    In reality, I think that my RC filter in Proteus is bad.

    If I watch the raw PWM outputs, it seems perfectly good (with correct phase angles and duty cycles). However, in extreme duty (like 0 or 1023), the PWM "jumps" (like before, I think it's a sim issue, I will try the PIC in the real life with an oscilloscope).

    In other words, my code is working quite well now, thanks for the "**", I didn't know this operator before, until now.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 6 HPWM signal generation with PIC18F4431

    Hi,
    Like I said in an earlier post, I think it is the dead-time insertion that makes the waveform "jump" at the extreme ends. Do try it with real hardware and let us know how it goes. Just remember that if you low-pass filter the PWM to watch it on a scope might not see any artifacts introduced by the deadtime insertion - if indeed that is what's causing it. So make sure you watch the "raw" PWM signals as well in order to see if it behaves as in the simulator.

    As a simple test, try removing the deadtime insertion from the code and see if it still looks strange in the simulator.

    /Henrik.

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: 6 HPWM signal generation with PIC18F4431

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    Like I said in an earlier post, I think it is the dead-time insertion that makes the waveform "jump" at the extreme ends. Do try it with real hardware and let us know how it goes. Just remember that if you low-pass filter the PWM to watch it on a scope might not see any artifacts introduced by the deadtime insertion - if indeed that is what's causing it. So make sure you watch the "raw" PWM signals as well in order to see if it behaves as in the simulator.

    As a simple test, try removing the deadtime insertion from the code and see if it still looks strange in the simulator.

    /Henrik.
    Yes, of course I've readed your post above. I've modified the code (add +3 to the end of each line), now the PWM signal doesn't "jump" anymore.
    However, if I remove the deadtime or even modify it, the jumpy PWM remains.

    Now signals are better, but sine are not perfect for the highest frequencies, I think that my low-pass filter hasn't good R and C values (1k and 1000nF).


  5. #5
    senertek's Avatar
    senertek Guest


    Did you find this post helpful? Yes | No

    Default Re: 6 HPWM signal generation with PIC18F4431

    hi ,
    I have already developped many ac inverters range 0.75 kw to 915 kw..with . I seen this thread ..it s very good..to see picbasic projects in this field....
    Designing one 3 phase ac inverter is not easy project...you must know many kind of points about high voltage igbt , drivers , dcbus topologys ,emc ,emi , multi tasking etc...(it take many years)
    If you want , I can help for your project..
    I can try your codes with my high voltage kits , igbt driver modules ...and inform you ..codes works or not...

    savas

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: 6 HPWM signal generation with PIC18F4431

    Quote Originally Posted by senertek View Post
    hi ,
    I have already developped many ac inverters range 0.75 kw to 915 kw..with . I seen this thread ..it s very good..to see picbasic projects in this field....
    Designing one 3 phase ac inverter is not easy project...you must know many kind of points about high voltage igbt , drivers , dcbus topologys ,emc ,emi , multi tasking etc...(it take many years)
    If you want , I can help for your project..
    I can try your codes with my high voltage kits , igbt driver modules ...and inform you ..codes works or not...

    savas
    Thanks.

    Well, I'm doing studies in electrical engineering, so I've a litte knowledge about this.
    I'm using an intelligent IGBT module from STMicroelectronics, the STGIPS20K60 (datasheet : http://www.st.com/internet/com/TECHN...CD00244265.pdf).

    No drivers needed (they're integrated), just optocouplers.

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: 6 HPWM signal generation with PIC18F4431

    Ok, a little update.

    I've tested the program on the real PIC with an oscilloscope. All of the output signals are correct, but the sine cycle is very slow (about 4 seconds to make a complete sine period, so f=1/4=0,25Hz).
    The PWM frequency seems correct (3,245kHz).
    I've defined correctly the configuration fuses (or bits), with "HS oscillator" setting, because I'm using a 40MHz quartz oscillator connected to OSC1/OSC2 pins with 22pF ceramic capacitors.

    The code (note I'm not using the FOR... NEXT loop in this case, like the upper programs, it's a lot faster if I use the FOR... NEXT loop, but I don't know why) :

    Code:
    'PIC initialization
    DEFINE OSC 40      
    DEFINE LCD_EREG PORTD
    DEFINE LCD_DREG PORTD
    DEFINE LCD_EBIT 0
    DEFINE LCD_RSBIT 1
    
    
    'DT interrupt system include
    INCLUDE "DT_INTS-18.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"  ' Include if using PBP interrupts
    
    
    'Port registers configuration
    PORTB=%0          ' Clear ports
    TRISB=%11000000   ' PWM 0,1,2,3,4,5 outputs
    
                                
    'PCPWM registers configuration
    DTCON=%110        ' Deadtime (600ns)
    PTCON0=%100       ' 1:1 postscale, Fosc/4 1:1 prescale, free running mode
    PTCON1=%10000000  ' PWM time base is ON, counts up, 19.45kHz/4
    PTPERL=%0         ' PWM low-side
    PTPERH=%1         ' PWM high-side
    
    	
    'PWM registers configuration
    PWMCON0=%1000000  'PWM 0,1,2,3,4,5 set in pair mode
    PWMCON1=%1        'PWM timer sync configuration
    
    
    'Interrupt processor
    ASM
    INT_LIST  macro    ; IntSource, Label, Type, ResetFlag
            INT_Handler   TMR1_INT,  _pwmint,   PBP,  yes
        endm
        INT_CREATE     ; Creates the interrupt processor
    ENDASM
    
    
    'Timer configuration
    T1CON=%10000001            ; Prescaler = 1:8, TMR1ON, 16-bit counter
    @ INT_ENABLE  TMR1_INT     ; Enable Timer 1 interrupts
    
    
    'PWM calculation variables
    uduty VAR WORD     'U phase duty
    vduty VAR WORD     'V phase duty
    wduty VAR WORD     'W phase duty
    dutydiv var WORD   'Frequency diviser
    dutymul VAR WORD   'Duty multiplier
    t VAR byte         'Incremental value
    
    
    'Variables definition
    dutydiv=0       'Range : 0-65535
    dutymul=65535   'Range : 0-65535 (for exemple, 32767=0.5)
    t=%0            'T initial value
    
    
    'Main program loop
    mainlp:
    
    HIGH PORTA.0
    pause 100
    LOW PORTA.0
    pause 100
    
    goto mainlp
    
    
    'PWM calculation and update interrupt
    pwmint:
    
        'Frequency diviser
        pauseus dutydiv
    
        'PWM U, V, W phases calculation
        uduty=(((sin(t)+%01111111)*%100)**dutymul)+%100
        vduty=(((sin(t+%01010101)+%01111111)*%100)**dutymul)+%100
        wduty=(((sin(t+%10101010)+%01111111)*%100)**dutymul)+%100
    
        'PWM U phase update
        PDC0L=uduty.LOWbyte
        PDC0H=uduty.HIGHByte
    
        'PWM V phase update
        PDC1L=vduty.LOWbyte
        PDC1H=vduty.HIGHByte
    
        'PWM W phase update
        PDC2L=wduty.LOWbyte
        PDC2H=wduty.HIGHByte
        
        'T variable verification and incrementation
        if t<%11111111 then 
        t=t+%1
        else 
        t=%0 
        endif
    
    @ INT_RETURN
    I think it's a TIMER problem (TMR1 is at 32kHz, isn't it?)

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