This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Reconfiguring ePWM Modules on the Fly

I am working on a controller for a phase shift controlled converter.  I need to implement a start up procedure to safely bring up the output voltage without blowing up the FETs.  There are two possible ways for the start up to be done; either a simple 10 percent duty cycle PWM type signal or an open loop phase shift modulated output.  Once the output is in a known state I would then like to switch over to the closed loop phase shift modulator operation.  My first attempt was to try the PWM method, but unfortunately it looks like the ePWM modules are not reconfiguring in real time.  Any ideas? 

  • Hi Lance,

    What exactly do you mean by " ePWM modules are not reconfiguring in real time"?
    Are you unable to change the configuration register values? Do the updated values reflect in incorrect operation?

    If you change the configuration registers on the fly - the module behavior should change accordingly, but since you are changing on the fly it may in abnormal behavior while PWM outputs are already ON - please make sure the s/w timings of the updates, possible change in PWM behavior are all as needed by your application.

    If possible, Please do share more details of the issue and configuration code you are using.

    -Bharathi.
  • Thanks for the reply. I can provide a bit more insight. Basically what I am doing is the following.

    I have been using a define as an incremental build variable. This is signifies an open or closed loop controller.
    For the open loop case I am simply calling a C function DAB_STARTUP_PWM_CNF which I call like any other DP library function.
    It simply configures the ePWM2 channels to put out a 1us pulse at a 100kHz on channels A and B with ePWMB having a 5us offset from ePWMA.
    After a delay I let the normal configuration process of setting up the registers and the ISRs complete. That is working as I would expect.

    For the closed loop case however I am trying to setup the microcontroller to have the ADC sample the converter output voltage while the start up routine is running. Once the ADCRESULT exceeds a reasonable threshold I plan to then update the configuration for the ePWM channels. I'm not totally clear on how to go from an ISR that only triggers the ADC to the ADC, 2P2Z control module and PSFB module working together. Is there an issue with running a DPL initialization to reconfigure things after an ISR is already running?

    I am also looking to an alternate startup scheme that would allow me to use the PSFB module directly. For the closed loop case I was thinking of forcing the output of the 2P2Z stage by tightly constraining the min and max values to force the desired phase shift regardless of the ADCRESULT. That would avoid the issue of initializing new DPL modules after the ISR is already running.

    I hope this provides a bit more insight into what I'm trying to do.
  • I've also been having a little trouble with my start up routine and I'm not sure what the problem is.  I try to get the ePWMxA channel to put out a 1us pulse every 10us as noted previously.  I also try to get the same thing on the corresponding ePWMxB channel with a 5us offset.  

    In practice however I am not getting anything on the ePWMxB channel.  It just stays off and does nothing.  I have a 60MHz clock speed and I set the period to be 600 counts long.  I looked at the registers while debugging and I get the period in updown count mode to be 300 counts and the CMPA = 60 and CMPB =240.  I even see the TBCTR register hitting 300 so I know it is counting up and down.  I'm at a loss to understand why this is happening. 

    I wrote the following code to set up the ePWM channel described above.

    #include "PeripheralHeaderIncludes.h"
    #include "DSP2803x_EPWM_defines.h"         // useful defines specific to EPWM

    extern volatile struct EPWM_REGS *ePWM[];

    //---------------------------------------------------------------------------
    void DAB_STARTUP_PWM_CNF(int16 n, int16 Period)
    {    
    // n = the ePWM module number, i.e. selects the target module for init.

        (*ePWM[n]).TBCTL.bit.PRDLD = TB_IMMEDIATE;            // set Immediate load    
        (*ePWM[n]).TBPRD = Period/2;
        (*ePWM[n]).CMPA.half.CMPA = Period/10;            // 1us pulse at T=0
        (*ePWM[n]).CMPB = (Period + Period)/5;            // 1us pulse at T=5us
        (*ePWM[n]).TBPHS.half.TBPHS = 0;
        (*ePWM[n]).TBCTR = 0;
     
        (*ePWM[n]).TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
        (*ePWM[n]).TBCTL.bit.PHSEN = TB_DISABLE;
        (*ePWM[n]).TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;         //used to sync EPWM(n+1) "down-stream"
        (*ePWM[n]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
        (*ePWM[n]).TBCTL.bit.CLKDIV = TB_DIV1;


        (*ePWM[n]).AQCTLA.bit.ZRO = AQ_SET;
        (*ePWM[n]).AQCTLA.bit.CAU = AQ_CLEAR;
        (*ePWM[n]).AQCTLB.bit.PRD = AQ_SET;
        (*ePWM[n]).AQCTLB.bit.CBD = AQ_CLEAR;
        
    }

    My thinking in terms of a timing diagram is as follows:

  • Hi Lance,

    I have, in the past, implemented both the start-up approaches you are considering. The key to the low duty approach is to make sure that when the system transitions to normal operation the PWM registers are re-configured (for normal operation) at a known good point in time (i.e. in the PWM ISR triggered by a time-base counter event). On the F28027 device the action qualifier registers are not shadowed so you have to be extra careful about when the registers are reconfigured. On devices with type 4 PWMs these registers are shadowed. You do not need to call DPL_init function again.

    The issue of PWMxB not responding the way you want could be because of the dead-band module. Please check the dead-band configuration and also make sure that the DB RED/FED values are not greater than the 10% duty cycle value.

    An easier way to do this, which I believe is done in the HVPSFBKIT solution, is to use a slewlimited command to the control loop whenever you want to start-up the system. This way you won't need to switch between duty mode and phase shift mode or between open loop and closed loop operation.

    I hope this helps.

    Hrishi

  • Hi Hrishi,


    I have actually switched over to a slightly different slow start approach.  I am trying to use ePWM2A and ePWM2B as 50% duty cycle, 100kHz outputs which are offset in time by 1us instead of being completely out of phase like during normal operation.  Unfortunately I'm having issues getting the ePWM2B output to do anything.  I even explicitly disabled the Deadband Module so that the ePWM2A/B signals would skip right over it.  I'm still not getting anything on the output for ePWM2B.  Here is the code I wrote to configure the ePWM module.


    Also as another data point, this code is running on a 28033 microcontroller, not a 28027 or one of the HVPSFB kits.

        (*ePWM[n]).TBCTL.bit.PRDLD = TB_IMMEDIATE;            // set Immediate load    
        (*ePWM[n]).TBPRD = Period/2;
        (*ePWM[n]).CMPA.half.CMPA = Period/10;            // ePWM2B 1us offset setting edge
        (*ePWM[n]).CMPB = (2*Period)/5;                    // ePWM2B 1us offset clearing edge
        (*ePWM[n]).TBPHS.half.TBPHS = 0;
        (*ePWM[n]).TBCTR = 0;

    // May need to add shadow register functionality, but not likely as this is a static ePWM operation.  
        (*ePWM[n]).TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
        (*ePWM[n]).TBCTL.bit.PHSEN = TB_DISABLE;
        (*ePWM[n]).TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;         //used to sync EPWM(n+1) "down-stream"
        (*ePWM[n]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
        (*ePWM[n]).TBCTL.bit.CLKDIV = TB_DIV1;


        (*ePWM[n]).AQCTLA.bit.ZRO = AQ_SET;
        (*ePWM[n]).AQCTLA.bit.PRD = AQ_CLEAR;
        (*ePWM[n]).AQCTLB.bit.CAU = AQ_SET;
        (*ePWM[n]).AQCTLB.bit.CBD = AQ_CLEAR;

        (*ePWM[n]).DBCTL.bit.OUT_MODE = DB_DISABLE;

  • Don't see anything wrong with this piece of code. Please make sure that the GPIO mux setting is correct for PWM2B output. Which controlCard/appkit tool are you using?

    Hrishi
  • It was the GPIO Mux setting for the ePWM2B channel. Now everything is working as I expect for the open loop case. I will have to see what happens in the closed loop case. I am using the 28035 non-isolated controlCARD and the 100 pin DIMM USB Docking Station board for code development/testing. I also have the code running on a converter board that I designed; I am using open loop operation for open loop converter testing and I'm working my way up to closed loop testing in hardware.
  • That's great! Thank you for the update!

    Hrishi