Skip to content

Commit

Permalink
el70xx: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anderssandstrom committed Oct 25, 2023
1 parent 37da40d commit e94a922
Show file tree
Hide file tree
Showing 7 changed files with 494 additions and 0 deletions.
82 changes: 82 additions & 0 deletions examples/test/el70xx/el7031_high_speed/cfg/stepper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
axis:
id: 1
type: joint # this is for future selection of axis type
parameters: powerAutoOnOff=2;powerOnDelay=6.0;powerOffDelay=2.0;

var:
drive: 4

epics:
name: M1
precision: 3
unit: mm
motorRecord:
enable: yes
description: stepper motor
fieldInit: "VMAX=5000"

drive:
numerator: 3600 # Fastest speed in engineering units
denominator: 32768 # I/O range for ECMC_EC_ALIAS_DRV_VELO_SET
type: 0 # Stepper: 0. DS402: 1 (DS402 = servos and advanced stepper drives)
control: ec0.s{{ var.drive }}.driveControl01
#enable: 0 # Enbale bit
status: ec0.s{{ var.drive }}.driveStatus01
#enabled: 1 # Enbaled bit
setpoint: ec0.s{{ var.drive }}.velocitySetpoint01
#reduceTorqueEnable: yes
#reduceTorque: 2 # Reduce torque bit in drive control word
#reset: 1 # Reset (if no drive reset bit then leave empty)
#warning: 2 # Warning (if no drive warning bit then leave empty)
#error: # max 3
# - 3 # Error 0 (if no drive error bit then leave empty)
# - 7 # Error 0 (if no drive error bit then leave empty)
# - 14 # Error 0 (if no drive error bit then leave empty)

encoder:
numerator: 360
denominator: 12800
type: 0 # Type: 0=Incremental, 1=Absolute
bits: 16 # Total bit count of encoder raw data
absOffset: 82.801 # Encoder offset in eng units (for absolute encoders)
position: ec0.s{{ var.drive }}.positionActual01 # Ethercat entry for act-pos (encoder)

controller:
Kp: 10
Ki: 0.1
Kd: 0.25

trajectory:
axis:
velocity: 3500
acceleration: 500

input:
limit:
forward: ec0.s{{ var.drive }}.ONE.0 # Ethercat entry for low limit switch input
backward: ec0.s{{ var.drive }}.ONE.0 # Ethercat entry for high limit switch input
home: ec0.s{{ var.drive }}.ONE.0 # Ethercat entry for home switch input
interlock: ec0.s{{ var.drive }}.ONE.0 # Ethercat entry for interlock switch input

softlimits:
enable: no
backwardEnable: no
forwardEnable: no
forward: 200000
backward: -35000

monitoring:
lag:
enable: yes
tolerance: 1
time: 100
target:
enable: yes
tolerance: 0.05
time: 100
velocity:
enable: yes
max: 4000
time:
trajectory: 100
drive: 200
68 changes: 68 additions & 0 deletions examples/test/el70xx/el7031_high_speed/el7031.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
require ecmccfg v9.0.1_RC2,"EC_RATE=5000,ECMC_VER=v9.0.1_RC2"

ecmcConfigOrDie "Cfg.EcSetDelayECOkAtStartup(1000)"

# Configure hardware
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=1, HW_DESC=EL3004"
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=2, HW_DESC=EL5001"
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=3, HW_DESC=EL1008"
${SCRIPTEXEC} ${ecmccfg_DIR}configureSlave.cmd, "SLAVE_ID=4, HW_DESC=EL7031, CONFIG=-Motor-Trinamic-QMot-QSH4218-41-10-035"
ecmcConfigOrDie "Cfg.EcApplyConfig(1)"

# Configure Motion
epicsEnvSet("DEV", "$(IOC)")
#$(SCRIPTEXEC) ($(ecmccfg_DIR)configureAxis.cmd, CONFIG=./cfg/rotary.ax)
${SCRIPTEXEC} ${ECMC_CONFIG_ROOT}loadYamlAxis.cmd, "FILE=cfg/stepper.yaml"

