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.
Tool/software:
Hello experts,
In the dual axis drive project,Inside the PWM initialation function `HAL_setupMotorPWMs()`:
Could you please tell me why is shadow load mode is enabled for Counter compare A only? Why is it not enabled for Counter compare B?
Is it not required as CPMA and CMPB are configured as complementary from the action qualifiers?
Hi,
The dead-band Submodule is configured such that PWMA and PWMB are complimentary outputs. So you'd just use CMPA in the SW.
Best,
Kevin
Thanks for your reply Kevin.
I am trying to configure a ePWM module to act as a brake chopper which is used to dessipates excess energy via a resistor during regenerative torque.
CMPA and CMPB are independently configured.CMPA is used for Motor 1 and CMPB is used for Motor 2.
In this case , Do you recomend enabling shadow load mode ?
This is my initializer function:
// Sets up the PWMs (Pulse Width Modulators) for Brake chopper void HAL_setupBrCpPWMs(HAL_MTR_Handle handle) { HAL_MTR_Obj *obj = (HAL_MTR_Obj*) handle; //Configure clock EPWM_setClockPrescaler(obj->pwmHandle[3], EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_2); EPWM_setTimeBaseCounterMode(obj->pwmHandle[3], EPWM_COUNTER_MODE_UP); //Set period(Switching frequency : 5 KHz) EPWM_setTimeBasePeriod(obj->pwmHandle[3], 10000U); EPWM_setPhaseShift(obj->pwmHandle[3], 0U); //Enable compare shadow load mode EPWM_setCounterCompareShadowLoadMode(obj->pwmHandle[3], EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setCounterCompareShadowLoadMode(obj->pwmHandle[3], EPWM_COUNTER_COMPARE_B, EPWM_COMP_LOAD_ON_CNTR_ZERO); //Set duty cycle to 0. EPWM_setCounterCompareValue(obj->pwmHandle[3], EPWM_COUNTER_COMPARE_A, 0); EPWM_setCounterCompareValue(obj->pwmHandle[3], EPWM_COUNTER_COMPARE_B, 0); //Set up action qualifiers EPWM_setActionQualifierAction(obj->pwmHandle[3], EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(obj->pwmHandle[3], EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(obj->pwmHandle[3], EPWM_AQ_OUTPUT_B, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(obj->pwmHandle[3], EPWM_AQ_OUTPUT_B, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); // configure sync EPWM_setSyncOutPulseMode(obj->pwmHandle[3], EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN); //configure interrupts EPWM_setInterruptSource(obj->pwmHandle[3], EPWM_INT_TBCTR_ZERO); EPWM_enableInterrupt(obj->pwmHandle[3]); EPWM_setInterruptEventCount(obj->pwmHandle[3], 1); }
Thanks,
AK
Hi AK,
CMPA and CMPB are independently configured.CMPA is used for Motor 1 and CMPB is used for Motor 2.
Ok, you're also using ePWMx channel A for motor 1 and Channel B for motor 2 then?
In this case , Do you recomend enabling shadow load mode ?
Shadow load mode will load the shadow CMPA/B register to the active register on CNTR_ZERO event, so ePWM CMPA/B updates are synchronized. You cna use this mode, unless you need immediate CMPx updates for your regenerative torque application.
Best,
Kevin
Ok, you're also using ePWMx channel A for motor 1 and Channel B for motor 2 then?
Yes correct.
Shadow load mode will load the shadow CMPA/B register to the active register on CNTR_ZERO event, so ePWM CMPA/B updates are synchronized. You cna use this mode, unless you need immediate CMPx updates for your regenerative torque application.
So if we take an example of shadow loading,
If the time period(TBPRD) is 10000, and lets say at
TBCTR of 1000 , i write CMPA to 500, then at
TBCTR of 5000 , i write CMPA to 800, then at
TBCTR of 9000 , i write CMPA to 100, and then when it the counter rolls over to zero
TBCTR of 0 , CMPA value of 100 will be taken in?(and the previous values of 800, 500 will be ignored?)
Hi AK,
Yes, the behavior you described is correct. The newest register value you write will move from shadow to active register at the configured load event (TBPRS, ZERO, etc).
Best,
Kevin