Skip to content

Commit

Permalink
Update some startup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
anderssandstrom committed Dec 16, 2024
1 parent c7fd99b commit 229ca9f
Show file tree
Hide file tree
Showing 16 changed files with 458 additions and 4 deletions.
79 changes: 79 additions & 0 deletions examples/PSI/lab_setup/master_slave/slit/common/axis_ax5_LO.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# https://paulscherrerinstitute.github.io/ecmccfg/manual/axis/axisyaml/

axis:
id: 5
group: realAxes
mode: CSV
features:
allowSrcChangeWhenEnabled: true

epics:
name: TR_LO
precision: 4
unit: mm
motorRecord:
description: "Low"
fieldInit: "SPAM=0,RTRY=1,FOFF=Frozen,TWV=1"

drive:
numerator: 10 # max velo in EGU/s
denominator: 32768 # MAX_INT for a 16-bit register, always this for this stepper drive!
type: 0
control: ec${M_ID=0}.s$(DRV_SLAVE).driveControl01
status: ec${M_ID=0}.s$(DRV_SLAVE).driveStatus01
setpoint: ec${M_ID=0}.s$(DRV_SLAVE).velocitySetpoint01

encoder:
numerator: 1 # 1egu = 1mm
denominator: 12800 # Number of ticks when motor moves numerator (=1mm): 1 mm / 50 nm = 20000
type: 0 # Type: 0=Incremental, 1=Absolute
bits: 16 # Total bit count of encoder raw data
absBits: 0 # Absolute bit count (for abs enc) always least significant part of 'bits'
absOffset: 0.0000 # Encoder offset in eng units (for absolute encoders)
position: ec${M_ID=0}.s$(ENC_SLAVE).positionActual$(ENC_CHANNEL)

controller:
Kp: 10.00
Ki: 0.001
Kd: 0.000
Kff: 1.00

trajectory:
axis:
velocity: 1.0
acceleration: 1.0
deceleration: 1.0

input:
limit:
forward: ec${M_ID=0}.s$(DRV_SLAVE).driveStatus01.12 # 1119994 cnts // 55.9997 mm
backward: ec${M_ID=0}.s$(DRV_SLAVE).driveStatus01.11 # 98010 cnts // 4.9005 mm
home: ec${M_ID=0}.s$(DRV_SLAVE).ONE.0 # unused
interlock: ec${M_ID=0}.s$(DRV_SLAVE).ONE.0 # unused

softlimits:
enable: false
backwardEnable: true
forwardEnable: true
forward: 55.8
backward: 5.1

monitoring:
lag:
enable: true
tolerance: 0.05
time: 100
target:
enable: true
tolerance: 0.05
time: 100
velocity:
enable: true
max: 5
time:
trajectory: 100
drive: 200

plc:
enable: true
externalCommands: true
79 changes: 79 additions & 0 deletions examples/PSI/lab_setup/master_slave/slit/common/axis_ax6_HI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# https://paulscherrerinstitute.github.io/ecmccfg/manual/axis/axisyaml/

axis:
id: 6
group: realAxes
mode: CSV
features:
allowSrcChangeWhenEnabled: true

epics:
name: TR_HI
precision: 4
unit: mm
motorRecord:
description: "Hi"
fieldInit: "SPAM=0,RTRY=1,FOFF=Frozen,TWV=1"

drive:
numerator: 10 # max velo in EGU/s
denominator: 32768 # MAX_INT for a 16-bit register, always this for this stepper drive!
type: 0
control: ec${M_ID=0}.s$(DRV_SLAVE).driveControl01
status: ec${M_ID=0}.s$(DRV_SLAVE).driveStatus01
setpoint: ec${M_ID=0}.s$(DRV_SLAVE).velocitySetpoint01

encoder:
numerator: 1 # 1egu = 1mm
denominator: 12800 # Number of ticks when motor moves numerator (=1mm): 1 mm / 50 nm = 20000
type: 0 # Type: 0=Incremental, 1=Absolute
bits: 16 # Total bit count of encoder raw data
absBits: 0 # Absolute bit count (for abs enc) always least significant part of 'bits'
absOffset: 0.0000 # Encoder offset in eng units (for absolute encoders)
position: ec${M_ID=0}.s$(ENC_SLAVE).positionActual$(ENC_CHANNEL)

controller:
Kp: 2.000
Ki: 0.001
Kd: 0.000
Kff: 1.00

trajectory:
axis:
velocity: 1.0
acceleration: 1.0
deceleration: 1.0

