forked from epics_driver_modules/motorBase
Converted MSTA #define's to bit field.
This commit is contained in:
+19
-22
@@ -183,9 +183,11 @@ STATIC int set_status(int card, int signal)
|
||||
long motorData;
|
||||
char buff[BUFF_SIZE];
|
||||
bool ls_active = false;
|
||||
msta_field status;
|
||||
|
||||
motor_info = &(motor_state[card]->motor_info[signal]);
|
||||
nodeptr = motor_info->motor_motion;
|
||||
status.All = motor_info->status.All;
|
||||
|
||||
/* Request the moving status of this motor */
|
||||
sprintf(command, "#%02dX", signal);
|
||||
@@ -193,34 +195,31 @@ STATIC int set_status(int card, int signal)
|
||||
recv_mess(card, response, WAIT);
|
||||
/* The response string is of the form "#01X=1" */
|
||||
|
||||
if (response[5] == '1')
|
||||
motor_info->status &= ~RA_DONE;
|
||||
else {
|
||||
motor_info->status |= RA_DONE;
|
||||
}
|
||||
status.Bits.RA_DONE = (response[5] == '1') ? 0 : 1;
|
||||
|
||||
/* Request the limit status of this motor */
|
||||
sprintf(command, "#%02dE", signal);
|
||||
send_mess(card, command, 0);
|
||||
recv_mess(card, response, WAIT);
|
||||
/* The response string is of the form "#01E=1" */
|
||||
motor_info->status &= ~(RA_PLUS_LS | RA_MINUS_LS);
|
||||
status.Bits.RA_PLUS_LS = 0;
|
||||
status.Bits.RA_MINUS_LS = 0;
|
||||
if (response[5] == '1') {
|
||||
motor_info->status |= RA_PLUS_LS;
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
status.Bits.RA_DIRECTION = 1;
|
||||
ls_active = true;
|
||||
}
|
||||
if (response[6] == '1') {
|
||||
motor_info->status |= RA_MINUS_LS;
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
status.Bits.RA_DIRECTION = 0;
|
||||
ls_active = true;
|
||||
}
|
||||
|
||||
/* encoder status */
|
||||
motor_info->status &= ~EA_SLIP;
|
||||
motor_info->status &= ~EA_POSITION;
|
||||
motor_info->status &= ~EA_SLIP_STALL;
|
||||
motor_info->status &= ~EA_HOME;
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_POSITION = 0;
|
||||
status.Bits.EA_SLIP_STALL = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
|
||||
/* Request the position of this motor */
|
||||
sprintf(command, "#%02dP", signal);
|
||||
@@ -233,10 +232,7 @@ STATIC int set_status(int card, int signal)
|
||||
motor_info->no_motion_count++;
|
||||
else
|
||||
{
|
||||
if (motorData >= motor_info->position)
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
else
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
status.Bits.RA_DIRECTION = (motorData >= motor_info->position) ? 1 : 0;
|
||||
motor_info->position = motorData;
|
||||
motor_info->encoder_position = motorData;
|
||||
motor_info->no_motion_count = 0;
|
||||
@@ -247,14 +243,14 @@ STATIC int set_status(int card, int signal)
|
||||
|
||||
motor_info->velocity = 0;
|
||||
|
||||
if (!(motor_info->status & RA_DIRECTION))
|
||||
if (!status.Bits.RA_DIRECTION)
|
||||
motor_info->velocity *= -1;
|
||||
|
||||
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
|
||||
(motor_info->status & (RA_DONE | RA_PROBLEM))) ? 1 : 0;
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
|
||||
/* Test for post-move string. */
|
||||
if ((motor_info->status & RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
nodeptr->postmsgptr != 0)
|
||||
{
|
||||
strcpy(buff, nodeptr->postmsgptr);
|
||||
@@ -265,6 +261,7 @@ STATIC int set_status(int card, int signal)
|
||||
nodeptr->postmsgptr = NULL;
|
||||
}
|
||||
|
||||
motor_info->status.All = status.All;
|
||||
return (rtn_state);
|
||||
}
|
||||
|
||||
@@ -499,7 +496,7 @@ STATIC int motor_init()
|
||||
send_mess(card_index, buff, 0);
|
||||
recv_mess(card_index, buff, WAIT); /* Throw away response */
|
||||
strcpy(brdptr->ident, "MCB-4B");
|
||||
motor_info->status = 0;
|
||||
motor_info->status.All = 0;
|
||||
motor_info->no_motion_count = 0;
|
||||
motor_info->encoder_position = 0;
|
||||
motor_info->position = 0;
|
||||
|
||||
@@ -3,9 +3,9 @@ FILENAME... drvIM483PL.cc
|
||||
USAGE... Motor record driver level support for Intelligent Motion
|
||||
Systems, Inc. IM483(I/IE).
|
||||
|
||||
Version: $Revision: 1.4 $
|
||||
Version: $Revision: 1.5 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-11-07 22:26:59 $
|
||||
Last Modified: $Date: 2003-12-12 21:39:28 $
|
||||
*/
|
||||
|
||||
/*****************************************************************
|
||||
@@ -238,44 +238,44 @@ STATIC int set_status(int card, int signal)
|
||||
register struct mess_info *motor_info;
|
||||
/* Message parsing variables */
|
||||
char buff[BUFF_SIZE];
|
||||
int status;
|
||||
int rtn_state;
|
||||
int rtnval, rtn_state;
|
||||
double motorData;
|
||||
bool plusdir, ls_active = false;
|
||||
msta_field status;
|
||||
|
||||
cntrl = (struct IM483controller *) motor_state[card]->DevicePrivate;
|
||||
motor_info = &(motor_state[card]->motor_info[signal]);
|
||||
nodeptr = motor_info->motor_motion;
|
||||
status.All = motor_info->status.All;
|
||||
|
||||
send_mess(card, "? ^", IM483PL_axis[signal]);
|
||||
rtn_state = recv_mess(card, buff, 1);
|
||||
if (rtn_state > 0)
|
||||
{
|
||||
cntrl->status = NORMAL;
|
||||
motor_info->status &= ~CNTRL_COMM_ERR;
|
||||
status.Bits.CNTRL_COMM_ERR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cntrl->status == NORMAL)
|
||||
{
|
||||
cntrl->status = RETRY;
|
||||
return(0);
|
||||
rtn_state = 0;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
cntrl->status = COMM_ERR;
|
||||
motor_info->status |= CNTRL_COMM_ERR;
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
return(1);
|
||||
status.Bits.CNTRL_COMM_ERR = 1;
|
||||
status.Bits.RA_PROBLEM = 1;
|
||||
rtn_state = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
status = atoi(&buff[4]);
|
||||
rtnval = atoi(&buff[4]);
|
||||
|
||||
if (status != 0)
|
||||
motor_info->status &= ~RA_DONE;
|
||||
else
|
||||
motor_info->status |= RA_DONE;
|
||||
status.Bits.RA_DONE = (rtnval != 0) ? 0 : 1;
|
||||
|
||||
/*
|
||||
* Parse motor position
|
||||
@@ -295,55 +295,49 @@ STATIC int set_status(int card, int signal)
|
||||
epicsInt32 newposition;
|
||||
|
||||
newposition = NINT(motorData);
|
||||
if (newposition >= motor_info->position)
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
else
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
status.Bits.RA_DIRECTION = (newposition >= motor_info->position) ? 1 : 0;
|
||||
motor_info->position = newposition;
|
||||
motor_info->no_motion_count = 0;
|
||||
}
|
||||
|
||||
plusdir = (motor_info->status & RA_DIRECTION) ? true : false;
|
||||
plusdir = (status.Bits.RA_DIRECTION) ? true : false;
|
||||
|
||||
send_mess(card, "? ] 0", IM483PL_axis[signal]);
|
||||
recv_mess(card, buff, 1);
|
||||
status = atoi(&buff[5]);
|
||||
rtnval = atoi(&buff[5]);
|
||||
|
||||
/* Set limit switch error indicators. */
|
||||
if (status & 1)
|
||||
if (rtnval & 1)
|
||||
{
|
||||
motor_info->status |= RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
if (plusdir == true)
|
||||
ls_active = true;
|
||||
}
|
||||
else
|
||||
motor_info->status &= ~RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 0;
|
||||
|
||||
if (status & 2)
|
||||
if (rtnval & 2)
|
||||
{
|
||||
motor_info->status |= RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
if (plusdir == false)
|
||||
ls_active = true;
|
||||
}
|
||||
else
|
||||
motor_info->status &= ~RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 0;
|
||||
|
||||
send_mess(card, "? ] 1", IM483PL_axis[signal]);
|
||||
recv_mess(card, buff, 1);
|
||||
status = buff[5];
|
||||
rtnval = buff[5];
|
||||
|
||||
if (status & 0x01)
|
||||
motor_info->status |= RA_HOME;
|
||||
else
|
||||
motor_info->status &= ~RA_HOME;
|
||||
status.Bits.RA_HOME = (rtnval & 0x01) ? 1 : 0;
|
||||
|
||||
/* !!! Assume no closed-looped control!!!*/
|
||||
motor_info->status &= ~EA_POSITION;
|
||||
status.Bits.EA_POSITION = 0;
|
||||
|
||||
/* encoder status */
|
||||
motor_info->status &= ~EA_SLIP;
|
||||
motor_info->status &= ~EA_SLIP_STALL;
|
||||
motor_info->status &= ~EA_HOME;
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_SLIP_STALL = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
|
||||
if (motor_state[card]->motor_info[signal].encoder_present == NO)
|
||||
motor_info->encoder_position = 0;
|
||||
@@ -355,21 +349,21 @@ STATIC int set_status(int card, int signal)
|
||||
motor_info->encoder_position = (int32_t) motorData;
|
||||
}
|
||||
|
||||
motor_info->status &= ~RA_PROBLEM;
|
||||
status.Bits.RA_PROBLEM = 0;
|
||||
|
||||
/* Parse motor velocity? */
|
||||
/* NEEDS WORK */
|
||||
|
||||
motor_info->velocity = 0;
|
||||
|
||||
if (!(motor_info->status & RA_DIRECTION))
|
||||
if (!status.Bits.RA_DIRECTION)
|
||||
motor_info->velocity *= -1;
|
||||
|
||||
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
|
||||
(motor_info->status & (RA_DONE | RA_PROBLEM))) ? 1 : 0;
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
|
||||
/* Test for post-move string. */
|
||||
if ((motor_info->status & RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
nodeptr->postmsgptr != 0)
|
||||
{
|
||||
strcpy(buff, nodeptr->postmsgptr);
|
||||
@@ -377,6 +371,8 @@ STATIC int set_status(int card, int signal)
|
||||
nodeptr->postmsgptr = NULL;
|
||||
}
|
||||
|
||||
exit:
|
||||
motor_info->status.All = status.All;
|
||||
return(rtn_state);
|
||||
}
|
||||
|
||||
@@ -586,21 +582,21 @@ STATIC int motor_init()
|
||||
struct mess_info *motor_info = &brdptr->motor_info[motor_index];
|
||||
int loop_state;
|
||||
|
||||
motor_info->status = 0;
|
||||
motor_info->status.All = 0;
|
||||
motor_info->no_motion_count = 0;
|
||||
motor_info->encoder_position = 0;
|
||||
motor_info->position = 0;
|
||||
brdptr->motor_info[motor_index].motor_motion = NULL;
|
||||
/* Assume encoder support, i.e., IM483IE. */
|
||||
motor_info->encoder_present = YES;
|
||||
motor_info->status |= EA_PRESENT;
|
||||
motor_info->status.Bits.EA_PRESENT = 1;
|
||||
|
||||
/* Determine if encoder present based on open/closed loop mode. */
|
||||
loop_state = 0;
|
||||
if (loop_state != 0)
|
||||
{
|
||||
motor_info->pid_present = YES;
|
||||
motor_info->status |= GAIN_SUPPORT;
|
||||
motor_info->status.Bits.GAIN_SUPPORT = 1;
|
||||
}
|
||||
|
||||
set_status(card_index, motor_index); /* Read status of each motor */
|
||||
|
||||
@@ -3,9 +3,9 @@ FILENAME... drvIM483SM.cc
|
||||
USAGE... Motor record driver level support for Intelligent Motion
|
||||
Systems, Inc. IM483(I/IE).
|
||||
|
||||
Version: $Revision: 1.5 $
|
||||
Version: $Revision: 1.6 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-11-07 22:27:00 $
|
||||
Last Modified: $Date: 2003-12-12 21:39:30 $
|
||||
*/
|
||||
|
||||
/*****************************************************************
|
||||
@@ -237,44 +237,44 @@ STATIC int set_status(int card, int signal)
|
||||
register struct mess_info *motor_info;
|
||||
/* Message parsing variables */
|
||||
char buff[BUFF_SIZE];
|
||||
int status;
|
||||
int rtn_state;
|
||||
int rtnval, rtn_state;
|
||||
double motorData;
|
||||
bool plusdir, ls_active = false;
|
||||
msta_field status;
|
||||
|
||||
cntrl = (struct IM483controller *) motor_state[card]->DevicePrivate;
|
||||
motor_info = &(motor_state[card]->motor_info[signal]);
|
||||
nodeptr = motor_info->motor_motion;
|
||||
status.All = motor_info->status.All;
|
||||
|
||||
send_mess(card, "^", (char) NULL);
|
||||
rtn_state = recv_mess(card, buff, 1);
|
||||
if (rtn_state > 0)
|
||||
{
|
||||
cntrl->status = NORMAL;
|
||||
motor_info->status &= ~CNTRL_COMM_ERR;
|
||||
status.Bits.CNTRL_COMM_ERR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cntrl->status == NORMAL)
|
||||
{
|
||||
cntrl->status = RETRY;
|
||||
return(0);
|
||||
rtn_state = 0;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
cntrl->status = COMM_ERR;
|
||||
motor_info->status |= CNTRL_COMM_ERR;
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
return(1);
|
||||
status.Bits.CNTRL_COMM_ERR = 1;
|
||||
status.Bits.RA_PROBLEM = 1;
|
||||
rtn_state = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
status = atoi(&buff[4]);
|
||||
rtnval = atoi(&buff[4]);
|
||||
|
||||
if (status != 0)
|
||||
motor_info->status &= ~RA_DONE;
|
||||
else
|
||||
motor_info->status |= RA_DONE;
|
||||
status.Bits.RA_DONE = (rtnval != 0) ? 0 : 1;
|
||||
|
||||
/*
|
||||
* Parse motor position
|
||||
@@ -294,55 +294,49 @@ STATIC int set_status(int card, int signal)
|
||||
epicsInt32 newposition;
|
||||
|
||||
newposition = NINT(motorData);
|
||||
if (newposition >= motor_info->position)
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
else
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
status.Bits.RA_DIRECTION = (newposition >= motor_info->position) ? 1 : 0;
|
||||
motor_info->position = newposition;
|
||||
motor_info->no_motion_count = 0;
|
||||
}
|
||||
|
||||
plusdir = (motor_info->status & RA_DIRECTION) ? true : false;
|
||||
plusdir = (status.Bits.RA_DIRECTION) ? true : false;
|
||||
|
||||
send_mess(card, "] 0", (char) NULL);
|
||||
recv_mess(card, buff, 1);
|
||||
status = atoi(&buff[5]);
|
||||
rtnval = atoi(&buff[5]);
|
||||
|
||||
/* Set limit switch error indicators. */
|
||||
if (status & 1)
|
||||
if (rtnval & 1)
|
||||
{
|
||||
motor_info->status |= RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
if (plusdir == true)
|
||||
ls_active = true;
|
||||
}
|
||||
else
|
||||
motor_info->status &= ~RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 0;
|
||||
|
||||
if (status & 2)
|
||||
if (rtnval & 2)
|
||||
{
|
||||
motor_info->status |= RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
if (plusdir == false)
|
||||
ls_active = true;
|
||||
}
|
||||
else
|
||||
motor_info->status &= ~RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 0;
|
||||
|
||||
send_mess(card, "] 1", (char) NULL);
|
||||
recv_mess(card, buff, 1);
|
||||
status = buff[5];
|
||||
rtnval = buff[5];
|
||||
|
||||
if (status & 0x01)
|
||||
motor_info->status |= RA_HOME;
|
||||
else
|
||||
motor_info->status &= ~RA_HOME;
|
||||
status.Bits.RA_HOME = (rtnval & 0x01) ? 1 : 0;
|
||||
|
||||
/* !!! Assume no closed-looped control!!!*/
|
||||
motor_info->status &= ~EA_POSITION;
|
||||
status.Bits.EA_POSITION = 0;
|
||||
|
||||
/* encoder status */
|
||||
motor_info->status &= ~EA_SLIP;
|
||||
motor_info->status &= ~EA_SLIP_STALL;
|
||||
motor_info->status &= ~EA_HOME;
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_SLIP_STALL = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
|
||||
if (motor_state[card]->motor_info[signal].encoder_present == NO)
|
||||
motor_info->encoder_position = 0;
|
||||
@@ -354,21 +348,21 @@ STATIC int set_status(int card, int signal)
|
||||
motor_info->encoder_position = (int32_t) motorData;
|
||||
}
|
||||
|
||||
motor_info->status &= ~RA_PROBLEM;
|
||||
status.Bits.RA_PROBLEM = 0;
|
||||
|
||||
/* Parse motor velocity? */
|
||||
/* NEEDS WORK */
|
||||
|
||||
motor_info->velocity = 0;
|
||||
|
||||
if (!(motor_info->status & RA_DIRECTION))
|
||||
if (!status.Bits.RA_DIRECTION)
|
||||
motor_info->velocity *= -1;
|
||||
|
||||
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
|
||||
(motor_info->status & (RA_DONE | RA_PROBLEM))) ? 1 : 0;
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
|
||||
/* Test for post-move string. */
|
||||
if ((motor_info->status & RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
nodeptr->postmsgptr != 0)
|
||||
{
|
||||
strcpy(buff, nodeptr->postmsgptr);
|
||||
@@ -376,6 +370,8 @@ STATIC int set_status(int card, int signal)
|
||||
nodeptr->postmsgptr = NULL;
|
||||
}
|
||||
|
||||
exit:
|
||||
motor_info->status.All = status.All;
|
||||
return(rtn_state);
|
||||
}
|
||||
|
||||
@@ -633,7 +629,7 @@ STATIC int motor_init()
|
||||
struct mess_info *motor_info = &brdptr->motor_info[motor_index];
|
||||
int loop_state;
|
||||
|
||||
motor_info->status = 0;
|
||||
motor_info->status.All = 0;
|
||||
motor_info->no_motion_count = 0;
|
||||
motor_info->encoder_position = 0;
|
||||
motor_info->position = 0;
|
||||
@@ -644,9 +640,9 @@ STATIC int motor_init()
|
||||
if (loop_state != 0)
|
||||
{
|
||||
motor_info->encoder_present = YES;
|
||||
motor_info->status |= EA_PRESENT;
|
||||
motor_info->status.Bits.EA_PRESENT = 1;
|
||||
motor_info->pid_present = YES;
|
||||
motor_info->status |= GAIN_SUPPORT;
|
||||
motor_info->status.Bits.GAIN_SUPPORT = 1;
|
||||
}
|
||||
|
||||
set_status(card_index, motor_index); /* Read status of each motor */
|
||||
|
||||
@@ -3,9 +3,9 @@ FILENAME... drvMDrive.cc
|
||||
USAGE... Motor record driver level support for Intelligent Motion
|
||||
Systems, Inc. IM483(I/IE).
|
||||
|
||||
Version: $Revision: 1.6 $
|
||||
Version: $Revision: 1.7 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-11-07 22:26:59 $
|
||||
Last Modified: $Date: 2003-12-12 21:39:31 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -260,45 +260,45 @@ STATIC int set_status(int card, int signal)
|
||||
register struct mess_info *motor_info;
|
||||
/* Message parsing variables */
|
||||
char buff[BUFF_SIZE];
|
||||
int status;
|
||||
int rtn_state;
|
||||
int rtnval, rtn_state;
|
||||
double motorData;
|
||||
SINPUTS inputs;
|
||||
bool plusdir, ls_active = false;
|
||||
msta_field status;
|
||||
|
||||
cntrl = (struct IM483controller *) motor_state[card]->DevicePrivate;
|
||||
motor_info = &(motor_state[card]->motor_info[signal]);
|
||||
nodeptr = motor_info->motor_motion;
|
||||
status.All = motor_info->status.All;
|
||||
|
||||
send_mess(card, "? PR MV", MDrive_axis[signal]);
|
||||
rtn_state = recv_mess(card, buff, 1);
|
||||
if (rtn_state > 0)
|
||||
{
|
||||
cntrl->status = NORMAL;
|
||||
motor_info->status &= ~CNTRL_COMM_ERR;
|
||||
status.Bits.CNTRL_COMM_ERR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cntrl->status == NORMAL)
|
||||
{
|
||||
cntrl->status = RETRY;
|
||||
return(OK);
|
||||
rtn_state = OK;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
cntrl->status = COMM_ERR;
|
||||
motor_info->status |= CNTRL_COMM_ERR;
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
return(1);
|
||||
status.Bits.CNTRL_COMM_ERR = 1;
|
||||
status.Bits.RA_PROBLEM = 1;
|
||||
rtn_state = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
status = atoi(buff);
|
||||
rtnval = atoi(buff);
|
||||
|
||||
if (status != 0)
|
||||
motor_info->status &= ~RA_DONE;
|
||||
else
|
||||
motor_info->status |= RA_DONE;
|
||||
status.Bits.RA_DONE = (rtnval != 0) ? 0 : 1;
|
||||
|
||||
/*
|
||||
* Parse motor position
|
||||
@@ -318,15 +318,12 @@ STATIC int set_status(int card, int signal)
|
||||
epicsInt32 newposition;
|
||||
|
||||
newposition = NINT(motorData);
|
||||
if (newposition >= motor_info->position)
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
else
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
status.Bits.RA_DIRECTION = (newposition >= motor_info->position) ? 1 : 0;
|
||||
motor_info->position = newposition;
|
||||
motor_info->no_motion_count = 0;
|
||||
}
|
||||
|
||||
plusdir = (motor_info->status & RA_DIRECTION) ? true : false;
|
||||
plusdir = (status.Bits.RA_DIRECTION) ? true : false;
|
||||
|
||||
send_mess(card, "? PR IN", MDrive_axis[signal]);
|
||||
recv_mess(card, buff, 1);
|
||||
@@ -335,35 +332,31 @@ STATIC int set_status(int card, int signal)
|
||||
/* Set limit switch error indicators. */
|
||||
if (inputs.Bits.ls_plus == 0)
|
||||
{
|
||||
motor_info->status |= RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
if (plusdir == true)
|
||||
ls_active = true;
|
||||
}
|
||||
else
|
||||
motor_info->status &= ~RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 0;
|
||||
|
||||
if (inputs.Bits.ls_minus == 0)
|
||||
{
|
||||
motor_info->status |= RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
if (plusdir == false)
|
||||
ls_active = true;
|
||||
}
|
||||
else
|
||||
motor_info->status &= ~RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 0;
|
||||
|
||||
|
||||
if (inputs.Bits.homels == 0)
|
||||
motor_info->status |= RA_HOME;
|
||||
else
|
||||
motor_info->status &= ~RA_HOME;
|
||||
status.Bits.RA_HOME = (inputs.Bits.homels) ? 1 : 0;
|
||||
|
||||
/* !!! Assume no closed-looped control!!!*/
|
||||
motor_info->status &= ~EA_POSITION;
|
||||
status.Bits.EA_POSITION = 0;
|
||||
|
||||
/* encoder status */
|
||||
motor_info->status &= ~EA_SLIP;
|
||||
motor_info->status &= ~EA_SLIP_STALL;
|
||||
motor_info->status &= ~EA_HOME;
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_SLIP_STALL = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
|
||||
if (motor_state[card]->motor_info[signal].encoder_present == NO)
|
||||
motor_info->encoder_position = 0;
|
||||
@@ -375,21 +368,21 @@ STATIC int set_status(int card, int signal)
|
||||
motor_info->encoder_position = (int32_t) motorData;
|
||||
}
|
||||
|
||||
motor_info->status &= ~RA_PROBLEM;
|
||||
status.Bits.RA_PROBLEM = 0;
|
||||
|
||||
/* Parse motor velocity? */
|
||||
/* NEEDS WORK */
|
||||
|
||||
motor_info->velocity = 0;
|
||||
|
||||
if (!(motor_info->status & RA_DIRECTION))
|
||||
if (!status.Bits.RA_DIRECTION)
|
||||
motor_info->velocity *= -1;
|
||||
|
||||
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
|
||||
(motor_info->status & (RA_DONE | RA_PROBLEM))) ? 1 : 0;
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
|
||||
/* Test for post-move string. */
|
||||
if ((motor_info->status & RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
nodeptr->postmsgptr != 0)
|
||||
{
|
||||
strcpy(buff, nodeptr->postmsgptr);
|
||||
@@ -397,6 +390,8 @@ STATIC int set_status(int card, int signal)
|
||||
nodeptr->postmsgptr = NULL;
|
||||
}
|
||||
|
||||
exit:
|
||||
motor_info->status.All = status.All;
|
||||
return(rtn_state);
|
||||
}
|
||||
|
||||
@@ -621,7 +616,7 @@ STATIC int motor_init()
|
||||
struct mess_info *motor_info = &brdptr->motor_info[motor_index];
|
||||
int loop_state;
|
||||
|
||||
motor_info->status = 0;
|
||||
motor_info->status.All = 0;
|
||||
motor_info->no_motion_count = 0;
|
||||
motor_info->encoder_position = 0;
|
||||
motor_info->position = 0;
|
||||
@@ -634,7 +629,7 @@ STATIC int motor_init()
|
||||
if (loop_state != 0)
|
||||
{
|
||||
motor_info->pid_present = YES;
|
||||
motor_info->status |= GAIN_SUPPORT;
|
||||
motor_info->status.Bits.GAIN_SUPPORT = 1;
|
||||
}
|
||||
|
||||
set_status(card_index, motor_index); /* Read status of each motor */
|
||||
|
||||
@@ -208,75 +208,72 @@ STATIC int set_status(int card, int signal)
|
||||
char buff[BUFF_SIZE];
|
||||
bool ls_active = false;
|
||||
struct PM304controller *cntrl;
|
||||
msta_field status;
|
||||
|
||||
cntrl = (struct PM304controller *) motor_state[card]->DevicePrivate;
|
||||
|
||||
motor_info = &(motor_state[card]->motor_info[signal]);
|
||||
nodeptr = motor_info->motor_motion;
|
||||
status.All = motor_info->status.All;
|
||||
|
||||
/* Request the status of this motor */
|
||||
sprintf(command, "%dOS;", signal+1);
|
||||
send_recv_mess(card, command, response);
|
||||
Debug(2, "set_status, status query, card %d, response=%s\n", card, response);
|
||||
|
||||
status.Bits.RA_PLUS_LS = 0;
|
||||
status.Bits.RA_MINUS_LS = 0;
|
||||
|
||||
if (cntrl->model == MODEL_PM304) {
|
||||
/* The response string is an eight character string of ones and zeroes */
|
||||
|
||||
if (strcmp(response, "00000000") == 0)
|
||||
motor_info->status &= ~RA_DONE;
|
||||
status.Bits.RA_DONE = 0;
|
||||
else {
|
||||
motor_info->status |= RA_DONE;
|
||||
status.Bits.RA_DONE = 1;
|
||||
if (drvPM304ReadbackDelay != 0.)
|
||||
epicsThreadSleep(drvPM304ReadbackDelay);
|
||||
}
|
||||
|
||||
if (response[2] == '1')
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
else
|
||||
motor_info->status &= ~RA_PROBLEM;
|
||||
status.Bits.RA_PROBLEM = (response[2] == '1') ? 1 : 0;
|
||||
|
||||
motor_info->status &= ~(RA_PLUS_LS | RA_MINUS_LS);
|
||||
if (response[1] == '1') {
|
||||
motor_info->status |= RA_PLUS_LS;
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
ls_active = true;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
status.Bits.RA_DIRECTION = 1;
|
||||
ls_active = true;
|
||||
}
|
||||
if (response[0] == '1') {
|
||||
motor_info->status |= RA_MINUS_LS;
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
ls_active = true;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
status.Bits.RA_DIRECTION = 0;
|
||||
ls_active = true;
|
||||
}
|
||||
} else {
|
||||
/* The response string is 01: followed by an eight character string of ones and zeroes */
|
||||
strcpy(response, &response[3]);
|
||||
if (response[0] == '0')
|
||||
motor_info->status &= ~RA_DONE;
|
||||
status.Bits.RA_DONE = 0;
|
||||
else {
|
||||
motor_info->status |= RA_DONE;
|
||||
status.Bits.RA_DONE = 1;
|
||||
if (drvPM304ReadbackDelay != 0.)
|
||||
epicsThreadSleep(drvPM304ReadbackDelay);
|
||||
}
|
||||
|
||||
if (response[1] == '1')
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
else
|
||||
motor_info->status &= ~RA_PROBLEM;
|
||||
status.Bits.RA_PROBLEM = (response[1] == '1') ? 1 : 0;
|
||||
|
||||
motor_info->status &= ~(RA_PLUS_LS | RA_MINUS_LS);
|
||||
if (response[2] == '1') {
|
||||
motor_info->status |= RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
}
|
||||
if (response[3] == '1') {
|
||||
motor_info->status |= RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* encoder status */
|
||||
motor_info->status &= ~EA_SLIP;
|
||||
motor_info->status &= ~EA_POSITION;
|
||||
motor_info->status &= ~EA_SLIP_STALL;
|
||||
motor_info->status &= ~EA_HOME;
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_POSITION = 0;
|
||||
status.Bits.EA_SLIP_STALL = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
|
||||
/* Request the position of this motor */
|
||||
if (cntrl->use_encoder[signal]) {
|
||||
@@ -293,10 +290,7 @@ STATIC int set_status(int card, int signal)
|
||||
motor_info->no_motion_count++;
|
||||
else
|
||||
{
|
||||
if (motorData >= motor_info->position)
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
else
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
status.Bits.RA_DIRECTION = (motorData >= motor_info->position) ? 1 : 0;
|
||||
motor_info->position = motorData;
|
||||
motor_info->encoder_position = motorData;
|
||||
motor_info->no_motion_count = 0;
|
||||
@@ -307,14 +301,14 @@ STATIC int set_status(int card, int signal)
|
||||
|
||||
motor_info->velocity = 0;
|
||||
|
||||
if (!(motor_info->status & RA_DIRECTION))
|
||||
if (!status.Bits.RA_DIRECTION)
|
||||
motor_info->velocity *= -1;
|
||||
|
||||
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
|
||||
(motor_info->status & (RA_DONE | RA_PROBLEM))) ? 1 : 0;
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
|
||||
/* Test for post-move string. */
|
||||
if ((motor_info->status & RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
nodeptr->postmsgptr != 0)
|
||||
{
|
||||
strcpy(buff, nodeptr->postmsgptr);
|
||||
@@ -323,6 +317,7 @@ STATIC int set_status(int card, int signal)
|
||||
nodeptr->postmsgptr = NULL;
|
||||
}
|
||||
|
||||
motor_info->status.All = status.All;
|
||||
Debug(2, "set_status, return value=%d\n", rtn_state);
|
||||
return (rtn_state);
|
||||
}
|
||||
@@ -652,7 +647,7 @@ STATIC int motor_init()
|
||||
struct mess_info *motor_info = &brdptr->motor_info[motor_index];
|
||||
|
||||
motor_info->motor_motion = NULL;
|
||||
motor_info->status = 0;
|
||||
motor_info->status.All = 0;
|
||||
motor_info->no_motion_count = 0;
|
||||
motor_info->encoder_position = 0;
|
||||
motor_info->position = 0;
|
||||
|
||||
+57
-27
@@ -3,9 +3,9 @@ FILENAME... motor.h
|
||||
USAGE... Definitions and structures common to all levels of motorRecord
|
||||
support (i.e., record, device and driver).
|
||||
|
||||
Version: $Revision: 1.9 $
|
||||
Version: $Revision: 1.10 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-06-06 21:09:09 $
|
||||
Last Modified: $Date: 2003-12-12 21:36:37 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -36,7 +36,9 @@ Last Modified: $Date: 2003-06-06 21:09:09 $
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
*
|
||||
* .01 10-21-02 rls Convert to R3.14.x and C++.
|
||||
* .01 10-21-02 rls - Convert to R3.14.x and C++.
|
||||
* .02 12-12-03 rls - Added MAX_SCAN_RATE.
|
||||
* - Converted MSTA #define's to bit field.
|
||||
*/
|
||||
|
||||
#ifndef INCmotorh
|
||||
@@ -99,30 +101,65 @@ enum motor_cmnd {
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/* driver and device support parameters */
|
||||
#define SCAN_RATE 6 /* 60=once a second */
|
||||
#define MAX_COUNT 50000 /*19000*/ /* timeout value */
|
||||
#define MAX_SCAN_RATE 60 /* Maximum polling rate in HZ. */
|
||||
#define SCAN_RATE 6 /* Default polling rate in HZ. */
|
||||
#define MAX_COUNT 50000 /*19000*/ /* timeout value */
|
||||
#define MAX_AXIS 10 /* max number of axis per board */
|
||||
|
||||
#define NO 0
|
||||
#define YES 1
|
||||
|
||||
// Define, from top to bottom, how bit fields are packed.
|
||||
// This works for SunPro,
|
||||
#if #cpu(i386) && !#cpu(sparc)
|
||||
#define LSB_First (TRUE) // LSB is packed first.
|
||||
#else
|
||||
#define MSB_First (TRUE) // MSB is packed first.
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* axis and encoder status for return to requester */
|
||||
#define RA_DIRECTION 0x01 /* (last) 0=Negative, 1=Positive */
|
||||
#define RA_DONE 0x02 /* a motion is complete */
|
||||
#define RA_PLUS_LS 0x04 /* plus limit switch has been hit */
|
||||
#define RA_HOME 0x08 /* The home signal is on */
|
||||
#define EA_SLIP 0x10 /* encoder slip enabled */
|
||||
#define EA_POSITION 0x20 /* position maintenence enabled */
|
||||
#define EA_SLIP_STALL 0x40 /* slip/stall detected */
|
||||
#define EA_HOME 0x80 /* encoder home signal on */
|
||||
#define EA_PRESENT 0x100 /* encoder is present */
|
||||
#define RA_PROBLEM 0x200 /* driver stopped polling */
|
||||
#define RA_MOVING 0x400 /* non-zero velocity present */
|
||||
#define GAIN_SUPPORT 0x800 /* Motor supports closed-loop position
|
||||
control. */
|
||||
#define CNTRL_COMM_ERR 0x1000 /* Controller communication error. */
|
||||
#define RA_MINUS_LS 0x2000 /* minus limit switch has been hit */
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned long All;
|
||||
struct
|
||||
{
|
||||
#ifdef MSB_First
|
||||
unsigned int na :18;/* N/A bits */
|
||||
unsigned int RA_MINUS_LS :1; /* minus limit switch has been hit */
|
||||
unsigned int CNTRL_COMM_ERR :1; /* Controller communication error. */
|
||||
unsigned int GAIN_SUPPORT :1; /* Motor supports closed-loop position control. */
|
||||
unsigned int RA_MOVING :1; /* non-zero velocity present */
|
||||
unsigned int RA_PROBLEM :1; /* driver stopped polling */
|
||||
unsigned int EA_PRESENT :1; /* encoder is present */
|
||||
unsigned int EA_HOME :1; /* encoder home signal on */
|
||||
unsigned int EA_SLIP_STALL :1; /* slip/stall detected */
|
||||
unsigned int EA_POSITION :1; /* position maintenence enabled */
|
||||
unsigned int EA_SLIP :1; /* encoder slip enabled */
|
||||
unsigned int RA_HOME :1; /* The home signal is on */
|
||||
unsigned int RA_PLUS_LS :1; /* plus limit switch has been hit */
|
||||
unsigned int RA_DONE :1; /* a motion is complete */
|
||||
unsigned int RA_DIRECTION :1; /* (last) 0=Negative, 1=Positive */
|
||||
#else
|
||||
unsigned int RA_DIRECTION :1; /* (last) 0=Negative, 1=Positive */
|
||||
unsigned int RA_DONE :1; /* a motion is complete */
|
||||
unsigned int RA_PLUS_LS :1; /* plus limit switch has been hit */
|
||||
unsigned int RA_HOME :1; /* The home signal is on */
|
||||
unsigned int EA_SLIP :1; /* encoder slip enabled */
|
||||
unsigned int EA_POSITION :1; /* position maintenence enabled */
|
||||
unsigned int EA_SLIP_STALL :1; /* slip/stall detected */
|
||||
unsigned int EA_HOME :1; /* encoder home signal on */
|
||||
unsigned int EA_PRESENT :1; /* encoder is present */
|
||||
unsigned int RA_PROBLEM :1; /* driver stopped polling */
|
||||
unsigned int RA_MOVING :1; /* non-zero velocity present */
|
||||
unsigned int GAIN_SUPPORT :1; /* Motor supports closed-loop position control. */
|
||||
unsigned int CNTRL_COMM_ERR :1; /* Controller communication error. */
|
||||
unsigned int RA_MINUS_LS :1; /* minus limit switch has been hit */
|
||||
unsigned int na :18;/* N/A bits */
|
||||
#endif
|
||||
} Bits;
|
||||
} msta_field;
|
||||
|
||||
/*
|
||||
The RA_PROBLEM status bit indicates that the driver has stopped the polling
|
||||
@@ -143,13 +180,6 @@ struct motor_dset
|
||||
RTN_STATUS (*end_trans) (struct motorRecord *);
|
||||
};
|
||||
|
||||
// Define, from top to bottom, how bit fields are packed.
|
||||
// This works for SunPro,
|
||||
#if #cpu(i386) && !#cpu(sparc)
|
||||
#define LSB_First (TRUE) // LSB is packed first.
|
||||
#else
|
||||
#define MSB_First (TRUE) // MSB is packed first.
|
||||
#endif
|
||||
|
||||
/* All db_post_events() calls set both VALUE and LOG bits. */
|
||||
#define DBE_VAL_LOG (unsigned int) (DBE_VALUE | DBE_LOG)
|
||||
|
||||
@@ -3,9 +3,9 @@ FILENAME: motordevCom.c
|
||||
USAGE... This file contains device functions that are common to all motor
|
||||
record device support modules.
|
||||
|
||||
Version: $Revision: 1.4 $
|
||||
Version: $Revision: 1.5 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-06-16 15:08:24 $
|
||||
Last Modified: $Date: 2003-12-12 21:38:42 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -181,6 +181,7 @@ long motor_init_record_com(struct motorRecord *mr, int brdcnt, struct driver_tab
|
||||
struct mess_node *motor_call;
|
||||
double ep_mp[2]; /* encoder pulses, motor pulses */
|
||||
int rtnStat;
|
||||
msta_field msta;
|
||||
|
||||
/* allocate space for private field - an motor_trans structure */
|
||||
mr->dpvt = (struct motor_trans *) malloc(sizeof(struct motor_trans));
|
||||
@@ -236,7 +237,9 @@ long motor_init_record_com(struct motorRecord *mr, int brdcnt, struct driver_tab
|
||||
if (rtnStat)
|
||||
{
|
||||
/* Initialize readback fields for simulation */
|
||||
mr->msta = RA_PROBLEM;
|
||||
msta.All = 0;
|
||||
msta.Bits.RA_PROBLEM = 1;
|
||||
mr->msta = msta.All;
|
||||
mr->rmp = 0; /* raw motor pulse count */
|
||||
mr->rep = 0; /* raw encoder pulse count */
|
||||
return(rtnStat);
|
||||
@@ -244,7 +247,7 @@ long motor_init_record_com(struct motorRecord *mr, int brdcnt, struct driver_tab
|
||||
|
||||
/* query motor for all info to fill into record */
|
||||
(tabptr->get_axis_info) (card, signal, &axis_query, tabptr);
|
||||
mr->msta = axis_query.status; /* status info */
|
||||
msta.All = mr->msta = axis_query.status.All; /* status info */
|
||||
brdptr->axis_stat[signal].in_use = true;
|
||||
|
||||
/*jps: setting the encoder ratio was moved from init_record() remove callbacks during iocInit */
|
||||
@@ -254,7 +257,7 @@ long motor_init_record_com(struct motorRecord *mr, int brdcnt, struct driver_tab
|
||||
* per engineering unit (EGU). Send an array containing this information
|
||||
* to device support.
|
||||
*/
|
||||
initEncoder = ((mr->msta & EA_PRESENT) && mr->ueip) ? true : false;
|
||||
initEncoder = (msta.Bits.EA_PRESENT && mr->ueip) ? true : false;
|
||||
if (initEncoder == true)
|
||||
{
|
||||
if (fabs(mr->mres) < 1.e-9)
|
||||
@@ -333,7 +336,7 @@ long motor_init_record_com(struct motorRecord *mr, int brdcnt, struct driver_tab
|
||||
|
||||
mr->rmp = axis_query.position; /* raw motor pulse count */
|
||||
mr->rep = axis_query.encoder_position; /* raw encoder pulse count */
|
||||
mr->msta = axis_query.status; /* status info */
|
||||
mr->msta = axis_query.status.All; /* status info */
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@@ -363,7 +366,7 @@ CALLBACK_VALUE motor_update_values(struct motorRecord * mr)
|
||||
mr->rmp = ptrans->motor_pos;
|
||||
mr->rep = ptrans->encoder_pos;
|
||||
mr->rvel = ptrans->vel;
|
||||
mr->msta = ptrans->status;
|
||||
mr->msta = ptrans->status.All;
|
||||
ptrans->callback_changed = NO;
|
||||
rc = CALLBACK_DATA;
|
||||
}
|
||||
@@ -425,12 +428,16 @@ RTN_STATUS motor_end_trans_com(struct motorRecord *mr, struct driver_table *tabp
|
||||
motor_call = &(trans->motor_call);
|
||||
if ((*trans->tabptr->card_array)[motor_call->card] == NULL)
|
||||
{
|
||||
msta_field msta;
|
||||
|
||||
/* If the controller does not exits, then set "done moving"
|
||||
* and communication error TRUE.
|
||||
*/
|
||||
mr->dmov = TRUE;
|
||||
db_post_events(mr, &mr->dmov, DBE_VAL_LOG);
|
||||
mr->msta |= CNTRL_COMM_ERR;
|
||||
msta.All = mr->msta;
|
||||
msta.Bits.CNTRL_COMM_ERR = 1;
|
||||
mr->msta = msta.All;
|
||||
return(rc = ERROR);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ FILENAME... motordevCom.h
|
||||
USAGE... This file contains definitions and structures that
|
||||
are common to all motor record device support modules.
|
||||
|
||||
Version: $Revision: 1.4 $
|
||||
Version: $Revision: 1.5 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2002-10-31 20:41:29 $
|
||||
Last Modified: $Date: 2003-12-12 21:36:38 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -26,6 +26,7 @@ Last Modified: $Date: 2002-10-31 20:41:29 $
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* .01 12-12-03 rls - Converted MSTA #define's to bit field.
|
||||
*/
|
||||
|
||||
|
||||
@@ -64,7 +65,7 @@ struct motor_trans
|
||||
int motor_pos;
|
||||
int encoder_pos;
|
||||
int vel;
|
||||
unsigned long status;
|
||||
msta_field status;
|
||||
epicsEvent *initSem;
|
||||
struct driver_table *tabptr;
|
||||
bool dpm; /* For OMS VME58 only, drive power monitoring. */
|
||||
|
||||
@@ -3,9 +3,9 @@ FILENAME... motordrvCom.cc
|
||||
USAGE... This file contains driver functions that are common
|
||||
to all motor record driver modules.
|
||||
|
||||
Version: $Revision: 1.6 $
|
||||
Version: $Revision: 1.7 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-11-06 21:21:57 $
|
||||
Last Modified: $Date: 2003-12-12 21:38:43 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -191,24 +191,24 @@ static int query_axis(int card, struct driver_table *tabptr, epicsTime tick)
|
||||
mess_ret->status = motor_motion->status;
|
||||
mess_ret->type = motor_motion->type;
|
||||
|
||||
if (motor_motion->status & RA_DIRECTION)
|
||||
if (motor_motion->status.Bits.RA_DIRECTION)
|
||||
{
|
||||
if (motor_motion->status & RA_PLUS_LS)
|
||||
if (motor_motion->status.Bits.RA_PLUS_LS)
|
||||
ls_active = true;
|
||||
else
|
||||
ls_active = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (motor_motion->status & RA_MINUS_LS)
|
||||
if (motor_motion->status.Bits.RA_MINUS_LS)
|
||||
ls_active = true;
|
||||
else
|
||||
ls_active = false;
|
||||
}
|
||||
|
||||
if (ls_active == true ||
|
||||
motor_motion->status & RA_DONE ||
|
||||
motor_motion->status & RA_PROBLEM)
|
||||
motor_motion->status.Bits.RA_DONE ||
|
||||
motor_motion->status.Bits.RA_PROBLEM)
|
||||
{
|
||||
(*tabptr->query_done) (card, index, motor_motion);
|
||||
brdptr->motor_in_motion--;
|
||||
@@ -330,9 +330,9 @@ static void process_messages(struct driver_table *tabptr, epicsTime tick)
|
||||
* and this we can tell by looking for a struct motor_motion.
|
||||
==============================================================================*/
|
||||
if (motor_motion)
|
||||
node->status &= ~RA_DONE;
|
||||
node->status.Bits.RA_DONE = 0;
|
||||
else
|
||||
node->status |= RA_DONE;
|
||||
node->status.Bits.RA_DONE = 1;
|
||||
|
||||
callbackRequest((CALLBACK *) node);
|
||||
break;
|
||||
@@ -360,7 +360,8 @@ static void process_messages(struct driver_table *tabptr, epicsTime tick)
|
||||
node->position = 0;
|
||||
node->encoder_position = 0;
|
||||
node->velocity = 0;
|
||||
node->status = RA_PROBLEM;
|
||||
node->status.All = 0;
|
||||
node->status.Bits.RA_PROBLEM = 1;
|
||||
callbackRequest((CALLBACK *) node);
|
||||
}
|
||||
}
|
||||
@@ -419,7 +420,7 @@ RTN_STATUS motor_send(struct mess_node *u_msg, struct driver_table *tabptr)
|
||||
new_message->signal = u_msg->signal;
|
||||
new_message->card = u_msg->card;
|
||||
new_message->mrecord = u_msg->mrecord;
|
||||
new_message->status = 0;
|
||||
new_message->status.All = 0;
|
||||
strcpy(new_message->message, u_msg->message);
|
||||
new_message->postmsgptr = u_msg->postmsgptr;
|
||||
new_message->termstring = u_msg->termstring;
|
||||
@@ -556,7 +557,8 @@ int motor_axis_info(int card, int signal, MOTOR_AXIS_QUERY * aq, struct driver_t
|
||||
else
|
||||
{
|
||||
aq->position = aq->encoder_position = 0;
|
||||
aq->status = RA_PROBLEM;
|
||||
aq->status.All = 0;
|
||||
aq->status.Bits.RA_PROBLEM = 1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
@@ -4,9 +4,9 @@ FILENAME... motordrvCom.h
|
||||
USAGE... This file contains definitions and structures that
|
||||
are common to all motor record driver support modules.
|
||||
|
||||
Version: $Revision: 1.12 $
|
||||
Version: $Revision: 1.13 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-10-28 16:31:29 $
|
||||
Last Modified: $Date: 2003-12-12 21:36:40 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -38,6 +38,7 @@ Last Modified: $Date: 2003-10-28 16:31:29 $
|
||||
* -----------------
|
||||
* .01 10-02-01 rls added RETRY to CommStatus enumeration.
|
||||
* .02 10-24-03 rls moved irqdatastr to OmsSrc.
|
||||
* .03 12-12-03 rls Converted MSTA #define's to bit field.
|
||||
*/
|
||||
|
||||
|
||||
@@ -51,6 +52,8 @@ Last Modified: $Date: 2003-10-28 16:31:29 $
|
||||
#include <epicsRingPointer.h>
|
||||
#include <epicsMessageQueue.h>
|
||||
|
||||
#include "motor.h"
|
||||
|
||||
#define MAX_IDENT_LEN 100
|
||||
|
||||
/* Controller communication port type, followed by status. */
|
||||
@@ -107,7 +110,7 @@ struct mess_node
|
||||
long position;
|
||||
long encoder_position;
|
||||
long velocity;
|
||||
unsigned long status;
|
||||
msta_field status;
|
||||
struct dbCommon *mrecord; /* "Hidden" pointer to motor record. */
|
||||
struct mess_node *next;
|
||||
char *postmsgptr;
|
||||
@@ -126,7 +129,7 @@ typedef struct mess_axis_query
|
||||
{
|
||||
long position;
|
||||
long encoder_position;
|
||||
unsigned long status;
|
||||
msta_field status;
|
||||
} MOTOR_AXIS_QUERY;
|
||||
|
||||
struct axis_status
|
||||
@@ -155,7 +158,7 @@ struct mess_info
|
||||
int no_motion_count;
|
||||
epicsTime status_delay; /* Insure 10ms delay between motion/velocity
|
||||
* commands and status query. */
|
||||
unsigned long status; /* one pos for each axis */
|
||||
msta_field status; /* one pos for each axis */
|
||||
int pid_present; /* PID control indicator for VME58 (YES/NO). */
|
||||
double high_limit; /* MM4000 only; Controller's high travel limit. */
|
||||
double low_limit; /* MM4000 only; Controller's low travel limit. */
|
||||
@@ -204,7 +207,7 @@ struct driver_table
|
||||
|
||||
struct thread_args
|
||||
{
|
||||
int motor_scan_rate;
|
||||
int motor_scan_rate; /* Poll rate in HZ. */
|
||||
struct driver_table *table;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
FILENAME... drvESP300.cc
|
||||
USAGE... Motor record driver level support for Newport ESP300.
|
||||
|
||||
Version: $Revision: 1.5 $
|
||||
Version: $Revision: 1.6 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-11-07 22:21:50 $
|
||||
Last Modified: $Date: 2003-12-12 21:40:23 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -215,10 +215,12 @@ static int set_status(int card, int signal)
|
||||
long mstatus;
|
||||
double motorData;
|
||||
bool power, done, plusdir, ls_active = false;
|
||||
msta_field status;
|
||||
|
||||
cntrl = (struct MMcontroller *) motor_state[card]->DevicePrivate;
|
||||
motor_info = &(motor_state[card]->motor_info[signal]);
|
||||
nodeptr = motor_info->motor_motion;
|
||||
status.All = motor_info->status.All;
|
||||
|
||||
sprintf(outbuff, "%.2dMD", signal + 1);
|
||||
send_mess(card, outbuff, (char) NULL);
|
||||
@@ -226,29 +228,28 @@ static int set_status(int card, int signal)
|
||||
if (charcnt == 3)
|
||||
{
|
||||
cntrl->status = NORMAL;
|
||||
motor_info->status &= ~CNTRL_COMM_ERR;
|
||||
status.Bits.CNTRL_COMM_ERR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cntrl->status == NORMAL)
|
||||
{
|
||||
cntrl->status = RETRY;
|
||||
return(0);
|
||||
rtn_state = 0;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
cntrl->status = COMM_ERR;
|
||||
motor_info->status |= CNTRL_COMM_ERR;
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
return(1);
|
||||
status.Bits.CNTRL_COMM_ERR = 1;
|
||||
status.Bits.RA_PROBLEM = 1;
|
||||
rtn_state = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
done = atoi(inbuff) ? true : false;
|
||||
if (done == true)
|
||||
motor_info->status |= RA_DONE;
|
||||
else
|
||||
motor_info->status &= ~RA_DONE;
|
||||
status.Bits.RA_DONE = (done == true) ? 1 : 0;
|
||||
|
||||
/* Get motor position. */
|
||||
sprintf(outbuff, READ_POSITION, signal + 1);
|
||||
@@ -264,16 +265,12 @@ static int set_status(int card, int signal)
|
||||
epicsInt32 newposition;
|
||||
|
||||
newposition = NINT(motorData);
|
||||
if (newposition >= motor_info->position)
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
else
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
status.Bits.RA_DIRECTION = (newposition >= motor_info->position) ? 1 : 0;
|
||||
motor_info->position = newposition;
|
||||
motor_info->no_motion_count = 0;
|
||||
}
|
||||
|
||||
plusdir = (motor_info->status & RA_DIRECTION) ? true : false;
|
||||
|
||||
plusdir = (status.Bits.RA_DIRECTION) ? true : false;
|
||||
|
||||
/* Get travel limit switch status. */
|
||||
sprintf(outbuff, "%.2dPH", signal + 1);
|
||||
@@ -283,25 +280,26 @@ static int set_status(int card, int signal)
|
||||
if (cptr == NULL)
|
||||
{
|
||||
Debug(2, "set_status(): PH error = %s\n", inbuff);
|
||||
return(1);
|
||||
rtn_state = 1;
|
||||
goto exit;
|
||||
}
|
||||
mstatus = strtol(inbuff, &cptr, 16);
|
||||
|
||||
/* Set Travel limit switch status bits. */
|
||||
if (((mstatus >> signal) & 0x01) == false)
|
||||
motor_info->status &= ~RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 0;
|
||||
else
|
||||
{
|
||||
motor_info->status |= RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
if (plusdir == true)
|
||||
ls_active = true;
|
||||
}
|
||||
|
||||
if (((mstatus >> (signal + 8)) & 0x01) == false)
|
||||
motor_info->status &= ~RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 0;
|
||||
else
|
||||
{
|
||||
motor_info->status |= RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
if (plusdir == false)
|
||||
ls_active = true;
|
||||
}
|
||||
@@ -311,10 +309,7 @@ static int set_status(int card, int signal)
|
||||
tok_save = strchr(inbuff, 'H');
|
||||
mstatus = strtol(cptr, &tok_save, 16);
|
||||
|
||||
if (((mstatus >> signal) & 0x01) == false)
|
||||
motor_info->status &= ~RA_HOME;
|
||||
else
|
||||
motor_info->status |= RA_HOME;
|
||||
status.Bits.RA_HOME = ((mstatus >> signal) & 0x01) ? 1 : 0;
|
||||
|
||||
/* Get motor power on/off status. */
|
||||
sprintf(outbuff, "%.2dMO?", signal + 1);
|
||||
@@ -322,30 +317,27 @@ static int set_status(int card, int signal)
|
||||
charcnt = recv_mess(card, inbuff, 1);
|
||||
power = atoi(inbuff) ? true : false;
|
||||
|
||||
if (power == true)
|
||||
motor_info->status |= EA_POSITION;
|
||||
else
|
||||
motor_info->status &= ~EA_POSITION;
|
||||
status.Bits.EA_POSITION = (power == true) ? 1 : 0;
|
||||
|
||||
/* encoder status */
|
||||
motor_info->status &= ~EA_SLIP;
|
||||
motor_info->status &= ~EA_SLIP_STALL;
|
||||
motor_info->status &= ~EA_HOME;
|
||||
motor_info->status &= ~RA_PROBLEM;
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_SLIP_STALL = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
status.Bits.RA_PROBLEM = 0;
|
||||
|
||||
/* Parse motor velocity? */
|
||||
/* NEEDS WORK */
|
||||
|
||||
motor_info->velocity = 0;
|
||||
|
||||
if (!(motor_info->status & RA_DIRECTION))
|
||||
if (!status.Bits.RA_DIRECTION)
|
||||
motor_info->velocity *= -1;
|
||||
|
||||
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
|
||||
(motor_info->status & (RA_DONE | RA_PROBLEM))) ? 1 : 0;
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
|
||||
/* Test for post-move string. */
|
||||
if ((motor_info->status & RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
nodeptr->postmsgptr != 0)
|
||||
{
|
||||
strcpy(outbuff, nodeptr->postmsgptr);
|
||||
@@ -353,6 +345,8 @@ static int set_status(int card, int signal)
|
||||
nodeptr->postmsgptr = NULL;
|
||||
}
|
||||
|
||||
exit:
|
||||
motor_info->status.All = status.All;
|
||||
return (rtn_state);
|
||||
}
|
||||
|
||||
@@ -677,7 +671,7 @@ static int motor_init()
|
||||
recv_mess(card_index, buff, 1);
|
||||
cntrl->drive_resolution[motor_index] = atof(&buff[0]);
|
||||
|
||||
motor_info->status = 0;
|
||||
motor_info->status.All = 0;
|
||||
motor_info->no_motion_count = 0;
|
||||
motor_info->encoder_position = 0;
|
||||
motor_info->position = 0;
|
||||
@@ -685,9 +679,9 @@ static int motor_init()
|
||||
|
||||
if (motor_info->encoder_present == YES)
|
||||
{
|
||||
motor_info->status |= EA_PRESENT;
|
||||
motor_info->status.Bits.EA_PRESENT = 1;
|
||||
motor_info->pid_present = YES;
|
||||
motor_info->status |= GAIN_SUPPORT;
|
||||
motor_info->status.Bits.GAIN_SUPPORT = 1;
|
||||
}
|
||||
|
||||
set_status(card_index, motor_index); /* Read status of each motor */
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
FILENAME... drvMM3000.cc
|
||||
USAGE... Motor record driver level support for Newport MM3000.
|
||||
|
||||
Version: $Revision: 1.5 $
|
||||
Version: $Revision: 1.6 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-11-07 22:22:11 $
|
||||
Last Modified: $Date: 2003-12-12 21:40:24 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -243,9 +243,11 @@ STATIC int set_status(int card, int signal)
|
||||
int rtn_state, charcnt;
|
||||
double motorData;
|
||||
bool plusdir, ls_active = false;
|
||||
msta_field status;
|
||||
|
||||
cntrl = (struct MMcontroller *) motor_state[card]->DevicePrivate;
|
||||
motor_info = &(motor_state[card]->motor_info[signal]);
|
||||
status.All = motor_info->status.All;
|
||||
|
||||
sprintf(outbuff, "%dMS", signal + 1);
|
||||
send_mess(card, outbuff, (char) NULL);
|
||||
@@ -253,21 +255,23 @@ STATIC int set_status(int card, int signal)
|
||||
if (charcnt > 0)
|
||||
{
|
||||
cntrl->status = NORMAL;
|
||||
motor_info->status &= ~CNTRL_COMM_ERR;
|
||||
status.Bits.CNTRL_COMM_ERR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cntrl->status == NORMAL)
|
||||
{
|
||||
cntrl->status = RETRY;
|
||||
return(0);
|
||||
rtn_state = 0;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
cntrl->status = COMM_ERR;
|
||||
motor_info->status |= CNTRL_COMM_ERR;
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
return(1);
|
||||
status.Bits.CNTRL_COMM_ERR = 1;
|
||||
status.Bits.RA_PROBLEM = 1;
|
||||
rtn_state = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,51 +280,39 @@ STATIC int set_status(int card, int signal)
|
||||
|
||||
nodeptr = motor_info->motor_motion;
|
||||
|
||||
if (mstat.Bits.direction == false)
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
else
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
status.Bits.RA_DIRECTION = (mstat.Bits.direction == false) ? 0 : 1;
|
||||
|
||||
plusdir = (motor_info->status & RA_DIRECTION) ? true : false;
|
||||
plusdir = (status.Bits.RA_DIRECTION) ? true : false;
|
||||
|
||||
if (mstat.Bits.inmotion == false)
|
||||
motor_info->status |= RA_DONE;
|
||||
else
|
||||
motor_info->status &= ~RA_DONE;
|
||||
status.Bits.RA_DONE = (mstat.Bits.inmotion == false) ? 1 : 0;
|
||||
|
||||
/* Set Travel limit switch status bits. */
|
||||
if (mstat.Bits.plustTL == false)
|
||||
motor_info->status &= ~RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 0;
|
||||
else
|
||||
{
|
||||
motor_info->status |= RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
if (plusdir == true)
|
||||
ls_active = true;
|
||||
}
|
||||
|
||||
if (mstat.Bits.minusTL == false)
|
||||
motor_info->status &= ~RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 0;
|
||||
else
|
||||
{
|
||||
motor_info->status |= RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
if (plusdir == false)
|
||||
ls_active = true;
|
||||
}
|
||||
|
||||
if (mstat.Bits.homels == false)
|
||||
motor_info->status &= ~RA_HOME;
|
||||
else
|
||||
motor_info->status |= RA_HOME;
|
||||
status.Bits.RA_HOME = (mstat.Bits.homels == false) ? 0 : 1;
|
||||
|
||||
if (mstat.Bits.NOT_power == false)
|
||||
motor_info->status |= EA_POSITION;
|
||||
else
|
||||
motor_info->status &= ~EA_POSITION;
|
||||
status.Bits.EA_POSITION = (mstat.Bits.NOT_power == false) ? 1 : 0;
|
||||
|
||||
/* encoder status */
|
||||
motor_info->status &= ~EA_SLIP;
|
||||
motor_info->status &= ~EA_SLIP_STALL;
|
||||
motor_info->status &= ~EA_HOME;
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_SLIP_STALL = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
|
||||
sprintf(outbuff, "%dTP", signal + 1);
|
||||
send_mess(card, outbuff, (char) NULL);
|
||||
@@ -328,21 +320,23 @@ STATIC int set_status(int card, int signal)
|
||||
if (charcnt > 0)
|
||||
{
|
||||
cntrl->status = NORMAL;
|
||||
motor_info->status &= ~CNTRL_COMM_ERR;
|
||||
status.Bits.CNTRL_COMM_ERR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cntrl->status == NORMAL)
|
||||
{
|
||||
cntrl->status = RETRY;
|
||||
return(0);
|
||||
rtn_state = 0;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
cntrl->status = COMM_ERR;
|
||||
motor_info->status |= CNTRL_COMM_ERR;
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
return(1);
|
||||
status.Bits.CNTRL_COMM_ERR = 1;
|
||||
status.Bits.RA_PROBLEM = 1;
|
||||
rtn_state = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,21 +357,21 @@ STATIC int set_status(int card, int signal)
|
||||
motor_info->no_motion_count = 0;
|
||||
}
|
||||
|
||||
motor_info->status &= ~RA_PROBLEM;
|
||||
status.Bits.RA_PROBLEM = 0;
|
||||
|
||||
/* Parse motor velocity? */
|
||||
/* NEEDS WORK */
|
||||
|
||||
motor_info->velocity = 0;
|
||||
|
||||
if (!(motor_info->status & RA_DIRECTION))
|
||||
if (!status.Bits.RA_DIRECTION)
|
||||
motor_info->velocity *= -1;
|
||||
|
||||
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
|
||||
(motor_info->status & (RA_DONE | RA_PROBLEM))) ? 1 : 0;
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
|
||||
/* Test for post-move string. */
|
||||
if ((motor_info->status & RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
nodeptr->postmsgptr != 0)
|
||||
{
|
||||
strcpy(outbuff, nodeptr->postmsgptr);
|
||||
@@ -385,6 +379,8 @@ STATIC int set_status(int card, int signal)
|
||||
nodeptr->postmsgptr = NULL;
|
||||
}
|
||||
|
||||
exit:
|
||||
motor_info->status.All = status.All;
|
||||
return(rtn_state);
|
||||
}
|
||||
|
||||
@@ -731,7 +727,7 @@ STATIC int motor_init()
|
||||
{
|
||||
struct mess_info *motor_info = &brdptr->motor_info[motor_index];
|
||||
|
||||
motor_info->status = 0;
|
||||
motor_info->status.All = 0;
|
||||
motor_info->no_motion_count = 0;
|
||||
motor_info->encoder_position = 0;
|
||||
motor_info->position = 0;
|
||||
@@ -752,9 +748,9 @@ STATIC int motor_init()
|
||||
|
||||
if (motor_info->encoder_present == YES)
|
||||
{
|
||||
motor_info->status |= EA_PRESENT;
|
||||
motor_info->status.Bits.EA_PRESENT = 1;
|
||||
motor_info->pid_present = YES;
|
||||
motor_info->status |= GAIN_SUPPORT;
|
||||
motor_info->status.Bits.GAIN_SUPPORT = 1;
|
||||
}
|
||||
|
||||
set_status(card_index, motor_index); /* Read status of each motor */
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
FILENAME... drvMM4000.cc
|
||||
USAGE... Motor record driver level support for Newport MM4000.
|
||||
|
||||
Version: $Revision: 1.4 $
|
||||
Version: $Revision: 1.5 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-11-07 22:24:21 $
|
||||
Last Modified: $Date: 2003-12-12 21:40:26 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -312,22 +312,29 @@ STATIC int set_status(int card, int signal)
|
||||
int rtn_state;
|
||||
double motorData;
|
||||
bool plusdir, ls_active = false;
|
||||
msta_field status;
|
||||
|
||||
cntrl = (struct MMcontroller *) motor_state[card]->DevicePrivate;
|
||||
motor_info = &(motor_state[card]->motor_info[signal]);
|
||||
status.All = motor_info->status.All;
|
||||
|
||||
if (cntrl->status != NORMAL)
|
||||
{
|
||||
if (cntrl->status == COMM_ERR)
|
||||
{
|
||||
motor_info->status |= CNTRL_COMM_ERR;
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
return(1);
|
||||
status.Bits.CNTRL_COMM_ERR = 1;
|
||||
status.Bits.RA_PROBLEM = 1;
|
||||
rtn_state = 1;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
return(0);
|
||||
{
|
||||
rtn_state = 0;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
motor_info->status &= ~CNTRL_COMM_ERR;
|
||||
status.Bits.CNTRL_COMM_ERR = 0;
|
||||
|
||||
nodeptr = motor_info->motor_motion;
|
||||
|
||||
@@ -340,16 +347,13 @@ STATIC int set_status(int card, int signal)
|
||||
mstat.All = cntrl->status_string[pos];
|
||||
Debug(5, "set_status(): status byte = %x\n", mstat.All);
|
||||
|
||||
if (mstat.Bits.direction == false)
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
else
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
status.Bits.RA_DIRECTION = (mstat.Bits.direction == false) ? 0 : 1;
|
||||
|
||||
plusdir = (motor_info->status & RA_DIRECTION) ? true : false;
|
||||
plusdir = (status.Bits.RA_DIRECTION) ? true : false;
|
||||
|
||||
if (mstat.Bits.inmotion == false)
|
||||
{
|
||||
motor_info->status |= RA_DONE;
|
||||
status.Bits.RA_DONE = 1;
|
||||
/* TEMPORARY FIX, Mark Rivers, 2/1/99. The MM4000 has reported that the
|
||||
* motor is done moving, which means that the "jerk time" is done. However,
|
||||
* the axis can still be settling. For now we put in a delay and poll the
|
||||
@@ -369,47 +373,40 @@ STATIC int set_status(int card, int signal)
|
||||
pos = signal*5 + 3; /* Offset in status string */
|
||||
mstat.All = cntrl->status_string[pos];
|
||||
if (mstat.Bits.inmotion == true)
|
||||
motor_info->status &= ~RA_DONE;
|
||||
status.Bits.RA_DONE = 0;
|
||||
send_mess(card, READ_POSITION, NULL);
|
||||
recv_mess(card, cntrl->position_string, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
motor_info->status &= ~RA_DONE;
|
||||
status.Bits.RA_DONE = 0;
|
||||
|
||||
/* Set Travel limit switch status bits. */
|
||||
if (mstat.Bits.plustTL == false)
|
||||
motor_info->status &= ~RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 0;
|
||||
else
|
||||
{
|
||||
motor_info->status |= RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
if (plusdir == true)
|
||||
ls_active = true;
|
||||
}
|
||||
|
||||
if (mstat.Bits.minusTL == false)
|
||||
motor_info->status &= ~RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 0;
|
||||
else
|
||||
{
|
||||
motor_info->status |= RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
if (plusdir == false)
|
||||
ls_active = true;
|
||||
}
|
||||
|
||||
if (mstat.Bits.homels == false)
|
||||
motor_info->status &= ~RA_HOME;
|
||||
else
|
||||
motor_info->status |= RA_HOME;
|
||||
|
||||
if (mstat.Bits.NOT_power == false)
|
||||
motor_info->status |= EA_POSITION;
|
||||
else
|
||||
motor_info->status &= ~EA_POSITION;
|
||||
status.Bits.RA_HOME = (mstat.Bits.homels == false) ? 0 : 1;
|
||||
status.Bits.EA_POSITION = (mstat.Bits.NOT_power == false) ? 1 : 0;
|
||||
|
||||
/* encoder status */
|
||||
motor_info->status &= ~EA_SLIP;
|
||||
motor_info->status &= ~EA_SLIP_STALL;
|
||||
motor_info->status &= ~EA_HOME;
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_SLIP_STALL = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
|
||||
/*
|
||||
* Parse motor position
|
||||
@@ -438,21 +435,21 @@ STATIC int set_status(int card, int signal)
|
||||
motor_info->no_motion_count = 0;
|
||||
}
|
||||
|
||||
motor_info->status &= ~RA_PROBLEM;
|
||||
status.Bits.RA_PROBLEM = 0;
|
||||
|
||||
/* Parse motor velocity? */
|
||||
/* NEEDS WORK */
|
||||
|
||||
motor_info->velocity = 0;
|
||||
|
||||
if (!(motor_info->status & RA_DIRECTION))
|
||||
if (!status.Bits.RA_DIRECTION)
|
||||
motor_info->velocity *= -1;
|
||||
|
||||
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
|
||||
(motor_info->status & (RA_DONE | RA_PROBLEM))) ? 1 : 0;
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
|
||||
/* Test for post-move string. */
|
||||
if ((motor_info->status & RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
nodeptr->postmsgptr != 0)
|
||||
{
|
||||
strcpy(buff, nodeptr->postmsgptr);
|
||||
@@ -460,6 +457,8 @@ STATIC int set_status(int card, int signal)
|
||||
nodeptr->postmsgptr = NULL;
|
||||
}
|
||||
|
||||
exit:
|
||||
motor_info->status.All = status.All;
|
||||
return(rtn_state);
|
||||
}
|
||||
|
||||
@@ -763,7 +762,7 @@ STATIC int motor_init()
|
||||
struct mess_info *motor_info = &brdptr->motor_info[motor_index];
|
||||
int loop_state;
|
||||
|
||||
motor_info->status = 0;
|
||||
motor_info->status.All = 0;
|
||||
motor_info->no_motion_count = 0;
|
||||
motor_info->encoder_position = 0;
|
||||
motor_info->position = 0;
|
||||
@@ -776,9 +775,9 @@ STATIC int motor_init()
|
||||
if (loop_state != 0)
|
||||
{
|
||||
motor_info->encoder_present = YES;
|
||||
motor_info->status |= EA_PRESENT;
|
||||
motor_info->status.Bits.EA_PRESENT = 1;
|
||||
motor_info->pid_present = YES;
|
||||
motor_info->status |= GAIN_SUPPORT;
|
||||
motor_info->status.Bits.GAIN_SUPPORT = 1;
|
||||
}
|
||||
|
||||
/* Determine drive resolution. */
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
FILENAME... drvPM500.cc
|
||||
USAGE... Motor record driver level support for Newport PM500.
|
||||
|
||||
Version: $Revision: 1.4 $
|
||||
Version: $Revision: 1.5 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-11-07 22:20:55 $
|
||||
Last Modified: $Date: 2003-12-12 21:40:27 $
|
||||
*/
|
||||
|
||||
/* Device Driver Support routines for PM500 motor controller */
|
||||
@@ -230,37 +230,41 @@ STATIC int set_status(int card, int signal)
|
||||
/* Message parsing variables */
|
||||
char axis_name, status_char, dir_char, buff[BUFF_SIZE],
|
||||
response[BUFF_SIZE];
|
||||
int status, rtn_state = 0;
|
||||
int rtnval, rtn_state = 0;
|
||||
double motorData;
|
||||
bool ls_active;
|
||||
msta_field status;
|
||||
|
||||
cntrl = (struct MMcontroller *) motor_state[card]->DevicePrivate;
|
||||
motor_info = &(motor_state[card]->motor_info[signal]);
|
||||
nodeptr = motor_info->motor_motion;
|
||||
axis_name = PM500_axis_names[signal];
|
||||
status.All = motor_info->status.All;
|
||||
|
||||
/* Request the status and position of this motor */
|
||||
sprintf(buff, "%cR", axis_name);
|
||||
send_mess(card, buff, (char) NULL);
|
||||
status = recv_mess(card, response, 1);
|
||||
if (status > 0)
|
||||
rtnval = recv_mess(card, response, 1);
|
||||
if (rtnval > 0)
|
||||
{
|
||||
cntrl->status = NORMAL;
|
||||
motor_info->status &= ~CNTRL_COMM_ERR;
|
||||
status.Bits.CNTRL_COMM_ERR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cntrl->status == NORMAL)
|
||||
{
|
||||
cntrl->status = RETRY;
|
||||
return(0);
|
||||
rtn_state = 0;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
cntrl->status = COMM_ERR;
|
||||
motor_info->status |= CNTRL_COMM_ERR;
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
return(1);
|
||||
status.Bits.CNTRL_COMM_ERR = 1;
|
||||
status.Bits.RA_PROBLEM = 1;
|
||||
rtn_state = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,43 +272,32 @@ STATIC int set_status(int card, int signal)
|
||||
dir_char = response[2];
|
||||
motorData = atof(&response[2]) / cntrl->drive_resolution[signal];
|
||||
|
||||
if (status_char == 'B')
|
||||
motor_info->status &= ~RA_DONE;
|
||||
else
|
||||
motor_info->status |= RA_DONE;
|
||||
|
||||
if (status_char == 'E')
|
||||
motor_info->status |= RA_PROBLEM;
|
||||
else
|
||||
motor_info->status &= ~RA_PROBLEM;
|
||||
|
||||
if (dir_char == '+')
|
||||
motor_info->status |= RA_DIRECTION;
|
||||
else
|
||||
motor_info->status &= ~RA_DIRECTION;
|
||||
status.Bits.RA_DONE = (status_char == 'B') ? 0 : 1;
|
||||
status.Bits.RA_PROBLEM = (status_char == 'E') ? 1 : 0;
|
||||
status.Bits.RA_DIRECTION = (dir_char == '+') ? 1 : 0;
|
||||
|
||||
if (status_char == 'L')
|
||||
{
|
||||
ls_active = true;
|
||||
if (dir_char == '+')
|
||||
motor_info->status |= RA_PLUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
else
|
||||
motor_info->status |= RA_MINUS_LS;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ls_active = false;
|
||||
motor_info->status &= ~RA_PLUS_LS;
|
||||
motor_info->status &= ~RA_MINUS_LS;
|
||||
status.Bits.RA_PLUS_LS = 0;
|
||||
status.Bits.RA_MINUS_LS = 0;
|
||||
}
|
||||
|
||||
motor_info->status &= ~RA_HOME;
|
||||
status.Bits.RA_HOME = 0;
|
||||
|
||||
/* encoder status */
|
||||
motor_info->status &= ~EA_POSITION;
|
||||
motor_info->status &= ~EA_SLIP;
|
||||
motor_info->status &= ~EA_SLIP_STALL;
|
||||
motor_info->status &= ~EA_HOME;
|
||||
status.Bits.EA_POSITION = 0;
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_SLIP_STALL = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
|
||||
/*
|
||||
* Parse motor position
|
||||
@@ -312,7 +305,6 @@ STATIC int set_status(int card, int signal)
|
||||
* Skip to substring for this motor, convert to double
|
||||
*/
|
||||
|
||||
|
||||
if (motorData == motor_info->position)
|
||||
motor_info->no_motion_count++;
|
||||
else
|
||||
@@ -326,21 +318,21 @@ STATIC int set_status(int card, int signal)
|
||||
motor_info->no_motion_count = 0;
|
||||
}
|
||||
|
||||
motor_info->status &= ~RA_PROBLEM;
|
||||
status.Bits.RA_PROBLEM = 0;
|
||||
|
||||
/* Parse motor velocity? */
|
||||
/* NEEDS WORK */
|
||||
|
||||
motor_info->velocity = 0;
|
||||
|
||||
if (!(motor_info->status & RA_DIRECTION))
|
||||
if (!status.Bits.RA_DIRECTION)
|
||||
motor_info->velocity *= -1;
|
||||
|
||||
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
|
||||
(motor_info->status & (RA_DONE | RA_PROBLEM))) ? 1 : 0;
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
|
||||
/* Test for post-move string. */
|
||||
if ((motor_info->status & RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
nodeptr->postmsgptr != 0)
|
||||
{
|
||||
strcpy(buff, nodeptr->postmsgptr);
|
||||
@@ -349,6 +341,8 @@ STATIC int set_status(int card, int signal)
|
||||
nodeptr->postmsgptr = NULL;
|
||||
}
|
||||
|
||||
exit:
|
||||
motor_info->status.All = status.All;
|
||||
return(rtn_state);
|
||||
}
|
||||
|
||||
@@ -702,11 +696,11 @@ STATIC int motor_init()
|
||||
|
||||
/* PM500 only supports DC motors. */
|
||||
motor_info->encoder_present = YES;
|
||||
motor_info->status |= EA_PRESENT;
|
||||
motor_info->status.Bits.EA_PRESENT = 1;
|
||||
motor_info->pid_present = YES;
|
||||
motor_info->status |= GAIN_SUPPORT;
|
||||
motor_info->status.Bits.GAIN_SUPPORT = 1;
|
||||
|
||||
motor_info->status = 0;
|
||||
motor_info->status.All = 0;
|
||||
motor_info->no_motion_count = 0;
|
||||
motor_info->encoder_position = 0;
|
||||
motor_info->position = 0;
|
||||
|
||||
Reference in New Issue
Block a user