Skip to content

Commit

Permalink
Merge branch 'master' of github.com:paulscherrerinstitute/ecmccfg
Browse files Browse the repository at this point in the history
  • Loading branch information
anderssandstrom committed Mar 22, 2024
2 parents ef2cf2c + 65c7b9c commit d6c6921
Show file tree
Hide file tree
Showing 4 changed files with 265 additions and 5 deletions.
196 changes: 196 additions & 0 deletions examples/test/festo/cfg/axis_CSP.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
macros:

axis:
id: 1 # Axis id
type: joint # this is for future selection of axis type
mode: CSP # supported mode, CSV and CSP, defaults CSV
# parameters: 'axisPar' # additional parameters # Additional params to motor record driver
# healthOutput: ec0... # Ethercat entry for health output
# autoMode: # Switch drive modes automaticaly for normal motion and homing (smaract for instance)
# modeSet: ec0.. # Ethercat entry drive mode write (set CSV,CSP,homing)
# modeAct: ec0.. # Ethercat entry drive mode reading (set CSV,CSP,homing)
# modeCmdMotion: 9 # Drive mode value for normal motion (written to axis.drvMode.modeSet when normal motion)
# modeCmdHome: 10 # Drive mode value for when homing (written to axis.drvMode.modeSet when homing)
# features:
# blockCom: 0 # Block communication to axis
# allowedFunctions:
# homing: 1 # Allow homing
# constantVelocity: 1 # Allow constant velocity
# positioning: 1 # Allow positioning

epics:
name: Axis1 # Axis anme
precision: 3 # Decimal count
description: Festo drive test # Axis description
unit: deg # Unit
# fieldInit: 'RRES=1.0,RTRY=2,RMOD=1,UEIP=0,RDBD=0.1,URIP=1,RDBL=$(IOC):$(ECMC_MOTOR_NAME)-PosActSim' # Extra config for Motor record

drive:
numerator: 1 # Fastest speed in engineering units
denominator: 100000 # I/O range for ECMC_EC_ALIAS_DRV_VELO_SET
type: 1 # Stepper: 0. DS402: 1 (DS402 = servos and advanced stepper drives)
control: ec0.s$(DRV_ID).driveControl01 # Control word ethercat entry
# enable: 0 # Enable bit index in control word (not used if DS402)
# enabled: 1 # Enabled bit index in status word (not used if DS402)
status: ec0.s$(DRV_ID).driveStatus01 # Status word ethercat entry
setpoint: ec0.s$(DRV_ID).positionSetpoint01 # Velocity setpoint if CSV. Position setpoint if CSP
# reduceTorque: 2 # Reduce torque bit in drive control word
# brake:
# output: ec0... # Ethercat link to brake output
# openDelay: 0 # Brake timing parameter in cycles (default 1kHz)
# closeAhead: 0 # Brake timing parameter in cycles (default 1kHz)
# 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 1 (if no drive error bit then leave empty)
# - 14 # Error 2 (if no drive error bit then leave empty)

encoder:
numerator: 1 # Scaling numerator example 360 deg/rev
denominator: 1000000 # Scaling denominator example 4096 ticks per 360 degree
type: 1 # Type: 0=Incremental, 1=Absolute
bits: 32 # Total bit count of encoder raw data
# absBits: 0 # Absolute bit count (for absolute encoders) always least significant part of 'bits'
# absOffset: 0 # Encoder offset in eng units (for absolute encoders)
# mask: 0xFFF00 # Mask applied to raw encoder value
position: ec0.s$(DRV_ID).positionActual01 # Ethercat entry for actual position input (encoder)
control: ec0.s$(DRV_ID).encoderControl01 # mandatory only if 'reset' is used
status: ec0.s$(DRV_ID).encoderStatus01 # mandatory only if 'warning' or 'error' are used
# ready: ec.. # Etehrcat entry for encoder ready
# source: 0 # 0 = Encoder value from etehrcat hardware, 1 = Encoder value from PLC
# reset: 1 # Reset (optional)
# warning: 2 # Warning (optional)
# error: # max 3 (optional)
# - 5 # Error 0
# - 9 # Error 1
# - 11 # Error 2
# filter:
# velocity:
# size: 100 # Filter size for velocity
# enable: 1 # enable velocity filter
# position:
# size: 100 # Filter size for encoder value
# enable: 1 # enable encoder value filter
# latch:
# position: '' # Link to latched value. Used for some homing seqs
# control: '' # Latch control trigger ethercat entry bit. Used for some homing seqs
# status: '' # Latch status ethercat entry bit. Used for some homing seqs
# primary: 1 # Use this encoder as primary (for control)
homing:
type: 0 # Homing sequence type
# position: -30 # Position to reference encoder to
# velocity:
# to: 10 # Velocity to cam/sensor (used for some homing seqs)
# from: 5 # Velocity from cam/sensor (used for some homing seqs)
# acceleration: 20 # Acceleration during homing
# deceleration: 100 # Deceleration during homing
# refToEncIDAtStartup: 1 # At startup then set the start value of this encoder to actpos of this encoder id
# refAtHome: 1 # If homing is executed then set position of this encoder
# tolToPrim: 0 # If set then this is the max allowed tolerance between prim encoder and this encoder
# postMoveEnable: yes # Enable move after successfull homing
# postMovePosition: 10 # Position to move to after successfull homing
# trigg: ec0.. # Ethercat entry for triggering drive internal homing seq (seq id 26)
# ready: ec0.. # Ethercat entry for readinf drive internal homing seq ready (seq id 26)

