Twincat 3 ADS not working!

Hi,

Having trouble configuring https://www.home-assistant.io/components/ads/. I get no errors when i do configuration check but when HA start up it says “Invalid config” ‘ads’ could not be set up and that i need to check my config. Twincat is running on my device “Beckhoff CX5130”. I guess i have to create ads rout between my CX and HA. But how?

My configuration.yaml ->

ads:
 device: '192.168.10.210.1.1'
 port: 851
 ip_address: 192.168.10.210 
 
sensor:
  - platform: ads
    adsvar: GVL.rutetemp
    unit_of_measurement: '°C'
    adstype: integer 

*****

Error during setup of component ads
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/setup.py”, line 148, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/ads/init.py”, line 57, in setup
import pyads
File “/usr/local/lib/python3.6/site-packages/pyads/init.py”, line 5, in
from .ads import open_port, close_port, get_local_address, read_state,
File “/usr/local/lib/python3.6/site-packages/pyads/ads.py”, line 23, in
from .pyads_ex import (
File “/usr/local/lib/python3.6/site-packages/pyads/pyads_ex.py”, line 46, in
_adsDLL = ctypes.CDLL(adslib)
File “/usr/local/lib/python3.6/ctypes/init.py”, line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: Error loading shared library /usr/local/lib/python3.6/site-packages/pyads/adslib.so: Exec format error

Thanks!

I had a similar problem with Twincat2. Problem was the AMS router of the PLC. I added the AmsNetId id of my raspberry pi (id = ipaddress + ‘.1.1’ f.e. 192.168.0.50.1.1). You can add this on the PLC (rightclick on the beckoff tray icon - properties - tab ‘AMS router’). Didn’t work after adding ams router. I had to reboot the PLC, then I saw thecorrect sensor values.

configuration.yaml:
ads:
device: ‘172.20.4.254.1.1’
port: 801
ip_address: 172.20.4.254

sensor:
  - platform: ads
    adsvar: .TemperatuurEetruimte10
    adstype: int  
    unit_of_measurement: '°C'
    factor: 10
    name: AdsTempEetruimte

Hi!
I’ve got same problem. I added a route in System Manager
AmsNetId: 192.168.0.108.1.1
Transport type: TCP/IP
Adress Info: 192.168.0.108

I rebooted my PLC, but it didn’t work anyway.
My configuration.yaml is simmilar to your:

ads:
device: ‘5.20.43.2.1.1’
port: 801
ip_address: 192.168.0.105

sensor:
  - platform: ads
    adsvar: KOMINEK.iTempKOMORA
    adstype: int  
    unit_of_measurement: '°C'
    factor: 10
    name: Temp

Any advice?

anyone, can help ??
Seru udało się tobe polaczyc z PLC ??

Yeah it worked. But only with hassbian not hassio.

can you explain your complete setting?
What do have done in your setting?
Can you sent me a example with HA config, PLC program. more ore less a complete example for both sides (HA and PLC).
My configuration is HA on PI, Beckhoff CX9020 with running PLC on Port 801
I was not able to get a connection to the ADS.

Best regards
Norbert

Can you explain your complete setting?
Can you post a example with HA config, PLC program.

Best regards
Norbert

Hi.
Here are some extracts from my Home assistant: configuration.yaml.

Create an ADS connection to the Twincat PLC (port 801). In my example the PLC IP address is 192.168.0.250. AmsNetID is 192.168.0.250.1.1:

ads:
  device: '192.168.0.250.1.1'
  port: 801
  ip_address: 192.168.0.250

binary and analogue lights:

light:
    #binary
  - platform: ads
    name: Keuken TL
    adsvar: Keuken.HAKeukenTL
    #analogue
- platform: ads
    name: Bureau spots
    adsvar: Bureau.HABureauSpots
    adsvar_brightness: GvlBureau.HABureauSpotsDimValue

sensors (f.e. temperature):

sensor:
  - platform: ads
    adsvar: Temperatuur.HAEetruimte
    adstype: int  
    unit_of_measurement: '°C'
    factor: 10
    name: Temp Eetruimte

switch (to open a port):

switch:
  - platform: ads
    name: Open port  
    adsvar: Garage.HAGaragepoortOpenen

In ui-lovelace.yaml you can refer to the ads entities:

entities:
  - light.keuken_tl
  - light.bureau_spots
  - sensor.temp_eetruimte
  - switch.open_garagepoort

On the beckhoff side:
First you must add your HA device to the AMS router of the PLC. I added the AmsNetId id of my raspberry pi (id = ipaddress + ‘.1.1’ f.e. 192.168.0.50.1.1). You can add this on the PLC (rightclick on the beckhoff tray icon - properties - tab ‘AMS router’). Don’t forget to restart the PLC.

And every ‘adsvar’ in the configuration.yaml points to a TwinCAT variable.
F.e. temperature: adsvar: Temperatuur.HAEetruimte is an integer variable ‘HAEetruimte’ in the program ‘Temperatuur’. (If you use global variables the variable must start with a point.)

PROGRAM Temperatuur
VAR
	HAEetruimte: INT;

Hope this helps to get started with ADS.

1 Like