Part Number: TMS320F280049C
Tool/software: Code Composer Studio
Dear TI,
I am using a state machine to detect direction rotation(clockwise or counter clockwise) of a synchronous machine,
I am using emf voltage phase to phase 1_2 and 2_3 comparison, the combination bellow,
10,11,01,00 for + direction and 10, 00, 01, 11 for -.
When i test this state machine, i figured out that the state doesn't work well in low speed,
The issue is, i want to detect rotation direction in low speed,
Do i have to activate any qualification factor for the GPIO pins?
C code
UINT16 l_u16Ph1_2;
UINT16 l_u16Ph2_3;
UINT32 l_u32Test;
int32 l_i16Dir = 0;
l_u16Ph1_2 = GPIO_ReadPin(DRV_GPIO_X_U_COMP_PH_2_3);
l_u16Ph2_3 = GPIO_ReadPin(DRV_GPIO_X_U_COMP_PH_1_2);
/* memo cmp n-1*/
l_u32Test = s_u32CmpDir;
switch (s_u16Stat)
{
case 'A':
if (1u == l_u16Ph1_2 && 0u == l_u16Ph2_3)
{
s_u16Stat = 'B';
s_u32CmpDir+=10;
}
else if (0u == l_u16Ph1_2 && 1u == l_u16Ph2_3)
{
s_u16Stat = 'D';
s_u32CmpDir-=10;
}
else
{
s_u16Stat = 'A';
}
break;
case 'B':
if (1u == l_u16Ph1_2 && 1u == l_u16Ph2_3)
{
s_u16Stat = 'C';
s_u32CmpDir+=10;
}
else if (0u == l_u16Ph1_2 && 1u == l_u16Ph2_3)
{
s_u16Stat = 'A';
s_u32CmpDir-=10;
}
else
{
s_u16Stat = 'B';
}
break;
case 'C':
if (0u == l_u16Ph1_2 && 1u == l_u16Ph2_3)
{
s_u16Stat = 'D';
s_u32CmpDir+=10;
}
else if (1u == l_u16Ph1_2 && 0u == l_u16Ph2_3)
{
s_u16Stat = 'B';
s_u32CmpDir-=10;
}
else
{
s_u16Stat = 'C';
}
break;
case 'D':
if (0u == l_u16Ph1_2 && 0u == l_u16Ph2_3)
{
s_u16Stat = 'A';
s_u32CmpDir+=10;
}
else if (1u == l_u16Ph1_2 && 1u == l_u16Ph2_3)
{
s_u16Stat = 'C';
s_u32CmpDir-=10;
}
else
{
s_u16Stat = 'D';
}
break;
default:
break;
}
l_i16Dir = l_u32Test - s_u32CmpDir;
if (l_i16Dir>0)
{
s_u16CmpConfirm++;
}
else
{
s_u16CmpConfirm = 0;
}
if (s_u16CmpConfirm > 10)
{
*p_bRotationDir = TRUE;
}
else
{
*p_bRotationDir = FALSE;
}
code:
Thank you in advance,
S.Tarik,