controller:
Kp: 1 # Kp proportinal gain
Ki: 0.02 # Ki integral gain
Kd: 0 # Kd derivative gain
# Kff: 1 # Feed forward gain
# deadband:
# tol: 0.01 # Stop control if within this distance from target for the below time
# time: 100
# limits:
# minOutput: -100 # Minimum controller output
# maxOutput: 100 # Maximum controller output
# minIntegral: -100 # Minimum integral output
# maxIntegral: 100 # Maximum integral output
# inner:
# Kp: 0.1 # Kp for when close to target
# Ki: 0.1 # Ki for when close to target
# Kd: 0.1 # Kd for when close to target
# tol: 0.1 # Distance from target for when inner PID params will be used, defaults to atTarget tol

trajectory:
# type: 1 # Default 0 = trapetz, 1 = S-curve (ruckig)
axis:
velocity: 720 # Default velo for axis
acceleration: 720 # Default acc for axis
deceleration: 720 # Default dec for axis
# emergencyDeceleration: 0.05 # Deceleration when axis in error state
jerk: 10 # Default jerk for axis
jog:
velocity: 5 # Default velo fro JOG (motor record)
# modulo:
# range: 360 # Modulo range 0..360
# type: 0 # Modulo type

input:
limit:
forward: ec0.s$(DRV_ID).ONE.0 # Ethercat entry for low limit switch input
# forwardPolarity: 0 # Polarity of forward limit switch
backward: ec0.s$(DRV_ID).ONE.0 # Ethercat entry for high limit switch input
# backwardPolarity: 0 # Polarity of forward limit switch
home: 'ec0.s$(DRV_ID).ONE.0' # Ethercat entry for home switch
# homePolarity: 0 # Polarity of home switch
interlock: 'ec0.s$(DRV_ID).ONE.0' # Ethercat entry for interlock switch input
# interlockPolarity: 0 # Polarity of interlock switch

# homing:
# type: 3 # Homing sequence type
# position: -30 # Position to reference encoder to
# velocity:
# to: 10 # Velocity to cam/sensor (used for some homing seqs)
# from: 5 # Velocity from cam/sensor (used for some homing seqs)
# acc: 20 # Acceleration during homing
# dec: 100 # Deceleration during homing
# refToEncIDAtStartup: 1 # At startup then set the start value of this encoder to actpos of this encoder id
# refAtHome: 1 # If homing is executed then set position of this encoder
# tolToPrim: 0 # If set then this is the max allowed tolerance between prim encoder and this encoder
# postMoveEnable: yes # Enable move after successfull homing
# postMovePosition: 10 # Position to move to after successfull homing
# timeout: 100 # Sequence timeout

softlimits:
enable: false # Enable soft limits
forward: 100 # Soft limit position fwd
forwardEnable: false # Soft limit position fwd enable
backward: -100 # Soft limit position bwd
backwardEnable: false # Soft limit position bwd enable

monitoring:
lag:
enable: false # Enable position lag monitoring (following error)
tolerance: 0.5 # Allowed tolerance
time: 100 # Allowed time outside tolerance
target:
enable: true # Enable at target monitoring (needs to be enabled if using motor record)
tolerance: 0.5 # Allowed tolerance
time: 10 # Filter time inside tolerance to be at target
velocity:
enable: false # Enable velocity monitoring
max: 2000 # Allowed max velocity
time:
trajectory: 100 # Time allowed outside max velo before system init halt
drive: 200 # Time allowed outside max velo before system disables drive
# velocityDifference:
# enable: 1 # Enable velocity diff monitoring (velo set vs velo act)
# max: 100 # Allowed max difference
# time:
# trajectory: 100 # Time allowed outside max diff velo before system init halt
# drive: 200 # Time allowed outside max diff velo before system disables drive

