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.
I use F28069M control card.
Lab 1 - done, fine.
Lab 1b
Stuck at the beggining. As recommended I try to make 4 DACPWM signals with code:
// set DAC parameters
gDacData.ptrData[0] = &gPwmData.Tabc.value[0];
gDacData.ptrData[1] = &gPwmData.Tabc.value[1];
gDacData.ptrData[2] = &gPwmData.Tabc.value[2];
gDacData.ptrData[3] = &gAdcData.V.value[0];
HAL_setDacParameters(halHandle, &gDacData);
// set PWMDAC parameters for each channel to ensure the output waveform void HAL_setDacParameters(HAL_Handle handle, HAL_DacData_t *pDacData) {
HAL_Obj *obj = (HAL_Obj *)handle;
pDacData->PeriodMax = PWMDAC_getPeriod(obj->pwmDacHandle[PWMDAC_Number_1]);
pDacData->offset[0] = _IQ(0.5);
pDacData->offset[1] = _IQ(0.5);
pDacData->offset[2] = _IQ(0.5);
pDacData->offset[3] = _IQ(0.5);
pDacData->gain[0] = _IQ(1.0);
pDacData->gain[1] = _IQ(1.0);
pDacData->gain[2] = _IQ(1.0);
pDacData->gain[3] = _IQ(1.0);
} // end of HAL_setDacParameters() function
BTW in pdf offset[2] and [3] are 0.5, but in motorware lab they are 0. Tried both values - no changes.
When I start debugging I can see 6 main PWM signals using oscilloscope at U11,U13,U15 pins 7,3.
Signals duration changing from 26 to 37 us (PWM), period 66 us (think this is fine).
What I see at pins U5 pins 1,3 DAC_PWM 3.3V most of the time, and some PWM pulses changing from 100% to 0% and back to 100%, 11.5 us period.
At pins 1,3 U7 - always zero, according to sch. U7 connected to PWM7 but in
hal.c (comes with motorware lab)
// initialize PWM DAC handles
obj->pwmDacHandle[0] = PWMDAC_init((void *)PWM_ePWM6_BASE_ADDR,sizeof(PWM_Obj));
obj->pwmDacHandle[1] = PWMDAC_init((void *)PWM_ePWM5_BASE_ADDR,sizeof(PWM_Obj));
obj->pwmDacHandle[2] = PWMDAC_init((void *)PWM_ePWM4_BASE_ADDR,sizeof(PWM_Obj));
DacHandlers use 4, 5, 6 pwm, so I suppose this is right that I see nothing.
As said in the example output waveforms captured using DRV8312_RevD kit, but I suppose there shouldn't be such difference.
Tried part 2 of the lab using datalog module, still strange results. What can be wrong with PWM_DAC?
No edits were made to the code in the lab 1b.
\ti\motorware\motorware_1_01_00_18\sw\modules\hal\boards\hvkit_rev1p1\f28x\f2806x\src\hal.c
...
// initialize PWM DAC handles
obj->pwmDacHandle[0] = PWMDAC_init((void *)PWM_ePWM6_BASE_ADDR,sizeof(PWM_Obj));
obj->pwmDacHandle[1] = PWMDAC_init((void *)PWM_ePWM5_BASE_ADDR,sizeof(PWM_Obj));
obj->pwmDacHandle[2] = PWMDAC_init((void *)PWM_ePWM4_BASE_ADDR,sizeof(PWM_Obj));
...
// PWM-DAC4
GPIO_setMode(obj->gpioHandle,GPIO_Number_6,GPIO_6_Mode_EPWM4A);
// PWM-DAC3
GPIO_setMode(obj->gpioHandle,GPIO_Number_8,GPIO_8_Mode_EPWM5A);
...
void HAL_setDacParameters(HAL_Handle handle, HAL_DacData_t *pDacData)
{
HAL_Obj *obj = (HAL_Obj *)handle;
pDacData->PeriodMax = PWMDAC_getPeriod(obj->pwmDacHandle[PWMDAC_Number_1]);
pDacData->offset[0] = _IQ(0.5);
pDacData->offset[1] = _IQ(0.5);
pDacData->offset[2] = _IQ(0.0);
pDacData->offset[3] = _IQ(0.0);
pDacData->gain[0] = _IQ(1.0);
pDacData->gain[1] = _IQ(1.0);
pDacData->gain[2] = _IQ(1.0);
pDacData->gain[3] = _IQ(1.0);
return;
} //end of HAL_setDacParameters() function
// end of file
At least ePWM5, ePWM4 are not used on HV board and not connected. Insteard ePWM7 and ePWM6 coonected to U7 and U5. Offsets are different from mentioned in pdf. I tried to figure out why DacPwm most of the time at 3.3V. I tried to use constant value as an input for DacPwm.
Something like:
uint32_t test1 = _IQ(0.01);
uint32_t test2 = _IQ(0.0);
uint32_t test3 = 80000;
gDacData.ptrData[0] = &test1; // test2... and so on
test1 case - output at 3.3V all the time
test2 case - output at 0V all the time
test3 case - ~80% fill ratio.
Can't understand, how does value convert to fill ratio? Bec. it seems like almost any _IQ(x) value makes it at 3.3V or 0V.
Maybe I'm not right that I use projects for hvkit_rev1p1? Which one should I use for TMDSHVMTRINSPIN?
Sorry. The PWMDAC doesn't work well in the project for TMDSHVMTRINSPIN. Please follow the below steps to check/configure the settings for PWMDAC function.
1. HAL_Handle HAL_init() in hal.c
// initialize PWM DAC handles
obj->pwmDacHandle[0] = PWMDAC_init((void *)PWM_ePWM6_BASE_ADDR,sizeof(PWM_Obj));
obj->pwmDacHandle[1] = PWMDAC_init((void *)PWM_ePWM7_BASE_ADDR,sizeof(PWM_Obj));
2. HAL_setupPeripheralClks() in hal.c
CLK_enablePwmClock(obj->clkHandle,PWM_Number_6);
CLK_enablePwmClock(obj->clkHandle,PWM_Number_7);
3. HAL_setupGpios() in hal.c
//
GPIO_setMode(obj->gpioHandle,GPIO_Number_6,GPIO_6_Mode_GeneralPurpose);
//
GPIO_setMode(obj->gpioHandle,GPIO_Number_7,GPIO_7_Mode_GeneralPurpose);
//
GPIO_setMode(obj->gpioHandle,GPIO_Number_8,GPIO_8_Mode_GeneralPurpose);
// PWM-DAC1
GPIO_setMode(obj->gpioHandle,GPIO_Number_10,GPIO_10_Mode_EPWM6A);
// PWM-DAC2
GPIO_setMode(obj->gpioHandle,GPIO_Number_11,GPIO_11_Mode_EPWM6B);
// PWM7A-DAC3
GPIO_setMode(obj->gpioHandle,GPIO_Number_40,GPIO_40_Mode_EPWM7A);
// PWM7B->DAC4
GPIO_setMode(obj->gpioHandle,GPIO_Number_41,GPIO_41_Mode_EPWM7B);
4. HAL_setupPwmDacs() in hal.c
void HAL_setupPwmDacs(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;
uint16_t halfPeriod_cycles = 512; // 3000->10kHz, 1500->20kHz, 1000-> 30kHz, 500->60kHz
uint_least8_t cnt;
for(cnt=0;cnt<2;cnt++)
{
// initialize the Time-Base Control Register (TBCTL)
PWMDAC_setCounterMode(obj->pwmDacHandle[cnt],PWM_CounterMode_UpDown);
PWMDAC_disableCounterLoad(obj->pwmDacHandle[cnt]);
PWMDAC_setPeriodLoad(obj->pwmDacHandle[cnt],PWM_PeriodLoad_Immediate);
PWMDAC_setSyncMode(obj->pwmDacHandle[cnt],PWM_SyncMode_EPWMxSYNC);
PWMDAC_setHighSpeedClkDiv(obj->pwmDacHandle[cnt],PWM_HspClkDiv_by_1);
PWMDAC_setClkDiv(obj->pwmDacHandle[cnt],PWM_ClkDiv_by_1);
PWMDAC_setPhaseDir(obj->pwmDacHandle[cnt],PWM_PhaseDir_CountUp);
PWMDAC_setRunMode(obj->pwmDacHandle[cnt],PWM_RunMode_FreeRun);
// initialize the Timer-Based Phase Register (TBPHS)
PWMDAC_setPhase(obj->pwmDacHandle[cnt],0);
// setup the Time-Base Counter Register (TBCTR)
PWMDAC_setCount(obj->pwmDacHandle[cnt],0);
// Initialize the Time-Base Period Register (TBPRD)
// set to zero initially
PWMDAC_setPeriod(obj->pwmDacHandle[cnt],0);
// initialize the Counter-Compare Control Register (CMPCTL)
PWMDAC_setLoadMode_CmpA(obj->pwmDacHandle[cnt],PWM_LoadMode_Zero);
PWMDAC_setLoadMode_CmpB(obj->pwmDacHandle[cnt],PWM_LoadMode_Zero);
PWMDAC_setShadowMode_CmpA(obj->pwmDacHandle[cnt],PWM_ShadowMode_Shadow);
PWMDAC_setShadowMode_CmpB(obj->pwmDacHandle[cnt],PWM_ShadowMode_Shadow);
// Initialize the Action-Qualifier Output A Register (AQCTLA)
PWMDAC_setActionQual_CntUp_CmpA_PwmA(obj->pwmDacHandle[cnt],PWM_ActionQual_Clear);
PWMDAC_setActionQual_CntDown_CmpA_PwmA(obj->pwmDacHandle[cnt],PWM_ActionQual_Set);
// Initialize the Action-Qualifier Output B Register (AQCTLN)
PWMDAC_setActionQual_CntUp_CmpB_PwmB(obj->pwmDacHandle[cnt],PWM_ActionQual_Clear);
PWMDAC_setActionQual_CntDown_CmpB_PwmB(obj->pwmDacHandle[cnt],PWM_ActionQual_Set);
// Initialize the Dead-Band Control Register (DBCTL)
PWMDAC_disableDeadBand(obj->pwmDacHandle[cnt]);
// Initialize the PWM-Chopper Control Register (PCCTL)
PWMDAC_disableChopping(obj->pwmDacHandle[cnt]);
// Initialize the Trip-Zone Control Register (TZSEL)
PWMDAC_disableTripZones(obj->pwmDacHandle[cnt]);
// Initialize the Trip-Zone Control Register (TZCTL)
PWMDAC_setTripZoneState_TZA(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
PWMDAC_setTripZoneState_TZB(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
PWMDAC_setTripZoneState_DCAEVT1(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
PWMDAC_setTripZoneState_DCAEVT2(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
PWMDAC_setTripZoneState_DCBEVT1(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
}
// since the PWM is configured as an up/down counter, the period register is set to one-half
// of the desired PWM period
PWMDAC_setPeriod(obj->pwmDacHandle[PWMDAC_Number_1],halfPeriod_cycles);
PWMDAC_setPeriod(obj->pwmDacHandle[PWMDAC_Number_2],halfPeriod_cycles);
return;
} // end of HAL_setupPwmDacs() function
5. HAL_setDacParameters() in hal.c. You need to change the offset and gain according to the variables linked to PWMDAC.
void HAL_setDacParameters(HAL_Handle handle, HAL_DacData_t *pDacData)
{
HAL_Obj *obj = (HAL_Obj *)handle;
pDacData->PeriodMax = PWMDAC_getPeriod(obj->pwmDacHandle[PWMDAC_Number_1]);
pDacData->offset[0] = _IQ(0.5);
pDacData->offset[1] = _IQ(0.5);
pDacData->offset[2] = _IQ(0.5);
pDacData->offset[3] = _IQ(0.0);
pDacData->gain[0] = _IQ(1.0);
pDacData->gain[1] = _IQ(1.0);
pDacData->gain[2] = _IQ(1.0);
pDacData->gain[3] = _IQ(1.0);
return;
} //end of HAL_setDacParameters() function
6. HAL_writeDacData in hal.h
static inline void HAL_writeDacData(HAL_Handle handle,HAL_DacData_t *pDacData)
{
HAL_Obj *obj = (HAL_Obj *)handle;
// convert values from _IQ to _IQ15
uint_least8_t cnt;
_iq period;
_iq dacData_sat_dc;
_iq value;
uint16_t cmpValue[4];
period = (_iq)pDacData->PeriodMax;
for(cnt=0;cnt<4;cnt++)
{
dacData_sat_dc = _IQmpy(pDacData->value[cnt], pDacData->gain[cnt]) + pDacData->offset[cnt];
value = _IQmpy(dacData_sat_dc, period);
cmpValue[cnt] = (uint16_t)_IQsat(value, period, 0);
}
// write the DAC data
PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_1],cmpValue[0]);
PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_1],cmpValue[1]);
PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_2],cmpValue[2]);
PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_2],cmpValue[3]);
return;
} // end of HAL_writeDacData() function
7. Set up DAC parameters in proj_lab01b.c
// set DAC parameters
gDacData.ptrData[0] = &gPwmData.Tabc.value[0];
gDacData.ptrData[1] = &gPwmData.Tabc.value[1];
gDacData.ptrData[2] = &gPwmData.Tabc.value[2];
gDacData.ptrData[3] = &angle_gen.Angle_pu;
HAL_setDacParameters(halHandle, &gDacData);