Reading data type UNION and BIT with OPC-UA

In an Indralogic project we have a union of DWORD and a 32 element structure of type BIT. For example:

TYPE UN_CONTROL :
UNION
   Word : WORD;
   Bits : ST_CTRL_BITS;
END_UNION
END_TYPE

TYPE ST_CTRL_BITS:
STRUCT
   b0 : BIT;
   b1 :  BIT;
   ...
   ...
   b31 : BIT;
END_STRUCT
END_TYPE;

We have this because some legacy HMI used words to communicate, but within the PLC itself it is nice to be able to address variables as control.bits.b<whatever name>.

This works within indralogic, no problem. The trouble is, when trying to access this word via OPC-UA (UA-client, Web-IQ, etc) it neither appears as the bits or the word, it is like it has completely dissappeared.

I know I could re-write the code to switch between WORDs and, say, a BOOL structure, but I was hoping to find a neater solution utilising the UNION. Any suggestions?

p.s. in an integration with a 3rd-party (UniOP device), I shared the XML schema and XML file with the project variables, and the developer could read and manipulate the BIT!

Best reply by HmiGuide

NickOS in the MLC version you are using there is an older CoDeSys version than in ctrlX.

 There is an easy workaround to access the variable. Just add a refence which points to your structure. I tested it with IW 14V22 P5.

 

VAR_GLOBAL
  stTest:  UN_CONTROL;
  // reference MUST be initialized to export it into symbol file
  refDWord: REFERENCE TO DWORD REF= stTest.dwValue;
END_VAR

 

 

View original
8 replies