1

I am trying to connect to TwinCAT using Pyads package in Python to communicate with the PLC. I already added the route in TwinCAT but when I try to connect on Python I receive the following error:

"ADSError: target machine not found Missing ADS routes (7)"

My Python code is as follows:

import pyads

plc = pyads.Connection('141.23.196.107.1.1', pyads.PORT_SPS1)

plc.open()

plc.read_by_name('global.bool_value', pyads.PLCTYPE_BOOL)

Please let me know where am I going wrong. I shall be grateful if anyone can give step by step instructions about connecting Python with TwinCAT using Pyads.

sentence
  • 8,213
  • 4
  • 31
  • 40
  • Does the PORT_SPS1 have value of 851? Try to remove the route from both sides, your client and the PLC and then create the route again. That usually helps. – Quirzo May 21 '19 at 04:45
  • I’ve haven’t looked much into pyads, I’ve started to do so some time ago. You might need to reference the correct port somehow to properly communicate to your project instance. It’s usually done by adding the port number at the end of an IP address or something like so ‘192.168.101.25:851’ for example. But I’m not sure how it would work in this case. Hope this helps. – CrypticParadigm Nov 07 '19 at 07:11

2 Answers2

0

Is the run-time on the same PC as your application? If so, use an empty string for the ADS address. If not, did you use the Broadcast search and Add Route function?

Archie
  • 91
  • 3
0

I solved it ,having a look in the application bar of windows ;There you can find the Twincat icon , if you click on it you can find the voice "change AMS net ID" in the menu "router" ,you find the right numer to insert in the pyads.Connection("ams net id",851). This number doesn't match with the IP number of the server.