forked from epics_driver_modules/motorBase
Set drive_resolution when open-loop steppers are used.
Previously drive resolution was determined using the SU? command, which returns the encoder resolution. The SU? value is not meaningful when open-loop steppers are used, and cannot even be set in the controller. Use the ZB? command to see if stepper positioning is enabled and encoder feedback is disabled. If so the full-step (FR?) and microstep (QS?) values are used to determine drive_resolution. If not then SU? is used to determine drive resolution, as previously.
This commit is contained in:
@@ -674,6 +674,9 @@ errexit:
|
||||
for (motor_index = 0; motor_index < total_axis; motor_index++)
|
||||
{
|
||||
struct mess_info *motor_info = &brdptr->motor_info[motor_index];
|
||||
int feedback;
|
||||
double fullStep;
|
||||
int microStep;
|
||||
|
||||
/* Get controller's EGU for the user (see README). */
|
||||
sprintf(buff, "%.2dSN?", motor_index + 1);
|
||||
@@ -681,11 +684,28 @@ errexit:
|
||||
recv_mess(card_index, buff, 1);
|
||||
|
||||
/* Set axis resolution. */
|
||||
sprintf(buff, "%.2dSU?", motor_index + 1);
|
||||
/* If encoder feedback is being used then use SU command */
|
||||
/* If not then assume open-loop stepper and use full-step resolution (FR) and microstepping (QS) */
|
||||
sprintf(buff, "%.2dZB?", motor_index + 1);
|
||||
send_mess(card_index, buff, 0);
|
||||
recv_mess(card_index, buff, 1);
|
||||
cntrl->drive_resolution[motor_index] = atof(&buff[0]);
|
||||
|
||||
feedback = strtol(buff,0,16);
|
||||
if ((feedback & 0x100) == 0) {
|
||||
sprintf(buff, "%.2dFR?", motor_index + 1);
|
||||
send_mess(card_index, buff, 0);
|
||||
recv_mess(card_index, buff, 1);
|
||||
fullStep = atof(buff);
|
||||
sprintf(buff, "%.2dQS?", motor_index + 1);
|
||||
send_mess(card_index, buff, 0);
|
||||
recv_mess(card_index, buff, 1);
|
||||
microStep = strtol(buff, 0, 10);
|
||||
cntrl->drive_resolution[motor_index] = fullStep/microStep;
|
||||
} else {
|
||||
sprintf(buff, "%.2dSU?", motor_index + 1);
|
||||
send_mess(card_index, buff, 0);
|
||||
recv_mess(card_index, buff, 1);
|
||||
cntrl->drive_resolution[motor_index] = atof(&buff[0]);
|
||||
}
|
||||
motor_info->status.All = 0;
|
||||
motor_info->no_motion_count = 0;
|
||||
motor_info->encoder_position = 0;
|
||||
|
||||
Reference in New Issue
Block a user