work related to spindle

This commit is contained in:
Anders Sandstrom
2022-02-01 11:21:38 +01:00
parent af5b857f16
commit 770c1b4362
11 changed files with 1981 additions and 6888 deletions

View File

@@ -124,6 +124,7 @@ ecmcGrbl::ecmcGrbl(char* configStr,
writerBusy_ = 0;
limitsSummary_ = 0;
limitsSummaryOld_ = 0;
spindleAcceleration_ = 0;
grblCommandBufferIndex_ = 0;
grblCommandBuffer_.clear();
@@ -571,6 +572,7 @@ void ecmcGrbl::giveControlToEcmcIfNeeded() {
// Stop spindle
if(cfgSpindleAxisId_>=0) {
setAxisTargetVel(cfgSpindleAxisId_, 0);
moveStop(cfgSpindleAxisId_);
}
// Halt grbl and stop motion (even though should be handled by ecmc)
@@ -616,6 +618,23 @@ void ecmcGrbl::syncAxisPositionIfNotEnabled(int ecmcAxisId, int grblAxisId) {
// prepare for rt here
int ecmcGrbl::enterRT() {
// readback spindleAcceleration_
if(cfgSpindleAxisId_ >= 0) {
double acc = 0;
int errorCode = getAxisAcceleration(cfgSpindleAxisId_,
&acc);
if(errorCode) {
errorCode_ = errorCode;
return errorCode;
}
if(acc <= 0) {
errorCode_ = ECMC_PLUGIN_SPINDLE_ACC_ERROR_CODE;
retrun errorCode_;
}
spindleAcceleration_ = acc;
}
return 0;
}
@@ -679,9 +698,14 @@ void ecmcGrbl::postExeAxes() {
postExeAxis(cfgXAxisId_,X_AXIS);
postExeAxis(cfgYAxisId_,Y_AXIS);
postExeAxis(cfgZAxisId_,Z_AXIS);
// if(cfgSpindleAxisId_>=0) {
// setAxisTargetVel(xxx);
// }
//printf("Spindle Velo %f\n", sys.spindle_speed);
if(cfgSpindleAxisId_>=0) {
setAxisTargetVel(cfgSpindleAxisId_,(double)sys.spindle_speed);
moveVelocity(cfgSpindleAxisId_,
(double)sys.spindle_speed,
spindleAcceleration_,
spindleAcceleration_);
}
}
// trigg start of g-code

View File

@@ -96,6 +96,7 @@ class ecmcGrbl : public asynPortDriver {
bool writerBusy_;
int limitsSummary_;
int limitsSummaryOld_;
double spindleAcceleration_;
};
#endif /* ECMC_GRBL_H_ */

View File

@@ -30,6 +30,7 @@
#define ECMC_PLUGIN_AXIS_AT_LIMIT_ERROR_CODE 0x102
#define ECMC_PLUGIN_LOAD_FILE_ERROR_CODE 0x103
#define ECMC_PLUGIN_LIMIT_SWITCH_VIOLATION_ERROR_CODE 0x104
#define ECMC_PLUGIN_SPINDLE_ACC_ERROR_CODE 0x105
#define ECMC_PLUGIN_GRBL_GRBL_STARTUP_STRING "for help]"
#define ECMC_PLUGIN_GRBL_GRBL_OK_STRING "ok"

View File

@@ -30,68 +30,73 @@ void spindle_init()
{
printf("%s:%s:%d Not supported yet..\n",__FILE__,__FUNCTION__,__LINE__);
// #ifdef VARIABLE_SPINDLE
// // Configure variable spindle PWM and enable pin, if requried. On the Uno, PWM and enable are
// // combined unless configured otherwise.
// SPINDLE_PWM_DDR |= (1<<SPINDLE_PWM_BIT); // Configure as PWM output pin.
// SPINDLE_TCCRA_REGISTER = SPINDLE_TCCRA_INIT_MASK; // Configure PWM output compare timer
// SPINDLE_TCCRB_REGISTER = SPINDLE_TCCRB_INIT_MASK;
// #ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
// SPINDLE_ENABLE_DDR |= (1<<SPINDLE_ENABLE_BIT); // Configure as output pin.
// #else
// #ifndef ENABLE_DUAL_AXIS
// SPINDLE_DIRECTION_DDR |= (1<<SPINDLE_DIRECTION_BIT); // Configure as output pin.
// #endif
// #endif
// pwm_gradient = SPINDLE_PWM_RANGE/(settings.rpm_max-settings.rpm_min);
// #else
// SPINDLE_ENABLE_DDR |= (1<<SPINDLE_ENABLE_BIT); // Configure as output pin.
// #ifndef ENABLE_DUAL_AXIS
// SPINDLE_DIRECTION_DDR |= (1<<SPINDLE_DIRECTION_BIT); // Configure as output pin.
// #endif
// #endif
//
// spindle_stop();
#ifdef VARIABLE_SPINDLE
// Configure variable spindle PWM and enable pin, if requried. On the Uno, PWM and enable are
// combined unless configured otherwise.
//SPINDLE_PWM_DDR |= (1<<SPINDLE_PWM_BIT); // Configure as PWM output pin.
//SPINDLE_TCCRA_REGISTER = SPINDLE_TCCRA_INIT_MASK; // Configure PWM output compare timer
//SPINDLE_TCCRB_REGISTER = SPINDLE_TCCRB_INIT_MASK;
//#ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
// SPINDLE_ENABLE_DDR |= (1<<SPINDLE_ENABLE_BIT); // Configure as output pin.
//#else
// #ifndef ENABLE_DUAL_AXIS
// SPINDLE_DIRECTION_DDR |= (1<<SPINDLE_DIRECTION_BIT); // Configure as output pin.
// #endif
//#endif
pwm_gradient = SPINDLE_PWM_RANGE/(settings.rpm_max-settings.rpm_min);
#else
// SPINDLE_ENABLE_DDR |= (1<<SPINDLE_ENABLE_BIT); // Configure as output pin.
// #ifndef ENABLE_DUAL_AXIS
// SPINDLE_DIRECTION_DDR |= (1<<SPINDLE_DIRECTION_BIT); // Configure as output pin.
// #endif
#endif
spindle_stop();
}
uint8_t spindle_get_state()
{
printf("%s:%s:%d Not supported yet..\n",__FILE__,__FUNCTION__,__LINE__);
//
//#ifdef VARIABLE_SPINDLE
// #ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
// // No spindle direction output pin.
// #ifdef INVERT_SPINDLE_ENABLE_PIN
// if (bit_isfalse(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) { return(SPINDLE_STATE_CW); }
// #else
// if (bit_istrue(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) { return(SPINDLE_STATE_CW); }
// #endif
// #else
// if (SPINDLE_TCCRA_REGISTER & (1<<SPINDLE_COMB_BIT)) { // Check if PWM is enabled.
// #ifdef ENABLE_DUAL_AXIS
// return(SPINDLE_STATE_CW);
// #else
// if (SPINDLE_DIRECTION_PORT & (1<<SPINDLE_DIRECTION_BIT)) { return(SPINDLE_STATE_CCW); }
// else { return(SPINDLE_STATE_CW); }
// #endif
// }
// #endif
//#else
// #ifdef INVERT_SPINDLE_ENABLE_PIN
// if (bit_isfalse(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) {
// #else
// if (bit_istrue(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) {
// #endif
// #ifdef ENABLE_DUAL_AXIS
// return(SPINDLE_STATE_CW);
// #else
// if (SPINDLE_DIRECTION_PORT & (1<<SPINDLE_DIRECTION_BIT)) { return(SPINDLE_STATE_CCW); }
// else { return(SPINDLE_STATE_CW); }
// #endif
// }
//#endif
// #ifdef VARIABLE_SPINDLE
// #ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
// // No spindle direction output pin.
// #ifdef INVERT_SPINDLE_ENABLE_PIN
// if (bit_isfalse(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) { return(SPINDLE_STATE_CW); }
// #else
// if (bit_istrue(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) { return(SPINDLE_STATE_CW); }
// #endif
// #else
// if (SPINDLE_TCCRA_REGISTER & (1<<SPINDLE_COMB_BIT)) { // Check if PWM is enabled.
// #ifdef ENABLE_DUAL_AXIS
// return(SPINDLE_STATE_CW);
// #else
// if (SPINDLE_DIRECTION_PORT & (1<<SPINDLE_DIRECTION_BIT)) { return(SPINDLE_STATE_CCW); }
// else { return(SPINDLE_STATE_CW); }
// #endif
// }
// #endif
// #else
// #ifdef INVERT_SPINDLE_ENABLE_PIN
// if (bit_isfalse(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) {
// #else
// if (bit_istrue(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) {
// #endif
// #ifdef ENABLE_DUAL_AXIS
// return(SPINDLE_STATE_CW);
// #else
// if (SPINDLE_DIRECTION_PORT & (1<<SPINDLE_DIRECTION_BIT)) { return(SPINDLE_STATE_CCW); }
// else { return(SPINDLE_STATE_CW); }
// #endif
// }
// #endif
if(sys.spindle_speed > 0) {
return(SPINDLE_STATE_CW);
} else if(sys.spindle_speed < 0) {
return(SPINDLE_STATE_CCW);
}
return(SPINDLE_STATE_DISABLE);
}
@@ -154,12 +159,13 @@ void spindle_stop()
//#ifdef ENABLE_PIECEWISE_LINEAR_SPINDLE
// Called by spindle_set_state() and step segment generator. Keep routine small and efficient.
uint8_t spindle_compute_pwm_value(float rpm) // 328p PWM register is 8-bit.
{
printf("%s:%s:%d Not supported yet..\n",__FILE__,__FUNCTION__,__LINE__);
return 0;
// // Called by spindle_set_state() and step segment generator. Keep routine small and efficient.
// uint8_t spindle_compute_pwm_value(float rpm) // 328p PWM register is 8-bit.
// {
// //printf("%s:%s:%d Not supported yet..\n",__FILE__,__FUNCTION__,__LINE__);
// sys.spindle_speed = rpm; // ecmc
// return 0;
//
// uint8_t pwm_value;
// rpm *= (0.010*sys.spindle_speed_ovr); // Scale by spindle speed override value.
// // Calculate PWM register value based on rpm max/min settings and programmed rpm.
@@ -201,30 +207,30 @@ void spindle_stop()
// #else
//
// // Called by spindle_set_state() and step segment generator. Keep routine small and efficient.
// uint8_t spindle_compute_pwm_value(float rpm) // 328p PWM register is 8-bit.
// {
// uint8_t pwm_value;
// rpm *= (0.010*sys.spindle_speed_ovr); // Scale by spindle speed override value.
// // Calculate PWM register value based on rpm max/min settings and programmed rpm.
// if ((settings.rpm_min >= settings.rpm_max) || (rpm >= settings.rpm_max)) {
// // No PWM range possible. Set simple on/off spindle control pin state.
// sys.spindle_speed = settings.rpm_max;
// pwm_value = SPINDLE_PWM_MAX_VALUE;
// } else if (rpm <= settings.rpm_min) {
// if (rpm == 0.0) { // S0 disables spindle
// sys.spindle_speed = 0.0;
// pwm_value = SPINDLE_PWM_OFF_VALUE;
// } else { // Set minimum PWM output
// sys.spindle_speed = settings.rpm_min;
// pwm_value = SPINDLE_PWM_MIN_VALUE;
// }
// } else {
// // Compute intermediate PWM value with linear spindle speed model.
// // NOTE: A nonlinear model could be installed here, if required, but keep it VERY light-weight.
// sys.spindle_speed = rpm;
// pwm_value = floor((rpm-settings.rpm_min)*pwm_gradient) + SPINDLE_PWM_MIN_VALUE;
// }
// return(pwm_value);
uint8_t spindle_compute_pwm_value(float rpm) // 328p PWM register is 8-bit.
{
uint8_t pwm_value;
rpm *= (0.010*sys.spindle_speed_ovr); // Scale by spindle speed override value.
// Calculate PWM register value based on rpm max/min settings and programmed rpm.
if ((settings.rpm_min >= settings.rpm_max) || (rpm >= settings.rpm_max)) {
// No PWM range possible. Set simple on/off spindle control pin state.
sys.spindle_speed = settings.rpm_max;
pwm_value = SPINDLE_PWM_MAX_VALUE;
} else if (rpm <= settings.rpm_min) {
if (rpm == 0.0) { // S0 disables spindle
sys.spindle_speed = 0.0;
pwm_value = SPINDLE_PWM_OFF_VALUE;
} else { // Set minimum PWM output
sys.spindle_speed = settings.rpm_min;
pwm_value = SPINDLE_PWM_MIN_VALUE;
}
} else {
// Compute intermediate PWM value with linear spindle speed model.
// NOTE: A nonlinear model could be installed here, if required, but keep it VERY light-weight.
sys.spindle_speed = rpm;
pwm_value = floor((rpm-settings.rpm_min)*pwm_gradient) + SPINDLE_PWM_MIN_VALUE;
}
return(pwm_value);
}
//#endif
@@ -240,48 +246,47 @@ void spindle_stop()
void _spindle_set_state(uint8_t state)
#endif
{
printf("%s:%s:%d Not supported yet..\n",__FILE__,__FUNCTION__,__LINE__);
//
//if (sys.abort) { return; } // Block during abort.
//
//if (state == SPINDLE_DISABLE) { // Halt or set spindle direction and rpm.
//
// #ifdef VARIABLE_SPINDLE
// sys.spindle_speed = 0.0;
// #endif
// spindle_stop();
//
//} else {
//
// #if !defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(ENABLE_DUAL_AXIS)
// if (state == SPINDLE_ENABLE_CW) {
// SPINDLE_DIRECTION_PORT &= ~(1<<SPINDLE_DIRECTION_BIT);
// } else {
// SPINDLE_DIRECTION_PORT |= (1<<SPINDLE_DIRECTION_BIT);
// }
// #endif
//
// #ifdef VARIABLE_SPINDLE
// // NOTE: Assumes all calls to this function is when Grbl is not moving or must remain off.
// if (settings.flags & BITFLAG_LASER_MODE) {
// if (state == SPINDLE_ENABLE_CCW) { rpm = 0.0; } // TODO: May need to be rpm_min*(100/MAX_SPINDLE_SPEED_OVERRIDE);
// }
// spindle_set_speed(spindle_compute_pwm_value(rpm));
// #endif
// #if (defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && \
// !defined(SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED)) || !defined(VARIABLE_SPINDLE)
// // NOTE: Without variable spindle, the enable bit should just turn on or off, regardless
// // if the spindle speed value is zero, as its ignored anyhow.
// #ifdef INVERT_SPINDLE_ENABLE_PIN
// SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
// #else
// SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
// #endif
// #endif
//
//}
//
//sys.report_ovr_counter = 0; // Set to report change immediately
//printf("%s:%s:%d Not supported yet..\n",__FILE__,__FUNCTION__,__LINE__);
if (sys.abort) { return; } // Block during abort.
if (state == SPINDLE_DISABLE) { // Halt or set spindle direction and rpm.
#ifdef VARIABLE_SPINDLE
sys.spindle_speed = 0.0;
#endif
spindle_stop();
} else {
//#if !defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(ENABLE_DUAL_AXIS)
// if (state == SPINDLE_ENABLE_CW) {
// SPINDLE_DIRECTION_PORT &= ~(1<<SPINDLE_DIRECTION_BIT);
// } else {
// SPINDLE_DIRECTION_PORT |= (1<<SPINDLE_DIRECTION_BIT);
// }
//#endif
#ifdef VARIABLE_SPINDLE
// NOTE: Assumes all calls to this function is when Grbl is not moving or must remain off.
if (settings.flags & BITFLAG_LASER_MODE) {
if (state == SPINDLE_ENABLE_CCW) { rpm = 0.0; } // TODO: May need to be rpm_min*(100/MAX_SPINDLE_SPEED_OVERRIDE);
}
spindle_set_speed(spindle_compute_pwm_value(rpm));
#endif
//#if (defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && \
// !defined(SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED)) || !defined(VARIABLE_SPINDLE)
// // NOTE: Without variable spindle, the enable bit should just turn on or off, regardless
// // if the spindle speed value is zero, as its ignored anyhow.
// #ifdef INVERT_SPINDLE_ENABLE_PIN
// SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
// #else
// SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
// #endif
//#endif
}
sys.report_ovr_counter = 0; // Set to report change immediately
}
@@ -290,10 +295,10 @@ void spindle_stop()
#ifdef VARIABLE_SPINDLE
void spindle_sync(uint8_t state, float rpm)
{
printf("%s:%s:%d Not supported yet..\n",__FILE__,__FUNCTION__,__LINE__);
//if (sys.state == STATE_CHECK_MODE) { return; }
//protocol_buffer_synchronize(); // Empty planner buffer to ensure spindle is set when programmed.
//spindle_set_state(state,rpm);
//printf("%s:%s:%d Not supported yet..\n",__FILE__,__FUNCTION__,__LINE__);
if (sys.state == STATE_CHECK_MODE) { return; }
protocol_buffer_synchronize(); // Empty planner buffer to ensure spindle is set when programmed.
spindle_set_state(state,rpm);
}
#else
void _spindle_sync(uint8_t state)

View File

@@ -414,8 +414,8 @@ double ecmc_grbl_main_rt_thread()
#endif
#ifdef VARIABLE_SPINDLE
// Set real-time spindle output as segment is loaded, just prior to the first step.
spindle_set_speed(st.exec_segment->spindle_pwm);
// Set real-time spindle output as segment is loaded, just prior to the first step.
//spindle_set_speed(st.exec_segment->spindle_pwm);
#endif
} else {
@@ -424,7 +424,9 @@ double ecmc_grbl_main_rt_thread()
st_go_idle();
#ifdef VARIABLE_SPINDLE
// Ensure pwm is set properly upon completion of rate-controlled motion.
if (st.exec_block->is_pwm_rate_adjusted) { spindle_set_speed(SPINDLE_PWM_OFF_VALUE); }
if (st.exec_block->is_pwm_rate_adjusted) {
//spindle_set_speed(SPINDLE_PWM_OFF_VALUE);
}
#endif
system_set_exec_state_flag(EXEC_CYCLE_STOP); // Flag main program for cycle end
return -1.0; // Nothing to do but exit.

View File

@@ -153,6 +153,7 @@ extern system_t sys;
// NOTE: These position variables may need to be declared as volatiles, if problems arise.
extern int enableDebugPrintouts;
extern int stepperInterruptEnable;
extern int32_t sys_position[N_AXIS]; // Real-time machine (aka home) position vector in steps.
extern int32_t sys_probe_position[N_AXIS]; // Last probe position in machine coordinates and steps.

96
iocsh/cfg/el7201_mod.ax Normal file
View File

@@ -0,0 +1,96 @@
#General
epicsEnvSet("ECMC_MOTOR_NAME", "Axis1")
epicsEnvSet("ECMC_R", "Axis1-")
epicsEnvSet("ECMC_AXIS_NO", "3")
epicsEnvSet("ECMC_DESC", "EL7201 Test")
epicsEnvSet("ECMC_EGU", "mm") # Motor Record Unit
epicsEnvSet("ECMC_PREC", "3") # Motor Record Precision
epicsEnvSet("ECMC_AXISCONFIG", "") # Extra parameters to driver
epicsEnvSet("ECMC_EC_AXIS_HEALTH", "") # Entry for axis health output (example: ec0.s1.binaryOutput01.0)
epicsEnvSet("ECMC_MOD_RANGE" , "0") # Modulo range (traj setpoints and encoder values will be in range 0..ECMC_MOD_RANGE)
epicsEnvSet("ECMC_MOD_TYPE", "0") # For positioning and MOD_RANGE!=: 0 = Normal, 1 = Always Fwd, 2 = Always Bwd, 3 = Closest Distance
#Encoder
epicsEnvSet("ECMC_ENC_SCALE_NUM" "360")
epicsEnvSet("ECMC_ENC_SCALE_DENOM" "1048576")
epicsEnvSet("ECMC_ENC_TYPE" "0") # Type: 0=Incremental, 1=Absolute (in this case its single turn absolute (needs homing))
epicsEnvSet("ECMC_ENC_BITS" "32") # Total bit count of encoder raw data
epicsEnvSet("ECMC_ENC_ABS_BITS", "20") # Absolute bit count (for absolute encoders) always least significant part of ECMC_ENC_BITS
epicsEnvSet("ECMC_ENC_ABS_OFFSET" "0") # Encoder offset in eng units (for absolute encoders)
epicsEnvSet("ECMC_EC_ENC_ACTPOS", "ec0.s$(ECMC_EC_SLAVE_NUM_SPINDLE).positionActual01") # Ethercat entry for actual position input (encoder)
epicsEnvSet("ECMC_EC_ENC_RESET", "") # Reset handled by DS402 statemachine
epicsEnvSet("ECMC_EC_ENC_ALARM_0", "") # Error 0 handled by DS402 statemachine
epicsEnvSet("ECMC_EC_ENC_ALARM_1", "") # Error 1 handled by DS402 statemachine
epicsEnvSet("ECMC_EC_ENC_ALARM_2", "") # Error 2 handled by DS402 statemachine
epicsEnvSet("ECMC_EC_ENC_WARNING", "") # Warning handled by DS402 statemachine
#Drive
epicsEnvSet("ECMC_DRV_TYPE" "1") # Stepper: 0. DS402: 1 (DS402 = servos and advanced stepper drives)
# Scalings: Amplifier Max 8000Hz = 2880000 deg/s (8kHz Reverse engineered)
epicsEnvSet("ECMC_DRV_SCALE_NUM" "2880000") # Fastest speed in engineering units
epicsEnvSet("ECMC_DRV_SCALE_DENOM" "2147483648") # I/O range for ECMC_EC_ALIAS_DRV_VELO_SET
epicsEnvSet("ECMC_EC_DRV_CONTROL", "ec0.s$(ECMC_EC_SLAVE_NUM_SPINDLE).driveControl01") # Ethercat entry for control word or bit output
epicsEnvSet("ECMC_EC_DRV_STATUS", "ec0.s$(ECMC_EC_SLAVE_NUM_SPINDLE).driveStatus01") # Ethercat entry for status word or bit input
epicsEnvSet("ECMC_EC_DRV_VELOCITY", "ec0.s$(ECMC_EC_SLAVE_NUM_SPINDLE).velocitySetpoint01") # Ethercat entry for velocity setpoint output
epicsEnvSet("ECMC_EC_DRV_REDUCE_TORQUE", "") # Ethercat entry for reduce torque output
epicsEnvSet("ECMC_EC_DRV_BRAKE", "") # Ethercat entry for brake output
epicsEnvSet("ECMC_DRV_BRAKE_OPEN_DLY_TIME", "0") # Brake timing parameter in cycles (default 1kHz)
epicsEnvSet("ECMC_DRV_BRAKE_CLOSE_AHEAD_TIME", "0") # Brake timing parameter in cycles (default 1kHz)
epicsEnvSet("ECMC_EC_DRV_RESET", "") # Reset (handled by ds402 statemachine, but this bit can be used anyway if needed)
epicsEnvSet("ECMC_EC_DRV_ALARM_0", "") # Error 0 (handled by ds402 statemachine, but this bit can be used anyway if needed)
epicsEnvSet("ECMC_EC_DRV_ALARM_1", "") # Error 1 (handled by ds402 statemachine, but this bit can be used anyway if needed)
epicsEnvSet("ECMC_EC_DRV_ALARM_2", "") # Error 2 (handled by ds402 statemachine, but this bit can be used anyway if needed)
epicsEnvSet("ECMC_EC_DRV_WARNING", "") # Warning (handled by ds402 statemachine, but this bit can be used anyway if needed)
#Trajectory
epicsEnvSet("ECMC_TRAJ_TYPE", "1") # Trapetz: 0, S-Curve: 1
epicsEnvSet("ECMC_VELO", "1000.0")
epicsEnvSet("ECMC_JOG_VEL", "3600")
epicsEnvSet("ECMC_JAR", "0.0") # JAR defaults to VELO/ACCL
epicsEnvSet("ECMC_ACCS_EGU_PER_S2", "1000")
epicsEnvSet("ECMC_EMERG_DECEL", "1000") # Emergency deceleration
epicsEnvSet("ECMC_JERK", "1000") # Only valid for ECMC_TRAJ_TYPE==1
#Homing
epicsEnvSet("ECMC_HOME_PROC", "1")
epicsEnvSet("ECMC_HOME_POS", "0.0")
epicsEnvSet("ECMC_HOME_VEL_TO", "5")
epicsEnvSet("ECMC_HOME_VEL_FRM", "4")
epicsEnvSet("ECMC_HOME_ACC", "21")
epicsEnvSet("ECMC_HOME_DEC", "100")
epicsEnvSet("ECMC_HOME_POS_MOVE_ENA", "0") # Enable move to position after successfull homing
epicsEnvSet("ECMC_HOME_POS_MOVE_TARG_POS","0") # Target position to go to after successfull homing
#Controller
epicsEnvSet("ECMC_CNTRL_KP", "50")
epicsEnvSet("ECMC_CNTRL_KI", "0.1")
epicsEnvSet("ECMC_CNTRL_KD", "0.0")
epicsEnvSet("ECMC_CNTRL_KFF", "1.0")
#Monitoring
# Switches
epicsEnvSet("ECMC_EC_MON_LOWLIM", "ec0.s$(ECMC_EC_SLAVE_NUM_SPINDLE).ONE.0") # Ethercat entry for low limit switch input
epicsEnvSet("ECMC_EC_MON_HIGHLIM", "ec0.s$(ECMC_EC_SLAVE_NUM_SPINDLE).ONE.0") # Ethercat entry for high limit switch inpuit
epicsEnvSet("ECMC_EC_MON_HOME_SWITCH", "ec0.s$(ECMC_EC_SLAVE_NUM_SPINDLE).ONE.0") # Ethercat entry for home switch input
epicsEnvSet("ECMC_EC_MON_EXT_INTERLOCK", "ec0.s$(ECMC_EC_SLAVE_NUM_SPINDLE).ONE.0") # Ethercat entry for external interlock input
# Softlimits (disable with 0,0,0)
epicsEnvSet("ECMC_SOFT_LOW_LIM", "$(SM_DLLM=0)")
epicsEnvSet("ECMC_SOFT_HIGH_LIM", "$(SM_DHLM=0)")
epicsEnvSet("ECMC_DXLM_ENABLE", "0")
# Position lag
epicsEnvSet("ECMC_MON_LAG_MON_TOL", "5")
epicsEnvSet("ECMC_MON_LAG_MON_TIME", "100")
epicsEnvSet("ECMC_MON_LAG_MON_ENA", "0")
# At target
epicsEnvSet("ECMC_MON_AT_TARGET_TOL", "0.3")
epicsEnvSet("ECMC_MON_AT_TARGET_TIME", "100")
epicsEnvSet("ECMC_MON_AT_TARGET_ENA", "1")
# Velocity
epicsEnvSet("ECMC_MON_VELO_MAX", "100.0")
epicsEnvSet("ECMC_MON_VELO_MAX_TRAJ_TIME","100")
epicsEnvSet("ECMC_MON_VELO_MAX_DRV_TIME", "200")
epicsEnvSet("ECMC_MON_VELO_MAX_ENA", "0")

View File

@@ -1,36 +1,14 @@
G1X20Y20F360
S10
M03
G4P2
G2X0Y0R20
G4P2
G0X10Y10
G2X10Y-10R10
M05
G4P2
G1X0Y0
G1X20Y20F360
G4P2
G2X0Y0R20
G4P2
G0X10Y10
G4P2
G1X0Y0
G1X20Y20F360
G4P2
G2X0Y0R20
G4P2
G0X10Y10
G4P2
G1X0Y0
G1X20Y20F360
G4P2
G2X0Y0R20
G4P2
G0X10Y10
G4P2
G1X0Y0
G1X20Y20F360
G4P2
G2X0Y0R20
G4P2
G0X10Y10
G4P2
G1X0Y0

View File

@@ -0,0 +1,35 @@
############################################################
############# Parmetrization of EL7211-0010 for motor AM8121-F00-0000
#
# Note: For important parameters see TwinCAT CoE startup list for the
# motor terminal configuration.
#Nominal voltage = 48V
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8010,0x19,24000,4)"
#Motor max current = 6A
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8011,0x11,6000,4)"
#Motor rated current = 4A
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8011,0x12,4000,4)"
#Motor pole pairs = 3
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8011,0x13,3,1)"
#Torque contstant = 125
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8011,0x16,125,4)"
#Winding inductance = 28
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8011,0x19,28,2)"
#Rotor moment of inertia = 134
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8011,0x18,134,4)"
#Commutation offset = 270
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8011,0x15,270,2)"
#Motor thermal time constant = 564
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8011,0x2d,564,2)"
#Motor speed limitation = 3378
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8011,0x1b,3378,4)"
#Current loop proportianal gain = 332
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8010,0x13,332,2)"
#Current loop integral time = 5
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8010,0x12,5,2)"
#Velocity loop proportianal gain = 95
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8010,0x15,95,4)"
#Velocity loop integral time = 150
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8010,0x14,150,4)"

