epics-modules / xxx

APS BCDA synApps module: xxx
http://epics-modules.github.io/xxx
Other
5 stars 6 forks source link

What imposes the high limit switch value for this soft asynMotor? #59

Closed prjemian closed 1 year ago

prjemian commented 1 year ago
          What imposes the high limit switch value for this soft asynMotor?

Originally posted by @prjemian in https://github.com/epics-modules/xxx/issues/46#issuecomment-775008691

prjemian commented 1 year ago

My motivation is to set the MRES for soft motors to some ridiculous precision (say 1e-5 or so) and the raw motor count seems to be limited.

prjemian commented 1 year ago

The ridiculous precision corresponds to motors that simulate a Bragg angle rotation. These rotations require precision of 10 microdegrees to step the motor through the effective energy resolution.

kmpeters commented 1 year ago

The RMP field of the motor record is limited to 32-bits:

https://github.com/epics-modules/motor/blob/34474ed958838ea5083f598fa4bd9f1ca7e1821c/motorApp/MotorSrc/motorRecord.dbd#L582-L585

Changing it will break compatibility with EPICS base 3.15, iirc.

prjemian commented 1 year ago

Ok. I'll try to stay within that limit. Will report if additional problem identified.

prjemian commented 1 year ago

Specifically, -2147483648 <= RMP <= 2147483647, correct?

prjemian commented 1 year ago

So, with MRES=1e-5, then travel between user soft limits of +/- 20,000 should be possible with tripping the (simulated) limit switch, correct?

MarkRivers commented 1 year ago

Could RMP be changed to DBF_DOUBLE? That allows exact representation of integers up to about 52 bits.

kmpeters commented 1 year ago

So, with MRES=1e-5, then travel between user soft limits of +/- 20,000 should be possible with tripping the (simulated) limit switch, correct?

Yes.

kmpeters commented 1 year ago

Could RMP be changed to DBF_DOUBLE? That allows exact representation of integers up to about 52 bits.

I don't know what the unintended consequences of changing it to DBF_DOUBLE would be. I am unlikely to have time to test that change until the APS upgrade is complete.

prjemian commented 1 year ago

With motor 7.2.2, synApps 6.2.1, asyn 4.42, XXX master, just downloaded and built within the hour, using these motors:

iocshLoad("$(MOTOR)/iocsh/motorSim.iocsh", "INSTANCE=motorSim, HOME_POS=0, NUM_AXES=56, HIGH_LIM=32000, LOW_LIM=-32000, SUB=substitutions/motorSim.substitutions")

And the substitutions file (built from bash script) has these lines:

file "$(MOTOR)/db/asyn_motor.db"
{
pattern
{N, M, ADDR, DESC, EGU, DIR, VELO, VBAS, ACCL, BDST, BVEL, BACC, MRES, PREC, INIT}
{1, "m1", 0, "motor 1", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{2, "m2", 1, "motor 2", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{3, "m3", 2, "motor 3", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{4, "m4", 3, "motor 4", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{5, "m5", 4, "motor 5", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{6, "m6", 5, "motor 6", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{7, "m7", 6, "motor 7", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{8, "m8", 7, "motor 8", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
{9, "m9", 8, "motor 9", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
...
{56, "m56", 55, "motor 56", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, ""}
}
prjemian commented 1 year ago

When the IOC is started, this is what one of the motors (sky:m5 by name) shows: as-supplied

kmpeters commented 1 year ago

@prjemian, is there a problem on those caQtDM screens? If so, it isn't jumping out at me.

prjemian commented 1 year ago

Here is the problem I have seen:

When the SREV field is changed from 200 steps/rev to 200,000 steps/rev, the MRES=1e-5, as expected.

Note that HLM and LLM are not affected by this change in SREV, as expected.

When the motor is moved from zero to 0.35 (any target above 0.32), a hard limit is shown and the RBV is pegged to 0.32000. This is clearly within the travel limits as shown. SREV 200k and move to 0 35

kmpeters commented 1 year ago

That comes from this line, specifically HIGH_LIM=32000, which is setting the limit in counts:

iocshLoad("$(MOTOR)/iocsh/motorSim.iocsh", "INSTANCE=motorSim, HOME_POS=0, NUM_AXES=56, HIGH_LIM=32000, LOW_LIM=-32000, SUB=substitutions/motorSim.substitutions")
prjemian commented 1 year ago

HIGH_LIM is not HLM?

kmpeters commented 1 year ago

HIGH_LIM is not HLM?

No. It is an argument passed to motorSimCreate to allow hardware limits to be simulated by the motor driver:

https://github.com/epics-motor/motorMotorSim/blob/4eba04d8c2fa48bab65db6b935017c6531da5749/motorSimApp/iocsh/motorSim.iocsh#L29

prjemian commented 1 year ago

Oh. In raw motor pulses, not user units, correct? I'll reconfigure with 1000x the default numbers and retry.

kmpeters commented 1 year ago

Oh. In raw motor pulses, not user units, correct? I'll reconfigure with 1000x the default numbers and retry.

Correct.

prjemian commented 1 year ago

I'm trying with sed -i s:'32000':'32000000':g ./motors.iocsh

prjemian commented 1 year ago

To stay within (2^31)-1, I'll dial that down to 20,000,000

prjemian commented 1 year ago

That will fix this issue, thanks!

prjemian commented 1 year ago

What confused me is that the value for HIGH_LIM becomes the HLM value when the IOC is first booted (unless the DHLM macro is provided to asyn_motor.db). I was expecting the IOC to consider the MRES between these numbers. Similar for LOW_LIM and LLM.

kmpeters commented 1 year ago

What confused me is that the value for HIGH_LIM becomes the HLM value when the IOC is first booted (unless the DHLM macro is provided to asyn_motor.db). I was expecting the IOC to consider the MRES between these numbers. Similar for LOW_LIM and LLM.

It should probably be considered a bug that the HIGH_LIM and LOW_LIM values are also used as the default values for DHLM & DLLM:

https://github.com/epics-motor/motorMotorSim/blob/4eba04d8c2fa48bab65db6b935017c6531da5749/motorSimApp/iocsh/motorSim.iocsh#L34

prjemian commented 1 year ago

Right. I suggest adding DHLM and DLLM macros (with some reasonable defaults) in motorMotorSim/motorSimApp/iocsh/motorSim.iocsh, line 34:

dbLoadTemplate("$(SUB=$(MOTOR)/iocsh/EXAMPLE_motorSim.substitutions)", "P=$(PREFIX), DTYP='asynMotor', PORT=$(INSTANCE)$(CONTROLLER=0), DHLM=$(HIGH_LIM=32000), DLLM=$(LOW_LIM=-32000)")
kmpeters commented 1 year ago

I've created a branch for improving the motorMotorSim examples. That is a change I plan to make to motorSim.iocsh.