S32K344 ABZ encoder

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
511件の閲覧回数
jiafeimao
Contributor III

Regarding the ABZ encoder interface of S32K344, I would like to ask a question. The ST MCU I used before only had one register CNT for counting. When the motor rotates forward, the register CNT counts from the current value to 4096, and when it reverses, it counts from the current value to 0. Angle=CNT/4095 * 360.
Now there are two counters in S32K344. When the motor rotates forward, CW counts from the current value to 4096, The CCW value remains unchanged, and when the motor reverses, the CCW counter counts from the current value to 4096, How can I get the angle when the CW value remains unchanged?
As shown in the figure below, I want to directly obtain angle values from 0 to 360 degrees based on counterCW and counterCCW.

jiafeimao_0-1716797265734.png

 

0 件の賞賛
返信
1 解決策
421件の閲覧回数
jiafeimao
Contributor III

I tested the ABZ magnetic encoder interface, the underlying reference S32K344 motor control suite, using ACTUATE () to get a 0-360 angle, and zero the angle by offset in the Z interrupt. The reference code is as follows:

static volatile uint16_t counterCWOffset = 0;
extern eMIOS_Type * const s_emiosBase[];
float ACTUATE_GetPos(void)
{
uint16_t counterCW,counterCCW;
float Absolut_position;
/* read encoder edges to get mechanical position */
// counterCW = (int16_t)(Emios_Icu_Ip_GetEdgeNumbers(0U, 5U)); /* CW counter */
// counterCCW = (int16_t)(Emios_Icu_Ip_GetEdgeNumbers(0U, 6U)); /* CCW counter */
counterCW = (uint16_t)s_emiosBase[0]->CH.UC[5].CNT - counterCWOffset;
counterCCW = (uint16_t)s_emiosBase[0]->CH.UC[6].CNT;
Absolut_position = (float)(((uint16_t)(counterCW-counterCCW))&(uint16_t)(4095)) * 0.0879120879120879F; /* 360 divided by 4095 */

return Absolut_position;
}

void ENC_PHZ_Handler(void)
{
counterCWOffset = (uint16_t)(s_emiosBase[0]->CH.UC[5].CNT - s_emiosBase[0]->CH.UC[6].CNT);
// Emios_Icu_Ip_ResetEdgeCount(0,5); /*Clear A Edge Count*/
// Emios_Icu_Ip_ResetEdgeCount(0,6); /*Clear B Edge Count*/

// Emios_Icu_Ip_SetInitialCounterValue(0U, 5U, (uint32_t)0x1U);
// Emios_Icu_Ip_SetInitialCounterValue(0U, 6U, (uint32_t)0x1U);

// Emios_Icu_Ip_SetMaxCounterValue(0U, 5U, (uint32_t)(4096U));
// Emios_Icu_Ip_SetMaxCounterValue(0U, 6U, (uint32_t)(4096U));

// Emios_Icu_Ip_EnableEdgeCount(0u, 5U);
// Emios_Icu_Ip_EnableEdgeCount(0u, 6U);
}

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
422件の閲覧回数
jiafeimao
Contributor III

I tested the ABZ magnetic encoder interface, the underlying reference S32K344 motor control suite, using ACTUATE () to get a 0-360 angle, and zero the angle by offset in the Z interrupt. The reference code is as follows:

static volatile uint16_t counterCWOffset = 0;
extern eMIOS_Type * const s_emiosBase[];
float ACTUATE_GetPos(void)
{
uint16_t counterCW,counterCCW;
float Absolut_position;
/* read encoder edges to get mechanical position */
// counterCW = (int16_t)(Emios_Icu_Ip_GetEdgeNumbers(0U, 5U)); /* CW counter */
// counterCCW = (int16_t)(Emios_Icu_Ip_GetEdgeNumbers(0U, 6U)); /* CCW counter */
counterCW = (uint16_t)s_emiosBase[0]->CH.UC[5].CNT - counterCWOffset;
counterCCW = (uint16_t)s_emiosBase[0]->CH.UC[6].CNT;
Absolut_position = (float)(((uint16_t)(counterCW-counterCCW))&(uint16_t)(4095)) * 0.0879120879120879F; /* 360 divided by 4095 */

return Absolut_position;
}

void ENC_PHZ_Handler(void)
{
counterCWOffset = (uint16_t)(s_emiosBase[0]->CH.UC[5].CNT - s_emiosBase[0]->CH.UC[6].CNT);
// Emios_Icu_Ip_ResetEdgeCount(0,5); /*Clear A Edge Count*/
// Emios_Icu_Ip_ResetEdgeCount(0,6); /*Clear B Edge Count*/

// Emios_Icu_Ip_SetInitialCounterValue(0U, 5U, (uint32_t)0x1U);
// Emios_Icu_Ip_SetInitialCounterValue(0U, 6U, (uint32_t)0x1U);

// Emios_Icu_Ip_SetMaxCounterValue(0U, 5U, (uint32_t)(4096U));
// Emios_Icu_Ip_SetMaxCounterValue(0U, 6U, (uint32_t)(4096U));

// Emios_Icu_Ip_EnableEdgeCount(0u, 5U);
// Emios_Icu_Ip_EnableEdgeCount(0u, 6U);
}

0 件の賞賛
返信
458件の閲覧回数
_Leo_
NXP TechSupport
NXP TechSupport

Hi,

Thank you so much for your interest in our products and for using our community.

In 4.2.5. Quadrature decoder section from AN13767: 3-phase Sensorless PMSM Motor Control Kit with S32K344 using RTD Low Level API you can see that it is performed a sum between counterCW and counterCCW to get the absolute position and then is processed by the angle tracking observer (ATO) to get the rotor position. For more detail you can also refer to the MCSPTE1AK344 Development Kit Application Software.

Hope it helps you.

Have a nice day!

0 件の賞賛
返信