Commit Graph

462 Commits

Author SHA1 Message Date
Freddie Akeroyd 524696a8d0 Fix negative backlash with relative moves in a negative direction
A negative BDST was correctly applied to negative direction moves
if moves are absolute. When retries are enabled all moves become
relative and backlash was not applied correctly for negative direction
moves.
2021-11-26 18:23:29 +00:00
Torsten Bögershausen 24a53e660e motorRecord: Reset UEIP to No if no encoder is present
When a database is loaded with UEIP=Yes and the controller says that there is no
encoder present, reset UEIP to No
2021-11-17 08:42:23 +01:00
Torsten Bögershausen 784e41927b motordrvCom.h needs shareLib.h
We can't compile motor against this commit of EPICS base:
  commit 0f428ea3346d89719b03a6419319c85afb0fee13
  Author: Michael Davidsaver <mdavidsaver@gmail.com>
  Date:   Thu Apr 1 10:57:19 2021 -0700

      use DBCORE_API

Solution: Include <shareLib.h>
2021-04-19 14:19:50 +02:00
Mark Rivers 394998bb1b Add shareLib.h 2020-09-04 11:01:47 -05:00
Torsten Bögershausen 2906f3d8f9 Add field RSTM: Restore Mode
Partly revert the following commit:
  commit 3090983c31
  Author: Ron Sluiter <rsluiter@users.noreply.github.com>
  Date:   Wed Jul 29 15:50:23 2015 +0000
      Bug fix for target position (VAL/DVAL/RVAL) initialization error
      when the motor record is configured to do retries.
And from the release notes:

6) Kevin Peterson discovered an initialization bug when the motor record is
    configured to do retries. When configured to do retries, the motor
    record issues incremental rather than absolute moves. If the motor
    behaves badly (e.g., a piezo stiction motor) the controller's absolute
    step count can be far from its' absolute readback position. The motor
    record initialization logic that determines how the target positions
    are initialized at boot-up was not taking into consideration whether
    or not the motor record is configured to do retries, and therefore,
    whether or not absolute or incremental moves were issued by the motor
    record. With this release, if the motor record is configured to do
    retries, then the controller's absolute position is ignored (because
    the controller's absolute position was "corrupted" by retries) and the
    autosave/restore position is used to set the controllers position.

    Switching between retries on and off (relative vs. absolute moves)
    between reboots will cause unpredictable results and is not covered
    by this bug fix.

   Files modified: motor_init_record_com() in MotorSrc/motordevCom.cc
                   init_controller()       in MotorSrc/devMotorAsyn.c

Commit 3090983c improves the situation for setups where autosave is
used, and makes things worse when autosave is not used.
When autosave is not used and the motor is configured to do retries,
the the DVAL field is loaded into the controller regardless.
And because DVAL is 0.0 at startup, the controller position is lost.

The first issue report is found here:
"Problem with R6-10 issue 6 fix - controller position can be lost on reboot"
https://github.com/epics-modules/motor/issues/85

And the we have another issue report here:
"IOC zeroes encoder on startup"
https://github.com/motorapp/Galil-3-0/issues/13

A possible way forward is discussed here:
"Add a field to the motor record to allow always restoring the
 autosaved position"
https://github.com/epics-modules/motor/issues/151

This commit adds the "RSTM" field:
- 0 Disables restoring the autosaved position
- 1 Always restores the autosaved position
- 2 Uses the same logic as motorRecord 6.9 (or older)
- 3 Uses the same logic as motorRecord 6.10

This numbering maps 0 and 1 somewhat to false/true, uses 2/3 for
special handlings and leaves room for more choices.

E.g. "use the encoder value, if valid, fall back to autosave if not.
Or "use the URIP/RDBL" if possible.
I am getting off-topic,
those improvements should be done in later commits anyway.
2020-06-10 07:55:22 +02:00
Kevin Peterson d472dd10f5 Updated the motor record version to 7.2 2020-05-13 17:30:57 -05:00
Mark Rivers 5642bb1089 Initialize some parameters to avoid errors reading them 2020-01-28 16:32:56 -06:00
Torsten Bögershausen 8b43d40d18 send_mess() uses 'const char *' (and more const char*)
The 2nd and 3rd parameter in send_mess() can and should
be a 'const char *' instead of just 'char *'.
Modern compilers complain here, so that the signature now
gets the const.

