make poll rates configurable by adding motorPollSlow, motorPollFast and airPollTimer parameters
r3682 | dcl | 2012-07-26 15:48:38 +1000 (Thu, 26 Jul 2012) | 1 line
This commit is contained in:
@@ -168,6 +168,9 @@ struct __MoDriv {
|
|||||||
double cntsPerX; /**< absolute encoder counts per physical unit */
|
double cntsPerX; /**< absolute encoder counts per physical unit */
|
||||||
int motOnDelay; /**< msec to wait after switching motor on */
|
int motOnDelay; /**< msec to wait after switching motor on */
|
||||||
int motOffDelay; /**< msec to wait before switching motor off */
|
int motOffDelay; /**< msec to wait before switching motor off */
|
||||||
|
int motorPollFast; /**< msec between polls when busy */
|
||||||
|
int motorPollSlow; /**< msec between polls when idle */
|
||||||
|
int airPollTimer; /**< msec between polls when waiting for airpads */
|
||||||
int currFlags;
|
int currFlags;
|
||||||
int currSteps;
|
int currSteps;
|
||||||
int currCounts;
|
int currCounts;
|
||||||
@@ -231,7 +234,7 @@ struct __MoDriv {
|
|||||||
int DMC2280MotionControl = 1; /* defaults to enabled */
|
int DMC2280MotionControl = 1; /* defaults to enabled */
|
||||||
static bool trace_switches = false;
|
static bool trace_switches = false;
|
||||||
|
|
||||||
#define AIR_POLL_TIMER 1000
|
#define AIR_POLL_TIMER 250
|
||||||
#define MOTOR_POLL_FAST 100
|
#define MOTOR_POLL_FAST 100
|
||||||
#define MOTOR_POLL_SLOW 500
|
#define MOTOR_POLL_SLOW 500
|
||||||
#define DEFAULT_DELAY_MOTOR_ON 200 /* msec to wait after switching motor on */
|
#define DEFAULT_DELAY_MOTOR_ON 200 /* msec to wait after switching motor on */
|
||||||
@@ -1801,7 +1804,7 @@ static void DMCState_Unknown(pDMC2280Driv self, pEvtEvent event) {
|
|||||||
change_state(self, DMCState_Idle);
|
change_state(self, DMCState_Idle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DMC_SetTimer(self, MOTOR_POLL_SLOW);
|
DMC_SetTimer(self, self->motorPollSlow);
|
||||||
return;
|
return;
|
||||||
case eMessageEvent:
|
case eMessageEvent:
|
||||||
do {
|
do {
|
||||||
@@ -1898,9 +1901,9 @@ static void DMCState_Idle(pDMC2280Driv self, pEvtEvent event) {
|
|||||||
report_motion(self);
|
report_motion(self);
|
||||||
}
|
}
|
||||||
if (trace_switches || self->debug)
|
if (trace_switches || self->debug)
|
||||||
DMC_SetTimer(self, MOTOR_POLL_FAST);
|
DMC_SetTimer(self, self->motorPollFast);
|
||||||
else
|
else
|
||||||
DMC_SetTimer(self, MOTOR_POLL_SLOW);
|
DMC_SetTimer(self, self->motorPollSlow);
|
||||||
self->subState = 0;
|
self->subState = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1929,7 +1932,7 @@ static void DMCState_Idle(pDMC2280Driv self, pEvtEvent event) {
|
|||||||
strncpy(self->lastCmd, event->event.msg.cmd->out_buf, CMDLEN);
|
strncpy(self->lastCmd, event->event.msg.cmd->out_buf, CMDLEN);
|
||||||
self->errorCode = MOTCMDTMO;
|
self->errorCode = MOTCMDTMO;
|
||||||
self->driver_status = HWFault;
|
self->driver_status = HWFault;
|
||||||
DMC_SetTimer(self, MOTOR_POLL_SLOW);
|
DMC_SetTimer(self, self->motorPollSlow);
|
||||||
self->subState = 0;
|
self->subState = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2013,7 +2016,7 @@ static void DMCState_MotorStart(pDMC2280Driv self, pEvtEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DMC_SetTimer(self, AIR_POLL_TIMER);
|
DMC_SetTimer(self, self->airPollTimer);
|
||||||
self->subState = 0;
|
self->subState = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2033,7 +2036,7 @@ static void DMCState_MotorStart(pDMC2280Driv self, pEvtEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* TODO handle airpad timeout */
|
/* TODO handle airpad timeout */
|
||||||
DMC_SetTimer(self, AIR_POLL_TIMER);
|
DMC_SetTimer(self, self->airPollTimer);
|
||||||
self->subState = 0;
|
self->subState = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2257,7 +2260,7 @@ static void DMCState_Moving(pDMC2280Driv self, pEvtEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self->subState = 2;
|
self->subState = 2;
|
||||||
DMC_SetTimer(self, MOTOR_POLL_FAST);
|
DMC_SetTimer(self, self->motorPollFast);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (self->subState == 3) { /* PA */
|
else if (self->subState == 3) { /* PA */
|
||||||
@@ -2364,7 +2367,7 @@ static void DMCState_Moving(pDMC2280Driv self, pEvtEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
self->subState = 2;
|
self->subState = 2;
|
||||||
DMC_SetTimer(self, MOTOR_POLL_FAST);
|
DMC_SetTimer(self, self->motorPollFast);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Motor has stopped */
|
/* Motor has stopped */
|
||||||
@@ -2566,7 +2569,7 @@ static void DMCState_MotorHalt(pDMC2280Driv self, pEvtEvent event) {
|
|||||||
if (iRet == 0)
|
if (iRet == 0)
|
||||||
break;
|
break;
|
||||||
if (self->moving) {
|
if (self->moving) {
|
||||||
DMC_SetTimer(self, MOTOR_POLL_FAST);
|
DMC_SetTimer(self, self->motorPollFast);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self->faultPending) {
|
if (self->faultPending) {
|
||||||
@@ -2721,7 +2724,7 @@ static void DMCState_MotorStop(pDMC2280Driv self, pEvtEvent event) {
|
|||||||
}
|
}
|
||||||
/* TODO handle airpad timeout */
|
/* TODO handle airpad timeout */
|
||||||
}
|
}
|
||||||
DMC_SetTimer(self, AIR_POLL_TIMER);
|
DMC_SetTimer(self, self->airPollTimer);
|
||||||
} while (0);
|
} while (0);
|
||||||
return;
|
return;
|
||||||
case eCommandEvent:
|
case eCommandEvent:
|
||||||
@@ -3158,6 +3161,18 @@ static int DMC2280GetPar(void *pData, char *name,
|
|||||||
*fValue = self->bias_bits;
|
*fValue = self->bias_bits;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if(strcasecmp(name,"motorPollFast") == 0) {
|
||||||
|
*fValue = self->motorPollFast;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(strcasecmp(name,"motorPollSlow") == 0) {
|
||||||
|
*fValue = self->motorPollSlow;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(strcasecmp(name,"airPollTimer") == 0) {
|
||||||
|
*fValue = self->airPollTimer;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (self->posit_count > 0) {
|
if (self->posit_count > 0) {
|
||||||
if (strncasecmp(name, "posit_", 6) == 0 && isdigit(name[6])) {
|
if (strncasecmp(name, "posit_", 6) == 0 && isdigit(name[6])) {
|
||||||
int index;
|
int index;
|
||||||
@@ -3518,6 +3533,27 @@ static int DMC2280SetPar(void *pData, SConnection *pCon,
|
|||||||
self->bias_bits = newValue;
|
self->bias_bits = newValue;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (self->abs_encoder && strcasecmp("motorPollFast", name) == 0) {
|
||||||
|
/* Debug Managers only */
|
||||||
|
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||||
|
return 0;
|
||||||
|
self->motorPollFast = newValue;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (self->abs_encoder && strcasecmp("motorPollSlow", name) == 0) {
|
||||||
|
/* Debug Managers only */
|
||||||
|
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||||
|
return 0;
|
||||||
|
self->motorPollSlow = newValue;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (self->abs_encoder && strcasecmp("airPollTimer", name) == 0) {
|
||||||
|
/* Debug Managers only */
|
||||||
|
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||||
|
return 0;
|
||||||
|
self->airPollTimer = newValue;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
/* XXX Maybe move this to a configuration parameter.*/
|
/* XXX Maybe move this to a configuration parameter.*/
|
||||||
/* Set home, managers only. Users should set softposition */
|
/* Set home, managers only. Users should set softposition */
|
||||||
if(strcasecmp(name, HOME) == 0) {
|
if(strcasecmp(name, HOME) == 0) {
|
||||||
@@ -3612,6 +3648,12 @@ static void DMC2280List(void *pData, char *name, SConnection *pCon){
|
|||||||
SCWrite(pCon, buffer, eStatus);
|
SCWrite(pCon, buffer, eStatus);
|
||||||
snprintf(buffer, BUFFLEN, "%s.motOffDelay = %d\n", name, self->motOffDelay);
|
snprintf(buffer, BUFFLEN, "%s.motOffDelay = %d\n", name, self->motOffDelay);
|
||||||
SCWrite(pCon, buffer, eStatus);
|
SCWrite(pCon, buffer, eStatus);
|
||||||
|
snprintf(buffer, BUFFLEN, "%s.motorPollFast = %d\n", name, self->motorPollFast);
|
||||||
|
SCWrite(pCon, buffer, eStatus);
|
||||||
|
snprintf(buffer, BUFFLEN, "%s.motorPollSlow = %d\n", name, self->motorPollSlow);
|
||||||
|
SCWrite(pCon, buffer, eStatus);
|
||||||
|
snprintf(buffer, BUFFLEN, "%s.airPollTimer = %d\n", name, self->airPollTimer);
|
||||||
|
SCWrite(pCon, buffer, eStatus);
|
||||||
snprintf(buffer, BUFFLEN, "%s.Debug = %d\n", name, self->debug);
|
snprintf(buffer, BUFFLEN, "%s.Debug = %d\n", name, self->debug);
|
||||||
SCWrite(pCon, buffer, eStatus);
|
SCWrite(pCon, buffer, eStatus);
|
||||||
snprintf(buffer, BUFFLEN, "%s.Settle = %d\n", name, self->settle);
|
snprintf(buffer, BUFFLEN, "%s.Settle = %d\n", name, self->settle);
|
||||||
@@ -3932,6 +3974,19 @@ MotorDriver *CreateDMC2280(SConnection *pCon, char *motor, char *params) {
|
|||||||
else
|
else
|
||||||
sscanf(pPtr,"%d",&(pNew->motOffDelay));
|
sscanf(pPtr,"%d",&(pNew->motOffDelay));
|
||||||
|
|
||||||
|
if ((pPtr=getParam(pCon, interp, params,"motorPollFast",_OPTIONAL)) == NULL)
|
||||||
|
pNew->motorPollFast=MOTOR_POLL_FAST;
|
||||||
|
else
|
||||||
|
sscanf(pPtr,"%d",&(pNew->motOffDelay));
|
||||||
|
if ((pPtr=getParam(pCon, interp, params,"motorPollSlow",_OPTIONAL)) == NULL)
|
||||||
|
pNew->motorPollSlow=MOTOR_POLL_SLOW;
|
||||||
|
else
|
||||||
|
sscanf(pPtr,"%d",&(pNew->motOffDelay));
|
||||||
|
if ((pPtr=getParam(pCon, interp, params,"airPollTimer",_OPTIONAL)) == NULL)
|
||||||
|
pNew->airPollTimer=AIR_POLL_TIMER;
|
||||||
|
else
|
||||||
|
sscanf(pPtr,"%d",&(pNew->motOffDelay));
|
||||||
|
|
||||||
/* SETTLE: this motor need time to settle */
|
/* SETTLE: this motor need time to settle */
|
||||||
if ((pPtr=getParam(pCon, interp, params,"settle",_OPTIONAL)) == NULL)
|
if ((pPtr=getParam(pCon, interp, params,"settle",_OPTIONAL)) == NULL)
|
||||||
pNew->settle=0;
|
pNew->settle=0;
|
||||||
|
|||||||
Reference in New Issue
Block a user