From 1512357f70cb416652aa61fc9293b6d81844745e Mon Sep 17 00:00:00 2001 From: Mark Rivers Date: Wed, 22 Nov 2017 14:32:29 -0600 Subject: [PATCH] Added comments, improved logic --- motorApp/NewportSrc/drvESP300.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/motorApp/NewportSrc/drvESP300.cc b/motorApp/NewportSrc/drvESP300.cc index ae2ea4af..afc38321 100644 --- a/motorApp/NewportSrc/drvESP300.cc +++ b/motorApp/NewportSrc/drvESP300.cc @@ -684,13 +684,15 @@ errexit: recv_mess(card_index, buff, 1); /* Set axis resolution. */ - /* 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) */ + /* Read the feedback status */ sprintf(buff, "%.2dZB?", motor_index + 1); send_mess(card_index, buff, 0); recv_mess(card_index, buff, 1); feedback = strtol(buff,0,16); - if ((feedback & 0x100) == 0) { + /* If stepper closed loop positioning is enabled (bit 9=1) and encoder feedback is disabled (bit 8=0) + * then use the full-step resolution (FR) and microstepping (QS) to determine drive_resolution. + * If not then use SU (encoder resolution) for drive_resolution. */ + if ((feedback & 0x300) == 0x200) { sprintf(buff, "%.2dFR?", motor_index + 1); send_mess(card_index, buff, 0); recv_mess(card_index, buff, 1); @@ -699,7 +701,7 @@ errexit: send_mess(card_index, buff, 0); recv_mess(card_index, buff, 1); microStep = strtol(buff, 0, 10); - cntrl->drive_resolution[motor_index] = fullStep/microStep; + cntrl->drive_resolution[motor_index] = fullStep / microStep; } else { sprintf(buff, "%.2dSU?", motor_index + 1); send_mess(card_index, buff, 0);