Update drivers from the following list to use the new send_mess():
    modules/motorAcs
    modules/motorAcsTech80
    modules/motorAerotech
    modules/motorFaulhaber
    modules/motorIms
    modules/motorKohzu
    modules/motorMclennan
    modules/motorMicos
    modules/motorMicroMo
    modules/motorNewFocus
    modules/motorNewport
    modules/motorOms
    modules/motorOriel
    modules/motorPI
    modules/motorParker
    modules/motorPiJena
    modules/motorSmartMotor
    modules/motorThorLabs

And while there, fix one more "const char *" in motordrvCom.cc
2019-09-30 13:15:35 +02:00
kpetersn d809076a32 Incremented the version number (for the first time since commit 0ef39053aa) 2019-08-15 09:52:15 -05:00
Kevin Peterson 6f2f42305a Merge pull request #114 from EuropeanSpallationSource/add_SPDB_v1
Add field SPDB, "Set Point Dead Band"
2018-12-11 13:19:05 -06:00
Torsten Bögershausen 0ea2d9ec87 Add field SPDB, "Set Point Dead Band"
This is from Matthew Pearson, pearsonmr@ornl.gov

A number of users and staff have requested that the motor record have a
setpoint deadband field (eg. SPDB), which prevents any motion from
happening if the readback position is within SPDB.
Without a SPDB we have issues with motors moving unnecessarily.

For example, if the RBV is 0.001 and we set VAL to 0.0, if we have a
non-zero backlash correction then the motor will move unnecessarily
to take out backlash.
Even without backlash correction we often enable and disable the
drive amplifier for no good reason.

Currently the effective setpoint deadband is equal to MRES,
but this is often too small to be an effective setpoint deadband.

The new SPDB field would default to 0.0

The new code hooks into do_work():
When the new setpoint is within DPDB, set too_small and don't move.

The new code does not use snipptes like "abs(npos - rpos)", these
already produce warnings on 64 bit sytems.
abs() is declared to work on int, but we feed long values.
Simply compare the coordinates in engineering units.
2018-11-20 08:51:49 +01:00
Kevin Peterson ff8c74a6e8 Merge pull request #112 from EuropeanSpallationSource/base-3_16_typedef_rset
Base 3.16 typedef rset
2018-10-19 15:22:14 -05:00
Torsten Bögershausen 8deb21c463 Deprecated constructor "asynPortDriver" since asyn R4.32.0
The asyn module make the constructor
asynPortDriver::asynPortDriver(const char *portNameIn, int maxAddrIn,
           int paramTableSize, int interfaceMask, int interruptMask,
           int asynFlags, int autoConnect, int priority, int stackSize)

obsolete in R4.32.0, the more modern version should be used, which does
not have the parameter paramTableSize.
Using a modern version of asyn for the motor gives a compiler warning.
As I don't like compiler warnings, add a #ifdef construct to suppress it
for asyn > R4.32, and still allow to compile agains asyn >= R4.32
2018-10-11 11:07:08 +02:00
Torsten Bögershausen 5198a2d552 Clean up the EPICS_VERSION/rec sup, use motor_epics_inc.h
Refactor the changes for the deprecated RECSUP in later EPICS base
version, which need a typedef for struct rset.
Unite all common code and put it into a single include file.
Add motor_epics_inc.h.
2018-09-19 07:48:00 +02:00
Torsten Bögershausen 71e417b4db define VERSION_INT when using older EPICS bases
Newer EPICS base versions define VERSION_INT, but older don't.
Add a conditional #define to compile against those older bases, like 3.14
2018-09-18 18:04:05 +02:00
Torsten Bögershausen eb3566976d More adaptions to base-3.16/7.0 with typed rset
Remove more compiler warnings when compiling against the base 7.0 branch.
Note:
Some of the model1/2 drivers still give a warning. As I can not test the
code, leave those files untouched.
2018-09-18 16:30:25 +02:00
Ben Franksen 8eacc2f05a Adapt motorRecord.cc to base-3.16 with typed rset 2018-09-18 16:27:59 +02:00
Mark Rivers ae637292db Added stdarg.h, otherwise compiler error with va_start and va_end undefined if DEBUG is defined 2018-09-07 08:11:59 -05:00
kpetersn 26771f23dc Added a comment about reverting the change from .69 2018-08-21 12:05:30 -05:00
kpetersn 95c0a4caa2 Don't set "stop" field true if driver returns RA_PROBLEM true. It is
the driver's responsiblity to stop a motor if the condition that results
in the RA_PROBLEM bit being set doesn't result in the motor
automatically stopping.

