Skip to main content
Associate II
July 31, 2024
Question

MCSDK 6.3 - Correct way to restart / retrigger encoder alignment

  • July 31, 2024
  • 3 replies
  • 1344 views

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.

 

3 replies

sleits_96Author
Associate II
July 31, 2024

Topic was resolved. How do i delete posts ?

Gael A
ST Employee
August 12, 2024

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 :)

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.Hope this will help,Gaël A.
Associate II
August 12, 2024

how u did that

sleits_96Author
Associate II
August 12, 2024

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.