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