This partially reverts commit 303a9208e3
2018-08-21 11:56:25 -05:00
kpetersn 270347dfb3 Set LVIO=1 if DLLM > DHLM, since at least one limit being violated 2018-08-20 17:41:34 -05:00
Kevin Peterson a21b1ccbd6 Merge pull request #99 from EuropeanSpallationSource/JOG_LVIO_JOG_nolockup
motorRecord.cc: Jogging against to LVIO in LVIO

This change resets the JOGF/JOGR fields to zero when a limit violation occurs, rather than when the JOGF/JOGR fields get reset to zero by the user.
2018-08-20 14:50:07 -05:00
Torsten Bögershausen 9e5b54323a motorRecord.cc: Jogging against to LVIO in LVIO
When jogging has stopped because the motor is close to a softlimit,
the record seems to be locked up when the same jog button is pressed again.

The user must release the jog button, before doing any other action.
STOP doesn't help, neither does jog into the opposite direction work.

Solution:
Clear the JOGF and JOGR button in the record.
2018-08-20 09:08:22 +02:00
Kevin Peterson 3683d3f0ea Merge pull request #56 from EuropeanSpallationSource/JOG_stopped
Record recognizes motor stop while jogging.

Text from the pull request:

'The following situation came up while debugging soft limits in a
motion controller which had different values then the record.

The motor is at position 50mm (RBV=50), the low soft limit is 15 (LLM=15),
jogging velocity is 10 mm/sec (JVEL=10).

The motion controller has an internal soft limit which is 35 mm, which
we want to test.
Set JOGR to 1, the motor will move backwards.
(Side note: it would be stopped by the record once it passed 25mm).

Before that, the motion controller stops the motor internally and reports DONE.
The state machine in the record is not prepared to handle this and JOGR stays 1.
The expected behavior is that JOGR returns to 0.
Because this is an unexpected stop, reset even pending home requests.
In other words: call clear_buttons(pmr)

Whether or not an alarm is raised may be another question.
The natural thing would be to set LVIO to 1, but we don't know why the controller
stopped the motion.
Unless we add a bit in MSTA like "RA_LVIO"...
But in any case this can and should go into a separate commit.'
2018-07-03 09:11:27 -05:00
Torsten Bögershausen 9c8a8e8c35 Record recognizes motor stop while jogging
The following situation came up while debugging soft limits in a
motion controller which had different values then the record.

The motor is at position 50mm (RBV=50), the low soft limit is 15 (LLM=15),
jogging velocity is 10 mm/sec (JVEL=10).

The motion controller has an internal soft limit which is 35 mm, which
we want to test.
Set JOGR to 1, the motor will move backwards.
(Side note: it would be stopped by the record once it passed 25mm).

Before that, the motion controller stops the motor internally and reports DONE.
The state machine in the record is not prepared to handle this and JOGR stays 1.
The expected behavior is that JOGR returns to 0.
Because this is an unexpected stop, reset even pending home requests.
In other words: call clear_buttons(pmr)

