Using Siemens Logo!Soft Comfort, I want to connect a Siemens Logo! (8) with pymodbus
Settings on a network input on siemens soft comfort (I also tried Unit ID 255 and Modbus Type "DI" (Digital input))
Pc Settings, (I have tried both Interfaces)
Pymodbus code:
import time
client = ModbusTcpClient('192.168.0.3')
print(client.connect())
while True:
time.sleep(1)
print(client.write_coil(1, True))
time.sleep(1)
print(client.write_coil(1, False))
The output:
True
Modbus Error: [Input/Output] [WinError 10054] An existing connection was forcibly closed by the remote host
Modbus Error: [Input/Output] [WinError 10054] An existing connection was forcibly closed by the remote host
There are two ways to connect to the Logo via PC, either with the Logo acting as a Modbus server or a Modbus client.
Add a server connection:
Leave the options completely empty:
You should then see a little yellow socket at the bottom of the logo:
No further configuration is needed (the Diagram Editor can be left empty)
Push this configuration to the Logo:
Send modbus-tcp-messages to the Logo, as described in the original post. The coils to target are described in the Logo!-Settings (they start at 1, while pymodbus starts at 0, so you need to subtract 1:
So if we want to turn on the Q1:
from pymodbus.client.sync import ModbusTcpClient
client = ModbusTcpClient('192.168.0.3') # Default port is 502
client.write_coil(address=8192, value=True) # Default unit_id is 1
Add a Client connection:
Enter the values you want to read:
Run a modbus server, see Documentation