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

Add more parameter setup, fix potential PCOF issue #782

Merged
merged 5 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions MCLEN/MCLEN-IOC-01App/Db/mclen_motor_extra.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
record(motor, "$(P)$(M)") {
field(PCOF, "$(PCOF)")
field(HVEL, "$(HVEL)")
}
6 changes: 6 additions & 0 deletions MCLEN/MCLEN-IOC-01App/Db/motor.substitutions
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ pattern {P, M, OFF, JVEL}
{"\$(P)", "\$(M)", "\$(OFF)", "\$(JVEL)"}
}

file "$(TOP)/MCLEN-IOC-01App/Db/mclen_motor_extra.db" {
pattern {P, M, PCOFF}
{"\$(P)", "\$(M)", "\$(PCOFF)"}
}

file $(MOTOR)/db/periodic_polling.db {
pattern {P, M, POLL_RATE}
{"\$(P)", "\$(M)", "\$(POLL_RATE=10)"}
}

7 changes: 7 additions & 0 deletions MCLEN/iocBoot/iocMCLEN-IOC-01/st-common.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

< $(IOCSTARTUP)/dbload.cmd

## set to 1 or higher to enable motor debugging
var drvPM304Debug 1

# specify additional directories in which to to search for included request files
set_requestfile_path("${MOTOR}/motorApp/Db", "")
## as we are common, we need to explicity define the 01 area for when we are run by 02, 03 etc
Expand Down Expand Up @@ -40,6 +43,10 @@ $(IFNOTDEVSIM) $(IFNOTRECSIM) asynSetOption("$(ASERIAL)",0,"ixoff","N")
$(IFNOTRECSIM) asynOctetSetInputEos("$(ASERIAL)",0,"\r\n")
$(IFNOTRECSIM) asynOctetSetOutputEos("$(ASERIAL)",0,"\r")

## enable asyn trace debugging
#asynSetTraceMask("$(ASERIAL)", -1, 0x9)
#asynSetTraceIOMask("$(ASERIAL)", -1, 0x2)

# Test for Mclennan PM600 stepper motor controller
# Note that setup must be done in sim mode too or unconfigured card will crash at first caput
# PM304Setup(controller count, poll rate (1 to 60Hz))
Expand Down
39 changes: 39 additions & 0 deletions MCLEN/iocBoot/iocMCLEN-IOC-01/st-motor-init.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,42 @@ $(IFNOTCMOPEN) asynOctetWrite("MKINIT","$(MN)CM14")

## Initialise the encoder ratio using the exact string of ERES$
asynOctetWrite("MKINIT","$(MN)ER$(ERES$(MN)=400/4096)")

## end of move check window
asynOctetWrite("MKINIT","$(MN)WI5")

## Not Complete/Time-Out time
asynOctetWrite("MKINIT","$(MN)TO8000")

## tracking window
asynOctetWrite("MKINIT","$(MN)TR4000")

## SL1 enables soft limits in controller, SL0 disables
## we disable for now until we are sure they work
## see comment in driver
asynOctetWrite("MKINIT","$(MN)SL0")

## backoff steps as 0
asynOctetWrite("MKINIT","$(MN)BO0")

## creep steps at end of move
#asynOctetWrite("MKINIT","$(MN)CR10")
asynOctetWrite("MKINIT","$(MN)CR5")

## creep speed
#asynOctetWrite("MKINIT","$(MN)CS250")

## settle time
asynOctetWrite("MKINIT","$(MN)SE1000")

## set abort mode, controller default is 00000000
## however passing 00111000 for example would make stall error, tracking error and timeout error not abort motion
asynOctetWrite("MKINIT","$(MN)AM00000000")

## set datum mode, controller default is 00000000
## this also controls expected encoder index polarity, automatic direction search etc. on datum
## not set at moment
#asynOctetWrite("MKINIT","$(MN)DM00000000")

## define home position as 0, this will be applied if DM set accordingly
#asynOctetWrite("MKINIT","$(MN)SH0")
11 changes: 2 additions & 9 deletions MCLEN/iocBoot/iocMCLEN-IOC-01/st-motor.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ epicsEnvSet("AMOTORPV", "MOT:$(AMOTORNAME)")

## Load record instances

