Other Parts Discussed in Thread: TIDA-010031, MSP430F5529, DRV8323, , DRV832X
Hi DRV experts,
I'm supporting a customer using our TIDA-010031 reference design that seems to be based on code from the BOOSTXL-DRV8320H evaluation software (SLVC683). I'm looking at the "DRV8323_MSP430F5529_Trapezoidal_Sensorless_BLDC" project here.
They are asking about the MOTOR_DIRECTION case that appears to be missing from the DRV8x_State_Machine() switch statement. I looked into this and can confirm that when "ApplicationStatus.currentstate" is set to MOTOR_DIRECTION in CCS, the code appears to enter an endless loop without doing anything because there is no case defined for MOTOR_DIRECTION.
In both the MOTOR_ALIGN and MOTOR_IPD cases in DRV8x_State_Machine(), the direction is reversed and the current state is changed to MOTOR_DIRECTION when the direction flag is set. This would be the dead end scenario.
if(SensorlessTrapController.Direction_flag)
{
SensorlessTrapController.Direction_flag = FALSE;
SensorlessTrapController.Direction =
!SensorlessTrapController.Direction; // This flag monitors for change in direction, If direction change is applied multiple times in quick succession before speed becoming zero, this flag determines the true direction by the time motor is ramped up. __delay_cycles(25000000); /* A delay of 1s is applied before changing the direction of spin*/
ApplicationStatus.previousstate =
ApplicationStatus.currentstate;
ApplicationStatus.currentstate = MOTOR_DIRECTION;
}
My main question - is MOTOR_DIRECTION just a typo and instead should be a different case such as MOTOR_STOP or MOTOR_IDLE or should there be code specifically for the MOTOR_DIRECTION case that's just missing?
If the motor is running and the direction flag is set, the code seems to slow down the motor, reverse "SensorlessTrapController.Direction" and change the state to MOTOR_STOP. That makes sense.
case MOTOR_RUN:
if((SensorlessTrapController.Direction_flag)||(HostController.Start_Stop_Motor))
{
if(SensorlessTrapController.SpeedDivider > SensorlessTrapController.RampRateDelay)
{
SensorlessTrapController.SpeedDivider = 0;
if(SensorlessTrapController.CurrentDutyCycle >= (SensorlessTrapController.MinOffDutyCycle)) // Addidng hysteresis for going to Motor direction state
{
SensorlessTrapController.CurrentDutyCycle -= RAMP_RATE;
}
else
{
if(SensorlessTrapController.Direction_flag)
{
SensorlessTrapController.Direction_flag = FALSE;
SensorlessTrapController.Direction =
!SensorlessTrapController.Direction; // This flag monitors for change in direction, If direction change is applied multiple times in quick succession before speed becoming zero, this flag determines the true direction by the time motor is ramped up. __delay_cycles(25000000); /* A delay of 1s is applied before changing the direction of spin*/
if(SensorlessTrapController.Direction == TRUE)
{
P1OUT |= BIT0; /* Turn on LED1 */
P4OUT &= ~BIT7; /* Turn off LED 2*/
}
else
{
P1OUT &= ~BIT0; /* Turn off LED1 */
P4OUT |= BIT7; /* Turn on LED 2*/
}
ApplicationStatus.previousstate = ApplicationStatus.currentstate;
ApplicationStatus.currentstate = MOTOR_STOP; // move to motor initialization
}
if(HostController.Start_Stop_Motor)
{
ApplicationStatus.previousstate =
ApplicationStatus.currentstate;
ApplicationStatus.currentstate = MOTOR_STOP;
}
}
}
}
Thanks for your help.