epics-modules / epics-twincat-ads

GNU Lesser General Public License v3.0
4 stars 4 forks source link

Callback fails when state machine in PLC overwrites requested value #13

Open mac-kan opened 16 hours ago

mac-kan commented 16 hours ago

With the ads module, it is possible to setup an output record, e.g. BO (EnableAxis), to control a BOOL variable (bEnable) in a Beckhoff PLC. It is possible to add an info tag to the record definition to allow callbacks to update the BO record in case the PLC variable has been updated from the PLC. See example:

record(bo, "$(P)$(M1)$(B)EnableAxis") {
    field(DESC, "Enable axis")
    field(PINI, "1")
    field(TSE,  "-2")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,1)ADSPORT=852/LightShutterSystem.aFbLightShutter$(C)[$(CH)].stAxis.stControl.bEnable?")
    field(ZNAM, "Zero")
    field(ONAM, "One")

    info(asyn:READBACK, "1")
}

Problem: A state machine is used in the PLC to govern if the BOOL variable bEnable is allowed to only be FALSE. A pvput is made to EnableAxis to turn the value to TRUE: pvput EnableAxis 1 *The requested value of TRUE is directly overwritten by the state machine in the PLC to FALSE. => The callback is not updating the BO record to FALSE, but remains TRUE.

tboegi commented 16 hours ago

Is that bEnable? with a question mark ?

mac-kan commented 13 hours ago

Yes, the OUT field address ends with "bEnable?".