input:
limit:
forward: ec${M_ID=0}.s$(DRV_SLAVE).driveStatus01.12 # 1111969 cnts // 55.5984 mm
backward: ec${M_ID=0}.s$(DRV_SLAVE).driveStatus01.11 # 109007 cnts // 5.4504 mm
home: ec${M_ID=0}.s$(DRV_SLAVE).ONE.0 # unused
interlock: ec${M_ID=0}.s$(DRV_SLAVE).ONE.0 # unused

softlimits:
enable: false
backwardEnable: true
forwardEnable: true
forward: 55.4
backward: 5.7

monitoring:
lag:
enable: true
tolerance: 0.05
time: 100
target:
enable: true
tolerance: 0.05
time: 100
velocity:
enable: true
max: 5
time:
trajectory: 100
drive: 200

plc:
enable: true
externalCommands: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
axis:
id: ${AX_ID}
group: virtualAxes
type: end effector

epics:
name: CENTERY
precision: 4
unit: mm
motorRecord:
description: "Center (Virtual)"
fieldInit: "SPAM=0,RTRY=1,FOFF=Frozen,TWV=1"

encoder:
type: 1
source: 1
numerator: 1
bits: 32

trajectory:
axis:
velocity: 0.5
acceleration: 0.25
jerk: 0.25

input:
limit:
forward: ec${M_ID=0}.s${DRV_SLAVE}.ONE.0 # unused
backward: ec${M_ID=0}.s${DRV_SLAVE}.ONE.0 # unused
home: ec${M_ID=0}.s${DRV_SLAVE}.ONE.0 # unused
interlock: ec${M_ID=0}.s${DRV_SLAVE}.ONE.0 # unused

softlimits:
enable: false
forwardEnable: true
backwardEnable: true
forward: 52
backward: 8

monitoring:
lag:
enable: yes
tolerance: 0.02
time: 100
target:
enable: yes
tolerance: 0.02
time: 100
velocity:
enable: yes
max: 0.6
time:
trajectory: 100
drive: 100

plc:
enable: true
externalCommands: true
filter:
velocity:
enable: false
size: 10
trajectory:
enable: false
size: 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
axis:
id: ${AX_ID}
group: virtualAxes
type: end effector

epics:
name: GAPY
precision: 4
unit: mm
motorRecord:
description: "Gap (Virtual)"
fieldInit: "SPAM=0,RTRY=1,FOFF=Frozen,TWV=1"

encoder:
type: 1
source: 1
numerator: 1
bits: 32

trajectory:
axis:
velocity: 0.5
acceleration: 0.25
jerk: 0.25

input:
limit:
forward: ec${M_ID=0}.s${DRV_SLAVE}.ONE.0 # unused
backward: ec${M_ID=0}.s${DRV_SLAVE}.ONE.0 # unused
home: ec${M_ID=0}.s${DRV_SLAVE}.ONE.0 # unused
interlock: ec${M_ID=0}.s${DRV_SLAVE}.ONE.0 # unused

softlimits:
enable: false
forwardEnable: true
backwardEnable: true
forward: 20
backward: -20

monitoring:
lag:
enable: yes
tolerance: 0.02
time: 100
target:
enable: yes
tolerance: 0.02
time: 100
velocity:
enable: yes
max: 0.6
time:
trajectory: 100
drive: 100

plc:
enable: true
externalCommands: true
filter:
velocity:
enable: false
size: 10
trajectory:
enable: false
size: 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


# 0:7 - EL7031 1Ch Stepper
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=12,HW_DESC=EL7031"
${SCRIPTEXEC} ${ecmccfg_DIR}applyComponent.cmd "COMP=Motor-Generic-2Phase-Stepper, MACROS='I_MAX_MA=1000, I_STDBY_MA=500, U_NOM_MV=24000, R_COIL_MOHM=1230'"
${SCRIPTEXEC} ${ecmccfg_DIR}loadYamlAxis.cmd, "FILE=../common/axis_ax6_HI.yaml, DRV_SLAVE=${ECMC_EC_SLAVE_NUM}, ENC_SLAVE=${ECMC_EC_SLAVE_NUM}, ENC_CHANNEL=01,M_ID=${ECMC_EC_MASTER_ID}"


# 0:7 - EL7041 1Ch Stepper
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=14,HW_DESC=EL7041-0052"
${SCRIPTEXEC} ${ecmccfg_DIR}applyComponent.cmd "COMP=Motor-Generic-2Phase-Stepper, MACROS='I_MAX_MA=1000, I_STDBY_MA=500, U_NOM_MV=48000, R_COIL_MOHM=1230'"
${SCRIPTEXEC} ${ecmccfg_DIR}loadYamlAxis.cmd, "FILE=../common/axis_ax5_LO.yaml, DRV_SLAVE=${ECMC_EC_SLAVE_NUM}, ENC_SLAVE=${ECMC_EC_SLAVE_NUM}, ENC_CHANNEL=01,M_ID=${ECMC_EC_MASTER_ID}"