## Initialise control mode. Defaults to CM14, closed
$(IFNOTRECSIM) asynOctetConnect("MKINIT","$(ASERIAL)")
$(IFNOTRECSIM) $(IFCMOPEN) asynOctetWrite("MKINIT","$(MN)CM11")
$(IFNOTRECSIM) $(IFNOTCMOPEN) asynOctetWrite("MKINIT","$(MN)CM14")
$(IFNOTRECSIM) asynOctetWrite("MKINIT","$(MN)ER$(ERES$(MN)=400/4096)")

# Set motor specific initial conditions
epicsEnvSet("EGUI",$(UNIT$(MN)="mm"))
epicsEnvSet("VELOI",$(VELO$(MN)=1))
Expand All @@ -27,8 +21,7 @@ epicsEnvSet("DHLMI",$(DHLM$(MN)=200))
epicsEnvSet("DLLMI",$(DLLM$(MN)=-200))
epicsEnvSet("NAMEI","$(NAME$(MN)=$(AMOTORNAME))")
epicsEnvSet("OFSTI", "$(OFST$(MN)=0)")


epicsEnvSet("PCOF", "$(PCOF$(MN)=0.7)") # used for KP (Correction Gain in steppers)

# The signal number is the axis-1
calc("SN", "$(MN)-1", 2, 2)
Expand All @@ -44,7 +37,7 @@ dbLoadRecords("$(ASYN)/db/asynRecord.db", "P=$(MYPVPREFIX),R=$(AMOTORPV):ASYN,PO
# on an absolute move unless the speed and base speed are different
#
$(IFRECSIM) dbLoadRecords("$(TOP)/db/motorSim.db", "P=$(MYPVPREFIX),M=$(AMOTORPV),VELO=$(VELOI),JVEL=$(JVELI),VBAS=0.0,ACCL=$(ACCLI),MRES=$(MRESI),ERES=$(ERESI),DHLM=$(DHLMI),DLLM=$(DLLMI),NAME=$(NAMEI),S=$(SN),C=0,UEIP=1,EGU=$(EGUI),OFF=$(OFSTI)")
$(IFNOTRECSIM) dbLoadRecords("$(TOP)/db/motor.db", "P=$(MYPVPREFIX),M=$(AMOTORPV),VELO=$(VELOI),JVEL=$(JVELI),VBAS=0.0,ACCL=$(ACCLI),MRES=$(MRESI),ERES=$(ERESI),DHLM=$(DHLMI),DLLM=$(DLLMI),NAME=$(NAMEI),S=$(SN),C=0,UEIP=1,EGU=$(EGUI),OFF=$(OFSTI), POLL_RATE=$(POLL_RATE=10)")
$(IFNOTRECSIM) dbLoadRecords("$(TOP)/db/motor.db", "P=$(MYPVPREFIX),M=$(AMOTORPV),VELO=$(VELOI),JVEL=$(JVELI),HVEL=$(VELOI),VBAS=0.0,ACCL=$(ACCLI),MRES=$(MRESI),ERES=$(ERESI),DHLM=$(DHLMI),DLLM=$(DLLMI),NAME=$(NAMEI),S=$(SN),C=0,UEIP=1,EGU=$(EGUI),OFF=$(OFSTI), POLL_RATE=$(POLL_RATE=10),PCOF=$(PCOF)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we definitely always want to set HVEL to base velocity?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for background, HVEL was not previously being set at all resulting in it defaulting to VBAS which is then being explicitly set to zero, so in the end the mclennan driver was trying to set the creep speed to 0, which the controller considers invalid, so the homing (creep) speed was never actually being set. Setting it to VELOI above would get capped at 800 sps in the driver anyway (max creep speed), but i agree is probably not ideal. I will add an extra macro for HVEL in the config.

dbLoadRecords("$(MOTOR)/db/motorStatus.db", "P=$(MYPVPREFIX),M=$(AMOTORPV),IOCNAME=$(IOCNAME)")
dbLoadRecords("$(AXIS)/db/axis.db", "P=$(MYPVPREFIX),AXIS=$(IOCNAME):AXIS$(MN),mAXIS=$(AMOTORPV)")

Expand Down
3 changes: 0 additions & 3 deletions MCLEN/iocBoot/iocMCLEN-IOC-01/st.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@ errlogInit2(65536, 256)
dbLoadDatabase "$(TOP)/dbd/MCLEN-IOC-01.dbd"
MCLEN_IOC_01_registerRecordDeviceDriver pdbbase

# enable debugging
var drvPM304Debug 0

< st-common.cmd