diff --git a/iocsh/cfg/axis.yaml b/iocsh/cfg/axis.yaml index d97d627..cf560ae 100644 --- a/iocsh/cfg/axis.yaml +++ b/iocsh/cfg/axis.yaml @@ -21,10 +21,10 @@ epics: precision: 3 # Decimal count description: very important motor axis # Axis description unit: mm # Unit - # motorRecord: - # enable: true - # description: This is MR - # 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 + motorRecord: + enable: true + description: This is MR + fieldInit: 'TWV=1000' # Extra config for Motor record drive: numerator: 3600 # Fastest speed in engineering units @@ -35,31 +35,31 @@ drive: enabled: 1 # Enabled bit index in status word (not used if DS402) status: ec0.s$(DRV_SLAVE).driveStatus01 # Status word ethercat entry setpoint: ec0.s$(DRV_SLAVE).velocitySetpoint01 # Velocity setpoint if CSV. Position setpoint if CSP -# reduceTorque: 2 # Reduce torque bit in drive control word -# reduceTorqueEnable: True # Enable reduce torque functionality + reduceTorque: 2 # Reduce torque bit in drive control word + reduceTorqueEnable: True # Enable reduce torque functionality # brake: # enable: true # Enable 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) + 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: 360 # Scaling numerator example 360 deg/rev - denominator: 12800 # Scaling denominator example 4096 ticks per 360 degree + numerator: 720 # Scaling numerator example 360 deg/rev + denominator: 8192 # Scaling denominator example 4096 ticks per 360 degree # type: 0 # Type: 0=Incremental, 1=Absolute bits: 16 # 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_SLAVE).positionActual01 # Ethercat entry for actual position input (encoder) - control: ec0.s$(DRV_SLAVE).encoderControl01 # mandatory only if 'reset' is used - status: ec0.s$(DRV_SLAVE).encoderStatus01 # mandatory only if 'warning' or 'error' are used + position: ec0.s$(ENC_SLAVE).positionActual01 # Ethercat entry for actual position input (encoder) + control: ec0.s$(ENC_SLAVE).encoderControl01 # mandatory only if 'reset' is used + status: ec0.s$(ENC_SLAVE).encoderStatus01 # mandatory only if 'warning' or 'error' are used # ready: 10 # Bit in encoder status word for encoder ready # source: 0 # 0 = Encoder value from etehrcat hardware, 1 = Encoder value from PLC # reset: 1 # Reset (optional) @@ -165,11 +165,11 @@ softlimits: monitoring: lag: enable: true # Enable position lag monitoring (following error) - tolerance: 2 # Allowed tolerance + tolerance: 10 # Allowed tolerance time: 10 # Allowed time outside tolerance target: target: enable: true # Enable at target monitoring (needs to be enabled if using motor record) - tolerance: 0.5 # Allowed tolerance + tolerance: 0.1 # Allowed tolerance time: 10 # Filter time inside tolerance to be at target velocity: enable: true # Enable velocity monitoring @@ -183,20 +183,3 @@ monitoring: # 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: true # Enable axis plc -# externalCommands: true # Allow axis to inputs from PLC -# file: ${PLC_PATH}test.plc -# code: # Sync code -# - "if(static.counter % ${LIMIT} == 0){println('AX PLC: Appended');static.counter:=0;};" # calculate set pos for physical axis -# - "if(not(static.plc_code_loaded)) {static.counter:=static.counter+1;};" -# - ec0.s$(DRV_SLAVE).ONE > 1; # Enable axis if one of master axes is enabled -# - ec0.s$(DRV_SLAVE).ZERO > 1; # 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 diff --git a/iocsh/plc/plc_cfg.yaml b/iocsh/plc/plc_cfg.yaml deleted file mode 100644 index 7914e14..0000000 --- a/iocsh/plc/plc_cfg.yaml +++ /dev/null @@ -1,9 +0,0 @@ -macros: LIMIT=1000,TYPE=1 # Macros to pass to this file (also plc.file) -plc: - id: 1 - enable: yes - rateMilliseconds: 1 - file: ${PLC_PATH}test.plc - code: - - "if(static.counter % ${LIMIT} == 0){println('PLC: Appended');static.counter:=0;};" # calculate set pos for physical axis - - "if(not(static.plc_code_loaded)) {static.counter:=static.counter+1;};" diff --git a/iocsh/plc/plc_no_ec_fft_sin.plc b/iocsh/plc/plc_no_ec_fft_sin.plc deleted file mode 100644 index 3491427..0000000 --- a/iocsh/plc/plc_no_ec_fft_sin.plc +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################################### -# For help on syntax, variables and functions, please read the file: "plcSyntaxHelp.plc" -# -# PLC Functionality Demo: -# No hardware related variables -# - -static.time:=ec_get_time()/1E9; -static.sineval:=sin(2*pi*${FREQ=10}*static.time); diff --git a/iocsh/plc/test.plc b/iocsh/plc/test.plc deleted file mode 100644 index df6bb5c..0000000 --- a/iocsh/plc/test.plc +++ /dev/null @@ -1,9 +0,0 @@ -static.counter:=static.counter+1; -static.plc_code_loaded:=1; -if(static.counter % ${LIMIT} == 0) { - if(${TYPE}=0) { - println('AX PLC: File'); - } else { - println('PLC : File'); - }; -}; diff --git a/iocsh/test_4ax_box.script b/iocsh/test_4ax_box.script index 449f4eb..3a0c51b 100644 --- a/iocsh/test_4ax_box.script +++ b/iocsh/test_4ax_box.script @@ -45,13 +45,12 @@ ecmcConfigOrDie "Cfg.EcApplyConfig(1)" ## AXIS 1 # epicsEnvSet("DEV", "$(IOC)") -epicsEnvSet("PLC_PATH", "/ioc/c6025a5a/ecmccfg/examples/test/ecmccomp/plc/") ${SCRIPTEXEC} ${ECMC_CONFIG_ROOT}loadYamlAxis.cmd, "FILE=./cfg/axis.yaml" ############################################################################## ## Load safety plugin # -require ecmc_plugin_safety safety3 +require ecmc_plugin_safety sandst_a # Create SS1 group #- EC_RAMP_DOWN : Ethercat entry for ramp down command, input to ecmc (command from safety PLC/system) @@ -62,14 +61,14 @@ epicsEnvSet(EC_RAMP_DOWN,"ec${ECMC_EC_MASTER_ID}.s${BI_SLAVE}.binaryInput08.0") epicsEnvSet(EC_AXES_REST,"ec${ECMC_EC_MASTER_ID}.s${BO_SLAVE}.binaryOutput07.0") epicsEnvSet(EC_AXES_MAX_VELO,"ec${ECMC_EC_MASTER_ID}.s${BO_SLAVE}.ONE.0") epicsEnvSet(SAFETY_TIMEOUT,500) -${SCRIPTEXEC} ${ecmc_plugin_safety_DIR}addSS1Group.cmd "NAME=first,EC_RAMP_DOWN=${EC_RAMP_DOWN},EC_AXES_REST=${EC_AXES_REST},${EC_AXES_MAX_VELO},DELAY_MS=${SAFETY_TIMEOUT}" +${SCRIPTEXEC} ${ecmc_plugin_safety_DIR}addSS1Group.cmd "NAME=first,EC_RAMP_DOWN=${EC_RAMP_DOWN},EC_AXES_REST=${EC_AXES_REST},EC_AXES_MAX_VELO=${EC_AXES_MAX_VELO=empty},DELAY_MS=${SAFETY_TIMEOUT}" #- Add axis #- AX_ID : Axis ID #- VELO_REST_LIM : Velocity at rest limit [unit same as EGU of axis] #- VELO_MAX_LIM : Velocity maximum limit, -1 to disable [unit same as EGU of axis] ${SCRIPTEXEC} ${ecmc_plugin_safety_DIR}addAxisToSafetyGroup.cmd "NAME=first,AX_ID=1,VELO_REST_LIM=1,VELO_MAX_LIM=100" -#${SCRIPTEXEC} ${ecmc_plugin_safety_DIR}addAxisToSafetyGroup.cmd "NAME=first,AX_ID=1,VELO_REST_LIM=1" + ############################################################################## ## Configure diagnostics: diff --git a/src/ecmcSS1SafetyGroup.cpp b/src/ecmcSS1SafetyGroup.cpp index 06f3bde..1065e7e 100644 --- a/src/ecmcSS1SafetyGroup.cpp +++ b/src/ecmcSS1SafetyGroup.cpp @@ -291,6 +291,10 @@ void ecmcSS1SafetyGroup::connectToDataSources() { throw std::runtime_error( "Safety: EtherCAT entry for rampdown I/O NULL."); } + if(bitRampDown_ >= ecEntryRampDown_->getBits()) { + throw std::runtime_error( "Safety: Bit out of range for rampdown ethercat entry."); + } + // standstill slave = ecMaster_->findSlave(slaveIdStandStill_); if(!slave) { @@ -302,6 +306,9 @@ void ecmcSS1SafetyGroup::connectToDataSources() { throw std::runtime_error( "Safety: EtherCAT entry for standstill I/O NULL."); }; + if(bitStandStill_ >= ecEntryStandstill_->getBits()) { + throw std::runtime_error( "Safety: Bit out of range for standstill ethercat entry."); + } // Limit velo if( limitMaxVeloEnable_ ) { @@ -314,6 +321,10 @@ void ecmcSS1SafetyGroup::connectToDataSources() { if(!ecEntryLimitVelo_) { throw std::runtime_error( "Safety: EtherCAT entry for limit velo I/O NULL."); }; + + if(bitLimitVelo_ >= ecEntryLimitVelo_->getBits()) { + throw std::runtime_error( "Safety: Bit out of range for limit velo ethercat entry."); + } } dataSourcesLinked_ = 1;