Skip to content

Commit

Permalink
Add support for motor record SET field to GalilCSAxis
Browse files Browse the repository at this point in the history
  • Loading branch information
ics committed Oct 17, 2024
1 parent 97ff625 commit 97ccc56
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 14 deletions.
2 changes: 1 addition & 1 deletion GalilSup/op/ui/galil_motors_v4.ui
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<number>2</number>
</property>
<property name="gridOrder">
<enum>QE::rowMajor</enum>
<enum>QE::colMajor</enum>
</property>
<property name="slotNumberOffset" stdset="0">
<number>9</number>
Expand Down
19 changes: 16 additions & 3 deletions GalilSup/src/GalilAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ asynStatus GalilAxis::setDefaults(int limit_as_home, char *enables_string, int s
//Default softLimits
lowLimit_ = 0.0;
highLimit_ = 0.0;

//Operator has not used MR SET field yet
setPositionIn_ = false;
setPositionOut_ = false;

return asynSuccess;
}
Expand Down Expand Up @@ -1330,6 +1334,9 @@ asynStatus GalilAxis::setPosition(double position)

//Set encoder position
setEncoderPosition(enc_pos);

//GalilAxis position changed via MR SET field, inform any GalilCSAxis
setPositionOut_ = true;

//Always return success. Dont need more error mesgs
return asynSuccess;
Expand Down Expand Up @@ -2736,16 +2743,22 @@ asynStatus GalilAxis::poller(void)
setIntegerParam(pC_->motorStatusHome_, home);
//Pass direction to motorRecord
setIntegerParam(pC_->motorStatusDirection_, direction_);
//Tell upper layers motor is moving whilst sync encoded stepper, and homing requests are being executed
//Also when stopDelay has yet to expire
//Tell upper layers motor is moving whilst
//sync encoded stepper at stop or
//homing requests are being executed or
//GalilAxis has a new position from CSAxis (setPositionIn_ true) or
//stopDelay has yet to expire
//This prevents new moves being initiated whilst above functions are being executed
//Also keeps HOMR and HOMF 1 until homing finished
//Done late in poll to allow parallel execution with pollServices
if ((homedSent_ && !homedExecuted_) || homing_ ||
if ((homedSent_ && !homedExecuted_) || homing_ || setPositionIn_ ||
(syncEncodedStepperAtStopSent_ && !syncEncodedStepperAtStopExecuted_) ||
(stoppedTime_ < stopDelay && !status)) {
moving = true;
done_ = 0;
//Set setPositionIn_ false, we've acted by setting moving true for 1 cycle
//Moving true for 1 cycle will cause GalilAxis MR to synchronize drive field to new readback value
setPositionIn_ = (setPositionIn_) ? false : setPositionIn_;
}

//Dont show limits whilst homing otherwise mr may interrupt custom routines
Expand Down
4 changes: 4 additions & 0 deletions GalilSup/src/GalilAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ class GalilAxis : public asynMotorAxis
int ueip_; //motorRecord ueip. User wants to read main encoder if true, aux if false
int enc_tol_; //encoder tolerance. Used for determining encoder direction in setStatus()
bool ctrlUseMain_; //Based on selected motor type controller will use main or aux encoder register for positioning
bool setPositionIn_; //Flag to indicate associated CSAxis position change via motor record set/use field
//Set by GalilCSAxis, consumed by GalilAxis
bool setPositionOut_; //Flag to indicate this axis position change via motor record set/use field
//Set by GalilAxis, consumed by GalilCSAxis
double motor_position_; //aux encoder or step count register
double encoder_position_; //main encoder register
double last_encoder_position_; //main encoder register stored from previous poll. Used to detect movement.
Expand Down
38 changes: 38 additions & 0 deletions GalilSup/src/GalilCSAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,36 @@ asynStatus GalilCSAxis::home(double minVelocity, double maxVelocity, double acce
return (asynStatus)status;
}

/** Set the current position of the motor.
* \param[in] position The new absolute motor position that should be set. Units=steps.*/
asynStatus GalilCSAxis::setPosition(double position)
{
double npos[MAX_GALIL_AXES]; //Real axis position targets
double nvel[MAX_GALIL_AXES]; //Real axis velocity targets, not used
double naccel[MAX_GALIL_AXES]; //Real axis acceleration targets, not used
double acceleration = 100.0; //Arbitary acceleration, not used
double velocity = 100.0; //Arbitary velocity, not used
GalilAxis *pAxis; //Reverse/real axis
unsigned i; //Looping

// Perform reverse transform
reverseTransform(position, velocity, acceleration, npos, nvel, naccel);
// Loop thru real motor list and set new position
for (i = 0; revaxes_[i] != '\0'; i++) {
// Retrieve the axis
pAxis = pC_->getAxis(revaxes_[i] - AASCII);
// Process or skip
if (!pAxis) continue;
// Set reverse/real axis position
pAxis->setPosition(npos[i]);
// GalilCSAxis position changed via MR SET field, inform any GalilAxis
pAxis->setPositionIn_ = true;
}

// Always return success. Dont need more error mesgs
return asynSuccess;
}

/** Select a free coordinate system, or return -1
*/
int GalilCSAxis::selectFreeCoordinateSystem(void)
Expand Down Expand Up @@ -2191,6 +2221,14 @@ asynStatus GalilCSAxis::poller(void)
//Or moving status from all real axis to derive cs moving status
csmoving |= (deferredMove_ || (!rdmov && !pAxis->deferredMove_) || \
(rmoving && !pAxis->deferredMove_) || (pAxis->deferredMove_));
//Has operator used GalilAxis MR SET field to update real axis position?
if (pAxis->setPositionOut_) {
//Operator has used MR SET field to update real axis position
pAxis->setPositionOut_ = false;
//Hold CSAxis moving true for 1 cycle so
//CSAxis motor record drive field is updated to new readback position
csmoving = true;
}
//Or inmotion status from all real axis to derive cs inmotion status. Ignore CSAxis deferredMove
csinmotion |= pAxis->inmotion_;
//Retrieve stall/following error status
Expand Down
10 changes: 1 addition & 9 deletions GalilSup/src/GalilCSAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
#include "asynMotorController.h"
#include "asynMotorAxis.h"

//Related CSAxis may have new setpoints too
struct CSTargets
{
double ncspos[MAX_GALIL_AXES]; //The new position setpoints for the related CSAxis Units=Steps
double ncsvel[MAX_GALIL_AXES]; //The velocity required for the related CSAxis Units=Steps/s
double ncsaccel[MAX_GALIL_AXES]; //The acceleration required for the related CSAxis Units=Steps/s/s
char csaxes[MAX_GALIL_CSAXES]; //List of related csaxis that also have new position setpoints
};

class GalilCSAxis : public asynMotorAxis
{
public:
Expand Down Expand Up @@ -111,6 +102,7 @@ class GalilCSAxis : public asynMotorAxis
asynStatus moveVelocity(double min_velocity, double max_velocity, double acceleration);
asynStatus home(double minVelocity, double maxVelocity, double acceleration, int forwards);
asynStatus stop(double acceleration);
asynStatus setPosition(double position);
asynStatus initializeProfile(size_t maxProfilePoints);
asynStatus setHighLimit(double highLimit);
asynStatus setLowLimit(double lowLimit);
Expand Down
5 changes: 4 additions & 1 deletion GalilSup/src/GalilController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@
// 16/10/2024 M.Clift
// Fix change text entry widgets to string type in galil_csmotor_kinematics.adl
//
// 17/10/2024 M.Clift
// Add support for motor record SET field to GalilCSAxis
//

#include <stdio.h>
#include <math.h>
Expand Down Expand Up @@ -459,7 +462,7 @@ using namespace std; //cout ostringstream vector string
#include <epicsExport.h>

static const char *driverName = "GalilController";
static const char *driverVersion = "3-6-90";
static const char *driverVersion = "3-6-91";

static void GalilProfileThreadC(void *pPvt);
static void GalilArrayUploadThreadC(void *pPvt);
Expand Down

0 comments on commit 97ccc56

Please sign in to comment.