Compare commits

..

1 Commits

7 changed files with 81 additions and 55 deletions

6
.gitmodules vendored
View File

@ -1,6 +0,0 @@
[submodule "sinqmotor"]
path = sinqmotor
url = https://gitea.psi.ch/lin-epics-modules/sinqmotor
[submodule "sinqMotor"]
path = sinqMotor
url = https://gitea.psi.ch/lin-epics-modules/sinqMotor

View File

@ -1,4 +1,4 @@
# Include the external Makefile
# Use the PSI build system
include /ioc/tools/driver.makefile
MODULE=turboPmac
@ -8,30 +8,28 @@ ARCH_FILTER=RHEL%
# Additional module dependencies
REQUIRED+=motorBase
REQUIRED+=sinqMotor
# Specify the version of motorBase we want to build against
motorBase_VERSION=7.2.2
# Specify the version of sinqMotor we want to build against
sinqMotor_VERSION=0.14
# These headers allow to depend on this library for derived drivers.
HEADERS += src/pmacAsynIPPort.h
HEADERS += src/turboPmacAxis.h
HEADERS += src/turboPmacController.h
# Source files to build
SOURCES += sinqMotor/src/msgPrintControl.cpp
SOURCES += sinqMotor/src/sinqAxis.cpp
SOURCES += sinqMotor/src/sinqController.cpp
SOURCES += src/pmacAsynIPPort.c
SOURCES += src/turboPmacAxis.cpp
SOURCES += src/turboPmacController.cpp
# Store the record files
TEMPLATES += sinqMotor/db/asynRecord.db
TEMPLATES += sinqMotor/db/sinqMotor.db
TEMPLATES += db/turboPmac.db
# This file registers the motor-specific functions in the IOC shell.
DBDS += sinqMotor/src/sinqMotor.dbd
DBDS += src/turboPmac.dbd
USR_CFLAGS += -Wall -Wextra -Weffc++ -Wunused-result -Werror # -Wpedantic // Does not work because EPICS macros trigger warnings
USR_CFLAGS += -Wall -Wextra -Weffc++ -Wunused-result -Werror # -Wpedantic // Does not work because EPICS macros trigger warnings

View File

