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.

TMS320F28377S: EPWM1A and EPWM1B with independent modulation not working.

Part Number: TMS320F28377S

Hello everybody

I have a question for EPWM. I want to use EPWM1A and EPWM1B separately. For example EPWM1A can be activated and change its duty cycle how i want to and EPWM1B at the same time be at low or high without changing its duty cycle. And also the other way where EPWM1B is working and EPWM1A is "waiting".
By working them both alone (disable either one) they are working as intended with the good duty cycle and outputs. But as soon as I use them both at the same time they seem to be walking over each other.

What i want as final signal on my output of EPWM1A (top) and EPWM1B(bottom) With a different sine wave as modulation:

 

Alone they are working fine like this : 

But as soon as I put them at the same time there seems to be a problem : 

My code is this (image or text) : 

void init_epwm1(void){

	EPwm1Regs.TBCTL.bit.FREE_SOFT  	= 0x02;				// free run

	// Setup TBCLK
	EPwm1Regs.TBPRD			    	= PWR_IN_CNT_PRD;  	// Set timer period 2500
	EPwm1Regs.TBPHS.all 			= 0;
	EPwm1Regs.TBPHS.bit.TBPHS 		= 0x0000;
	EPwm1Regs.TBCTR			    	= 0x0000;           // Clear counter

	// Set Compare values
	EPwm1Regs.CMPA.bit.CMPA			= 500;     			// Set compare A
	EPwm1Regs.CMPB.bit.CMPB 		= 1000;                // Set Compare B

	// Setup counter mode
	EPwm1Regs.TBCTL.bit.CTRMODE 	= TB_COUNT_UPDOWN; 	// Symmetrical mode
	EPwm1Regs.TBCTL.bit.PHSEN 		= TB_DISABLE;       // Master module enable phase loading
	EPwm1Regs.TBCTL.bit.PRDLD 		= TB_SHADOW;
	EPwm1Regs.TBCTL.bit.SYNCOSEL 	= TB_SYNC_DISABLE; 	// Sync A and B disable
	EPwm1Regs.TBCTL.bit.HSPCLKDIV 	= TB_DIV1;       	// Clock ratio to PWM_CLOCK_FREQ
	EPwm1Regs.TBCTL.bit.CLKDIV 		= TB_DIV1;

	// Setup shadowing
	EPwm1Regs.CMPCTL.bit.SHDWAMODE 	= CC_SHADOW;
	EPwm1Regs.CMPCTL.bit.SHDWBMODE 	= CC_SHADOW;
	EPwm1Regs.CMPCTL.bit.LOADAMODE 	= CC_CTR_ZERO; 		  // Load on Zero
	EPwm1Regs.CMPCTL.bit.LOADBMODE 	= CC_CTR_ZERO;

	// Setup Output A and B with count up and down
    EPwm1Regs.AQCTLA.bit.CAU        = AQ_SET;             // Set actions for EPWM1A
    EPwm1Regs.AQCTLA.bit.CAD        = AQ_CLEAR;
    EPwm1Regs.AQCTLB.bit.CBU        = AQ_SET;             // Set actions for EPWM1B
    EPwm1Regs.AQCTLB.bit.CBD        = AQ_CLEAR;


	EPwm1Regs.DBCTL.bit.OUT_MODE 	= DB_DISABLE; 	        //Disable Dead-band module
//	EPwm1Regs.DBCTL.bit.POLSEL 		= DB_ACTV_LO; 		    // Active Low
//  EPwm1Regs.DBFED.bit.DBFED       = PWM_DEAD_TIME_COUNT;  // 100 TBCLKs    = 1us
//  EPwm1Regs.DBRED.bit.DBRED       = PWM_DEAD_TIME_COUNT;  // 100 TBCLKs    = 1us

	//	Trip-Zone
//	EPwm1Regs.TZSEL.bit.OSHT1		= TZ_ENABLE;		    // enables TZ1 as a one-shot event source for ePWM1
	EPwm1Regs.TZCTL.bit.TZA			= TZ_FORCE_LO;		    // Force EPWMxA to a low state
	EPwm1Regs.TZCTL.bit.TZB			= TZ_FORCE_LO;		    // Force EPWMxB to a low state
	EPwm1Regs.TZFRC.bit.OST	 		= 0x1;				    // Software Force Trip Zone

}

So if you have any more questions or solutions for things i did wrong here, I would be very happy. Thank you and have a good day

