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;

 

  1. Registrate Callback-Vi fotr the event method AdsReadConvertConnectUpdate.
     
  2. Event driven reading, structure variables 1:
  3. Global variables:
    - create cluster variable as illustration of the TwinCAT structure.
    - create global handle variable for the determination of the events.
     
  4. Event driven reading, structure variables 2:
  5. Initialise the data structure as illustration of the TwinCAT structure
     
  6. Event driven reading, structure variables 3:
  7. Create data connection and store the connection handle
     
  8. Event driven reading, structure variables 4:
  9. Cyclic access to global data and  disconnect the connection
     
  10. Event driven reading, structure variables 5:
  11. Event handling in the Callback-Vi
     
  12. 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.
  13.  
  14. Event driven reading, structure variables 6: