#include <SysDef.mh>
#include "..\..\..\..\SDK\SDK_ApossC.mc"
#define C_AXIS1 0 // Axis module number
#define C_AXIS1_ENCPORT 0 // Encoder port number
#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
#define C_COMM_METHODE C_METHODE_ENCODER_CHECK
#define C_RECORD_ENABLE 1
#define C_TIME_CURRENT_STEP 50 // [ms]
#define C_CURRENT_STEP 2000 // [mA]
#define C_TIME_VELOCITY_STEP 2500 // [ms]
#define C_VELOCITY_STEP 0X2000 // scaled to the maximum speed with -0x4000 to 0x4000 internal units
#define C_POSITION_RAMP 10*360 // [uu] → 5 turns
#define C_CONTROLLER_CASCADING HWAMP_MODE_POS_VEL_CUR // SDO Dictionary: HWAMP_MODE
#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
#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)
#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
#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
#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
#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);
}
long setupECi30_621403(long axisNo)
{
print("ECi30 MiniMACS6");
axisNo,
ECi30_621403_ENCRES,
ECi30_621403_ENC_LATCHTYPE,
ECi30_621403_ENC_LATCHPARAM,
ECi30_621403_ENC_LATCHSLOPE
);
#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
ECi30_621403_CURKPROP,
ECi30_621403_CURKINT,
ECi30_621403_CURKILIM
);
ECi30_621403_VELKPROP,
ECi30_621403_VELKINT,
ECi30_621403_VELKILIM
);
ECi30_621403_DIRECTION);
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);
AXIS_VELRES,
AXIS_MAX_RPM,
AXIS_RAMPTYPE,
AXIS_RAMPMIN,
AXIS_JERKMIN,
AXIS_POSERR
);
AXIS_POSENCREV,
AXIS_POSENCQC,
AXIS_POSFACT_Z,
AXIS_POSFACT_N,
AXIS_FEEDREV,
AXIS_FEEDDIST
);
return(1);
}