Search code examples
c#twincattwincat-ads

Read values through TwinCAT ADS without PLC variable declaration


I'm new to EtherCAT/TwinCAT. I have a slave device connected to Master. I can read data with an ADS Client from the slave device if I create a variable in my PLC and link that variable to a value on the slave. Is there a way to get a value from the slave without having to create a PLC variable? I'd like to be able to read and modify multiple objects on the slave without having to create a variable for each in the PLC.


Solution

  • In order to enable this functionality all you need to do is Enable ADS Server on the EtherCAT device that you are trying to access.

    Making ADS IO symbols available

    There are a few setup steps that are required to make this work, but it is reasonably straight-forward.

    1. Scan in IO from EtherCAT chain
    2. Add a new 'Twincat Task with Image'
      • Added from the context menu of 'System>Tasks'
    3. Create and link variable from added task to IO
      • Force the sync-unit updates and allow control of EtherCAT timing
      • I added a variable that linked to the SlaveCount with a UINT, very basic
    4. For EtherCAT master enable 'Enable ADS Server' and 'Create Symbols'
    5. Access Symbols as you would any other on the controller
      • Only oddity around this is that you need to access the CONTROLLER net ID, not the EtherCAT master, But you still use the port from the EtherCAT master

    Where to find 'Enable ADS Server', 'Create Symbols' and ADS Port

    Enabling the ADS Server


    Example Symbol path in the IO device list

    Symbol path as shown in XAE