Added MsgTxt support to Nanotec motor driver
This commit is contained in:
@ -14,6 +14,9 @@ list to the motor controller constructor.
|
||||
Mark Koennecke
|
||||
July 2015
|
||||
|
||||
Modified to use the MsgTxt field for SINQ
|
||||
|
||||
Mark Koennecke, January 2019
|
||||
*/
|
||||
|
||||
|
||||
@ -43,12 +46,7 @@ July 2015
|
||||
* \param[in] NanotecPortName The name of the drvAsynSerialPort that was created previously to connect to the Nanotec controller
|
||||
*/
|
||||
NanotecController::NanotecController(const char *portName, const char *NanotecPortName, int motCount, const char *bus)
|
||||
: asynMotorController(portName, motCount+1, 0,
|
||||
0, // No additional interfaces beyond those in base class
|
||||
0, // No additional callback interfaces beyond those in base class
|
||||
ASYN_CANBLOCK | ASYN_MULTIDEVICE,
|
||||
1, // autoconnect
|
||||
0, 0) // Default priority and stack size
|
||||
: SINQController(portName, NanotecPortName, motCount+1)
|
||||
{
|
||||
int axis, busAddress;
|
||||
asynStatus status;
|
||||
@ -136,7 +134,7 @@ NanotecAxis* NanotecController::getAxis(int axisNo)
|
||||
* Initializes register numbers, etc.
|
||||
*/
|
||||
NanotecAxis::NanotecAxis(NanotecController *pC, int axisNo, int busAddress)
|
||||
: asynMotorAxis(pC, axisNo),
|
||||
: SINQAxis(pC, axisNo),
|
||||
pC_(pC)
|
||||
{
|
||||
this->busAddress = busAddress;
|
||||
@ -162,17 +160,21 @@ void NanotecAxis::report(FILE *fp, int level)
|
||||
//asynMotorAxis::report(fp, level);
|
||||
}
|
||||
|
||||
asynStatus NanotecController::transactController(char command[COMLEN], char reply[COMLEN])
|
||||
asynStatus NanotecController::transactController(int axisNo, char command[COMLEN], char reply[COMLEN])
|
||||
{
|
||||
asynStatus status;
|
||||
size_t in, out;
|
||||
int reason;
|
||||
SINQAxis *axis = getAxis(axisNo);
|
||||
|
||||
pasynOctetSyncIO->flush(pasynUserController_);
|
||||
|
||||
status = pasynOctetSyncIO->writeRead(pasynUserController_, command, strlen(command),
|
||||
reply,COMLEN, 1.,&out,&in,&reason);
|
||||
if(status != asynSuccess){
|
||||
if(axis != NULL){
|
||||
axis->updateMsgTxtFromDriver("Lost connection to motor controller");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -200,6 +202,8 @@ asynStatus NanotecAxis::move(double position, int relative, double minVelocity,
|
||||
size_t in, out;
|
||||
int reason;
|
||||
|
||||
updateMsgTxtFromDriver("");
|
||||
|
||||
// status = sendAccelAndVelocity(acceleration, maxVelocity);
|
||||
|
||||
if (relative) {
|
||||
@ -215,7 +219,7 @@ asynStatus NanotecAxis::move(double position, int relative, double minVelocity,
|
||||
set mode
|
||||
*/
|
||||
snprintf(command,sizeof(command),"#%dp2",busAddress);
|
||||
status = pC_->transactController(command,reply);
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
if(status != asynSuccess){
|
||||
return status;
|
||||
}
|
||||
@ -224,7 +228,7 @@ asynStatus NanotecAxis::move(double position, int relative, double minVelocity,
|
||||
set target
|
||||
*/
|
||||
snprintf(command,sizeof(command),"#%ds%d",busAddress, (int)position);
|
||||
status = pC_->transactController(command,reply);
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
if(status != asynSuccess){
|
||||
return status;
|
||||
}
|
||||
@ -233,7 +237,7 @@ asynStatus NanotecAxis::move(double position, int relative, double minVelocity,
|
||||
and start..
|
||||
*/
|
||||
snprintf(command,sizeof(command),"#%dA",busAddress);
|
||||
status = pC_->transactController(command,reply);
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
if(status != asynSuccess){
|
||||
return status;
|
||||
}
|
||||
@ -250,11 +254,13 @@ asynStatus NanotecAxis::home(double minVelocity, double maxVelocity, double acce
|
||||
|
||||
setIntegerParam(pC_->motorStatusAtHome_, false);
|
||||
|
||||
updateMsgTxtFromDriver("");
|
||||
|
||||
/*
|
||||
reset positioning errors
|
||||
*/
|
||||
snprintf(command,sizeof(command),"#%dD",busAddress);
|
||||
status = pC_->transactController(command,reply);
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
if(status != asynSuccess){
|
||||
return status;
|
||||
}
|
||||
@ -263,7 +269,7 @@ asynStatus NanotecAxis::home(double minVelocity, double maxVelocity, double acce
|
||||
set mode
|
||||
*/
|
||||
snprintf(command,sizeof(command),"#%dp4",busAddress);
|
||||
status = pC_->transactController(command,reply);
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
if(status != asynSuccess){
|
||||
return status;
|
||||
}
|
||||
@ -273,7 +279,7 @@ asynStatus NanotecAxis::home(double minVelocity, double maxVelocity, double acce
|
||||
set direction
|
||||
*/
|
||||
snprintf(command,sizeof(command),"#%dd0",busAddress);
|
||||
status = pC_->transactController(command,reply);
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
if(status != asynSuccess){
|
||||
return status;
|
||||
}
|
||||
@ -283,7 +289,7 @@ asynStatus NanotecAxis::home(double minVelocity, double maxVelocity, double acce
|
||||
and start..
|
||||
*/
|
||||
snprintf(command,sizeof(command),"#%dA",busAddress);
|
||||
status = pC_->transactController(command,reply);
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
if(status != asynSuccess){
|
||||
return status;
|
||||
}
|
||||
@ -304,6 +310,7 @@ asynStatus NanotecAxis::moveVelocity(double minVelocity, double maxVelocity, dou
|
||||
// "%s: minVelocity=%f, maxVelocity=%f, acceleration=%f\n",
|
||||
// functionName, minVelocity, maxVelocity, acceleration);
|
||||
|
||||
updateMsgTxtFromDriver("");
|
||||
|
||||
|
||||
if (maxVelocity > 0.) {
|
||||
@ -326,7 +333,7 @@ asynStatus NanotecAxis::stop(double acceleration )
|
||||
char command[COMLEN], reply[COMLEN];
|
||||
|
||||
sprintf(command, "#%dS1", busAddress);
|
||||
status = pC_->transactController(command,reply);
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
errlogPrintf("Sent STOP on Axis %d\n", axisNo_);
|
||||
|
||||
return status;
|
||||
@ -338,8 +345,10 @@ asynStatus NanotecAxis::setPosition(double position)
|
||||
//static const char *functionName = "NanotecAxis::setPosition";
|
||||
char command[COMLEN], reply[COMLEN];
|
||||
|
||||
updateMsgTxtFromDriver("");
|
||||
|
||||
sprintf(command, "#%dD%d", busAddress, (int)position);
|
||||
status = pC_->transactController(command,reply);
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
next_poll = -1;
|
||||
|
||||
return status;
|
||||
@ -380,7 +389,7 @@ asynStatus NanotecAxis::poll(bool *moving)
|
||||
|
||||
// Read the current motor position
|
||||
sprintf(command,"#%dC", busAddress);
|
||||
comStatus = pC_->transactController(command,reply);
|
||||
comStatus = pC_->transactController(axisNo_,command,reply);
|
||||
if(comStatus) goto skip;
|
||||
|
||||
pPtr = strchr(reply,'C');
|
||||
@ -394,7 +403,7 @@ asynStatus NanotecAxis::poll(bool *moving)
|
||||
|
||||
// Read the moving status of this motor
|
||||
sprintf(command,"#%d$",busAddress);
|
||||
comStatus = pC_->transactController(command,reply);
|
||||
comStatus = pC_->transactController(axisNo_,command,reply);
|
||||
if(comStatus) goto skip;
|
||||
|
||||
pPtr = strchr(reply,'$');
|
||||
@ -438,10 +447,13 @@ asynStatus NanotecAxis::poll(bool *moving)
|
||||
setIntegerParam(pC_->motorStatusDone_, true);
|
||||
setIntegerParam(pC_->motorStatusProblem_, true);
|
||||
errlogSevPrintf(errlogMajor, "Limit or other positioning problem at %d", axisNo_);
|
||||
updateMsgTxtFromDriver("Positioning problem");
|
||||
if(ABS(posVal - lowLim) < ABS(posVal - highLim)){
|
||||
setIntegerParam(pC_->motorStatusLowLimit_, true);
|
||||
updateMsgTxtFromDriver("Low Limit Hit");
|
||||
} else {
|
||||
setIntegerParam(pC_->motorStatusHighLimit_, true);
|
||||
updateMsgTxtFromDriver("High Limit Hit");
|
||||
}
|
||||
*moving = false;
|
||||
}
|
||||
|
@ -5,15 +5,18 @@ USAGE... Motor driver support for the Nanotec SMCI controller.
|
||||
Mark Koennecke
|
||||
July 2015
|
||||
|
||||
Modified to use the MsgTxt field for SINQ
|
||||
|
||||
Mark Koennecke, January 2019
|
||||
*/
|
||||
|
||||
#include "asynMotorController.h"
|
||||
#include "asynMotorAxis.h"
|
||||
#include "SINQController.h"
|
||||
#include "SINQAxis.h"
|
||||
|
||||
#define COMLEN 80
|
||||
#define MAXMOT 99
|
||||
|
||||
class NanotecAxis : public asynMotorAxis
|
||||
class NanotecAxis : public SINQAxis
|
||||
{
|
||||
public:
|
||||
/* These are the methods we override from the base class */
|
||||
@ -38,7 +41,7 @@ private:
|
||||
friend class NanotecController;
|
||||
};
|
||||
|
||||
class NanotecController : public asynMotorController {
|
||||
class NanotecController : public SINQController {
|
||||
public:
|
||||
NanotecController(const char *portName, const char *NanotecPortName, int numMot, const char *busAddresses);
|
||||
|
||||
@ -50,7 +53,7 @@ friend class NanotecAxis;
|
||||
private:
|
||||
asynUser *pasynUserController_;
|
||||
|
||||
asynStatus transactController(char command[COMLEN], char reply[COMLEN]);
|
||||
asynStatus transactController(int axisNo, char command[COMLEN], char reply[COMLEN]);
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user