Event driven reading, structure variables
Method: AdsReadVarConvertConnect
Sample : Sample_OCX_008_StrucVarEventRead.zip
TwinCAT declaration:
TYPE ST_DataExchange :
STRUCT arrBool:
ARRAY[0..63] OF BOOL;
arrInt : ARRAY[0..63] OF INT;
arrReal : ARRAY[0..63] OF REAL;
END_STRUCT
END_TYPE
stTCtoLV AT%MB1000: ST_DataExchange;
- Registrate Callback-Vi fotr the event method AdsReadConvertConnectUpdate.
- Global variables:
- create cluster variable as illustration of the TwinCAT structure.
- create global handle variable for the determination of the events.
- Initialise the data structure as illustration of the TwinCAT structure
- Create data connection and store the connection handle
- Cyclic access to global data and disconnect the connection
- Event handling in the Callback-Vi
- With the passed handle hConnect the Callback-Vi decides for which variable the event has been called. It assigns the in data passed value to the right variable.