ApossC SDK  V01.15
Maxon_RE_40_1ax_Inc.mc
#include <SysDef.mh>
// Relative path to the main folder ApossC_SDK_Vxx.xx
#include "..\..\..\..\..\SDK\SDK_ApossC.mc"
// Setting the 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 RE_40_ENCRES 4*500 // Resolution of the encoder for position feed back in increments (quadcounts)
#define RE_40_ENC_LATCHTYPE 0 // Defines the latch type: Z-Signal
#define RE_40_ENC_LATCHPARAM 0 //
#define RE_40_ENC_LATCHSLOPE HWLATCH_SLOPE_RISING// Defines the slope of the trigger signal (Default 1)
#define RE_40_CONTROLMODE HWAMP_MODE_POS_CUR // Define control typ
#define RE_40_POLEPAIRS 1 // Number of pole pairs
#define RE_40_CONTCUR 3200 // Nomial continious current allowed in mA
#define RE_40_MAXCUR RE_40_CONTCUR*1.25 // Maximal current allowed in mA
#define RE_40_THERMAL_TIME 41500 // Thermal time constant of the winding
#define RE_40_MAX_RPM 3500 // Maximum velocity in RPM
#define RE_40_CURKPROP 1000 // Proportional factor of current controller
#define RE_40_CURKINT 100 // Integral factor of current controller
#define RE_40_CURKILIM 32767 // Integral limit of current controller
// not used in this example → HWAMP_MODE_POS_CUR
#define RE_40_VELKPROP 0 // Proportional factor of velocity controller
#define RE_40_VELKINT 1 // Integral factor of velocity controller
#define RE_40_VELKILIM 0 // Integral limit of velocity controller
#define RE_40_VELRES 100 // Velocity resolution, Scaling used for the velocity and acceleration/deceleration commands
#define RE_40_RAMPTYPE RAMPTYPE_JERKLIMITED // Defines the ramptype
#define RE_40_RAMPMIN 100 // Maximum acceleration
#define RE_40_JERKMIN 100 // Minimum time (ms) required before reaching the maximum acceleration
#define RE_40_POSERR 2000 // Minimum time (ms) required before reaching the maximum acceleration
#define RE_40_DIRECTION 1 // User units have normal orientation. Increasing encoder values result in increasing user positions.
#define RE_40_KPROP 500 // Proportional value for PID position control loop
#define RE_40_KINT 0 // Integral value for PID position control loop
#define RE_40_KDER 1000 // Derivative value for PID position control loop
#define RE_40_KILIM 1000 // Limit value for the integral sum of the PID position control loop
#define RE_40_KILIMTIME 0 // Time used to increase or decrease the integral limit
#define RE_40_BANDWIDTH 1000 // Bandwidth within which the PID filter is active. 1000 equals to 100% velocity setpoint
#define RE_40_FFVEL 0 // Velocity Feed forward
#define RE_40_KFFAC 0 // Acceleration Feed forward
#define RE_40_KFFDEC 0 // Deceleration Feed Forward
#define RE_40_POSENCREV 1 // Number of revolutions of the motor
#define RE_40_POSENCQC RE_40_ENCRES // Number of quadcounts in POSENCREV revolutions
#define RE_40_POSFACT_Z 1 // Number of revolutions of the input shaft
#define RE_40_POSFACT_N 1 // Number of revolutions of the output shaft in POSFACT_Z revolutions of the input shaft
#define RE_40_FEEDREV 1 // Number of revolutions of the gear box output shaft
#define RE_40_FEEDDIST 36000 // Distance travelled (in user units) in FEEDREV revolutions of the gear box output shaft
// Function delkratation
long setup_RE_40_Inc(long axisNo, long encPort);
long main(void)
{
ErrorClear();
DefOrigin(AXIS1_NO);
// Setup axis & amplifier
setup_RE_40_Inc(AXIS1_NO,AXIS1_ENCPORT);
// 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
Delay(500);
}
return(0);
}
long setup_RE_40_Inc(long axisNo, long encPort)
{
// Encoder setup
encPort,
RE_40_ENCRES,
RE_40_ENC_LATCHTYPE,
RE_40_ENC_LATCHPARAM,
RE_40_ENC_LATCHSLOPE
);
// Amplifier setup
RE_40_CONTROLMODE,
RE_40_POLEPAIRS,
RE_40_MAXCUR,
RE_40_ENCRES,
RE_40_MAX_RPM);
// Current control setup
RE_40_CURKPROP,
RE_40_CURKINT,
RE_40_CURKILIM
);
// Velocity control setup
RE_40_VELKPROP,
RE_40_VELKINT,
RE_40_VELKILIM
);
// Movement parameters for the axis
RE_40_VELRES,
RE_40_MAX_RPM,
RE_40_RAMPTYPE,
RE_40_RAMPMIN,
RE_40_JERKMIN,
RE_40_POSERR
);
// Set the direction of the axis
RE_40_DIRECTION);
// Position control setup
RE_40_KPROP,
RE_40_KINT,
RE_40_KDER,
RE_40_KILIM,
RE_40_KILIMTIME,
RE_40_BANDWIDTH,
RE_40_FFVEL,
RE_40_KFFAC,
RE_40_KFFDEC
);
// Definition of the user units
RE_40_POSENCREV,
RE_40_POSENCQC,
RE_40_POSFACT_Z,
RE_40_POSFACT_N,
RE_40_FEEDREV,
RE_40_FEEDDIST
);
// Setup virtual I2T
sdkSetupVirtualI2T(axisNo,RE_40_CONTCUR, RE_40_THERMAL_TIME);
return(1);
}
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
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
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
sdkSetupAxisDirection
long sdkSetupAxisDirection(long axis, long posdrct)
Definition of the rotation direction of the axis.
Definition: SDK_Axis_Setup.mc:186
sdkSetupAmpDcMotor
long sdkSetupAmpDcMotor(long axis, long controlMode, long polePairs, long maxCur, long encQc, long maxRpm)
Sets the amplifier parameters for a DC motor.
Definition: SDK_Amplifier_MACS.mc:48
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
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