From 9fbb2e64b9e3c2a870c8187dc5931f51da5cc562 Mon Sep 17 00:00:00 2001 From: smathis Date: Wed, 25 Nov 2026 08:54:13 +0100 Subject: [PATCH] Read out reference status at init When the driver is initialized, it reads from the hardware whether the motor needs to be referenced or not --- src/turboPmacAxis.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/turboPmacAxis.cpp b/src/turboPmacAxis.cpp index 9fd04ea..1c3a8b1 100644 --- a/src/turboPmacAxis.cpp +++ b/src/turboPmacAxis.cpp @@ -134,6 +134,9 @@ asynStatus turboPmacAxis::init() { double motorVmax = 0.0; double motorAccel = 0.0; + // If 0, the motor needs a reference drive. Otherwise, it doesnßt + int needs_reference = 0; + // Conversion factor between engineering units (EU) and encoder counts double counts_to_eu = 0.0; @@ -176,9 +179,11 @@ asynStatus turboPmacAxis::init() { Ixx65. */ snprintf(command, sizeof(command), - "Q%2.2d10 Q%2.2d03 Q%2.2d04 Q%2.2d06 P%2.2d22 Q%2.2d00 I%2.2d28", - axisNo_, axisNo_, axisNo_, axisNo_, axisNo_, axisNo_, axisNo_); - status = pC_->writeRead(axisNo_, command, response, 7); + "Q%2.2d10 Q%2.2d03 Q%2.2d04 Q%2.2d06 P%2.2d22 Q%2.2d00 I%2.2d28 " + "M%2.2d45", + axisNo_, axisNo_, axisNo_, axisNo_, axisNo_, axisNo_, axisNo_, + axisNo_); + status = pC_->writeRead(axisNo_, command, response, 8); msgPrintControlOptions options = {.maxRepetitions = 1, .minRepetitions = 0}; msgPrintControlKey keyDisconnected = msgPrintControlKey( @@ -206,9 +211,9 @@ asynStatus turboPmacAxis::init() { pC_->getMsgPrintControl().resetCount(keyDisconnected, pC_->pasynUser()); } - nvals = sscanf(response, "%lf %lf %lf %lf %d %lf %lf", &motorPos, + nvals = sscanf(response, "%lf %lf %lf %lf %d %lf %lf %d", &motorPos, &motorVmax, &motorVelocity, &motorAccel, &acoDelay, - &counts_to_eu, &deadband_counts); + &counts_to_eu, &deadband_counts, &needs_reference); // The acoDelay is given in milliseconds -> Convert to seconds, rounded // up @@ -219,7 +224,7 @@ asynStatus turboPmacAxis::init() { // here to mm/s^2. motorAccel = motorAccel * 1000; - if (nvals != 7) { + if (nvals != 8) { return pC_->couldNotParseResponse(command, response, axisNo_, __PRETTY_FUNCTION__, __LINE__); } @@ -263,6 +268,8 @@ asynStatus turboPmacAxis::init() { setAxisParamChecked(this, motorPositionDeadband, counts_to_eu * deadband_counts / 16.0); + setAxisParamChecked(this, motorStatusHomed, needs_reference != 0); + // Update the parameter library immediately status = callParamCallbacks(); if (status != asynSuccess) {