mirror of
https://github.com/Binary-Coalescence/motorDSM.git
synced 2025-08-04 21:55:40 -05:00
Merge branch 'homing' into dev
This commit is contained in:
@@ -12,6 +12,8 @@ March 1, 2012
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include <iocsh.h>
|
#include <iocsh.h>
|
||||||
#include <epicsThread.h>
|
#include <epicsThread.h>
|
||||||
@@ -219,11 +221,36 @@ asynStatus MD90Axis::move(double position, int relative, double minVelocity, dou
|
|||||||
|
|
||||||
asynStatus MD90Axis::home(double minVelocity, double maxVelocity, double acceleration, int forwards)
|
asynStatus MD90Axis::home(double minVelocity, double maxVelocity, double acceleration, int forwards)
|
||||||
{
|
{
|
||||||
|
int sleepTime;
|
||||||
asynStatus status;
|
asynStatus status;
|
||||||
static const char *functionName = "MD90Axis::home";
|
static const char *functionName = "MD90Axis::home";
|
||||||
|
|
||||||
status = sendAccelAndVelocity(acceleration, maxVelocity);
|
status = sendAccelAndVelocity(acceleration, maxVelocity);
|
||||||
|
|
||||||
|
// The MD-90 will start the home routine in the direction of the last move
|
||||||
|
// Here we first make a small move to set the desired direction before homing
|
||||||
|
|
||||||
|
sprintf(pC_->outString_, "SNS %d", SMALL_NSTEPS);
|
||||||
|
status = pC_->writeReadController();
|
||||||
|
if (!status) {
|
||||||
|
status = parseReply(functionName, pC_->inString_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forwards) {
|
||||||
|
sprintf(pC_->outString_, "ESF");
|
||||||
|
} else {
|
||||||
|
sprintf(pC_->outString_, "ESB");
|
||||||
|
}
|
||||||
|
status = pC_->writeReadController();
|
||||||
|
if (!status) {
|
||||||
|
status = parseReply(functionName, pC_->inString_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for the move to complete, then home
|
||||||
|
|
||||||
|
sleepTime = SLEEP_MARGIN * SMALL_NSTEPS * COUNTS_PER_STEP / maxVelocity;
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(sleepTime));
|
||||||
|
|
||||||
sprintf(pC_->outString_, "HOM");
|
sprintf(pC_->outString_, "HOM");
|
||||||
status = pC_->writeReadController();
|
status = pC_->writeReadController();
|
||||||
if (!status) {
|
if (!status) {
|
||||||
|
@@ -12,6 +12,8 @@ USAGE... Motor driver support for the DSM MD-90 controller.
|
|||||||
// No controller-specific parameters yet
|
// No controller-specific parameters yet
|
||||||
#define NUM_MD90_PARAMS 0
|
#define NUM_MD90_PARAMS 0
|
||||||
|
|
||||||
|
#define SLEEP_MARGIN 1.2 // Extra factor to wait after stepping before homing
|
||||||
|
#define SMALL_NSTEPS 5 // Number of steps to take to set direction for homing routine
|
||||||
#define COUNTS_PER_STEP 1000.0 // Number of encoder counts per motor step (measured by testing)
|
#define COUNTS_PER_STEP 1000.0 // Number of encoder counts per motor step (measured by testing)
|
||||||
|
|
||||||
class epicsShareClass MD90Axis : public asynMotorAxis
|
class epicsShareClass MD90Axis : public asynMotorAxis
|
||||||
|
Reference in New Issue
Block a user