File diff suppressed because it is too large Load Diff

View File

@@ -23,8 +23,25 @@ $(ECMCCFG_INIT)$(SCRIPTEXEC) ${ecmccfg_DIR}startup.cmd, "IOC=$(IOC),ECMC_VER=ruc
##############################################################################
## Configure hardware:
# Hardware for X and Y in ESS crate
$(SCRIPTEXEC) $(ecmccfg_DIR)ecmcMCU1021_coupler.cmd
# Use EL7211 as spindle
epicsEnvSet("ECMC_EC_SLAVE_NUM", "11")
epicsEnvSet("ECMC_EC_SLAVE_NUM_SPINDLE", "$(ECMC_EC_SLAVE_NUM)")
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=$(ECMC_EC_SLAVE_NUM), HW_DESC=EL7211-0010"
# Apply local 24V config (local here)
${SCRIPTEXEC} ${ecmccfg_DIR}applySlaveConfig.cmd, "LOCAL_CONFIG=./ecmcEL7211-0010-Motor-Beckhoff-AM8121-0F00-0000_24V.cmd"
#Apply hardware configuration (wronmg here, should only be caööed once)
ecmcConfigOrDie "Cfg.EcApplyConfig(1)"
#Does not work. Known issue DC-patch for etherlab manster needed...
#ecmcConfigOrDie "Cfg.EcSelectReferenceDC(0,$(ECMC_EC_SLAVE_NUM))"
# ADDITIONAL SETUP
# Set all outputs to feed switches
ecmcConfigOrDie "Cfg.WriteEcEntryIDString(${ECMC_EC_SLAVE_NUM_DIG_OUT},binaryOutput01,1)"
@@ -38,7 +55,7 @@ ecmcConfigOrDie "Cfg.WriteEcEntryIDString(${ECMC_EC_SLAVE_NUM_DIG_OUT},binaryOut
# END of ADDITIONAL SETUP
##############################################################################
## AXIS 1
## AXIS 1: X-axis
#
epicsEnvSet("DEV", "$(IOC)")
$(SCRIPTEXEC) ($(ecmccfg_DIR)configureAxis.cmd, CONFIG=./cfg/linear_1.ax)
@@ -46,20 +63,26 @@ $(SCRIPTEXEC) ($(ecmccfg_DIR)configureAxis.cmd, CONFIG=./cfg/linear_1.ax)
$(SCRIPTEXEC) ($(ecmccfg_DIR)applyAxisSynchronization.cmd, CONFIG=./cfg/linear_1.sax)
##############################################################################
## AXIS 2
## AXIS 2: Y-axis
#
#epicsEnvSet("DEV", "$(IOC)")
$(SCRIPTEXEC) ($(ecmccfg_DIR)configureAxis.cmd, CONFIG=./cfg/linear_2.ax)
# Set external setpoints
$(SCRIPTEXEC) ($(ecmccfg_DIR)applyAxisSynchronization.cmd, CONFIG=./cfg/linear_2.sax)
##############################################################################
## AXIS 3: Spindle
#
epicsEnvSet("DEV", "$(IOC)")
$(SCRIPTEXEC) ($(ecmccfg_DIR)configureAxis.cmd, CONFIG=./cfg/el7201_mod.ax)
##############################################################################
## Load plugin:
epicsEnvSet("PLUGIN_VER" ,"develop")
require ecmc_plugin_grbl $(PLUGIN_VER)
epicsEnvSet(ECMC_PLUGIN_FILNAME,"/home/pi/epics/base-7.0.5/require/${E3_REQUIRE_VERSION}/siteMods/ecmc_plugin_grbl/$(PLUGIN_VER)/lib/${EPICS_HOST_ARCH=linux-x86_64}/libecmc_plugin_grbl.so")
epicsEnvSet(ECMC_PLUGIN_CONFIG,"DBG_PRINT=1;X_AXIS=1;Y_AXIS=2;AUTO_ENABLE=1;AUTO_START=1;") # Only one option implemented in this plugin
epicsEnvSet(ECMC_PLUGIN_CONFIG,"DBG_PRINT=1;X_AXIS=1;Y_AXIS=2;SPINDLE_AXIS=3;AUTO_ENABLE=1;AUTO_START=1;") # Only one option implemented in this plugin
${SCRIPTEXEC} ${ecmccfg_DIR}loadPlugin.cmd, "PLUGIN_ID=0,FILE=${ECMC_PLUGIN_FILNAME},CONFIG='${ECMC_PLUGIN_CONFIG}', REPORT=1"
epicsEnvUnset(ECMC_PLUGIN_FILNAME)
epicsEnvUnset(ECMC_PLUGIN_CONFIG)