2024-07-30 11:10 PM
Hi Community,
does anybody know how to restart the encoder alignment process after the first initial alignent during motor startup ?
EAC_SetRestartState(&EncAlignCtrlM1, true);
EAC_StartAlignment(&EncAlignCtrlM1);
while(MC_GetSTMStateMotor1() == ALIGNMENT){}
seems not to do the trick.
2024-07-31 07:05 AM
Topic was resolved. How do i delete posts ?
2024-08-11 09:01 PM
how u did that
2024-08-12 12:46 AM
Hello sleits_96,
If your topic is resolved, you can start by explaining to the community how you managed to solve your issue, and then accept your own answer as solution. This way, any newcomer that faces the same issue as you did will easily find their answer here.
Thank you for contributing to the forum :)
2024-08-12 02:07 AM
Hi everybody, i am still not sure if it is the right way to do it but the following code snippet solved my issue:
/* Application requests realignment */
if(req_alignment == 1)
{
/* Clear realignment request flag */
req_alignment = 0;
/* Make sure the Motor is stopped */
if(MC_SUCCESS == MC_StopMotor1())
{
while(MC_GetSTMStateMotor1() == STOP){}
}
/* Reset alignment state */
EncAlignCtrlM1.EncAligned = false;
/* If necessary change alignment parameters here */
EncAlignCtrlM1.hFinalTorque = (uint16_t)(10 * CURRENT_CONV_FACTOR); // Alignment current = 10 Amperes
EncAlignCtrlM1.hDurationms = 2000; // 2000 ms
EncAlignCtrlM1.hElAngle = (int16_t)(90 * 65536u / 360u); // Alignment angle = 90 degrees
/* I am not completely sure what this does yet */
EAC_SetRestartState(&EncAlignCtrlM1, true);
/* Start alignment procedure */
EAC_StartAlignment(&EncAlignCtrlM1);
/* Wait for alignment procedure to finish */
while(MC_GetSTMStateMotor1() == ALIGNMENT){}
}
It is necessery to clear the EncAligned flag in the EncAlignCtrl struct before restarting the alignment procedure with EAC_StartAlignment.
Hope this helps.