Daniel

  • Hi Daniel,

    Can you please explain how the rest of your code works? How you are changing the duty cycle of the outputs? How do you disable one and not the other? It would also be helpful to indicate what is channel A and what is channel B within the waveforms you attached. 

    Best Regards,

    Marlyn

  • Hi Daniel,

    I see you have disabled dead band and pass through CMPA and CMPB, your code disables phase loading. Might it be CMPB is out of phase with CMPA by 180° when both are active?

    Also if your intent is DC inverter zero switch H bridge or some other topology it would be wise to enable some kind of dead band control over MOSFET switching. Should x77 support direct control of CMPB dead band it might be good to configure ePWM A/B for complementary drive signals. Perhaps otherwise enable dead band to invert CMPB from CMPA.

  • Yes I am sorry I didn't mention that.

    For both of these, the signal on top is the EPWM1A and the one on the bottom is the signal EPWM1B.

    For the duty cycle code : Right now I am using a fixed value on the init for the CMPA and CMPB because it doesn't work like I want it. And if I want to test something out without reloading everything, I have a variable that changes CMPA and CMPB

    But the duty cycle works fine if I only use EPWM1A alone and my code is like this to change the duty cycle : 

        control.uf.output_gen1_positive_only = func_gen.generator_1.out*2.0;        //func_gen.generator_1.out = sin 50Hz amplitude 1 pp, *2 for the signal to be at +1 and -1.
        control.uf.output_gen2_positive_only = (-func_gen.generator_1.out*2.0);     //func_gen.generator_1.out = Inverted sin 50Hz amplitude 1 pp, *2 for the signal to be at +1 and -1.
        if(control.uf.output_gen1_positive_only<0)
        {
            control.uf.output_gen1_positive_only = 0;
        }
        if(control.uf.output_gen2_positive_only<0)
        {
            control.uf.output_gen2_positive_only = 0;
        }
        
        
        epwm.modulator_1.in_modul = control.uf.output_gen1_positive_only*control.uf.input_duty;
        epwm.modulator_2.in_modul = control.uf.output_gen2_positive_only*control.uf.input_duty;

    process_modulator(&epwm.modulator_1);
    
    void process_modulator (struct modulator_t *const modulator)
    {
    
    	Uint16	temp;
    
    	// 1 PU Limitation on input
    	LIMIT(modulator->in_modul,0.0,1.0);
    
    	// float -> pwm adaptation
    	temp = (Uint16) (modulator->in_modul*PWR_IN_CNT_PRD); //PWR_IN_CNT_PRD max value of EPWM counter, 2500
    
    	// Pulse Limiter min value
    	if (temp <= modulator->pwm_min) temp = 0;
    
    	// Pulse Limiter max value
    	if (temp >= modulator->pwm_max) temp = (PWR_IN_CNT_PRD);
    
    	// loading in compare register
    	modulator->reg_handle->CMPA.bit.CMPA  = temp;
    
    }

    So like I said this part works fine if I only use A OR B.

    Hope this helps and I am here if you have other questions.

    Thank you

    Daniel

  • Yes. I disabled the dead band because I don't want them to interact with each other, I want to set some value with CMPA and other with CMPB. They should be completely independent. (Maybe there is something I didn't understand and with dead band you can do that).

    I tried to enable the phase loading with a value of 0 in TBPHS but I get the same result.

    What I want to do is this :

    Here it even says independent modulation. So It should be easy, but I am probably missing something :(

    EPWMA is modulated by CMPA, EPWMB is modulated by CMPB. Without them blocking each other. That is all I want.

    Thank you

    Daniel

  • Ok little update for you all. I asked for this issue around some people in my office and nobody knew. But today, somebody outside of the project made a small remark about something and the person that was looking for the issue with me remembered that they installed a protection on the output of the EPWM some time ago. So basically if you activate the EPWM1B, the EPWM1A will automatically be turned off. And this is exactly what was happening. We corrected this issue and it works perfectly fine now. Thank you for helping. I feel dumb, guess it happends sometimes Upside down

    Daniel

  • I found the issue, but thank you very much for your remarks and time. I put the solution under the post. Have a good day

    Daniel

  • I found the issue, but thank you very much for your remarks and time. I put the solution under the post. Have a good day

    Daniel

  • Hi Daniel,

    No worries, it happens. Thank you for explaining the error and solution. I am glad you were able to resolve this within your application. Hope you have a great day as well. 

    Best Regards,

    Marlyn

  • Hi Daniel,

    Sorry for late response we had bad storm 2 days no internet many trees went down. I was referring to some TI ePWM modules do not support independent dead band on both PWMA/B outputs without adding delay to A to make B, loosing Generator B in the process. Check the TRM for x377 MCU to see how the bits must be set to allow both A/B outputs independent dead band generators, not just pass through mode 1.

    X49c MCU dead band is uniquely different has ePWM module type 4 if I recall correctly. 

    Regards,