forked from epics_driver_modules/motorBase
Cleaned up code. Reduced delays added for testing.
This commit is contained in:
@@ -68,6 +68,7 @@ ANF2Controller::ANF2Controller(const char *portName, const char *ANF2InPortName,
|
||||
}
|
||||
for (i=0; i<MAX_OUTPUT_REGS; i++) {
|
||||
status = pasynInt32SyncIO->connect(ANF2OutPortName, i, &pasynUserOutReg_[j][i], NULL);
|
||||
// Maybe send the outputs with Array calls in the future
|
||||
//status = pasynInt32ArraySyncIO->connect(ANF2OutPortName, i, &pasynUserOutArrayReg_[j][i], NULL);
|
||||
}
|
||||
}
|
||||
@@ -204,6 +205,7 @@ asynStatus ANF2Controller::writeReg16(int axisNo, int axisReg, int output, doubl
|
||||
return status ;
|
||||
}
|
||||
|
||||
// This could be useful in the future, but it isn't needed yet
|
||||
/*asynStatus ANF2Controller::writeReg32Array(int axisNo, int axisReg, epicsInt32* output, int nElements, double timeout)
|
||||
{
|
||||
asynStatus status;
|
||||
@@ -222,6 +224,8 @@ asynStatus ANF2Controller::writeReg32(int axisNo, int axisReg, int output, doubl
|
||||
asynStatus status;
|
||||
|
||||
int lower,upper;
|
||||
|
||||
// This is the way the ANG1 driver does it, and the code doesn't appear to work
|
||||
/*float fnum;
|
||||
|
||||
fnum = (output / 1000.0);
|
||||
@@ -243,7 +247,7 @@ asynStatus ANF2Controller::writeReg32(int axisNo, int axisReg, int output, doubl
|
||||
axisReg++;
|
||||
status = writeReg16(axisNo, axisReg, lower, DEFAULT_CONTROLLER_TIMEOUT);
|
||||
|
||||
// No breaking up the output value required when writing an array
|
||||
// No breaking up the output value required when writing an array - maybe do this in the future
|
||||
//status = pasynInt32ArraySyncIO->write(pasynUserOutArrayReg_[axisNo][axisReg], &output, 2, timeout);
|
||||
|
||||
return status ;
|
||||
@@ -303,14 +307,11 @@ ANF2Axis::ANF2Axis(ANF2Controller *pC, const char *ANF2ConfName, int axisNo, epi
|
||||
pC_(pC)
|
||||
{
|
||||
int status;
|
||||
long long bigConfig;
|
||||
long long configAndSpeed;
|
||||
epicsInt32 configBits[2];
|
||||
|
||||
axisNo_ = axisNo;
|
||||
//this->axisNo_ = axisNo;
|
||||
|
||||
//status = pasynInt32SyncIO->connect(myModbusInputDriver, 0, &pasynUserForceRead_, "MODBUS_READ");
|
||||
status = pasynInt32SyncIO->connect(pC_->inputDriver_, 0, &pasynUserForceRead_, "MODBUS_READ");
|
||||
if (status) {
|
||||
//printf("%s:%s: Error, unable to connect pasynUserForceRead_ to Modbus input driver %s\n", pC_->inputDriver_, pC_->functionName, myModbusInputDriver);
|
||||
@@ -324,46 +325,34 @@ ANF2Axis::ANF2Axis(ANF2Controller *pC, const char *ANF2ConfName, int axisNo, epi
|
||||
}
|
||||
printf("ANF2Axis::ANF2Axis : pasynUserConfWrite_->reason=%d\n", pasynUserConfWrite_->reason);
|
||||
|
||||
epicsThreadSleep(3.0);
|
||||
epicsThreadSleep(1.0);
|
||||
|
||||
// Read data that is likely to be stale
|
||||
getInfo();
|
||||
|
||||
// Send the configuration
|
||||
//status = pC_->writeReg32(axisNo_, CONFIG_MSW, config, DEFAULT_CONTROLLER_TIMEOUT);
|
||||
//status = pC_->writeReg16(axisNo_, CONFIG_MSW, 0x8600, DEFAULT_CONTROLLER_TIMEOUT);
|
||||
// Send the configuration bits
|
||||
//status = pasynInt32SyncIO->write(pasynUserConfWrite_, config, DEFAULT_CONTROLLER_TIMEOUT);
|
||||
// Set the start speed to a non-zero value (100)
|
||||
//status = pC_->writeReg16(axisNo_, POS_WR_LWR, 0x0064, DEFAULT_CONTROLLER_TIMEOUT);
|
||||
//epicsThreadSleep(0.01);
|
||||
|
||||
/*bigConfig = (long long) config & 0xFFFFFFFF;
|
||||
configAndSpeed = (bigConfig << 32) | 0x00000064;
|
||||
printf("bigConfig = %lx, configAndSpeed = %lx\n", bigConfig, configAndSpeed);
|
||||
status = pasynInt32SyncIO->write(pasynUserConfWrite_, configAndSpeed, DEFAULT_CONTROLLER_TIMEOUT);*/
|
||||
|
||||
|
||||
// Send the configuration (array)
|
||||
// assemble the configuration bits; set the start speed to a non-zero value (100), which is required for the configuration to be accepted
|
||||
configBits[0] = config;
|
||||
configBits[1] = 0x00000064;
|
||||
/*status = pasynInt32SyncIO->write(pasynUserConfWrite_, *configBits, DEFAULT_CONTROLLER_TIMEOUT);
|
||||
status = pasynInt32SyncIO->write(pasynUserConfWrite_, *(configBits+1), DEFAULT_CONTROLLER_TIMEOUT);*/
|
||||
|
||||
// Does the number of elements refer to the number of 16-bit elements?
|
||||
//status = this->pC_->writeReg32Array(axisNo, CONFIG_MSW, configBits, 4, DEFAULT_CONTROLLER_TIMEOUT);
|
||||
//
|
||||
status = pasynInt32ArraySyncIO->write(pasynUserConfWrite_, configBits, 4, DEFAULT_CONTROLLER_TIMEOUT);
|
||||
// Mabye do it this way in the future
|
||||
//status = this->pC_->writeReg32Array(axisNo, CONFIG_MSW, configBits, 4, DEFAULT_CONTROLLER_TIMEOUT);
|
||||
|
||||
// Delay
|
||||
epicsThreadSleep(10.0);
|
||||
epicsThreadSleep(1.0);
|
||||
|
||||
// Read the configuration? Or maybe the command registers?
|
||||
getInfo();
|
||||
|
||||
//IAMHERE
|
||||
|
||||
// set position to 0
|
||||
//setPosition(0);
|
||||
setPosition(1337);
|
||||
//setPosition(3141);
|
||||
|
||||
// Delay
|
||||
epicsThreadSleep(1.0);
|
||||
@@ -382,12 +371,6 @@ ANF2Axis::ANF2Axis(ANF2Controller *pC, const char *ANF2ConfName, int axisNo, epi
|
||||
0x4 - Home Input (0 = Disabled, 1 = Enabled)
|
||||
0x8 -
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
extern "C" asynStatus ANF2CreateAxis(const char *ANF2Name, /* specify which controller by port name */
|
||||
|
||||
Reference in New Issue
Block a user