Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the simulated motor examples #9

Merged
merged 6 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ db/
dbd/
html/
include/
/iocsh/
lib/
templates/
cdCommands
Expand Down
4 changes: 2 additions & 2 deletions iocs/motorSimIOC/iocBoot/iocMotorSim/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
TOP = ../..
include $(TOP)/configure/CONFIG
ARCH = linux-x86_64
#ARCH = linux-x86_64
#ARCH = vxWorks-ppc32
#ARCH = $(EPICS_HOST_ARCH)
ARCH = $(EPICS_HOST_ARCH)
TARGETS = cdCommands
TARGETS += envPaths
include $(TOP)/configure/RULES.ioc
Expand Down
15 changes: 15 additions & 0 deletions iocs/motorSimIOC/iocBoot/iocMotorSim/motorSim.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
dbLoadTemplate("motorSim.substitutions")

motorSimCreateController("motorSim1", 8)
#asynSetTraceIOMask("motorSim1", 0, HEX)
#asynSetTraceMask("motorSim1", 0, ERROR|FLOW|DRIVER)

# motorSimConfigAxis(port, axis, lowLimit, highLimit, home, start)
motorSimConfigAxis("motorSim1", 0, 20000, -20000, 500, 0)
motorSimConfigAxis("motorSim1", 1, 20000, -20000, 1500, 0)
motorSimConfigAxis("motorSim1", 2, 20000, -20000, 2500, 0)
motorSimConfigAxis("motorSim1", 3, 20000, -20000, 3000, 0)
motorSimConfigAxis("motorSim1", 4, 20000, -20000, 500, 0)
motorSimConfigAxis("motorSim1", 5, 20000, -20000, 1500, 0)
motorSimConfigAxis("motorSim1", 6, 20000, -20000, 2500, 0)
motorSimConfigAxis("motorSim1", 7, 20000, -20000, 3000, 0)
2 changes: 2 additions & 0 deletions iocs/motorSimIOC/iocBoot/iocMotorSim/motorSim.iocsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Load 8 simulated motors with default settings
iocshLoad("$(MOTOR_MOTORSIM)/iocsh/motorSim8x.iocsh", "PREFIX=IOC:,INSTANCE=motorSim,SUB=$(MOTOR_MOTORSIM)/iocsh/EXAMPLE_motorSim8x.substitutions")
23 changes: 6 additions & 17 deletions iocs/motorSimIOC/iocBoot/iocMotorSim/st.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,15 @@
dbLoadDatabase("$(TOP)/dbd/motorSim.dbd")
motorSim_registerRecordDeviceDriver(pdbbase)

dbLoadTemplate("motor.substitutions")

motorSimCreateController("motorSim1", 8)
#asynSetTraceIOMask("motorSim1", 0, HEX)
#asynSetTraceMask("motorSim1", 0, ERROR|FLOW|DRIVER)

# motorSimConfigAxis(port, axis, lowLimit, highLimit, home, start)
motorSimConfigAxis("motorSim1", 0, 20000, -20000, 500, 0)
motorSimConfigAxis("motorSim1", 1, 20000, -20000, 1500, 0)
motorSimConfigAxis("motorSim1", 2, 20000, -20000, 2500, 0)
motorSimConfigAxis("motorSim1", 3, 20000, -20000, 3000, 0)
motorSimConfigAxis("motorSim1", 4, 20000, -20000, 500, 0)
motorSimConfigAxis("motorSim1", 5, 20000, -20000, 1500, 0)
motorSimConfigAxis("motorSim1", 6, 20000, -20000, 2500, 0)
motorSimConfigAxis("motorSim1", 7, 20000, -20000, 3000, 0)
# Use a local configuration if axes need individual customization
< motorSim.cmd
# Use a default, 8-axis configuration if axes can start with identical settings
#!< motorSim.iocsh

iocInit

## motorUtil (allstop & alldone)
motorUtilInit("motorSim:")
motorUtilInit("IOC:")

# Boot complete

date
16 changes: 10 additions & 6 deletions iocs/motorSimIOC/iocBoot/iocMotorSim/st.cmd.Vx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ cd startup
dbLoadDatabase("$(TOP)/dbd/motorSim.dbd")
WithAsynVx_registerRecordDeviceDriver(pdbbase)

dbLoadTemplate("motor.substitutions")

# Create simulated motors: ( start card , start axis , low limit, high limit, home posn, # cards, # axes to setup)
motorSimCreate( 0, 0, -32000, 32000, 0, 1, 4 )
# Setup the Asyn layer (portname, low-level driver drvet name, card, number of axes on card)
drvAsynMotorConfigure("motorSim1", "motorSim", 0, 4)
# Use a local configuration if axes need individual customization
< motorSim.cmd
# Use a default, 8-axis configuration if axes can start with identical settings
#!< motorSim.iocsh

iocInit

## motorUtil (allstop & alldone)
motorUtilInit("IOC:")

