Added scaffolding for velocity mode
All checks were successful
Test And Build / Lint (push) Successful in 5s
Test And Build / Build (push) Successful in 5s

Added records to support detection of the current operation mode
(position or velocity), whether one is allowed to change between the two
and a record to actually change between the two. Also added a
doMoveVelocity method which should be implemented by derived drivers if
they support velocity mode.
This commit is contained in:
2026-01-20 14:11:06 +01:00
parent e234d05815
commit 6f639d7233
7 changed files with 352 additions and 26 deletions

View File

@@ -117,11 +117,11 @@ does not matter):
file "$(SINQDBPATH)"
{
pattern
{ AXIS, M, DESC, EGU, DIR, MRES, MSGTEXTSIZE, ENABLEMOVWATCHDOG, LIMITSOFFSET, CANSETSPEED, ADAPTPOLL }
{ 1, "lin1", "Linear motor doing whatever", mm, Pos, 0.001, 200, 1, 1.0, 1, 1 }
{ 2, "rot1", "First rotary motor", degree, Neg, 0.001, 200, 0, 1.0, 0, 1 }
{ 3, "rot2", "Second rotary motor", degree, Pos, 0.001, 200, 0, 0.0, 1, 0 }
{ 5, "rot3", "Surprise: Third rotary motor", degree, Pos, 0.001, 200, 1, 2.0, 0, 0 }
{ AXIS, M, DESC, EGU, DIR, MRES, MSGTEXTSIZE, ENABLEMOVWATCHDOG, LIMITSOFFSET, CANSETSPEED, ADAPTPOLL, CANSETMODE }
{ 1, "lin1", "Linear motor doing whatever", mm, Pos, 0.001, 200, 1, 1.0, 1, 1, 0 }
{ 2, "rot1", "First rotary motor", degree, Neg, 0.001, 200, 0, 1.0, 0, 1, 0 }
{ 3, "rot2", "Second rotary motor", degree, Pos, 0.001, 200, 0, 0.0, 1, 0, 0 }
{ 5, "rot3", "Surprise: Third rotary motor", degree, Pos, 0.001, 200, 1, 2.0, 0, 0, 1 }
}
```
The variable `SINQDBPATH` has been set in "mcu1.cmd" before calling `dbLoadTemplate`.
@@ -166,6 +166,9 @@ behaviour so that the affected axis is only polled with the busy / moving poll
period if it itself is moving. This setting is ignored for "forced fast polls"
(when the poller is woken up, e.g. after an axis received a move command).
Defaults to 1.
- `CANSETMODE`: If set to any value other than 0, the operation mode of the
motor can be changed. See section [Velocity mode](#velocity-mode).
### Motor record resolution MRES
@@ -212,6 +215,29 @@ transferred to (motor_record_pv_name).MRES or to
`sinqMotor` provides a variety of additional records. See `db/sinqMotor.db` for
the complete list and the documentation.
### Velocity mode
The motor record was originally designed for motors which operate in _position_
mode: They are given a certain position, move to that position and then stop
on their own. Some motors however operate in a continuous _velocity_ mode, where
they move (usually rotate) with a fixed velocity until told to stop or change
the velocity. To support this operation mode, `sinqMotor` provides three
additional records:
- `$(INSTR)$(M):Mode`: This read-only record returns 0 if the motor is in
position mode and 1 if it is in velocity mode. Defaults to 0.
- `$(INSTR)$(M):CanSetMode`: If the value of this record is other than zero, the
motor mode can be changed during operation. Defaults to 0, but can be
overwritten in the substitution file with `CANSETMODE` or from within the driver
(e.g. by reading out a parameter from the hardware).
- `$(INSTR)$(M):SetMode`: This record can be used to switch between operation
modes if `$(INSTR)$(M):CanSetMode` is not zero. Currently accepted values are
`0` for position mode and `1` for velocity mode.
When in velocity mode, writing to the `VELO` field of the motor record directly
triggers the corresponding velocity change if the driver supports it. Writing
to the `VAL` field does nothing in velocity mode.
## Developer guide
### File structure
@@ -251,7 +277,10 @@ This is an empty function which should be overwritten by concrete driver impleme
- `reset`: This function is called when the `$(INSTR)$(M):Reset` PV from `db/sinqMotor.db` is set.
It calls `doReset` and performs some fast polls after `doReset` returns.
- `doReset`: This is an empty function which should be overwritten by concrete driver implementations.
- `move`: This function sets the absolute target position in the parameter library and then calls `doMove`.
- `moveVelocity`: This function checks if the motor is in velocity mode. If that is the case, it calls `doMoveVelocity`.
- `doMoveVelocity`: This is an empty function which should be overwritten by concrete driver implementations.
- `move`: This function checks if the motor is in position mode. If that is the
case, it then sets the absolute target position in the parameter library and then calls `doMove`.
- `doMove`: This is an empty function which should be overwritten by concrete driver implementations.
- `home`: This function sets the internal status flags for the homing process and then calls doHome.
- `doHome`: This is an empty function which should be overwritten by concrete driver implementations.