From b969f5a0abe036bf6922d7ebc60ef982b8a22b2a Mon Sep 17 00:00:00 2001 From: Mark Rivers Date: Wed, 22 Nov 2017 14:08:04 -0600 Subject: [PATCH] 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. --- motorApp/NewportSrc/drvESP300.cc | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/motorApp/NewportSrc/drvESP300.cc b/motorApp/NewportSrc/drvESP300.cc index 7e2c774d..ae2ea4af 100644 --- a/motorApp/NewportSrc/drvESP300.cc +++ b/motorApp/NewportSrc/drvESP300.cc @@ -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;