epics-motor / motorPIGCS2

EPICS asyn motor drivers for PI GCS2 controllers
2 stars 4 forks source link

E-727 and Closed Loop Control commands #10

Closed AugustoHorita closed 2 years ago

AugustoHorita commented 2 years ago

I am working with the PIE727 module and couldn't find support for gains and notch configuration. I implemented this code which works for us. I created a new class for PIE727 and also a header file with Closed Loop parameters and necessary structures. Included functions to set the CL parameters, and put the read function for these parameters in the poll thread.

There is a bug though, which I noticed also previously (also without this modification). If I use the asynRecord communication with the PI module, the poll thread starts to get timeouts for getting RAM parameters ("SPA?" commands) and position ("POS" commands) as soon as I set the ".OEOS" field in the asynRecord. I was thinking of maybe implementing a semaphore for this communication. (not yet done)

kmpeters commented 2 years ago

I am working with the PIE727 module and couldn't find support for gains and notch configuration. I implemented this code which works for us. I created a new class for PIE727 and also a header file with Closed Loop parameters and necessary structures. Included functions to set the CL parameters, and put the read function for these parameters in the poll thread.

@JensKappPI and @PI-SRau, should Augusto's changes be E-727-specific or would they also apply to the other piezo controllers support by motorPIGCS2?:

https://github.com/epics-motor/motorPIGCS2/blob/9c85d0b45555ecfbc11eb40837a4acccbd4ab107/pigcs2App/src/PIGCSController.cpp#L68-L76

kmpeters commented 2 years ago

There is a bug though, which I noticed also previously (also without this modification). If I use the asynRecord communication with the PI module, the poll thread starts to get timeouts for getting RAM parameters ("SPA?" commands) and position ("POS" commands) as soon as I set the ".OEOS" field in the asynRecord. I was thinking of maybe implementing a semaphore for this communication. (not yet done)

This problem is due to design decisions for handling both single-character commands that don't have a terminator and multi-character commands that require a terminator.

The driver sets the asyn records output end-of-string to an empty string in PIasynController.cpp and expects that to not change:

https://github.com/epics-motor/motorPIGCS2/blob/9c85d0b45555ecfbc11eb40837a4acccbd4ab107/pigcs2App/src/PIasynController.cpp#L109-L115

The sendAndReceive method of the PIInterface class is overloaded. If sendAndReceive is passed a C string, like when the version string is queried:

https://github.com/epics-motor/motorPIGCS2/blob/9c85d0b45555ecfbc11eb40837a4acccbd4ab107/pigcs2App/src/PIasynController.cpp#L120

Then the sendAndReceive method that is called adds a new line character:

https://github.com/epics-motor/motorPIGCS2/blob/9c85d0b45555ecfbc11eb40837a4acccbd4ab107/pigcs2App/src/PIInterface.cpp#L115-L118

If sendAndReceive is passed a char instead, like when the moving status is polled:

https://github.com/epics-motor/motorPIGCS2/blob/9c85d0b45555ecfbc11eb40837a4acccbd4ab107/pigcs2App/src/PIGCSController.cpp#L565

Then the sendAndReceive method that is called does NOT add any end-of-string characters:

https://github.com/epics-motor/motorPIGCS2/blob/9c85d0b45555ecfbc11eb40837a4acccbd4ab107/pigcs2App/src/PIInterface.cpp#L194-L233

kmpeters commented 2 years ago

There is a bug though, which I noticed also previously (also without this modification). If I use the asynRecord communication with the PI module, the poll thread starts to get timeouts for getting RAM parameters ("SPA?" commands) and position ("POS" commands) as soon as I set the ".OEOS" field in the asynRecord. I was thinking of maybe implementing a semaphore for this communication. (not yet done)

@AugustoHorita, are you able to send commands like SPA? to the controller from the asyn record without causing driver errors by leaving the OEOS blank and instead adding a \n to the end of command in the AOUT field? Sending SPA?\n is much less intuitive, but if it works that could eliminate the need to change the driver further (and possibly introduce new bugs).

AugustoHorita commented 2 years ago

There is a bug though, which I noticed also previously (also without this modification). If I use the asynRecord communication with the PI module, the poll thread starts to get timeouts for getting RAM parameters ("SPA?" commands) and position ("POS" commands) as soon as I set the ".OEOS" field in the asynRecord. I was thinking of maybe implementing a semaphore for this communication. (not yet done)

@AugustoHorita, are you able to send commands like SPA? to the controller from the asyn record without causing driver errors by leaving the OEOS blank and instead adding a \n to the end of command in the AOUT field? Sending SPA?\n is much less intuitive, but if it works that could eliminate the need to change the driver further (and possibly introduce new bugs).

First of all, @kmpeters: thanks for your feedback and detailed explanation. I will try to send the command like you suggested and get back here to inform.

AugustoHorita commented 2 years ago

@kmpeters...Sending the commands like you suggested worked fine! Thanks one more time for your help.

kmpeters commented 2 years ago

Jens responded by email with info about the other piezo controllers:

"In general these change are valid for all piezo controllers, but there is one exception. The E-709 controller does not support the parameter 0x07030600."

Applying these features to most of the piezo controllers is outside the scope of this pull request. I'll create an issue for that.

kmpeters commented 2 years ago

Applying these features to most of the piezo controllers is outside the scope of this pull request. I'll create an issue for that.

The issue has been created: https://github.com/epics-motor/motorPIGCS2/issues/11