Files
ecmc_plugin_grbl/iocsh/test_xy_PSI.script

113 lines
4.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
##############################################################################
## Example: Demo of ecmc grbl g-code plugin
## https://github.com/anderssandstrom/ecmc_plugin_grbl
## https://github.com/anderssandstrom/e3-ecmc_plugin_grbl
##
## The plugin exposes:
##
## Initiation:
require ecmccfg v9.0.1_RC1 "ECMC_VER=v9.0.1_RC1"
require ecmc_plugin_grbl sandst_a
##############################################################################
## 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"
epicsEnvSet(X_DRV_SID,${ECMC_EC_SLAVE_NUM})
ecmcConfigOrDie "Cfg.EcApplyConfig(1)"
#- HWE for EP7211
epicsEnvSet("BO_SID", "6")
${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=$(BO_SID), HW_DESC=EL2008"
ecmcConfigOrDie "Cfg.WriteEcEntryIDString(${BO_SID},binaryOutput02,1)"
# Limit torque to 50% of motor rated torque
#- Rated current = 2710mA (see motor config file, "0x8011 0x12 Rated current (mA)")
#- Set to 50% of 2710 = 1355mA (0x8011 0x11 Max current (mA))
epicsEnvSet("Y_DRV_SID", "11")
${SCRIPTEXEC} ${ecmccfg_DIR}configureSlave.cmd, "SLAVE_ID=$(Y_DRV_SID), HW_DESC=EP7211-0034_ALL, CONFIG=-Motor-Beckhoff-AM8111-0F20-0000,CFG_MACROS='I_MAX_MA=1355'"
#Apply hardware configuration
ecmcConfigOrDie "Cfg.EcApplyConfig(1)"
##############################################################################
## AXIS 1: X
# Configure Motion
epicsEnvSet("DRV_SID", "${X_DRV_SID}")
epicsEnvSet("DEV", "$(IOC)")
${SCRIPTEXEC} ${ecmccfg_DIR}configureAxis.cmd, "CONFIG=./cfg/X_psi.ax"
# AXIS 2: Y
epicsEnvSet("DRV_SID", "${Y_DRV_SID}")
epicsEnvSet("DEV", "$(IOC)")
$(SCRIPTEXEC) $(ecmccfg_DIR)configureAxis.cmd, CONFIG=./cfg/Y_psi.ax
##############################################################################
## Load plugin:
epicsEnvSet(ECMC_PLUGIN_FILNAME,"${ecmc_plugin_grbl_DIR}lib/${EPICS_HOST_ARCH}/libecmc_plugin_grbl.so")
epicsEnvSet(ECMC_PLUGIN_CONFIG,"DBG_PRINT=1;X_AXIS=1;Y_AXIS=2;AUTO_ENABLE=0;AUTO_START=0;")
${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)
# Load grbl configs (use "ecmcGrblAddConfig()" or "ecmcGrblAddConfig()"):
# $11 - Junction deviation, mm\n
# $12 Arc tolerance, mm\n
# $30 - Max spindle speed, RPM\n
# $31 - Min spindle speed, RPM\n
# $100, $101 and $102 [X,Y,Z] steps/mm\n
# $110, $111 and $112 [X,Y,Z] Max rate, mm/min\n
# $120, $121, $122 [X,Y,Z] Acceleration, mm/sec^2\n
ecmcGrblLoadConfigFile("./cfg/grbl.cfg")
#ecmcGrblAddConfig("$120=1234");
#ecmcGrblAddConfig("$121=1234");
#ecmcGrblAddConfig("$122=1234");
# Load g-code (use "ecmcGrblLoadGCodeFile()" or "ecmcGrblAddCommand()")
ecmcGrblLoadGCodeFile("./plc/gcode.nc",0)
#ecmcGrblAddCommand("G1X20Y20F360");
#ecmcGrblAddCommand("G4P2");
#ecmcGrblAddCommand("G2X0Y0R20");
#ecmcGrblAddCommand("G4P2");
#ecmcGrblAddCommand("G0X10Y10");
#ecmcGrblAddCommand("G4P2");
#ecmcGrblAddCommand("G1X0Y0");
##############################################################################
## PLC 0: Test some grbl plc commands
$(SCRIPTEXEC) $(ecmccfg_DIR)loadPLCFile.cmd, "PLC_ID=0, SAMPLE_RATE_MS=1000,FILE=./plc/grbl.plc")
##############################################################################
############# Configure diagnostics:
ecmcConfigOrDie "Cfg.EcSetDiagnostics(1)"
ecmcConfigOrDie "Cfg.EcEnablePrintouts(0)"
ecmcConfigOrDie "Cfg.EcSetDomainFailedCyclesLimit(100)"
ecmcConfigOrDie "Cfg.SetDiagAxisIndex(1)"
ecmcConfigOrDie "Cfg.SetDiagAxisFreq(2)"
ecmcConfigOrDie "Cfg.SetDiagAxisEnable(0)"
$(SCRIPTEXEC) ($(ecmccfg_DIR)setAppMode.cmd)
#asynSetTraceMask(MC_CPU1, -1, 0x41)
# Note need to test 0x21 later..
#asynSetTraceMask(MC_CPU1, -1, 0x21)
asynSetTraceMask(MC_CPU1, -1, 0x0)
##############################################################################
############# Go Live:
iocInit()
dbpf $(IOC):Axis1.SPAM 0
dbpf $(IOC):Axis2.SPAM 0