diff --git a/iocs/pigcs2IOC/iocBoot/iocPIGCS2/PI_GCS2 _CL.cmd b/iocs/pigcs2IOC/iocBoot/iocPIGCS2/PI_GCS2 _CL.cmd new file mode 100644 index 0000000..f5ef8c6 --- /dev/null +++ b/iocs/pigcs2IOC/iocBoot/iocPIGCS2/PI_GCS2 _CL.cmd @@ -0,0 +1,22 @@ +# PI GCS2 support with Closed loop params + +dbLoadTemplate("PI_GCS2.substitutions") + +drvAsynIPPortConfigure("C867_ETH","192.168.1.75:50000",0,0,0) +# Turn on asyn trace +asynSetTraceMask("C867_ETH",0,3) +asynSetTraceIOMask("C867_ETH",0,1) + +# PI_GCS2_CreateController(portName, asynPort, numAxes, priority, stackSize, movingPollingRate, idlePollingRate) +PI_GCS2_CreateController("C867", "C867_ETH",2, 0,0, 100, 1000) + +# Turn off asyn trace +asynSetTraceMask("C867_ETH",0,1) +asynSetTraceIOMask("C867_ETH",0,0) + +#!dbLoadRecords("$(TOP)/db/PI_Support.db","P=pigcs2:,R=m1:,PORT=C867,ADDR=0,TIMEOUT=1") +#!dbLoadRecords("$(TOP)/db/PI_Support.db","P=pigcs2:,R=m2:,PORT=C867,ADDR=1,TIMEOUT=1") +dbLoadRecords("$(TOP)/db/PI_SupportCL.db","P=pigcs2:,PORT=C867_ETH") + +# asyn record for troubleshooting +dbLoadRecords("$(ASYN)/db/asynRecord.db","P=pigcs2:,R=asyn_1,PORT=C867_ETH,ADDR=0,OMAX=256,IMAX=256") diff --git a/pigcs2App/Db/Makefile b/pigcs2App/Db/Makefile index 201f21f..3320391 100644 --- a/pigcs2App/Db/Makefile +++ b/pigcs2App/Db/Makefile @@ -14,6 +14,7 @@ include $(TOP)/configure/CONFIG DB += PI_SupportCtrl.db DB += PI_Support.db +DB += PI_SupportCL.db #---------------------------------------------------- # If .db template is not named *.template add diff --git a/pigcs2App/Db/PI_SupportCL.db b/pigcs2App/Db/PI_SupportCL.db new file mode 100644 index 0000000..2985b1e --- /dev/null +++ b/pigcs2App/Db/PI_SupportCL.db @@ -0,0 +1,411 @@ +record(ao, "$(P)KP_X") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_KP_1") + field(PREC, "5") +} + +record(ao, "$(P)KI_X") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_KI_1") + field(PREC, "5") +} + +record(ao, "$(P)KFF_X") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_KFF_1") + field(PREC, "5") +} + +record(ao, "$(P)NTCHFR1_X") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHFR1_1") + field(PREC, "5") +} + +record(ao, "$(P)NTCHFR2_X") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHFR2_1") + field(PREC, "5") +} + +record(ao, "$(P)NTCHRJT1_X") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHRJT1_1") + field(PREC, "5") +} + +record(ao, "$(P)NTCHRJT2_X") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHRJT2_1") + field(PREC, "5") +} + +record(ao, "$(P)NTCHBDWDT1_X") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHBDWDT1_1") + field(PREC, "5") +} + +record(ao, "$(P)NTCHBDWDT2_X") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHBDWDT2_1") + field(PREC, "5") +} + +record(ai, "$(P)RBKP_X") +{ + field(PINI, "1") + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBKP_1") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBKI_X") +{ + field(PINI, "1") + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBKI_1") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBKFF_X") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBKFF_1") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHFR1_X") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHFR1_1") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHFR2_X") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHFR2_1") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHRJT1_X") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHRJT1_1") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHRJT2_X") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHRJT2_1") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHBDWDT1_X") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHBDWDT1_1") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHBDWDT2_X") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHBDWDT2_1") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ao, "$(P)KP_Y") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_KP_2") + field(PREC, "5") +} + +record(ao, "$(P)KI_Y") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_KI_2") + field(PREC, "5") +} + +record(ao, "$(P)KFF_Y") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_KFF_2") + field(PREC, "5") +} + +record(ao, "$(P)NTCHFR1_Y") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHFR1_2") + field(PREC, "5") +} + +record(ao, "$(P)NTCHFR2_Y") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHFR2_2") + field(PREC, "5") +} + +record(ao, "$(P)NTCHRJT1_Y") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHRJT1_2") + field(PREC, "5") +} + +record(ao, "$(P)NTCHRJT2_Y") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHRJT2_2") + field(PREC, "5") +} + +record(ao, "$(P)NTCHBDWDT1_Y") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHBDWDT1_2") + field(PREC, "5") +} + +record(ao, "$(P)NTCHBDWDT2_Y") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHBDWDT2_2") + field(PREC, "5") +} + +record(ai, "$(P)RBKP_Y") +{ + field(PINI, "1") + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBKP_2") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBKI_Y") +{ + field(PINI, "1") + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBKI_2") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBKFF_Y") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBKFF_2") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHFR1_Y") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHFR1_2") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHFR2_Y") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHFR2_2") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHRJT1_Y") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHRJT1_2") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHRJT2_Y") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHRJT2_2") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHBDWDT1_Y") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHBDWDT1_2") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHBDWDT2_Y") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHBDWDT2_2") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + + +record(ao, "$(P)KP_Z") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_KP_3") + field(PREC, "5") +} + +record(ao, "$(P)KI_Z") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_KI_3") + field(PREC, "5") +} + +record(ao, "$(P)KFF_Z") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_KFF_3") + field(PREC, "5") +} + +record(ao, "$(P)NTCHFR1_Z") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHFR1_3") + field(PREC, "5") +} + +record(ao, "$(P)NTCHFR2_Z") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHFR2_3") + field(PREC, "5") +} + +record(ao, "$(P)NTCHRJT1_Z") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHRJT1_3") + field(PREC, "5") +} + +record(ao, "$(P)NTCHRJT2_Z") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHRJT2_3") + field(PREC, "5") +} + +record(ao, "$(P)NTCHBDWDT1_Z") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHBDWDT1_3") + field(PREC, "5") +} + +record(ao, "$(P)NTCHBDWDT2_Z") +{ + field(DTYP, "asynFloat64") + field(OUT, "@asyn($(PORT),0,0)PI_SUP_NTCHBDWDT2_3") + field(PREC, "5") +} + +record(ai, "$(P)RBKP_Z") +{ + field(PINI, "1") + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBKP_3") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBKI_Z") +{ + field(PINI, "1") + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBKI_3") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBKFF_Z") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBKFF_3") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHFR1_Z") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHFR1_3") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHFR2_Z") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHFR2_3") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHRJT1_Z") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHRJT1_3") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHRJT2_Z") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHRJT2_3") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHBDWDT1_Z") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHBDWDT1_3") + field(PREC, "5") + field(SCAN, "I/O Intr") +} + +record(ai, "$(P)RBNTCHBDWDT2_Z") +{ + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),0,0)PI_SUP_RBNTCHBDWDT2_3") + field(PREC, "5") + field(SCAN, "I/O Intr") +} diff --git a/pigcs2App/src/Makefile b/pigcs2App/src/Makefile index b9c8c59..e7332be 100644 --- a/pigcs2App/src/Makefile +++ b/pigcs2App/src/Makefile @@ -21,6 +21,7 @@ PI_GCS2Support_SRCS += PIGCSController.cpp PI_GCS2Support_SRCS += PIGCSMotorController.cpp PI_GCS2Support_SRCS += PIGCSPiezoController.cpp PI_GCS2Support_SRCS += PIE517Controller.cpp +PI_GCS2Support_SRCS += PIE727Controller.cpp PI_GCS2Support_SRCS += PIE755Controller.cpp PI_GCS2Support_SRCS += PIHexapodController.cpp PI_GCS2Support_SRCS += PIGCS2_HexapodController.cpp diff --git a/pigcs2App/src/PIE727Controller.cpp b/pigcs2App/src/PIE727Controller.cpp new file mode 100644 index 0000000..d06f727 --- /dev/null +++ b/pigcs2App/src/PIE727Controller.cpp @@ -0,0 +1,101 @@ +/* +FILENAME... PIGCSPiezoController.cpp + +************************************************************************* +* Copyright (c) 2011-2013 Physik Instrumente (PI) GmbH & Co. KG +* This file is distributed subject to the EPICS Open License Agreement +* found in the file LICENSE that is included with this distribution. +************************************************************************* + + +Original Author: Steffen Rau +Created: 15.12.2010 +*/ + +#include "PIE727Controller.h" +#include "PIasynController.h" +#include "PIasynAxis.h" +#include "PIInterface.h" +#include +#include + + +PIE727Controller::PIE727Controller(PIInterface* pInterface, const char* szIDN) +: PIGCSPiezoController (pInterface, szIDN) +{ + this->m_hasqFRF=false; ///< is "FRF?" command available + this->m_hasqTRS=false; ///< is "TRS?" command available + this->m_hasqSRG=false; +} + + +asynStatus PIE727Controller::setGCSCmdLvl(unsigned int cmdLvl) +{ + char cmd[100]; + + if (cmdLvl == m_CCL_ADVANCED_ID) + { + sprintf(cmd, "CCL %d %s", cmdLvl, m_CCL_ADVANCED_PWD); + } + else if (cmdLvl == m_CCL_DEFAULT_ID) + { + sprintf(cmd, "CCL %d", cmdLvl); + } + + asynStatus status = m_pInterface->sendOnly(cmd); + + return status; +} + +//---------------------------------------------------------------------------- +// setAxisKp: Method to set the Integrative gain (Ki) of an Axis +// +// Param: +// pAxis: identify Axis to be modified +// paramID: which closed loop parameter will be set +// wantedKp: Integrative gain to be set +// +// Return: +// asynStatus: check if gain was succesfully set +// +//---------------------------------------------------------------------------- +asynStatus PIE727Controller::setCLAxisParam( PIasynAxis* pAxis, unsigned int paramID, double wantedValue ) +{ + + // Set the CCL to advanced -> necessary to modify Kp + asynStatus status = setGCSCmdLvl(1); + + if (asynSuccess != status) + return status; + + // Set the wanted parameter into the volatile memory + status = setGCSParameter(pAxis, paramID, wantedValue); + // printf("PIGCSPiezoController::setCLAxisParam(), param: 0x%.8x \r\n",paramID); + + asynPrint(m_pInterface->m_pCurrentLogSink, ASYN_TRACE_FLOW, + "PIGCSPiezoController::setCLAxisParam(), param: 0x%.8x \r\n",paramID); + + if (asynSuccess != status) + { + setGCSCmdLvl(0); + return status; + } + + status = setGCSCmdLvl(0); + + return status; +} + +double PIE727Controller::getCLAxisParam( PIasynAxis* pAxis , unsigned int paramID) +{ + double pValue=0; + + if (pAxis != NULL) + { + getGCSParameter(pAxis, paramID , pValue); + } + + // printf("getCLAxisParam() axis %d, param: 0x%.8x = %f\r\n",pAxis->getAxisNo(), paramID, pValue); + + return pValue; +} diff --git a/pigcs2App/src/PIE727Controller.h b/pigcs2App/src/PIE727Controller.h new file mode 100644 index 0000000..b001c79 --- /dev/null +++ b/pigcs2App/src/PIE727Controller.h @@ -0,0 +1,54 @@ +/* +FILENAME... PIE727Controller.h + +************************************************************************* +* Copyright (c) 2011-2013 Physik Instrumente (PI) GmbH & Co. KG +* This file is distributed subject to the EPICS Open License Agreement +* found in the file LICENSE that is included with this distribution. +************************************************************************* + + +Original Author: Steffen Rau +*/ + +#ifndef PIE727CONTROLLER_H_ +#define PIE727CONTROLLER_H_ + +#include "PIGCSPiezoController.h" +#include "PIGCS2PiezoCL.h" + +#include + + +/** + * class representing PI E-727. + * + * These controllers share most of the parameters with digital piezo controllers. + * Encoders for Nexline stages are often only incremental, so they need to be homed. + * Homing works with "hard stops" and "Limit switches". + * From an EPICS point of view this behaves more like a motor than a piezo controller. + */ +class PIE727Controller : public PIGCSPiezoController +{ + public: + PIE727Controller(PIInterface* pInterface, const char* szIDN); + + ~PIE727Controller() {} + +// virtual asynStatus getStatus(PIasynAxis* pAxis, int& homing, int& moving, int& negLimit, int& posLimit, int& servoControl){return asynSuccess;} + + virtual asynStatus setCLAxisParam( PIasynAxis* pAxis, unsigned int paramID, double wantedValue ); + virtual double getCLAxisParam( PIasynAxis* pAxis, unsigned int paramID); + + private: + + asynStatus setGCSCmdLvl(unsigned int cmdLvl); + + const unsigned int m_CCL_ADVANCED_ID = 1; // advanced user ID + const unsigned int m_CCL_DEFAULT_ID = 0; // default user ID + + + const char *m_CCL_ADVANCED_PWD = "advanced"; // default user ID +}; + +#endif /* PIE727CONTROLLER_H_ */ diff --git a/pigcs2App/src/PIGCS2PiezoCL.h b/pigcs2App/src/PIGCS2PiezoCL.h new file mode 100644 index 0000000..4559b07 --- /dev/null +++ b/pigcs2App/src/PIGCS2PiezoCL.h @@ -0,0 +1,170 @@ +/* +FILENAME... PIGCS2PiezoCL.h + +************************************************************************* +* Copyright (c) 2011-2013 Physik Instrumente (PI) GmbH & Co. KG +* This file is distributed subject to the EPICS Open License Agreement +* found in the file LICENSE that is included with this distribution. +************************************************************************* + + +Augusto Horita +August 03, 2022 + +*/ + +#ifndef PI_GCS2CLPARAMS_INCLUDED_ +#define PI_GCS2CLPARAMS_INCLUDED_ + +#include +#include + + +#define PIGCS2_CL_PARAM_QTT ((sizeof(PIGCS2PiezoCLParams)/sizeof(int))/2) + +#define PI_X_CL_IDX 0 +#define PI_Y_CL_IDX 1 +#define PI_Z_CL_IDX 2 + +// ------------- X Axis Closed loop Parameters ------------- + +#define KP_String std::string("PI_SUP_KP_") +#define KI_String std::string("PI_SUP_KI_") // I-term Gain +#define KFF_String std::string("PI_SUP_KFF_") // Feed Foward Gain +#define NTCHFR1_String std::string("PI_SUP_NTCHFR1_") // Notch frequncy 1 +#define NTCHFR2_String std::string("PI_SUP_NTCHFR2_") // Notch frequncy 2 +#define NTCHRJT1_String std::string("PI_SUP_NTCHRJT1_") // Notch reject 1 +#define NTCHRJT2_String std::string("PI_SUP_NTCHRJT2_") // Notch reject 2 +#define NTCHBDWDT1_String std::string("PI_SUP_NTCHBDWDT1_") // Notch bandwidth 1 +#define NTCHBDWDT2_String std::string("PI_SUP_NTCHBDWDT2_") // Notch bandwidth 2 +#define RBKP_String std::string("PI_SUP_RBKP_") +#define RBKI_String std::string("PI_SUP_RBKI_") +#define RBKFF_String std::string("PI_SUP_RBKFF_") +#define RBNTCHFR1_String std::string("PI_SUP_RBNTCHFR1_") +#define RBNTCHFR2_String std::string("PI_SUP_RBNTCHFR2_") +#define RBNTCHRJT1_String std::string("PI_SUP_RBNTCHRJT1_") +#define RBNTCHRJT2_String std::string("PI_SUP_RBNTCHRJT2_") +#define RBNTCHBDWDT1_String std::string("PI_SUP_RBNTCHBDWDT1_") +#define RBNTCHBDWDT2_String std::string("PI_SUP_RBNTCHBDWDT2_") + +#define PI_SUP_KP_X_String "PI_SUP_KP_X" // P-term Gain +#define PI_SUP_KI_X_String "PI_SUP_KI_X" // I-term Gain +#define PI_SUP_KFF_X_String "PI_SUP_KFF_X" // Feed Foward Gain + +#define PI_SUP_NTCHFR1_X_String "PI_SUP_NTCHFR1_X" // Notch frequncy 1 +#define PI_SUP_NTCHFR2_X_String "PI_SUP_NTCHFR2_X" // Notch frequncy 2 +#define PI_SUP_NTCHRJT1_X_String "PI_SUP_NTCHRJT1_X" // Notch reject 1 +#define PI_SUP_NTCHRJT2_X_String "PI_SUP_NTCHRJT2_X" // Notch reject 2 +#define PI_SUP_NTCHBDWDT1_X_String "PI_SUP_NTCHBDWDT1_X" // Notch bandwidth 1 +#define PI_SUP_NTCHBDWDT2_X_String "PI_SUP_NTCHBDWDT2_X" // Notch bandwidth 2 + +// Readback variables +#define PI_SUP_RBKP_X_String "PI_SUP_RBKP_X" +#define PI_SUP_RBKI_X_String "PI_SUP_RBKI_X" +#define PI_SUP_RBKFF_X_String "PI_SUP_RBKFF_X" + +#define PI_SUP_RBNTCHFR1_X_String "PI_SUP_RBNTCHFR1_X" +#define PI_SUP_RBNTCHFR2_X_String "PI_SUP_RBNTCHFR2_X" +#define PI_SUP_RBNTCHRJT1_X_String "PI_SUP_RBNTCHRJT1_X" +#define PI_SUP_RBNTCHRJT2_X_String "PI_SUP_RBNTCHRJT2_X" +#define PI_SUP_RBNTCHBDWDT1_X_String "PI_SUP_RBNTCHBDWDT1_X" +#define PI_SUP_RBNTCHBDWDT2_X_String "PI_SUP_RBNTCHBDWDT2_X" + +// ------------- Y Axis Closed loop Parameters ------------- +#define PI_SUP_KP_Y_String "PI_SUP_KP_Y" +#define PI_SUP_KI_Y_String "PI_SUP_KI_Y" +#define PI_SUP_KFF_Y_String "PI_SUP_KFF_Y" + +#define PI_SUP_NTCHFR1_Y_String "PI_SUP_NTCHFR1_Y" +#define PI_SUP_NTCHFR2_Y_String "PI_SUP_NTCHFR2_Y" +#define PI_SUP_NTCHRJT1_Y_String "PI_SUP_NTCHRJT1_Y" +#define PI_SUP_NTCHRJT2_Y_String "PI_SUP_NTCHRJT2_Y" +#define PI_SUP_NTCHBDWDT1_Y_String "PI_SUP_NTCHBDWDT1_Y" +#define PI_SUP_NTCHBDWDT2_Y_String "PI_SUP_NTCHBDWDT2_Y" + +#define PI_SUP_RBKP_Y_String "PI_SUP_RBKP_Y" +#define PI_SUP_RBKI_Y_String "PI_SUP_RBKI_Y" +#define PI_SUP_RBKFF_Y_String "PI_SUP_RBKFF_Y" + +#define PI_SUP_RBNTCHFR1_Y_String "PI_SUP_RBNTCHFR1_Y" +#define PI_SUP_RBNTCHFR2_Y_String "PI_SUP_RBNTCHFR2_Y" +#define PI_SUP_RBNTCHRJT1_Y_String "PI_SUP_RBNTCHRJT1_Y" +#define PI_SUP_RBNTCHRJT2_Y_String "PI_SUP_RBNTCHRJT2_Y" +#define PI_SUP_RBNTCHBDWDT1_Y_String "PI_SUP_RBNTCHBDWDT1_Y" +#define PI_SUP_RBNTCHBDWDT2_Y_String "PI_SUP_RBNTCHBDWDT2_Y" + + +// ------------- Z Axis Closed loop Parameters ------------- +#define PI_SUP_KP_Z_String "PI_SUP_KP_Z" +#define PI_SUP_KI_Z_String "PI_SUP_KI_Z" +#define PI_SUP_KFF_Z_String "PI_SUP_KFF_Z" + +#define PI_SUP_NTCHFR1_Z_String "PI_SUP_NTCHFR1_Z" +#define PI_SUP_NTCHFR2_Z_String "PI_SUP_NTCHFR2_Z" +#define PI_SUP_NTCHRJT1_Z_String "PI_SUP_NTCHRJT1_Z" +#define PI_SUP_NTCHRJT2_Z_String "PI_SUP_NTCHRJT2_Z" +#define PI_SUP_NTCHBDWDT1_Z_String "PI_SUP_NTCHBDWDT1_Z" +#define PI_SUP_NTCHBDWDT2_Z_String "PI_SUP_NTCHBDWDT2_Z" + +#define PI_SUP_RBKP_Z_String "PI_SUP_RBKP_Z" +#define PI_SUP_RBKI_Z_String "PI_SUP_RBKI_Z" +#define PI_SUP_RBKFF_Z_String "PI_SUP_RBKFF_Z" + +#define PI_SUP_RBNTCHFR1_Z_String "PI_SUP_RBNTCHFR1_Z" +#define PI_SUP_RBNTCHFR2_Z_String "PI_SUP_RBNTCHFR2_Z" +#define PI_SUP_RBNTCHRJT1_Z_String "PI_SUP_RBNTCHRJT1_Z" +#define PI_SUP_RBNTCHRJT2_Z_String "PI_SUP_RBNTCHRJT2_Z" +#define PI_SUP_RBNTCHBDWDT1_Z_String "PI_SUP_RBNTCHBDWDT1_Z" +#define PI_SUP_RBNTCHBDWDT2_Z_String "PI_SUP_RBNTCHBDWDT2_Z" + + +typedef struct PIGCS2PiezoCLParams{ + int PI_SUP_KP; + int PI_SUP_KI; + int PI_SUP_KFF; + int PI_SUP_NTCHFR1; + int PI_SUP_NTCHFR2; + int PI_SUP_NTCHRJT1; + int PI_SUP_NTCHRJT2; + int PI_SUP_NTCHBDWDT1; + int PI_SUP_NTCHBDWDT2; + int PI_SUP_RBKP; + int PI_SUP_RBKI; + int PI_SUP_RBKFF; + int PI_SUP_RBNTCHFR1; + int PI_SUP_RBNTCHFR2; + int PI_SUP_RBNTCHRJT1; + int PI_SUP_RBNTCHRJT2; + int PI_SUP_RBNTCHBDWDT1; + int PI_SUP_RBNTCHBDWDT2; +}PIGCS2PiezoCLParams; + + +typedef union u_PIGCS2PiezoCLParams +{ + PIGCS2PiezoCLParams CLParams_str; + int CLParams_arr[PIGCS2_CL_PARAM_QTT*2]; // Params AND Readback +}u_PIGCS2PiezoCLParams; + + +namespace PI727_CL_PARAM_ADDR +{ + enum CL_PARAM + { + KP = 0x07000300UL, + KI = 0x07000301UL, + KFF = 0x07030600UL, + NOTCHFREQ1 = 0x08000100UL, + NOTCHFREQ2 = 0x08000101UL, + NOTCHREJEC1 = 0x07000200UL, + NOTCHREJEC2 = 0x07000201UL, + NOTCHBDWDT1 = 0x08000300UL, + NOTCHBDWDT2 = 0x08000301UL, + }; + + static const CL_PARAM All[] = { KP , KI , KFF , NOTCHFREQ1 , NOTCHFREQ2 , \ + NOTCHREJEC1 , NOTCHREJEC2 , NOTCHBDWDT1 , NOTCHBDWDT2 }; +} + + +#endif // PI_GCS2CLPARAMS_INCLUDED_ \ No newline at end of file diff --git a/pigcs2App/src/PIGCSController.cpp b/pigcs2App/src/PIGCSController.cpp index 3902400..9e19f6c 100644 --- a/pigcs2App/src/PIGCSController.cpp +++ b/pigcs2App/src/PIGCSController.cpp @@ -21,6 +21,7 @@ Created: 15.12.2010 #include "PIGCSMotorController.h" #include "PIGCSPiezoController.h" #include "PIE517Controller.h" +#include "PIE727Controller.h" #include "PIE755Controller.h" #include "PIHexapodController.h" #include "PIGCS2_HexapodController.h" @@ -70,10 +71,13 @@ PIGCSController* PIGCSController::CreateGCSController(PIInterface* pInterface, c || strstr(szIDN, "E-709") != NULL || strstr(szIDN, "E-712") != NULL || strstr(szIDN, "E-725") != NULL - || strstr(szIDN, "E-727") != NULL ) { return new PIGCSPiezoController(pInterface, szIDN); + } + else if ( strstr(szIDN, "E-727") != NULL) + { + return new PIE727Controller(pInterface, szIDN); } else if ( strstr(szIDN, "E-755") != NULL) { diff --git a/pigcs2App/src/PIGCSController.h b/pigcs2App/src/PIGCSController.h index aec10b4..0412272 100644 --- a/pigcs2App/src/PIGCSController.h +++ b/pigcs2App/src/PIGCSController.h @@ -84,6 +84,10 @@ class PIGCSController virtual double GetPivotY() { return 0.0; } virtual double GetPivotZ() { return 0.0; } + // Closed loop parameters + virtual asynStatus setCLAxisParam( PIasynAxis* pAxis, unsigned int paramID, double wantedValue ){return asynSuccess;} + virtual double getCLAxisParam( PIasynAxis* pAxis, unsigned int paramID){return 0.0;} + virtual bool AcceptsNewTarget() { return true; } virtual bool CanCommunicateWhileHoming() { return true; } @@ -121,6 +125,7 @@ class PIGCSController bool m_KnowsVELcommand; bool m_IsGCS2; bool m_IsGCS21; + }; #endif /* PIGCSCONTROLLER_H_ */ diff --git a/pigcs2App/src/PIGCSPiezoController.cpp b/pigcs2App/src/PIGCSPiezoController.cpp index 25d2372..686df1a 100644 --- a/pigcs2App/src/PIGCSPiezoController.cpp +++ b/pigcs2App/src/PIGCSPiezoController.cpp @@ -21,32 +21,38 @@ Created: 15.12.2010 //#undef asynPrint //#define asynPrint(user,reason,format...) 0 - asynStatus PIGCSPiezoController::getStatus(PIasynAxis* pAxis, int& homing, int& moving, int& negLimit, int& posLimit, int& servoControl) { char cmd[100]; char buf[255]; + asynStatus status= asynSuccess; + sprintf(cmd, "SRG? %s 1", pAxis->m_szAxisName); - asynStatus status = m_pInterface->sendAndReceive(cmd, buf, 99); - if (status != asynSuccess) - { - return status; - } - const char* p = strstr(buf, "="); - if (p==NULL || *p == '\0') + if (m_hasqSRG) { - return asynError; - } + status = m_pInterface->sendAndReceive(cmd, buf, 99); + if (status != asynSuccess) + { + m_hasqSRG=false; + return status; + } + + const char* p = strstr(buf, "="); + if (p==NULL || *p == '\0') + { + return asynError; + } - long mask = strtol(p+1, NULL, 0); - getStatusFromBitMask (mask, homing, moving, negLimit, posLimit, servoControl); - // TODO: use parameter or "LIM?" to find out if stage has limit switches - negLimit = 0; - posLimit = 0; - asynPrint(m_pInterface->m_pCurrentLogSink, ASYN_TRACE_FLOW, - "PIGCSPiezoController::getStatus() buf:%s moving %d, svo: %d\n", - buf, moving, servoControl); + long mask = strtol(p+1, NULL, 0); + getStatusFromBitMask (mask, homing, moving, negLimit, posLimit, servoControl); + // TODO: use parameter or "LIM?" to find out if stage has limit switches + negLimit = 0; + posLimit = 0; + asynPrint(m_pInterface->m_pCurrentLogSink, ASYN_TRACE_FLOW, + "PIGCSPiezoController::getStatus() buf:%s moving %d, svo: %d\n", + buf, moving, servoControl); + } return status; } diff --git a/pigcs2App/src/PIGCSPiezoController.h b/pigcs2App/src/PIGCSPiezoController.h index 1110515..b90b29b 100644 --- a/pigcs2App/src/PIGCSPiezoController.h +++ b/pigcs2App/src/PIGCSPiezoController.h @@ -16,6 +16,7 @@ Created: 15.12.2010 #define PIGCSPIEZOCONTROLLER_H_ #include "PIGCSController.h" + #include /** @@ -30,6 +31,7 @@ class PIGCSPiezoController : public PIGCSController : PIGCSController (pInterface, szIDN) , m_hasqFRF (true) , m_hasqTRS (true) + , m_hasqSRG (true) { } ~PIGCSPiezoController() {} @@ -38,15 +40,15 @@ class PIGCSPiezoController : public PIGCSController virtual asynStatus initAxis(PIasynAxis* pAxis); virtual asynStatus haltAxis(PIasynAxis* pAxis); - virtual asynStatus setAxisPosition(PIasynAxis* pAxis, double position); - virtual asynStatus getStatus(PIasynAxis* pAxis, int& homing, int& moving, int& negLimit, int& posLimit, int& servoControl); - virtual asynStatus getReferencedState(PIasynAxis* pAxis); - virtual asynStatus referenceVelCts( PIasynAxis* pAxis, double velocity, int forwards); - + virtual asynStatus setAxisPosition(PIasynAxis* pAxis, double position); + virtual asynStatus getStatus(PIasynAxis* pAxis, int& homing, int& moving, int& negLimit, int& posLimit, int& servoControl); + virtual asynStatus getReferencedState(PIasynAxis* pAxis); + virtual asynStatus referenceVelCts( PIasynAxis* pAxis, double velocity, int forwards); protected: bool m_hasqFRF; ///< is "FRF?" command available bool m_hasqTRS; ///< is "TRS?" command available + bool m_hasqSRG; ///< is "SRG?" command available }; diff --git a/pigcs2App/src/PIasynAxis.cpp b/pigcs2App/src/PIasynAxis.cpp index d15a91d..ac6746d 100644 --- a/pigcs2App/src/PIasynAxis.cpp +++ b/pigcs2App/src/PIasynAxis.cpp @@ -112,6 +112,32 @@ PIasynAxis::~PIasynAxis() } } +void PIasynAxis::createCLParams(const char* axisName) +{ + pController_->createParam( (KP_String + axisName).c_str() , asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_KP); + + + // printf("------------------- createCLParams() axis %s %s ------------------- \r\n",KP_String,axisName ); + + pController_->createParam( (KI_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_KI); + pController_->createParam( (KFF_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_KFF); + pController_->createParam( (NTCHFR1_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_NTCHFR1); + pController_->createParam( (NTCHFR2_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_NTCHFR2); + pController_->createParam( (NTCHRJT1_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_NTCHRJT1); + pController_->createParam( (NTCHRJT2_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_NTCHRJT2); + pController_->createParam( (NTCHBDWDT1_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_NTCHBDWDT1); + pController_->createParam( (NTCHBDWDT2_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_NTCHBDWDT2); + pController_->createParam( (RBKP_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_RBKP); + pController_->createParam( (RBKI_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_RBKI); + pController_->createParam( (RBKFF_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_RBKFF); + pController_->createParam( (RBNTCHFR1_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_RBNTCHFR1); + pController_->createParam( (RBNTCHFR2_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_RBNTCHFR2); + pController_->createParam( (RBNTCHRJT1_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_RBNTCHRJT1); + pController_->createParam( (RBNTCHRJT2_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_RBNTCHRJT2); + pController_->createParam( (RBNTCHBDWDT1_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_RBNTCHBDWDT1); + pController_->createParam( (RBNTCHBDWDT2_String + axisName).c_str(), asynParamFloat64, &m_CloseLoopParam.CLParams_str.PI_SUP_RBNTCHBDWDT2); +} + asynStatus PIasynAxis::poll(bool *returnMoving) { int done = 0; diff --git a/pigcs2App/src/PIasynAxis.h b/pigcs2App/src/PIasynAxis.h index 99b70be..f766784 100644 --- a/pigcs2App/src/PIasynAxis.h +++ b/pigcs2App/src/PIasynAxis.h @@ -18,6 +18,7 @@ Based on drvMotorSim.c, Mark Rivers, December 13, 2009 #include // for asynStatus #include +#include "PIGCS2PiezoCL.h" class PIasynController; class PIGCSController; @@ -41,6 +42,8 @@ class PIasynAxis : public asynMotorAxis virtual asynStatus setPosition(double position); + void createCLParams(const char* axisName); + char* m_szAxisName; ///< GCS name int m_isHoming; ///< if \b TRUE indicating that axis is currently homing/referencing @@ -69,6 +72,7 @@ class PIasynAxis : public asynMotorAxis bool m_bServoControl; bool m_bMoving; int m_movingStateMask; + u_PIGCS2PiezoCLParams m_CloseLoopParam; friend class PIasynController; private: diff --git a/pigcs2App/src/PIasynController.cpp b/pigcs2App/src/PIasynController.cpp index b459851..ede60d1 100644 --- a/pigcs2App/src/PIasynController.cpp +++ b/pigcs2App/src/PIasynController.cpp @@ -155,14 +155,14 @@ PIasynController::PIasynController(const char *portName, const char* asynPort, i { pAxis = new PIasynAxis(this, m_pGCSController, axis, m_pGCSController->getAxesID(axis)); pAxis->Init(portName); + + pAxis->createCLParams(m_pGCSController->getAxesID(axis)); } startPoller(double(movingPollPeriod)/1000, double(idlePollPeriod)/1000, 10); } - - void PIasynController::report(FILE *fp, int level) { int axis; @@ -318,44 +318,59 @@ asynStatus PIasynController::writeFloat64(asynUser *pasynUser, epicsFloat64 valu * status at the end, but that's OK */ status = pAxis->setDoubleParam(function, value); - if (function == PI_SUP_TARGET) - { - printf("PI_SUP_TargetAO: %f for axis %d\n", value, pAxis->axisNo_); - } - else if (function == PI_SUP_PIVOT_X) - { - status = m_pGCSController->SetPivotX(value); - } - else if (function == PI_SUP_PIVOT_Y) - { - status = m_pGCSController->SetPivotY(value); - } - else if (function == PI_SUP_PIVOT_Z) - { - status = m_pGCSController->SetPivotZ(value); - } -// else if (function == motorPosition_) // Entspricht das DFH ? -// { -// // pAxis->enc_offset = (double) value - pAxis->nextpoint.axis[0].p; -// asynPrint(pasynUser, ASYN_TRACE_FLOW, -// "%s:%s: Set axis %d to position %d", -// driverName, functionName, pAxis->axisNo_, value); -// } - else if (function == motorResolution_ ) - { - /* Call base class call its method (if we have our parameters check this here) */ - status = asynMotorController::writeFloat64(pasynUser, value); - } - else if (function == motorEncoderRatio_) + // Closed loop parameters + unsigned int cl_iter = 0; + + for(cl_iter = 0; cl_iter < PIGCS2_CL_PARAM_QTT; cl_iter++) { - /* Call base class call its method (if we have our parameters check this here) */ - status = asynMotorController::writeFloat64(pasynUser, value); + if ( (function == pAxis->m_CloseLoopParam.CLParams_arr[cl_iter]) ) + { + status = m_pGCSController->setCLAxisParam( pAxis, PI727_CL_PARAM_ADDR::All[cl_iter], value ); + break; + } } - else + if (cl_iter < PIGCS2_CL_PARAM_QTT) { - /* Call base class call its method (if we have our parameters check this here) */ - status = asynMotorController::writeFloat64(pasynUser, value); + if (function == PI_SUP_TARGET) + { + printf("PI_SUP_TargetAO: %f for axis %d\n", value, pAxis->axisNo_); + } + else if (function == PI_SUP_PIVOT_X) + { + status = m_pGCSController->SetPivotX(value); + } + else if (function == PI_SUP_PIVOT_Y) + { + status = m_pGCSController->SetPivotY(value); + } + else if (function == PI_SUP_PIVOT_Z) + { + status = m_pGCSController->SetPivotZ(value); + } + // else if (function == motorPosition_) // Entspricht das DFH ? + // { + // // pAxis->enc_offset = (double) value - pAxis->nextpoint.axis[0].p; + // asynPrint(pasynUser, ASYN_TRACE_FLOW, + // "%s:%s: Set axis %d to position %d", + // driverName, functionName, pAxis->axisNo_, value); + // } + else if (function == motorResolution_ ) + { + /* Call base class call its method (if we have our parameters check this here) */ + status = asynMotorController::writeFloat64(pasynUser, value); + } + else if (function == motorEncoderRatio_) + { + /* Call base class call its method (if we have our parameters check this here) */ + status = asynMotorController::writeFloat64(pasynUser, value); + } + else + { + /* Call base class call its method (if we have our parameters check this here) */ + status = asynMotorController::writeFloat64(pasynUser, value); + } } + /* Do callbacks so higher layers see any changes */ pAxis->callParamCallbacks(); if (status) @@ -370,8 +385,6 @@ asynStatus PIasynController::writeFloat64(asynUser *pasynUser, epicsFloat64 valu } - - asynStatus PIasynController::profileMove(asynUser *pasynUser, int npoints, double positions[], double times[], int relative, int trigger ) { asynPrint(pasynUser, ASYN_TRACE_FLOW|ASYN_TRACE_ERROR, @@ -486,12 +499,24 @@ asynStatus PIasynController::configAxis(PIasynAxis *pAxis) asynStatus PIasynController::poll() { + PIasynAxis *pAxis; + m_pGCSController->getGlobalState(pAxes_, numAxes_); setDoubleParam( 0, PI_SUP_RBPIVOT_X, m_pGCSController->GetPivotX()); setDoubleParam( 0, PI_SUP_RBPIVOT_Y, m_pGCSController->GetPivotY()); setDoubleParam( 0, PI_SUP_RBPIVOT_Z, m_pGCSController->GetPivotZ()); + for (int axis=0; axis < this->numAxes_; axis++) + { + pAxis = getPIAxis(axis); + + for(unsigned int param=0 ; paramm_CloseLoopParam.CLParams_arr[param+PIGCS2_CL_PARAM_QTT], m_pGCSController->getCLAxisParam(pAxis,PI727_CL_PARAM_ADDR::All[param])); + } + } + setIntegerParam( 0, PI_SUP_LAST_ERR, m_pGCSController->GetLastError() ); callParamCallbacks();