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: Code Composer Studio
Hello,
Thanks in advance for the help with this topic!
In hal.h, we define the below for the deadband. Due to some of the modes we use our motor in, we need to update the deadband on the fly. Is this possible? We are using TMS320F28069M and DRV 8303.
Thanks!
Jonathan
_________________________________________________________________
//hal.h This is where we define the deadband
//! \brief Defines the PWM deadband falling edge delay count (system clocks)
//!
#define HAL_PWM_DBFED_CNT 500 // 8205-725 8208-320
//! \brief Defines the PWM deadband rising edge delay count (system clocks)
//!
#define HAL_PWM_DBRED_CNT 500 // 8205-725 8208-320
______________________________________________________________________
//Main.c Below is a snipped where we are calling PWM functions
if(CTRL_isError(ctrlHandle)) {
// set the enable controller flag to false
CTRL_setFlag_enableCtrl(ctrlHandle,false);
// set the enable system flag to false
gMotorVars.Flag_enableSys = false;
// disable the PWM
HAL_disablePwm(halHandle);
} else {
// update the controller state
bool flag_ctrlStateChanged = CTRL_updateState(ctrlHandle);
// enable or disable the control
CTRL_setFlag_enableCtrl(ctrlHandle, gMotorVars.Flag_Run_Identify);
if(flag_ctrlStateChanged)
{
CTRL_State_e ctrlState = CTRL_getState(ctrlHandle);
if(ctrlState == CTRL_State_OffLine)
{
// enable the PWM
HAL_enablePwm(halHandle);
}
else if(ctrlState == CTRL_State_OnLine)
{
if(gMotorVars.Flag_enableOffsetcalc == true)
{
// update the ADC bias values
HAL_updateAdcBias(halHandle);
}
else
{
// set the current bias
HAL_setBias(halHandle,HAL_SensorType_Current,0,_IQ(I_A_offset));
HAL_setBias(halHandle,HAL_SensorType_Current,1,_IQ(I_B_offset));
HAL_setBias(halHandle,HAL_SensorType_Current,2,_IQ(I_C_offset));
// set the voltage bias
HAL_setBias(halHandle,HAL_SensorType_Voltage,0,_IQ(V_A_offset));
HAL_setBias(halHandle,HAL_SensorType_Voltage,1,_IQ(V_B_offset));
HAL_setBias(halHandle,HAL_SensorType_Voltage,2,_IQ(V_C_offset));
}
// Return the bias value for currents
gMotorVars.I_bias.value[0] = HAL_getBias(halHandle,HAL_SensorType_Current,0);
gMotorVars.I_bias.value[1] = HAL_getBias(halHandle,HAL_SensorType_Current,1);
gMotorVars.I_bias.value[2] = HAL_getBias(halHandle,HAL_SensorType_Current,2);
// Return the bias value for voltages
gMotorVars.V_bias.value[0] = HAL_getBias(halHandle,HAL_SensorType_Voltage,0);
gMotorVars.V_bias.value[1] = HAL_getBias(halHandle,HAL_SensorType_Voltage,1);
gMotorVars.V_bias.value[2] = HAL_getBias(halHandle,HAL_SensorType_Voltage,2);
// enable the PWM
HAL_enablePwm(halHandle);
}
else if(ctrlState == CTRL_State_Idle)
{
// disable the PWM
HAL_disablePwm(halHandle);
gMotorVars.Flag_Run_Identify = false;
}
if((CTRL_getFlag_enableUserMotorParams(ctrlHandle) == true) &&
(ctrlState > CTRL_State_Idle) &&
(gMotorVars.CtrlVersion.minor == 6))
{
// call this function to fix 1p6
USER_softwareUpdate1p6(ctrlHandle);
}
}
}
Hello,
Thanks in advance for the help with this topic!
In hal.h, we define the below for the deadband. Due to some of the modes we use our motor in, we need to update the deadband on the fly. Is this possible? We are using TMS320F28069M and DRV 8303.
Thanks!
Jonathan
_________________________________________________________________ //hal.h This is where we define the deadband //! \brief Defines the PWM deadband falling edge delay count (system clocks) //! #define HAL_PWM_DBFED_CNT 500 // 8205-725 8208-320 //! \brief Defines the PWM deadband rising edge delay count (system clocks) //! #define HAL_PWM_DBRED_CNT 500 // 8205-725 8208-320 ______________________________________________________________________ //Main.c Below is a snipped where we are calling PWM functions if(CTRL_isError(ctrlHandle)) { // set the enable controller flag to false CTRL_setFlag_enableCtrl(ctrlHandle,false); // set the enable system flag to false gMotorVars.Flag_enableSys = false; // disable the PWM HAL_disablePwm(halHandle); } else { // update the controller state bool flag_ctrlStateChanged = CTRL_updateState(ctrlHandle); // enable or disable the control CTRL_setFlag_enableCtrl(ctrlHandle, gMotorVars.Flag_Run_Identify); if(flag_ctrlStateChanged) { CTRL_State_e ctrlState = CTRL_getState(ctrlHandle); if(ctrlState == CTRL_State_OffLine) { // enable the PWM HAL_enablePwm(halHandle); } else if(ctrlState == CTRL_State_OnLine) { if(gMotorVars.Flag_enableOffsetcalc == true) { // update the ADC bias values HAL_updateAdcBias(halHandle); } else { // set the current bias HAL_setBias(halHandle,HAL_SensorType_Current,0,_IQ(I_A_offset)); HAL_setBias(halHandle,HAL_SensorType_Current,1,_IQ(I_B_offset)); HAL_setBias(halHandle,HAL_SensorType_Current,2,_IQ(I_C_offset)); // set the voltage bias HAL_setBias(halHandle,HAL_SensorType_Voltage,0,_IQ(V_A_offset)); HAL_setBias(halHandle,HAL_SensorType_Voltage,1,_IQ(V_B_offset)); HAL_setBias(halHandle,HAL_SensorType_Voltage,2,_IQ(V_C_offset)); } // Return the bias value for currents gMotorVars.I_bias.value[0] = HAL_getBias(halHandle,HAL_SensorType_Current,0); gMotorVars.I_bias.value[1] = HAL_getBias(halHandle,HAL_SensorType_Current,1); gMotorVars.I_bias.value[2] = HAL_getBias(halHandle,HAL_SensorType_Current,2); // Return the bias value for voltages gMotorVars.V_bias.value[0] = HAL_getBias(halHandle,HAL_SensorType_Voltage,0); gMotorVars.V_bias.value[1] = HAL_getBias(halHandle,HAL_SensorType_Voltage,1); gMotorVars.V_bias.value[2] = HAL_getBias(halHandle,HAL_SensorType_Voltage,2); // enable the PWM HAL_enablePwm(halHandle); } else if(ctrlState == CTRL_State_Idle) { // disable the PWM HAL_disablePwm(halHandle); gMotorVars.Flag_Run_Identify = false; } if((CTRL_getFlag_enableUserMotorParams(ctrlHandle) == true) && (ctrlState > CTRL_State_Idle) && (gMotorVars.CtrlVersion.minor == 6)) { // call this function to fix 1p6 USER_softwareUpdate1p6(ctrlHandle); } } }
Hello Hareesh,
Following up on the question above to see if it is possible to adjust the deaband time on the fly?
Best,
Jonathan
You might have a look at the datasheet of DRV8303, the dead time of DRV8303 is programmed through DTC pin. A resistor is connected from DTC to ground to control the dead time which range is from 50 ns to 500 ns.
Of course, you can set dead time by changing the registers of F28069M as the following code in HAL_setupPwms() in hal.c. Replace the HAL_PWM_DBRED_CNT and HAL_PWM_DBFED_CNT with two variables, set these vairables to the dead time value, and call these code at any time you want. But the minium dead time will be limited to DRV8303.
// setup the Dead-Band Rising Edge Delay Register (DBRED)
PWM_setDeadBandRisingEdgeDelay(halHandle->pwmHandle[0],HAL_PWM_DBRED_CNT);
PWM_setDeadBandRisingEdgeDelay(halHandle->pwmHandle[1],HAL_PWM_DBRED_CNT);
PWM_setDeadBandRisingEdgeDelay(halHandle->pwmHandle[2],HAL_PWM_DBRED_CNT);
// setup the Dead-Band Falling Edge Delay Register (DBFED)
PWM_setDeadBandFallingEdgeDelay(halHandle->pwmHandle[0],HAL_PWM_DBFED_CNT);
PWM_setDeadBandFallingEdgeDelay(halHandle->pwmHandle[1],HAL_PWM_DBFED_CNT);
PWM_setDeadBandFallingEdgeDelay(halHandle->pwmHandle[2],HAL_PWM_DBFED_CNT);
Thank you Yanming Luo,
We are now able to update the deadband in real-time, but are not calling the HAL_setupPwms() function. Does this need to also be called or can we just update via:
// setup the Dead-Band Rising Edge Delay Register (DBRED)
PWM_setDeadBandRisingEdgeDelay(halHandle->pwmHandle[0],HAL_PWM_DBRED_CNT);
PWM_setDeadBandRisingEdgeDelay(halHandle->pwmHandle[1],HAL_PWM_DBRED_CNT);
PWM_setDeadBandRisingEdgeDelay(halHandle->pwmHandle[2],HAL_PWM_DBRED_CNT);
// setup the Dead-Band Falling Edge Delay Register (DBFED)
PWM_setDeadBandFallingEdgeDelay(halHandle->pwmHandle[0],HAL_PWM_DBFED_CNT);
PWM_setDeadBandFallingEdgeDelay(halHandle->pwmHandle[1],HAL_PWM_DBFED_CNT);
PWM_setDeadBandFallingEdgeDelay(halHandle->pwmHandle[2],HAL_PWM_DBFED_CNT);
Although we are able to update on the fly, the motor at times seems unstable with the change. Is there anything else impacted by this change that we are leaving out?
Thanks!
Jonathan
That's fine as the code above you mentioned, only call a part of the code in HAL_setupPwms().