| ApossC SDK V01.15

Functions
SDK_Amplifier_MotorAlignment.mh File Reference

Declaration of the motor aligning function. More...

Go to the source code of this file.

## Functions
long | sdkMotorAlignment (long axis, long mode, long maxCurrentMotor, long alignCurrent)
| The purpose of this function is to find the rotor position of a brushless motor in relation to the encoder position feedback. More...
long | sdkMotorMultiAlignment (long axis, long axisNumber, long mode, long maxCurrent, long alignCurrent)
| The purpose of this function is to find the rotor position of a brushless motor in relation to the encoder position feedback. More...
long | sdkSetMotorAlignmentOffset (long axis, long elPol, long poselOffset)
| This function sets the offset of the electric field in relation to an absolute encoder. More...

## Detailed Description

Declaration of the motor aligning function.

Revision
  162

Definition in file SDK_Amplifier_MotorAlignment.mh.

## Function Documentation

## ◆ sdkMotorAlignment()

long sdkMotorAlignment | ( | long | axis,
|  | long | mode,
|  | long | maxCurrent,
|  | long | alignCurrent
| ) |  |

The purpose of this function is to find the rotor position of a brushless motor in relation to the encoder position feedback.

The function will start a program in the amplifier, which will apply a magnetic field to the rotor. The rotor will then align to this field. The field will then be varied a bit back and forth to commit the measurement. To use this function the maximum current of the motor must also be specified.

Note
  In order for this procedure to work, the motor must not be braked or be in a limit position. The rotor must be able to rotate freely for about half a revolution.

Parameters

  axis | Axis module number
  mode | Mode of aligment 1: For brushless motors 3: For stepper motors
  maxCurrent | Maximum current of the motor
  alignCurrent | Current for the alignment function

Returns
  value: Command Reference, MotorAlingStatus()
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Definition at line 34 of file SDK_Amplifier_MotorAlignment.mc.

35 {
36 long retVal;
37
38 HWAMP_PARAM((axis), HWAMP_MAXCUR) = alignCurrent; // Set the maximum current for aligning the motor
39
40 print("AxisNo ", axis, " Start position detection");
41 MotorAlignStart(axis, mode); // Start motor aliginment
42
43 while((retVal = MotorAlignStatus(axis)) == 0) // Wait until the alignment is successful or failed
44 {
45 print("Aligning... ", retVal);
46 Delay(500);
47 }
48 if(retVal < 0)
49 {
50 print("!!!! Rotor position detection FAILED !!!! retVal: ", retVal);
51 }
52 else if (retVal > 0)
53 {
54 print("Alignment completed with ", retVal);
55 }
56 HWAMP_PARAM((axis), HWAMP_MAXCUR) = maxCurrent; // Set the maximum current for the motor
57
58 return(retVal);
59 }

## ◆ sdkMotorMultiAlignment()

long sdkMotorMultiAlignment | ( | long | axis,
|  | long | axisNumber,
|  | long | mode,
|  | long | maxCurrent,
|  | long | alignCurrent
| ) |  |

The purpose of this function is to find the rotor position of a brushless motor in relation to the encoder position feedback.

The function is the same as function sdkMotorAlignment() - but several motors can be started in simultaneous. The same current is set for each axis.

Note
  In order for this procedure to work, the motor must not be braked or be in a limit position. The rotor must be able to rotate freely for about half a revolution.

Parameters

  axis | Axis module number (lowest axis)
  axisNumber | Number axes. These must be lined up and increased by one for each axis
  mode | Mode of aligment 1: For brushless motors 3: For stepper motors
  maxCurrent | Maximum current of the motor
  alignCurrent | Current for the alignment function

Returns
  value: Command Reference, MotorAlingStatus()
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Definition at line 79 of file SDK_Amplifier_MotorAlignment.mc.

80 {
81 long retVal[6]={0,0,0,0,0,0},retValCheck[6]={0,0,0,0,0,0}, retValSum=0, i;
82
83 axisNumber=axis+axisNumber;
84
85 for (i=axis;i<axisNumber;i++)
86 {
87 AxisControl(i,OFF);
88 HWAMP_PARAM((i), HWAMP_MAXCUR) = alignCurrent; // Set the maximum current for aligning the motor
89 print("AxisNo ", i, " Start position detection");
90 MotorAlignStart(i, mode);
91 Delay(250);
92 }
93 print("AxisNumber ", axisNumber - axis);
94
95 while(!(retValSum==(axisNumber-axis)))
96 {
97 retValSum=0;
98 for (i=axis;i<axisNumber;i++)
99 {
100 retVal[i] = MotorAlignStatus(i);
101 printf("Aligning Axis: %ld, Status: %ld", i, retVal[i]);
102 print("");
103
104 if(retVal[i] < 0)
105 {
106 print("!!!! Rotor position detection FAILED !!!! retVal: ", retVal[i]);
107 print("");
108 return(-1);
109 }
110 else if (retVal[i] > 0)
111 {
112 printf("Aligning Axis: %ld completed with: %ld", i, retVal[i]);
113 print("");
114 retValCheck[i]=1;
115 }
116 retValSum=retValCheck[i]+retValSum;
117 }
118 Delay(1000);
119 }
120 for (i=axis;i<=axisNumber;i++)
121 {
122 HWAMP_PARAM((i), HWAMP_MAXCUR) = maxCurrent; // Set the maximum current for the motor
123 }
124
125 return(1);
126 }

## ◆ sdkSetMotorAlignmentOffset()

long sdkSetMotorAlignmentOffset | ( | long | axis,
|  | long | elPol,
|  | long | poselOffset
| ) |  |

This function sets the offset of the electric field in relation to an absolute encoder.

If an absolute encoder is used and the offset between rotor/ encoder is already known, the classic motor alignment can be dispensed with. The offset and the polarity can be determined with the function sdkMotorAlignment() during commissioning.

Parameters

  axis | Axis module number
  elPol | Encoder polarity vs. electrical polarity (default -1) 1 HWAMP_ELPOL_REGULAR: Electrical polarity is equal encoder's polarity -1 HWAMP_ELPOL_INVERS: Electrical polarity is inverse to encoder's polarity
  poselOffset | Sets the offsets for the aligned absolute encoders.

Returns
  value: Always 1 in this function
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Definition at line 143 of file SDK_Amplifier_MotorAlignment.mc.

144 {
145 HWAMP_PARAM(axis,HWAMP_ELPOL) = elPol;
146 HWAMP_PARAM(axis, HWAMP_POSEL_OFFSET) = poselOffset;
147
148 return(1);
149 }
HWAMP_ELPOL
#define HWAMP_ELPOL
encoder polarity vs.
Definition: SdoDictionary.mh:7917
HWAMP_MAXCUR
#define HWAMP_MAXCUR
Maximal current allowed.
Definition: SdoDictionary.mh:7815
HWAMP_POSEL_OFFSET
#define HWAMP_POSEL_OFFSET
Sets the offset of the electric field in relation to an absolute encoder.
Definition: SdoDictionary.mh:8238
HWAMP_PARAM
#define HWAMP_PARAM(modno, parno)
HW Amplifier Parameters: Setter.
Definition: SdoDictionary.mh:7627

Data Sheets | Released Software | Software Manuals | Hardware Manuals | Maxon Shop

Maxon Support Center