Whether or not an alarm is raised may be another question.
The natural thing would be to set LVIO to 1, but we don't know why the
controller stopped the motion.
Unless we add a bit in MSTA like "RA_LVIO"...
But in any case this can and should go into a separate commit.
2018-06-29 11:38:31 +02:00
Kevin Peterson 7a758b7238 Merge pull request #84 from mp49/encoder_ratio_fix
Keep the sign information on the MRES and ERES used to calculate the encoder ratio. This fixes issue #82.
2018-06-27 12:21:22 -05:00
Kevin Peterson 0dc3a09a0b Merge pull request #36 from rokvintar/ls_status_update_fix
Status of limit switches updated independent of movement direction.  Fixes #35
2018-06-26 15:45:59 -05:00
Kevin Peterson 90bb52f3c6 Merge pull request #60 from EuropeanSpallationSource/record-DLYandSTOP-problem
Record: motor record DLY and STOP problem
2018-05-01 09:51:03 -05:00
Kevin Peterson f3d4e0fd1d Merge pull request #83 from mp49/autopower_fix
Fix issue with power being left on when using autoPower option in asy…
2018-04-27 10:42:03 -05:00
sluiter 7493d50bc8 If URIP=Yes and reading RDBL causes LINK error, do not start a new target position move. 2018-04-10 14:30:50 -05:00
sluiter c1c4407644 Replaced invalid LT_EPICSBASE logic with working logic from SSCAN. Since EPICS_VERSION_INT defined in EPICSbase 3.15, added EPICS_PATCH_LEVEL argument. 2018-01-04 14:52:05 -06:00
klang a62c5e4e57 Further gcc errors reported 2017-11-21 16:49:37 -06:00
Matthew Pearson 928f79fc9d Keep the sign information on the MRES and ERES used to calculate the encoder ratio. This fixes issue #82. 2017-09-29 12:01:48 -04:00
Matthew Pearson 8229bb7658 Fix issue with power being left on when using autoPower option in asynMotorController. This could happen if the motor doesn't move because it's already in position, so the poller doesn't detect a move. 2017-09-29 11:36:59 -04:00
rsluiter 220d18fcff Merge pull request #63 from rsluiter/master
Stop motor if URIP is Yes and RDBL read returns an error.
2017-09-13 13:45:04 -05:00
Mitch D'Ewart b201e40ee3 Changed ACCL calculation when VELO == VBAS.
Previously ACCL was only calculated as (VELO-VBAS)/TIME.
This could cause problems for drivers setting ACCL=0.
Now if VELO == VBAS, ACCL = VELO/TIME.
2017-08-07 13:56:07 -07:00
sluiter db5da2f075 Stop motor if URIP is Yes and RDBL read returns an error. 2017-05-19 10:19:36 -05:00
Torsten Bögershausen 38186d00e4 Record: motor record DLY and STOP problem
Fix the problem that the record gets stuck when STOP is
pressed while the record is in MIP_DELAY (and the motor
is standing still, so that there is no record processing).

Currently the MIP_DELAY bits are set to 0, when a STOP is issued.
As the motor already hase stopped, the DMOV field never goes to 1.
There are 2 possible solutions here:
a) STOP wins:
  pmr->dmov = FALSE;
  MARK(M_DMOV);

b) DELAY wins
  Send a STOP to the controller (just to be sure), but wait for the DELAY.

a) may cause probles later, whena new positionioning is done after the STOP
and a new DELAY is triggered.
As the old callback is still active, it may be executed before the new
callback. And the time will be too short.
For this reason go with b)

http://www.aps.anl.gov/epics/tech-talk/2015/msg01786.php
2017-03-09 10:58:31 +01:00
ext-muir_j 02612bad41 Fix motorApp/MotorSrc/README header dash lines
Make motorApp/MotorSrc/README header dash lines match length of header text.
2017-03-08 07:05:27 -06:00
Mark Rivers 38cfa6aedf Minor corrections 2017-03-07 13:41:32 -06:00
timmmooney 5cad105357 ignore SET field, so a database can do it instead 2017-01-12 11:09:55 -06:00
sluiter c970afbfe7 Reverted FLNK change. Except for the condition that DMOV == FALSE, FLNK processing was standard. 2016-09-28 16:07:59 -05:00
Keenan Lang ee4bddd761 Merge pull request #33 from keenanlang/master
Switch asynMotorAxis status_ and statusChanged_ to be protected
2016-08-25 13:41:20 -05:00
Vintar Rok 7ee34a791b Velocity, baseVelocity and acceleration read only when needed. Fix for #37 2016-08-22 09:59:03 +02:00
Vintar Rok ddef3a8754 Status of limit switches updated independent of movement direction. Issue #35 2016-08-18 18:21:03 +02:00
Keenan Lang ebe51c0ebb Reverted wrong change, this should get it back to what I wanted it to be. 2016-07-25 14:42:51 -05:00
Keenan Lang 40816ddc65 Revert "Switched motor status and statusChanged to be protected instead of private."
This reverts commit 36ff229c44b8273cd7c4967a13eb64a24f73d37d.
2016-07-25 14:38:38 -05:00
Keenan Lang 4494eb14be Switched motor status and statusChanged to be protected instead of private. 2016-07-25 14:32:44 -05:00
sluiter d52fe5ee2e Changed jog error checks from dial to user limits. 2016-02-19 11:14:53 -06:00
Torsten Bögershausen 532afdc5a0 Remove all lines with svn keywords
They have no meaning in Git, are not updated and may cause unwanted diffs when
otherwise nothing is changed in a file
2015-11-23 08:23:12 +01:00