| ApossC SDK V01.15

Maxon_ECi52_1ax_SC_SSI.mc
#include <SysDef.mh>
// Relative path to the main folder ApossC_SDK_Vxx.xx
#include "..\..\..\..\..\..\SDK\SDK_ApossC.mc"
// Setting the axis number. Hall ports are always bound to the respective axis number.
#define AXIS1_NO 0 // Axis module number
#define AXIS1_ENCPORT 0 // Encoder port number. Usually, module instance 0 is connected to X1 and so on. Please refer to product manual
// Axis settings
#define ECI52_ENCRES 4096 // Resolution of the encoder for position feed back in increments (quadcounts)
#define ECI52_SSI_CLK_FREQ 2000000 // Clock frequency of the SSI encoder (Hz)
#define ECI52_FAST_UPDATE 1 // fastUpdate @b 1: The encoder is updated with the current controller update rate (24 kHz on MiniMACS6)
#define ECI52_DATLEN 12 // Databit length of endat position
#define ECI52_IS_BINARY 0 // 1 if data coding is binary otherwise it is gray coded.
#define ECI52_I_POS 0 // Define an indexposition
#define ECI52_BRUSHLESS 1 // Mode of aligment: For brushless motors
#define ECI52_ALIGN_CUR 3000 // Current for the alignment function in mA
#define ECI52_ALIGN_POS 463 // Offset of the encoder position to the electrical position
#define ECI52_CONTROLMODE HWAMP_MODE_POS_CUR // Define control typ
#define ECI52_POLEPAIRS 8 // Number of pole pairs
#define ECI52_ELPOL -1 // Always -1 with a maxon motor
#define ECI52_CONTCUR 9360 // Nomial continious current allowed in mA
#define ECI52_MAXCUR ECI52_CONTCUR*1.25 // Maximal current allowed in mA
#define ECI52_THERMAL_TIME 12800 // Thermal time constant of the winding
#define ECI52_MAX_RPM 2000 // Maximum velocity in RPM
#define ECI52_CURKPROP 1100 // Proportional factor of current controller
#define ECI52_CURKINT 150 // Integral factor of current controller
#define ECI52_CURKILIM 15000 // Integral limit of current controller
// not used in this example → HWAMP_MODE_POS_CUR
#define ECI52_VELKPROP 0 // Proportional factor of velocity controller
#define ECI52_VELKINT 0 // Integral factor of velocity controller
#define ECI52_VELKILIM 0 // Integral limit of velocity controller
#define ECI52_VELRES 100 // Velocity resolution, Scaling used for the velocity and acceleration/deceleration commands
#define ECI52_RAMPTYPE RAMPTYPE_JERKLIMITED // Defines the ramptype
#define ECI52_RAMPMIN 1000 // Maximum acceleration
#define ECI52_JERKMIN 100 // Minimum time (ms) required before reaching the maximum acceleration
#define ECI52_POSERR 2000 // Minimum time (ms) required before reaching the maximum acceleration
#define ECI52_DIRECTION 1 // User units have normal orientation. Increasing encoder values result in increasing user positions.
#define ECI52_KPROP 100 // Proportional value for PID position control loop
#define ECI52_KINT 0 // Integral value for PID position control loop
#define ECI52_KDER 300 // Derivative value for PID position control loop
#define ECI52_KILIM 1000 // Limit value for the integral sum of the PID position control loop
#define ECI52_KILIMTIME 0 // Time used to increase or decrease the integral limit
#define ECI52_BANDWIDTH 1000 // Bandwidth within which the PID filter is active. 1000 equals to 100% velocity setpoint
#define ECI52_FFVEL 0 // Velocity Feed forward
#define ECI52_KFFAC 0 // Acceleration Feed forward
#define ECI52_KFFDEC 0 // Deceleration Feed Forward
#define ECI52_POSENCREV 1 // Number of revolutions of the motor
#define ECI52_POSENCQC ECI52_ENCRES // Number of quadcounts in POSENCREV revolutions
#define ECI52_POSFACT_Z 1 // Number of revolutions of the input shaft
#define ECI52_POSFACT_N 1 // Number of revolutions of the output shaft in POSFACT_Z revolutions of the input shaft
#define ECI52_FEEDREV 1 // Number of revolutions of the gear box output shaft
#define ECI52_FEEDDIST 36000 // Distance travelled (in user units) in FEEDREV revolutions of the gear box output shaft
// Function delkratation
long setupECi52_SC_SSI(long axisNo, long encPort, long posOffset);
long main(void)
{
ErrorClear();
DefOrigin(AXIS1_NO);
// Setup axis & amplifier
setupECi52_SC_SSI(AXIS1_NO,AXIS1_ENCPORT,ECI52_ALIGN_POS);
// Activate the axis
AxisControl(AXIS1_NO, ON);
// Start an endless movement with continuous move control with 50% velocity and 50% acceleration
sdkStartContinuousMove(AXIS1_NO, 50, 50);
while(1)
{
// Print axis information all 500 ms
sdkInfoPrintAxesPos();
Delay(500);
}
return(0);
}
long setupECi52_SC_SSI(long axisNo, long encPort, long posOffset)
{
long checkMotorAlignment;
// Amplifier setup
sdkSetupAmpHallPmsmMotor( axisNo,
ECI52_CONTROLMODE,
ECI52_POLEPAIRS,
ECI52_MAXCUR,
ECI52_ENCRES,
ECI52_MAX_RPM,
-1
);
// Encoder setup
sdkSetupAbsSSIEncoder ( axisNo,
encPort,
ECI52_ENCRES,
ECI52_SSI_CLK_FREQ,
ECI52_FAST_UPDATE,
ECI52_DATLEN,
ECI52_IS_BINARY,
ECI52_I_POS
);
// Current control setup
sdkSetupCurrentPIControl( axisNo,
ECI52_CURKPROP,
ECI52_CURKINT,
ECI52_CURKILIM
);
// Velocity control setup
sdkSetupVelocityPIControl( axisNo,
ECI52_VELKPROP,
ECI52_VELKINT,
ECI52_VELKILIM
);
// Movement parameters for the axis
sdkSetupAxisMovementParam( axisNo,
ECI52_VELRES,
ECI52_MAX_RPM,
ECI52_RAMPTYPE,
ECI52_RAMPMIN,
ECI52_JERKMIN,
ECI52_POSERR
);
// Set the direction of the axis
sdkSetupAxisDirection( axisNo,
ECI52_DIRECTION);
// Position control setup
sdkSetupPositionPIDControlExt( axisNo,
ECI52_KPROP,
ECI52_KINT,
ECI52_KDER,
ECI52_KILIM,
ECI52_KILIMTIME,
ECI52_BANDWIDTH,
ECI52_FFVEL,
ECI52_KFFAC,
ECI52_KFFDEC
);
// Definition of the user units
sdkSetupAxisUserUnits( axisNo,
ECI52_POSENCREV,
ECI52_POSENCQC,
ECI52_POSFACT_Z,
ECI52_POSFACT_N,
ECI52_FEEDREV,
ECI52_FEEDDIST
);
// Motor Alignment
if(posOffset==0)
{
print("The first alignment is open loop and is used in commissioning to detect the offset of the encoder position to the electrical position.");
print("");
checkMotorAlignment = sdkMotorAlignment(
axisNo,
ECI52_BRUSHLESS,
ECI52_MAXCUR,
ECI52_ALIGN_CUR);
if(checkMotorAlignment<0)
{
print("Sorry alignement didn't work we exit");
Exit(0);
}
else
{
print("");
print("Alignement posiston offset: ", HWAMP_PARAM(axisNo, HWAMP_POSEL_OFFSET));
print("The determined alingment offset can now be entered.");
print("The value must be specified in the macro: ");
print("#define ECI52_ALIGN_POS ", HWAMP_PARAM(axisNo, HWAMP_POSEL_OFFSET));
Exit(0);
}
}
else
{
// Motor Alignment
sdkSetMotorAlignmentOffset( axisNo,
-1,
posOffset
);
}
// Setup virtual I2T
sdkSetupVirtualI2T(axisNo,ECI52_CONTCUR, ECI52_THERMAL_TIME);
return(1);
}
sdkSetupAmpHallPmsmMotor
long sdkSetupAmpHallPmsmMotor(long axis, long controlMode, long polePairs, long maxCur, long encQc, long maxRpm, long elPol)
Sets the amplifier parameters for a brushless, PMSM commuted motor (Hall sensors are used)
Definition: SDK_Amplifier_MACS.mc:268
sdkSetupAxisUserUnits
long sdkSetupAxisUserUnits(long axis, long posencrev, long posencqc, long posfact_z, long posfact_n, long feedrev, long feeddist)
Setup to convert the resolution of the machine in user units.
Definition: SDK_Axis_Setup.mc:104
sdkSetupVirtualI2T
long sdkSetupVirtualI2T(long axis, long nominalCur, long thermalTime)
Function to generate a virtual I2T protection.
Definition: SDK_Amplifier_MACS.mc:336
sdkSetupVelocityPIControl
long sdkSetupVelocityPIControl(long axis, long velkprop, long velkint, long velkilim)
Set parameters for PI velocity control loop.
Definition: SDK_Amplifier_MACS.mc:315
sdkSetMotorAlignmentOffset
long sdkSetMotorAlignmentOffset(long axis, long elPol, long poselOffset)
This function sets the offset of the electric field in relation to an absolute encoder.
Definition: SDK_Amplifier_MotorAlignment.mc:143
sdkInfoPrintAxesPos
long sdkInfoPrintAxesPos()
Prints the position information of all axes.
Definition: SDK_Information_General.mc:78
sdkStartContinuousMove
long sdkStartContinuousMove(long axis, long vel, long acc)
Start a movement in continuous position mode.
Definition: SDK_Motion_Movement.mc:26
sdkSetupAbsSSIEncoder
long sdkSetupAbsSSIEncoder(long axis, long encPort, long encRes, long clockFreq, long fastUpdate, long datlen, long isBinary, long latchBitMask)
Settings for a SSI encoder.
Definition: SDK_Encoder_Setup.mc:179
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 en...
Definition: SDK_Amplifier_MotorAlignment.mc:34
sdkSetupAxisDirection
long sdkSetupAxisDirection(long axis, long posdrct)
Definition of the rotation direction of the axis.
Definition: SDK_Axis_Setup.mc:186
sdkSetupPositionPIDControlExt
long sdkSetupPositionPIDControlExt(long axis, long kprop, long kint, long kder, long kilim, long kilimtime, long bandwidth, long ffvel, long kffacc, long kffdec)
Set extended parameters for PID position control loop.
Definition: SDK_Axis_Setup.mc:65
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
sdkSetupAxisMovementParam
long sdkSetupAxisMovementParam(long axis, long velres, long maxRpm, long ramptype, long rampmin, long jerkmin, long poserr)
Defines parameters which are required for the calculation of ramps and velocities.
Definition: SDK_Axis_Setup.mc:136
sdkSetupCurrentPIControl
long sdkSetupCurrentPIControl(long axis, long curkprop, long curkint, long curkilim)
Set parameters for PI current control loop.
Definition: SDK_Amplifier_MACS.mc:293

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

Maxon Support Center