# Boot complete
date
2 changes: 2 additions & 0 deletions motorSimApp/iocsh/EXAMPLE_motorSim.substitutions
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
file "$(MOTOR)/db/asyn_motor.db"
# The following line should be used for motor versions greater than 7.2.2 to avoid errors at iocInit
#!file "$(MOTOR)/db/asyn_motor_model2.db"
{
pattern
{N, M, ADDR, DESC, EGU, DIR, VELO, VBAS, ACCL, BDST, BVEL, BACC, MRES, PREC, INIT}
Expand Down
13 changes: 13 additions & 0 deletions motorSimApp/iocsh/EXAMPLE_motorSim8x.substitutions
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
file "$(MOTOR)/db/asyn_motor.db"
{
pattern
{N, M, ADDR, DESC, EGU, DIR, VELO, VBAS, ACCL, BDST, BVEL, BACC, MRES, PREC, INIT}
{1, "m$(N)", 0, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{2, "m$(N)", 1, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{3, "m$(N)", 2, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{4, "m$(N)", 3, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{5, "m$(N)", 4, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{6, "m$(N)", 5, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{7, "m$(N)", 6, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{8, "m$(N)", 7, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
}
1 change: 1 addition & 0 deletions motorSimApp/iocsh/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ TOP = ../..
include $(TOP)/configure/CONFIG

IOCSH += EXAMPLE_motorSim.substitutions
IOCSH += EXAMPLE_motorSim8x.substitutions

include $(TOP)/configure/RULES
12 changes: 9 additions & 3 deletions motorSimApp/iocsh/motorSim.iocsh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@
#- NUM_AXES - Optional: Number of axes on this controller
#- Default: 1
#-
#- LOW_LIM - Optional: Low Limit
#- LOW_LIM - Optional: Low Limit (in steps)
#- Default: -32000
#-
#- HIGH_LIM - Optional: High Limit
#- HIGH_LIM - Optional: High Limit (in steps)
#- Default: 32000
#-
#- DLLM - Optional: Motor Record Low Limit (in EGU)
#- Default: -320.0
#-
#- DHLM - Optional: Motor Record High Limit (in EGU)
#- Default: 320.0
#-
#- HOME_POS - Optional: Home position
#- Default: 0
#- ###################################################
Expand All @@ -31,4 +37,4 @@ motorSimCreate($(CONTROLLER=0), 0, $(LOW_LIM=-32000), $(HIGH_LIM=32000), $(HOME_
# Setup the Asyn layer (portname, low-level driver drvet name, card, number of axes on card)
drvAsynMotorConfigure("$(INSTANCE)$(CONTROLLER=0)", "$(INSTANCE)", $(CONTROLLER=0), $(NUM_AXES=1))

dbLoadTemplate("$(SUB=$(MOTOR)/iocsh/EXAMPLE_motorSim.substitutions)", "P=$(PREFIX), DTYP='asynMotor', PORT=$(INSTANCE)$(CONTROLLER=0), DHLM=$(HIGH_LIM=32000), DLLM=$(LOW_LIM=-32000)")
dbLoadTemplate("$(SUB=$(MOTOR)/iocsh/EXAMPLE_motorSim.substitutions)", "P=$(PREFIX), DTYP='asynMotor', PORT=$(INSTANCE)$(CONTROLLER=0),DHLM=$(DHLM=320.0),DLLM=$(DLLM=-320.0)")
43 changes: 43 additions & 0 deletions motorSimApp/iocsh/motorSim8x.iocsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# ### motorSim8x.iocsh ###

#- ###################################################
#- PREFIX - IOC Prefix
#- INSTANCE - Instance name, used to create the asyn port name
#-
#- SUB - Optional: Subsitutions file (asyn_motor.db), Macros P, DTYP, PORT,
#- DHLM, DLLM, and INIT will be predefined.
#- Default: $(MOTOR)/iocsh/EXAMPLE_motorSim8x.substitutions
#-
#- LOW_LIM - Optional: Low Limit (in steps)
#- Default: -32000
#-
#- HIGH_LIM - Optional: High Limit (in steps)
#- Default: 32000
#-
#- DLLM - Optional: Motor Record Low Limit (in EGU)
#- Default: -320.0
#-
#- DHLM - Optional: Motor Record High Limit (in EGU)
#- Default: 320.0
#-
#- HOME_POS - Optional: Home position
#- Default: 0
#- ###################################################

# Create simulated motors: (port name, number of axes on card)
motorSimCreateController("$(INSTANCE)", 8)

#asynSetTraceIOMask("$(INSTANCE)", 0, HEX)
#asynSetTraceMask("$(INSTANCE)", 0, ERROR|FLOW|DRIVER)

# motorSimConfigAxis(port, axis, highLimit, lowLimit, home, start)
motorSimConfigAxis("$(INSTANCE)", 0, $(HIGH_LIM=32000), $(LOW_LIM=-32000), $(HOME_POS=0), 0)
motorSimConfigAxis("$(INSTANCE)", 1, $(HIGH_LIM=32000), $(LOW_LIM=-32000), $(HOME_POS=0), 0)
motorSimConfigAxis("$(INSTANCE)", 2, $(HIGH_LIM=32000), $(LOW_LIM=-32000), $(HOME_POS=0), 0)
motorSimConfigAxis("$(INSTANCE)", 3, $(HIGH_LIM=32000), $(LOW_LIM=-32000), $(HOME_POS=0), 0)
motorSimConfigAxis("$(INSTANCE)", 4, $(HIGH_LIM=32000), $(LOW_LIM=-32000), $(HOME_POS=0), 0)
motorSimConfigAxis("$(INSTANCE)", 5, $(HIGH_LIM=32000), $(LOW_LIM=-32000), $(HOME_POS=0), 0)
motorSimConfigAxis("$(INSTANCE)", 6, $(HIGH_LIM=32000), $(LOW_LIM=-32000), $(HOME_POS=0), 0)
motorSimConfigAxis("$(INSTANCE)", 7, $(HIGH_LIM=32000), $(LOW_LIM=-32000), $(HOME_POS=0), 0)

dbLoadTemplate("$(SUB=$(MOTOR)/iocsh/EXAMPLE_motorSim8x.substitutions)", "P=$(PREFIX),DTYP='asynMotor',PORT=$(INSTANCE),DHLM=$(DHLM=320.0),DLLM=$(DLLM=-320.0)")