#- #################################################################
#- Virtual axes
${SCRIPTEXEC} ${ecmccfg_DIR}loadYamlAxis.cmd, "FILE=../common/axis_vax5_YCEN.yaml, AX_ID=${AX_NUM=12},M_ID=${ECMC_EC_MASTER_ID},DRV_SLAVE=${ECMC_EC_SLAVE_NUM}"
${SCRIPTEXEC} ${ecmccfg_DIR}loadYamlAxis.cmd, "FILE=../common/axis_vax6_YGAP.yaml, AX_ID=${AX_NUM=13},M_ID=${ECMC_EC_MASTER_ID},DRV_SLAVE=${ECMC_EC_SLAVE_NUM}"

7 changes: 7 additions & 0 deletions examples/PSI/lab_setup/master_slave/slit/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Panel
```
caqtdm -macro "IOC=c6025a" ecmcMain.ui
```

## TODO
Test with motor record.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

####### Kinematics for slit system.
# Macros cannot be used in an include. In order to find files, the loadPLCFile.cmd parameter "INC" defines the dirs that MSI will look for the file)
include "axis_kin_slit.plc_inc"

####### State machine
# Macros cannot be used in an include. In order to find files, the loadPLCFile.cmd parameter "INC" defines the dirs that MSI will look for the file)
include "axis_sm.plc_inc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# The following lines were generated by "ioc install"
# Generated at: 2024-08-07 16:32:41.171272

epicsEnvSet IOC c6025a
epicsEnvSet ENGINEER sandst_a
< /ioc/startup/startup.script_linux

# ---- ioc/system specific startup script(s)
< startup.script_ecmc_local_hw

iocInit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

#- Configuration scripts
require ecmccfg v10.0.0_RC1,"MASTER_ID=1,ENG_MODE=1,EC_RATE=100,ECMC_VER=v10.0.0_RC1"

#- Only output errors
asynSetTraceMask(${ECMC_ASYN_PORT}, -1, 0x01)

#- #################################################################
# Configure Hardware and Motion
< ../common/cfgHW_and_motion_local.cmd

#- #################################################################
#- PLCs with inverse kinematics (note the INC var including dirs to search for include files)
#- The group ID:s configured in yaml are stored in GRP_<axis.group>_ID
${SCRIPTEXEC} ${ecmccfg_DIR}loadPLCFile.cmd, "FILE=./cfg/axis_main.plc, PLC_ID=1, INC=.:${ecmccfg_DIR}, PLC_MACROS='PLC_ID=1, AX_CEN=12, AX_GAP=13, AX_LO=5, AX_HI=6, GRP_ID_SA=${GRP_realAxes_ID}, GRP_ID_MA=${GRP_virtualAxes_ID}'"

#- #############################################################################
#- reset all errors
afterInit("ecmcConfigOrDie 'ControllerErrorReset()'")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* Forward kinematics to calculate virtual axes from real axes
| CEN | = FWD * | S1_LO |
| GAP | | S2_HI |

Equations:
ax{AX_CEN}.enc.actpos:=(ax{AX_LO}.enc.actpos+ax{AX_HI}.enc.actpos)/2;
ax{AX_GAP}.enc.actpos:=ax{AX_HI}.enc.actpos-ax{AX_LO}.enc.actpos;
*/

var FWD1[2] := {0.5, 0.5};
var FWD2[2] := { -1, 1 };

/* Inverse kinematics to calculate real axes from virtal axes
| S1_LO | = INV * | CEN |
| S2_HI | | GAP |

Equations:
ax{AX_LO}.traj.extsetpos:=ax{AX_CEN}.traj.setpos-ax{AX_GAP}.traj.setpos/2;
ax{AX_HI}.traj.extsetpos:=ax{AX_CEN}.traj.setpos+ax{AX_GAP}.traj.setpos/2;
*/

var INV1[2] := { 1, -0.5};
var INV2[2] := { 1, 0.5};

####### Kinematics for slit system.
# Macros cannot be used in an include. In order to find files, the loadPLCFile.cmd parameter "INC" defines the dirs that MSI will look for the file)
include "axis_kin_2DoF.plc_inc"

####### State machine
# Macros cannot be used in an include. In order to find files, the loadPLCFile.cmd parameter "INC" defines the dirs that MSI will look for the file)
include "axis_sm.plc_inc"
Loading

0 comments on commit 229ca9f

Please sign in to comment.