cancel
Showing results for 
Search instead for 
Did you mean: 

MCSDK 6.3 - Correct way to restart / retrigger encoder alignment

sleits_96
Associate II

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.

 

4 REPLIES 4
sleits_96
Associate II

Topic was resolved. How do i delete posts ?

Rajeswari
Associate III

how u did that

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.
sleits_96
Associate II

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.