dbLoadTemplate(ho.subs,"P=${IOC}:,PORT=${ECMC_ASYN_PORT},AXIS_NAME=${ECMC_MOTOR_NAME},AXIS_NO=${ECMC_AXIS_NO}")

# mode velo
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8012,0x1,1,1)"

# velo range
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8012,0x5,1,1)"


ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8010,0x1,1000,2)"
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8010,0x2,400,2)"

ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8010,0x3,24000,2)"
# 2.5Ohm (250)
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8010,0x4,250,2)"

# EMF ???
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8010,0x5,1354,2)"

# Filter cut off
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8011,0x7,0,2)"

# Current boosts (set to 0 according to beckhoff)
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8011,0x7,0,2)"
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8011,0x8,0,2)"

# Current control keep 1/40 ratio
# kp
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8011,0x1,400,2)"
# ki
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8011,0x2,4,2)"

# velo kp
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8013,0x1,0,2)"
## velo ki
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8013,0x1,0,2)"


# Debug PLC
#$(SCRIPTEXEC) $(ecmccfg_DIR)loadPLCFile.cmd, "PLC_ID=1, SAMPLE_RATE_MS=1000,FILE=./test.plc")

# Other
ecmcConfigOrDie "Cfg.EcSetDiagnostics(1)"
ecmcConfigOrDie "Cfg.EcEnablePrintouts(0)"
ecmcConfigOrDie "Cfg.EcSetDomainFailedCyclesLimit(100)"
ecmcConfigOrDie "Cfg.SetDiagAxisIndex(1)"
ecmcConfigOrDie "Cfg.SetDiagAxisFreq(2)"
ecmcConfigOrDie "Cfg.SetDiagAxisEnable(0)"

# go active
$(SCRIPTEXEC) ($(ecmccfg_DIR)setAppMode.cmd)

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
axis:
id: 1
type: joint # this is for future selection of axis type
parameters: powerAutoOnOff=2;powerOnDelay=6.0;powerOffDelay=2.0;

var:
drive: 4

epics:
name: M1
precision: 3
unit: mm
motorRecord:
enable: yes
description: stepper motor
fieldInit: "VMAX=5000"

drive:
numerator: 3600 # Fastest speed in engineering units
denominator: 32768 # I/O range for ECMC_EC_ALIAS_DRV_VELO_SET
type: 0 # Stepper: 0. DS402: 1 (DS402 = servos and advanced stepper drives)
control: ec0.s{{ var.drive }}.driveControl01
#enable: 0 # Enbale bit
status: ec0.s{{ var.drive }}.driveStatus01
#enabled: 1 # Enbaled bit
setpoint: ec0.s{{ var.drive }}.velocitySetpoint01
#reduceTorqueEnable: yes
#reduceTorque: 2 # Reduce torque bit in drive control word
#reset: 1 # Reset (if no drive reset bit then leave empty)
#warning: 2 # Warning (if no drive warning bit then leave empty)
#error: # max 3
# - 3 # Error 0 (if no drive error bit then leave empty)
# - 7 # Error 0 (if no drive error bit then leave empty)
# - 14 # Error 0 (if no drive error bit then leave empty)

encoder:
numerator: 360
denominator: 12800
type: 0 # Type: 0=Incremental, 1=Absolute
bits: 16 # Total bit count of encoder raw data
absOffset: 82.801 # Encoder offset in eng units (for absolute encoders)
position: ec0.s{{ var.drive }}.positionActual01 # Ethercat entry for act-pos (encoder)

controller:
Kp: 10
Ki: 0.1
Kd: 0.25

trajectory:
axis:
velocity: 3500
acceleration: 500

input:
limit:
forward: ec0.s{{ var.drive }}.ONE.0 # Ethercat entry for low limit switch input
backward: ec0.s{{ var.drive }}.ONE.0 # Ethercat entry for high limit switch input
home: ec0.s{{ var.drive }}.ONE.0 # Ethercat entry for home switch input
interlock: ec0.s{{ var.drive }}.ONE.0 # Ethercat entry for interlock switch input

softlimits:
enable: no
backwardEnable: no
forwardEnable: no
forward: 200000
backward: -35000

