Reputation: 11
I used pycharm for writing my code and plcsim for simulatio. When I run my code and run plcsim I get an error. I used Tia portal V16 and s7-1200 and I want to communicate between S7-1200 and python-snap7 This is the error:
PS C:\Users\Badro\PycharmProjects\pythonProject1\venv> py test.py
b' TCP : Unreachable peer'
Traceback (most recent call last):
- File "C:\Users\Badro\PycharmProjects\pythonProject1\venv\test.py", line 8, in <module>
plc.connect(IP, RACK, SLOT)
- File "C:\Users\Badro\AppData\Local\Programs\Python\Python310\lib\site-
packages\snap7\client.py",
line 24, in f
check_error(code, context="client")
- File "C:\Users\Badro\AppData\Local\Programs\Python\Python310\lib\site-
packages\snap7\common.py",
line 89, in check_error
raise RuntimeError(error)
RuntimeError: b' TCP : Unreachable peer'enter code here
and this is my code:
import snap7
IP = '192.168.100.100'
RACK = 0
SLOT = 1
plc = snap7.client.Client()
plc.connect(IP, RACK, SLOT)
print(plc.get_cpu_state())
I watched this videohttps://www.youtube.com/watch?v=BKnK4AT_WKs
Where is the problem or is the problem that plcsim must be the real plc for simulation not plcsim?
Upvotes: 1
Views: 4288
Reputation: 1
I have PLCSIM V13 SP1 and have tested your program and it works. I think you need to install NetToPLCSim which allows you to connect to the Plc to test your application using the network interface of the PC running the simulation. It is recommended that you run NetToPLCSim as an administrator.
Upvotes: 0
Reputation: 450
PLCSIM
cannot simulate a network interface on simulated PLCs.
You have to install PLCSIM Advanced V3.0
, which also simulates the network interface for each simulated PLC.
Upvotes: 0