# plc:
# enable: 1 # Enable axis plc
# externalCommands: 1 # Allow axis to inputs from PLC
# code: # Sync code
# - if(ax2.traj.source){ax2.drv.enable:=(ax10.drv.enable or ax11.drv.enable)}; # Enable axis if one of master axes is enabled
# - ax2.traj.setpos:=ax10.traj.setpos-ax11.traj.setpos/2; # calculate set pos for physical axis
# velocity_filter: # Filter used to smother velocity feedforward
# encoder: # Filter plc enc velo
# enable: false # Filter enable
# size: 100 # Filter size
# trajectory: # Filter plc traj velo
# enable: false # Filter enable
# size: 100 # Filter size
5 changes: 1 addition & 4 deletions examples/test/festo/festo.script
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@ ${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=${DRV_ID}, HW_DESC=Festo-CMM
${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Motor-Generic-2Phase-Stepper,MACROS='CTRL_MODE=2,I_MAX_MA=1000,I_STDBY_MA=200,L_COIL_UH=3300,R_COIL_MOHM=1750,U_NOM_MV=24000'"
#${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Motor-Festo-EMMS-ST-42-S-SE-G2,MACROS='U_NOM_MV=24000,I_MAX_MA=1000,I_STDBY_MA=1000'"
#${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Encoder-Generic-BISS-C,MACROS='ST_BITS=26,CLK_FRQ_KHZ=1000'"
${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Encoder-RLS-LA11-26bit-BISS-C,MACROS='FORCE_CLK_FRQ_HZ=6000000'"
${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Encoder-RLS-LA11-26bit-BISS-C,MACROS='FORCE_CLK_FRQ_HZ=6000000,ST_BITS=12,MT_BITS=14,INV_DIR=1'"
#${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Encoder-Generic-INC"

#ecmcConfigOrDie "Cfg.EcAddSdoDT(0,0x21A2,0x0c,150000,U32)"

ecmcConfigOrDie "Cfg.EcApplyConfig(1)"

# To check mode:
${SCRIPTEXEC} ${ecmccfg_DIR}addEcSdoRT.cmd, "SLAVE_ID=${DRV_ID},INDEX=0x6060,SUBINDEX=0x0,DT=U8,NAME=DrvMode"

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

# Other
Expand Down
41 changes: 41 additions & 0 deletions examples/test/festo/festo_CSP.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ecmc test system
# Anders Sandström

require ecmccfg sandst_a "EC_RATE=500,MASTER_ID=1,ENG_MODE=1"
# require ecmccfg v9.0.1_RC4,"EC_RATE=500,ECMC_VER=sandst_a,MASTER_ID=1,ENG_MODE=1"

require ecmccomp sandst_a

epicsEnvSet("IOC" ,"$(IOC="c6025a")")
epicsEnvSet("SCRIPTEXEC" ,"$(SCRIPTEXEC="iocshLoad")")

# Configuration loaded via FoE
epicsEnvSet(DRV_ID,0)
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=${DRV_ID}, HW_DESC=Festo-CMMT-ST_CSP"
${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Motor-Generic-2Phase-Stepper,MACROS='I_MAX_MA=1000,I_STDBY_MA=200,L_COIL_UH=3300,R_COIL_MOHM=1750,U_NOM_MV=24000'"
#${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Motor-Festo-EMMS-ST-42-S-SE-G2,MACROS='U_NOM_MV=24000,I_MAX_MA=1000,I_STDBY_MA=1000'"
#${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Encoder-Generic-BISS-C,MACROS='ST_BITS=26,CLK_FRQ_KHZ=1000'"
${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Encoder-RLS-LA11-26bit-BISS-C,MACROS='FORCE_CLK_FRQ_HZ=6000000,ST_BITS=12,MT_BITS=14,INV_DIR=1'"
#${SCRIPTEXEC} ${ecmccomp_DIR}applyComponent.cmd "COMP=Encoder-Generic-INC"

ecmcConfigOrDie "Cfg.EcApplyConfig(1)"

# To check mode:
${SCRIPTEXEC} ${ecmccfg_DIR}addEcSdoRT.cmd, "SLAVE_ID=${DRV_ID},INDEX=0x6060,SUBINDEX=0x0,DT=U8,NAME=DrvMode"

# Configure Motion
epicsEnvSet("DEV", "$(IOC)")
${SCRIPTEXEC} ${ECMC_CONFIG_ROOT}loadYamlAxis.cmd, "FILE=./cfg/axis_CSP.yaml"

# 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)


28 changes: 27 additions & 1 deletion examples/test/festo/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,31 @@ Tghe drive will not update the openloop position if configured in CSV also confi


# BISS

* Seems will only work with 6MHz..
* Bit count divided into single turn and multiturn..

# RLS LA11 test
* Real scaling of LA11 is 1/4096mm, leadscrew pitch 1mm/rev
* Bit count = 26
* This means that the drive will see 4096 ticks per rev => ST_BITS=12bits,ST_BITS=14bits,
* Seems to work!





# Todo test generic scalings
* 256 levels of microsetp=>51200 microsteps/rev for a 200 stepper
* Set single tun count as close as possible = 16bits = 65536



# Closed loop
Get error about "closed loop not permissable" reasomn should be that commutation angle is unknown..







0 comments on commit d6c6921

Please sign in to comment.