monitoring:
lag:
enable: yes
tolerance: 1
time: 100
target:
enable: yes
tolerance: 0.05
time: 100
velocity:
enable: yes
max: 4000
time:
trajectory: 100
drive: 200
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
require ecmccfg v9.0.1_RC2,"EC_RATE=5000,ECMC_VER=v9.0.1_RC2"

ecmcConfigOrDie "Cfg.EcSetDelayECOkAtStartup(1000)"

# Configure hardware
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=1, HW_DESC=EL3004"
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=2, HW_DESC=EL5001"
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=3, HW_DESC=EL1008"
${SCRIPTEXEC} ${ecmccfg_DIR}configureSlave.cmd, "SLAVE_ID=4, HW_DESC=EL7031, CONFIG=-Motor-Trinamic-QMot-QSH4218-41-10-035"
ecmcConfigOrDie "Cfg.EcApplyConfig(1)"

# Configure Motion
epicsEnvSet("DEV", "$(IOC)")
#$(SCRIPTEXEC) ($(ecmccfg_DIR)configureAxis.cmd, CONFIG=./cfg/rotary.ax)
${SCRIPTEXEC} ${ECMC_CONFIG_ROOT}loadYamlAxis.cmd, "FILE=cfg/stepper.yaml"

dbLoadTemplate(ho.subs,"P=${IOC}:,PORT=${ECMC_ASYN_PORT},AXIS_NAME=${ECMC_MOTOR_NAME},AXIS_NO=${ECMC_AXIS_NO}")

# mode velo
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8012,0x1,1,1)"

# velo range
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8012,0x5,1,1)"


ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8010,0x1,1000,2)"
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8010,0x2,400,2)"

ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8010,0x3,24000,2)"
# 2.5Ohm (250)
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8010,0x4,250,2)"

# EMF ???
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8010,0x5,1354,2)"

# Filter cut off
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8011,0x7,0,2)"

# Current boosts (set to 0 according to beckhoff)
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8011,0x7,0,2)"
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8011,0x8,0,2)"

# Current control keep 1/40 ratio
# kp
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8011,0x1,400,2)"
# ki
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8011,0x2,4,2)"

# velo kp
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8013,0x1,0,2)"
## velo ki
ecmcConfigOrDie "Cfg.EcAddSdo(4,0x8013,0x1,0,2)"


# Debug PLC
#$(SCRIPTEXEC) $(ecmccfg_DIR)loadPLCFile.cmd, "PLC_ID=1, SAMPLE_RATE_MS=1000,FILE=./test.plc")

# Other
ecmcConfigOrDie "Cfg.EcSetDiagnostics(1)"
ecmcConfigOrDie "Cfg.EcEnablePrintouts(0)"
ecmcConfigOrDie "Cfg.EcSetDomainFailedCyclesLimit(100)"
ecmcConfigOrDie "Cfg.SetDiagAxisIndex(1)"
ecmcConfigOrDie "Cfg.SetDiagAxisFreq(2)"
ecmcConfigOrDie "Cfg.SetDiagAxisEnable(0)"

# go active
$(SCRIPTEXEC) ($(ecmccfg_DIR)setAppMode.cmd)

93 changes: 93 additions & 0 deletions examples/test/el70xx/el7037_high_speed/cfg/el7037_1.ax
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#General
epicsEnvSet("ECMC_MOTOR_NAME", "Axis1")
epicsEnvSet("ECMC_R", "Axis1-")
epicsEnvSet("ECMC_AXIS_NO", "1")
epicsEnvSet("ECMC_DESC", "Test EL7037")
epicsEnvSet("ECMC_EGU", "deg") # 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: 0 = Normal, 1 = Always Fwd, 2 = Always Bwd, 3 = Closest Distance

#Encoder
epicsEnvSet("ECMC_ENC_SCALE_NUM" "360")
epicsEnvSet("ECMC_ENC_SCALE_DENOM" "12800")
epicsEnvSet("ECMC_ENC_TYPE" "0") # Type: 0=Incremental, 1=Absolute
epicsEnvSet("ECMC_ENC_BITS" "16") # Total bit count of encoder raw data
epicsEnvSet("ECMC_ENC_ABS_BITS", "0") # 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).positionActual01") # Ethercat entry for actual position input (encoder)
epicsEnvSet("ECMC_EC_ENC_RESET", "") # Reset
epicsEnvSet("ECMC_EC_ENC_ALARM_0", "") # Error 0
epicsEnvSet("ECMC_EC_ENC_ALARM_1", "") # Error 1
epicsEnvSet("ECMC_EC_ENC_ALARM_2", "") # Error 2
epicsEnvSet("ECMC_EC_ENC_WARNING", "") # Warning

