ApossC SDK  V01.15
MotorCommissioning_MaxonECi30.mc
#include <SysDef.mh>
#include "..\..\..\..\SDK\SDK_ApossC.mc"
// Axis module number
#define C_AXIS1 0 // Axis module number
#define C_AXIS1_ENCPORT 0 // Encoder port number
// Definition of the methods
#define C_METHODE_ENCODER_CHECK 0
#define C_METHODE_HALL_CHECK 1
#define C_METHODE_CURRENT_STEP 2
#define C_METHODE_VELOCITY_STEP 3
#define C_METHODE_POSITION_RAMP 4
// Set methode and endable/ disable recording
#define C_COMM_METHODE C_METHODE_ENCODER_CHECK
#define C_RECORD_ENABLE 1
// Settings for the current step
#define C_TIME_CURRENT_STEP 50 // [ms]
#define C_CURRENT_STEP 2000 // [mA]
// Settings for the velocity step
#define C_TIME_VELOCITY_STEP 2500 // [ms]
#define C_VELOCITY_STEP 0X2000 // scaled to the maximum speed with -0x4000 to 0x4000 internal units
// Settings for the position ramp
#define C_POSITION_RAMP 10*360 // [uu] → 5 turns
#define C_CONTROLLER_CASCADING HWAMP_MODE_POS_VEL_CUR // SDO Dictionary: HWAMP_MODE
// Axis setup
#define AXIS_VELRES 100 // Velocity resolution, Scaling used for the velocity and acceleration/deceleration commands
#define AXIS_RAMPTYPE RAMPTYPE_JERKLIMITED // Defines the ramptype
#define AXIS_RAMPMIN 1000 // Maximum acceleration
#define AXIS_JERKMIN 500 // Minimum time (ms) required before reaching the maximum acceleration
#define AXIS_MAX_RPM 4000 // Maximum velocity in RPM
#define AXIS_POSERR 0 // Maximal track/ position error allowed in qc → disable for testing
#define AXIS_POSENCREV 1 // Number of revolutions of the motor
#define AXIS_POSENCQC ECi30_621403_ENCRES // Number of quadcounts in POSENCREV revolutions
#define AXIS_POSFACT_Z 1 // Number of revolutions of the input shaft
#define AXIS_POSFACT_N 1 // Number of revolutions of the output shaft in POSFACT_Z revolutions of the input shaft
#define AXIS_FEEDREV 1 // Number of revolutions of the gear box output shaft
#define AXIS_FEEDDIST 360 // Distance travelled (in user units) in FEEDREV revolutions of the gear box output shaft
// Encoder settings
#define ECi30_621403_ENCRES 4*4096 // Resolution of the encoder for position feed back in increments (quadcounts)
#define ECi30_621403_ENC_LATCHTYPE 0 // Defines the latch type: Index Line
#define ECi30_621403_ENC_LATCHPARAM 0 // -
#define ECi30_621403_ENC_LATCHSLOPE HWLATCH_SLOPE_RISING// Defines the slope of the trigger signal (Default 1)
// Motor settings
#define ECi30_621403_CONTROLMODE HWAMP_MODE_POS_VEL_CUR // Define control typ
#define ECi30_621403_POLEPAIRS 4 // Number of pole pairs
#define ECi30_621403_CONTCUR 2280 // Nomial continious current allowed in mA
#define ECi30_621403_MAXCUR ECi30_621403_CONTCUR*1.25 // Maximal current allowed in mA
#define ECi30_621403_THERMAL_TIME 27600 // Thermal time constant of the winding
#define ECi30_621403_MAX_RPM AXIS_MAX_RPM // Maximum velocity in RPM
#define ECi30_621403_DIRECTION 1 // Direction of the drive
// Parameter for the current controller
// The values were calculated with the Current Calculator Tool
#define ECi30_621403_CURKPROP 1500 // Proportional factor of current controller
#define ECi30_621403_CURKINT 150 // Integral factor of current controller
#define ECi30_621403_CURKILIM 32767 // Integral limit of current controller
// Parameter for the velocity controller
#define ECi30_621403_VELKPROP 2000 // Proportional factor of velocity controller
#define ECi30_621403_VELKINT 1000 // Integral factor of velocity controller
#define ECi30_621403_VELKILIM 0 // Integral limit of velocity controller
// Parameter for the position controller
#define ECi30_621403_KPROP 500 // Proportional value for PID position control loop
#define ECi30_621403_KINT 0 // Integral value for PID position control loop
#define ECi30_621403_KDER 1000 // Derivative value for PID position control loop
#define ECi30_621403_KILIM 1000 // Limit value for the integral sum of the PID position control loop
#define ECi30_621403_KILIMTIME 0 // Time used to increase or decrease the integral limit
#define ECi30_621403_BANDWIDTH 1000 // Bandwidth within which the PID filter is active. 1000 equals to 100% velocity setpoint
#define ECi30_621403_FFVEL 1000 // Velocity Feed forward
#define ECi30_621403_KFFACC 0 // Acceleration Feed forward
#define ECi30_621403_KFFDEC 0 // Deceleration Feed Forward
long setupECi30_621403(long axisNo);
long main(void)
{
long waitingTime = 5000;
long direction = 1;
setupECi30_621403(C_AXIS1);
DefOrigin(C_AXIS1);
while(1)
{
#if C_COMM_METHODE == C_METHODE_ENCODER_CHECK
waitingTime=250;
#elif C_COMM_METHODE == C_METHODE_HALL_CHECK
waitingTime=250;
#elif C_COMM_METHODE == C_METHODE_CURRENT_STEP
C_CURRENT_STEP,
C_TIME_CURRENT_STEP,
C_RECORD_ENABLE);
#elif C_COMM_METHODE == C_METHODE_VELOCITY_STEP
direction*C_VELOCITY_STEP,
C_TIME_VELOCITY_STEP,
C_RECORD_ENABLE);
direction = direction*-1;
#elif C_COMM_METHODE == C_METHODE_POSITION_RAMP
direction*C_POSITION_RAMP,
C_CONTROLLER_CASCADING,
C_RECORD_ENABLE);
direction = direction*-1;
#endif
if(waitingTime>1000)
print("Wait for ", waitingTime, " ms");
Delay(waitingTime);
}
return(0);
}
// Axis, motor and encoder setup
long setupECi30_621403(long axisNo)
{
print("ECi30 MiniMACS6");
// Encoder setup
axisNo,
ECi30_621403_ENCRES,
ECi30_621403_ENC_LATCHTYPE,
ECi30_621403_ENC_LATCHPARAM,
ECi30_621403_ENC_LATCHSLOPE
);
// Amplifier setup
#if 1
ECi30_621403_CONTROLMODE,
ECi30_621403_POLEPAIRS,
ECi30_621403_MAXCUR,
ECi30_621403_ENCRES,
ECi30_621403_MAX_RPM,
-1
);
#else
ECi30_621403_CONTROLMODE,
ECi30_621403_POLEPAIRS,
ECi30_621403_MAXCUR,
ECi30_621403_ENCRES,
ECi30_621403_MAX_RPM
);
#endif
// Current control setup
ECi30_621403_CURKPROP,
ECi30_621403_CURKINT,
ECi30_621403_CURKILIM
);
// Velocity control setup
ECi30_621403_VELKPROP,
ECi30_621403_VELKINT,
ECi30_621403_VELKILIM
);
// Set the direction of the axis
ECi30_621403_DIRECTION);
// Position control setup
ECi30_621403_KPROP,
ECi30_621403_KINT,
ECi30_621403_KDER,
ECi30_621403_KILIM,
ECi30_621403_KILIMTIME,
ECi30_621403_BANDWIDTH,
ECi30_621403_FFVEL,
ECi30_621403_KFFACC,
ECi30_621403_KFFDEC);
// Set the virtual I2T
sdkSetupVirtualI2T(axisNo, ECi30_621403_CONTCUR, ECi30_621403_THERMAL_TIME);
// Movement parameters for the axis
AXIS_VELRES,
AXIS_MAX_RPM,
AXIS_RAMPTYPE,
AXIS_RAMPMIN,
AXIS_JERKMIN,
AXIS_POSERR
);
// Definition of the user units
AXIS_POSENCREV,
AXIS_POSENCQC,
AXIS_POSFACT_Z,
AXIS_POSFACT_N,
AXIS_FEEDREV,
AXIS_FEEDDIST
);
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
sdkMotorCommVelStep
long sdkMotorCommVelStep(long axis, long velocity, long time, long recordEnable)
Velocity step for setting the velocity controller.
Definition: SDK_Amplifier_MotorCommissioning.mc:91
sdkSetupAmpBldcMotor
long sdkSetupAmpBldcMotor(long axis, long hallAligment, long controlMode, long polePairs, long maxCur, long encQc, long maxRpm)
Sets the amplifier parameters for a BLDC motor.
Definition: SDK_Amplifier_MACS.mc:122
sdkSetupIncEncoder
long sdkSetupIncEncoder(long axis, long encPort, long encRes, long latchType, long latchParam, long latchSlope)
Settings for an incremental encoder.
Definition: SDK_Encoder_Setup.mc:43
sdkSetupVelocityPIControl
long sdkSetupVelocityPIControl(long axis, long velkprop, long velkint, long velkilim)
Set parameters for PI velocity control loop.
Definition: SDK_Amplifier_MACS.mc:315
sdkMotorCommEncoderUserUnitCheck
long sdkMotorCommEncoderUserUnitCheck(long axis)
Checking the configured encoders and the user units.
Definition: SDK_Amplifier_MotorCommissioning.mc:218
sdkMotorCommHallSignalCheck
long sdkMotorCommHallSignalCheck(long axis)
Checking the hall signals.
Definition: SDK_Amplifier_MotorCommissioning.mc:195
sdkSetupAxisDirection
long sdkSetupAxisDirection(long axis, long posdrct)
Definition of the rotation direction of the axis.
Definition: SDK_Axis_Setup.mc:186
sdkMotorCommCurrentStep
long sdkMotorCommCurrentStep(long axis, long current, long time, long recordEnable)
Current step for setting the current controller.
Definition: SDK_Amplifier_MotorCommissioning.mc:33
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
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
sdkMotorCommPositionRamp
long sdkMotorCommPositionRamp(long axis, long distance, long controlMode, long recordEnable)
Position ramp for setting the position controller.
Definition: SDK_Amplifier_MotorCommissioning.mc:154
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