@ -4,7 +4,7 @@
## Overview
This is a driver for the Turbo PMAC motion controller with the SINQ communication protocol. It is based on the sinqMotor shared library (https://gitea.psi.ch/lin-epics-modules/sinqMotor). The header files contain detailed documentation for all public functions. The headers themselves are exported when building the library to allow other drivers to depend on this one.
This is a driver for the Turbo PMAC motion controller with the SINQ communication protocol. It is based on the sinqMotor shared library (https://git.psi.ch/sinq-epics-modules/sinqmotor). The header files contain detailed documentation for all public functions. The headers themselves are exported when building the library to allow other drivers to depend on this one.
## User guide
@ -14,6 +14,8 @@ The folder "utils" contains utility scripts for working with pmac motor controll
- writeRead.py: Allows sending commands to and receiving commands from a pmac controller over an ethernet connection.
- analyzeTcpDump.py: Parse the TCP communication between an IOC and a MCU and format it into a dictionary. "demo.py" shows how this data can be easily visualized for analysis.
### IOC startup script
turboPmac exports the following IOC shell functions:
@ -52,11 +54,11 @@ setMaxSubsequentTimeouts("$(DRIVER_PORT)", 20);
setThresholdComTimeout("$(DRIVER_PORT)", 300, 10);
# Parametrize the EPICS record database with the substitution file named after the MCU.
epicsEnvSet("SINQDBPATH","$(turboPmac_DB)/sinqMotor.db")
epicsEnvSet("SINQDBPATH","$(sinqMotor_DB)/sinqMotor.db")
dbLoadTemplate("$(TOP)/$(DRIVER_PORT).substitutions", "INSTR=$(INSTR)$(DRIVER_PORT):,CONTROLLER=$(DRIVER_PORT)")
epicsEnvSet("SINQDBPATH","$(turboPmac_DB)/turboPmac.db")
dbLoadTemplate("$(TOP)/$(DRIVER_PORT).substitutions", "INSTR=$(INSTR)$(DRIVER_PORT):,CONTROLLER=$(DRIVER_PORT)")
dbLoadRecords("$(turboPmac_DB)/asynRecord.db","P=$(INSTR)$(DRIVER_PORT),PORT=$(IP_PORT)")
dbLoadRecords("$(sinqMotor_DB)/asynRecord.db","P=$(INSTR)$(DRIVER_PORT),PORT=$(IP_PORT)")
```
### Additional records
@ -71,4 +73,4 @@ Please see the documentation for the module sinqMotor: https://git.psi.ch/sinq-e
### How to build it
This driver can be compiled and installed by running `make install` from the same directory where the Makefile is located. However, since it uses the git submodule sinqMotor, make sure that the correct version of the submodule repository is checked out AND the change is commited (`git status` shows no non-committed changes). Please see the section "Usage as static dependency" in https://git.psi.ch/sinq-epics-modules/sinqmotor/-/blob/main/README.md for more details.
Please see the documentation for the module sinqMotor: https://git.psi.ch/sinq-epics-modules/sinqmotor/-/blob/main/README.md.

Submodule sinqMotor deleted from 275672aaef

View File

@ -71,20 +71,6 @@ turboPmacAxis::turboPmacAxis(turboPmacController *pC, int axisNo,
exit(-1);
}
// Even though this happens already in sinqAxis, a default value for
// motorMessageText is set here again, because apparently the sinqAxis
// constructor is not run before the string is accessed?
status = setStringParam(pC_->motorMessageText(), "");
if (status != asynSuccess) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d:\nFATAL ERROR "
"(setting a parameter value failed "
"with %s)\n. Terminating IOC",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
pC_->stringifyAsynStatus(status));
exit(-1);
}
// turboPmac motors can always be disabled
status = pC_->setIntegerParam(axisNo_, pC_->motorCanDisable(), 1);
if (status != asynSuccess) {
@ -411,6 +397,13 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
case -5:
// Axis is deactivated
*moving = false;
pl_status = setStringParam(pC_->motorMessageText(), "Deactivated");
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
break;
case -4:
// Emergency stop
@ -433,10 +426,19 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
break;
case -3:
// Disabled
*moving = false;
pl_status = setStringParam(pC_->motorMessageText(), "Disabled");
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
break;
case 0:
// Idle
@ -597,7 +599,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
resetError = false;
status = setStringParam(pC_->motorMessageText(),
"Target position would exceed software limits");
"Target position would exceed software "
"limits. Please call the support.");
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,
@ -780,10 +783,10 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
}
resetError = false;
snprintf(
userMessage, sizeUserMessage,
"Driver hardware error (P%2.2d01 = 13). Please call the support.",
axisNo_);
snprintf(userMessage, sizeUserMessage,
"Driver hardware error (P%2.2d01 = 13). "
"Please call the support.",
axisNo_);
status = setStringParam(pC_->motorMessageText(), userMessage);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorMessageText_",
@ -1081,7 +1084,22 @@ asynStatus turboPmacAxis::doHome(double min_velocity, double max_velocity,
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
pl_status = setStringParam(pC_->motorMessageText(), "Homing");
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
return callParamCallbacks();
} else {
pl_status = setStringParam(pC_->motorMessageText(),
"Can't home a motor with absolute encoder");
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
}
return asynSuccess;
@ -1253,8 +1271,6 @@ asynStatus turboPmacAxis::enable(bool on) {
// Status of parameter library operations
asynStatus pl_status = asynSuccess;
// =========================================================================
/*
Continue regardless of the status returned by the poll; we just want to
find out whether the motor is currently moving or not. If the poll
@ -1264,6 +1280,8 @@ asynStatus turboPmacAxis::enable(bool on) {
bool moving = false;
doPoll(&moving);
// =========================================================================
// If the axis is currently moving, it cannot be disabled. Ignore the
// command and inform the user. We check the last known status of the axis
// instead of "moving", since status -6 is also moving, but the motor can
@ -1312,7 +1330,16 @@ asynStatus turboPmacAxis::enable(bool on) {
"Controller \"%s\", axis %d => %s, line %d\n%s axis\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
on ? "Enable" : "Disable");
if (on == 0) {
pl_status = setStringParam(pC_->motorMessageText(), "Disabling ...");
} else {
pl_status = setStringParam(pC_->motorMessageText(), "Enabling ...");
}
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,
__LINE__);
}
rw_status = pC_->writeRead(axisNo_, command, response, 0);
if (rw_status != asynSuccess) {
return rw_status;
@ -1355,7 +1382,7 @@ asynStatus turboPmacAxis::enable(bool on) {
// Output message to user
snprintf(command, sizeof(command), "Failed to %s within %d seconds",
on ? "enable" : "disable", timeout_enable_disable);
pl_status = setStringParam(pC_->motorMessageText(), command);
pl_status = setStringParam(pC_->motorMessageText(), "Enabling ...");
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
axisNo_, __PRETTY_FUNCTION__,

View File

@ -31,7 +31,7 @@ class turboPmacAxis : public sinqAxis {
* value is currently not used.
* @return asynStatus
*/
virtual asynStatus stop(double acceleration);
asynStatus stop(double acceleration);
/**
* @brief Implementation of the `doHome` function from sinqAxis. The
@ -43,8 +43,8 @@ class turboPmacAxis : public sinqAxis {
* @param forwards
* @return asynStatus
*/
virtual asynStatus doHome(double minVelocity, double maxVelocity,
double acceleration, int forwards);
asynStatus doHome(double minVelocity, double maxVelocity,
double acceleration, int forwards);
/**
* @brief Implementation of the `doPoll` function from sinqAxis. The
@ -53,7 +53,7 @@ class turboPmacAxis : public sinqAxis {
* @param moving
* @return asynStatus
*/
virtual asynStatus doPoll(bool *moving);
asynStatus doPoll(bool *moving);
/**
* @brief Implementation of the `doMove` function from sinqAxis. The
@ -66,9 +66,8 @@ class turboPmacAxis : public sinqAxis {
* @param acceleration
* @return asynStatus
*/
virtual asynStatus doMove(double position, int relative,
double min_velocity, double max_velocity,
double acceleration);
asynStatus doMove(double position, int relative, double min_velocity,
double max_velocity, double acceleration);
/**
* @brief Readout of some values from the controller at IOC startup
@ -80,7 +79,7 @@ class turboPmacAxis : public sinqAxis {
*
* @return asynStatus
*/
virtual asynStatus init();
asynStatus init();
/**
* @brief Implementation of the `doReset` function from sinqAxis.
@ -88,7 +87,7 @@ class turboPmacAxis : public sinqAxis {
* @param on
* @return asynStatus
*/
virtual asynStatus doReset();
asynStatus doReset();
/**
* @brief Enable / disable the axis.
@ -96,7 +95,7 @@ class turboPmacAxis : public sinqAxis {
* @param on
* @return asynStatus
*/
virtual asynStatus enable(bool on);
asynStatus enable(bool on);
/**
* @brief Read the encoder type (incremental or absolute) for this axis from
@ -104,14 +103,14 @@ class turboPmacAxis : public sinqAxis {
*
* @return asynStatus
*/
virtual asynStatus readEncoderType();
asynStatus readEncoderType();
/**
* @brief Trigger a rereading of the encoder position.
*
* @return asynStatus
*/
virtual asynStatus rereadEncoder();
asynStatus rereadEncoder();
/**
* @brief Interpret the error code and populate the user message accordingly

View File

@ -120,10 +120,17 @@ class turboPmacController : public sinqController {
int readConfig() { return readConfig_; }
int flushHardware() { return flushHardware_; }
// Set the maximum buffer size. This is an empirical value which must be
// large enough to avoid overflows for all commands to the device /
// responses from it.
static const uint32_t MAXBUF_ = 200;
asynUser *pasynInt32SyncIOipPort() { return pasynInt32SyncIOipPort_; }
protected:
// Timeout for the communication process in seconds
/*
Timeout for the communication process in seconds
*/
double comTimeout_;
char lastResponse[MAXBUF_];