#Drive
epicsEnvSet("ECMC_DRV_TYPE" "0") # Stepper: 0. DS402: 1 (DS402 = servos and advanced stepper drives)
epicsEnvSet("ECMC_DRV_SCALE_NUM" "3600") # Fastest speed in engineering units
epicsEnvSet("ECMC_DRV_SCALE_DENOM" "32768") # I/O range for ECMC_EC_ALIAS_DRV_VELO_SET
epicsEnvSet("ECMC_EC_DRV_CONTROL", "ec0.s$(ECMC_EC_SLAVE_NUM).driveControl01.0") # Ethercat entry for control word or bit output
epicsEnvSet("ECMC_EC_DRV_STATUS", "ec0.s$(ECMC_EC_SLAVE_NUM).driveStatus01.1") # Ethercat entry for status word or bit input
epicsEnvSet("ECMC_EC_DRV_VELOCITY", "ec0.s$(ECMC_EC_SLAVE_NUM).velocitySetpoint01") # Ethercat entry for velocity setpoint output
epicsEnvSet("ECMC_EC_DRV_REDUCE_TORQUE", "ec0.s$(ECMC_EC_SLAVE_NUM).driveControl01.2") # 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", "ec0.s$(ECMC_EC_SLAVE_NUM).driveControl01.1") # Reset
epicsEnvSet("ECMC_EC_DRV_ALARM_0", "ec0.s$(ECMC_EC_SLAVE_NUM).driveStatus01.3") # Error
epicsEnvSet("ECMC_EC_DRV_ALARM_1", "ec0.s$(ECMC_EC_SLAVE_NUM).driveStatus01.7") # Stall
epicsEnvSet("ECMC_EC_DRV_ALARM_2", "ec0.s$(ECMC_EC_SLAVE_NUM).driveStatus01.14") # Sync error
epicsEnvSet("ECMC_EC_DRV_WARNING", "ec0.s$(ECMC_EC_SLAVE_NUM).driveStatus01.2") # Warning

#Trajectory
epicsEnvSet("ECMC_VELO", "3500.0")
epicsEnvSet("ECMC_JOG_VEL", "3500.0")
epicsEnvSet("ECMC_JAR", "0.0") # JAR defaults to VELO/ACCL
epicsEnvSet("ECMC_ACCS_EGU_PER_S2", "1000")
epicsEnvSet("ECMC_EMERG_DECEL", "1000") # Emergency deceleration

#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", "5.0")
epicsEnvSet("ECMC_CNTRL_KI", "0.02")
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).ONE.0") # Ethercat entry for low limit switch input
epicsEnvSet("ECMC_EC_MON_HIGHLIM", "ec0.s$(ECMC_EC_SLAVE_NUM).ONE.0") # Ethercat entry for high limit switch inpuit
epicsEnvSet("ECMC_EC_MON_HOME_SWITCH", "ec0.s$(ECMC_EC_SLAVE_NUM).ONE.0") # Ethercat entry for home switch input
epicsEnvSet("ECMC_EC_MON_EXT_INTERLOCK", "ec0.s$(ECMC_EC_SLAVE_NUM).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.1")
epicsEnvSet("ECMC_MON_AT_TARGET_TIME", "100")
epicsEnvSet("ECMC_MON_AT_TARGET_ENA", "1")

# Velocity
epicsEnvSet("ECMC_MON_VELO_MAX", "21000.0")
epicsEnvSet("ECMC_MON_VELO_MAX_TRAJ_TIME","100")
epicsEnvSet("ECMC_MON_VELO_MAX_DRV_TIME", "200")
epicsEnvSet("ECMC_MON_VELO_MAX_ENA", "0")
Loading

0 comments on commit e94a922

Please sign in to comment.