I'm facing a weird issue with CODESYS Control Win V3 x64 on a fresh Windows install.
The situation is as follows:
CODESYS Modbus TCP Server (Slave) is running and I can see live values in the mapping display of Modbus settings: GVL (e.g., 32, 42, 50).
Port 502 is LISTENING according to netstat.
When connecting via Modbus Poll or Node-RED, the connection status changes to ESTABLISHED and everything reports as fine.
The Problem: Despite the successful connection, all holding registers return 0 no matter what. It's like the OS accepts the TCP handshake, the request counter goes up but the data payload never reaches Modbus Client (in this case Node-RED or Modbus Poll).
Quick Stats:
Firewall: Completely OFF.
Unit ID: Verified & Matching.
IP: Tried 127.0.0.1 and 192.168.0.1.
Interface: Correctly bound in Ethernet Device settings.
I already tried absolutely everything from changing IP address, subnet, port, deleting the project and starting new one and even nuking my old Windows install. Since I am near completion of my bachelor thesis only thing left for me to do is connect SoftPLC to NodeRED via Modbus but this issue is driving me crazy for weeks. I do not know what to do anymore.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Did you check the communication with a sniffer ? (ex. Wireshark) to check if the holding get to zero by a wrong writing (client initialization?) o something else?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Read the above description and experienced the same: Reading coil/discrete input/input register/holding register doesn't fill the mapped I/O variable.
Any suggestions?
Defined (see attachment):
- Ethernet (with parameters according to the used Ethernet adapter of my Windows 11 laptop)
- -Modbus TCP Client
- - -LOGO231 as Modbus TCP Server
- - -WS242 as Modbus TCP Server (WaveShare Modbus TCP <-> RTU converter)
- - - -WS242_01 as Modbus Server, COM port (slave-id 1 RTU)
- - - -WS242_03 idem (slave-id 3 RTU)
- - - -WS242_11 idem (slave-id 11 RTU)
Writing coil/holding register works from a mapped I/O variable works fine.
Verification of Modbus traffic with WireShark:
QUERY to and the RESPONSE of all slave-ids are correct
Status of all defined is CONNECTED, RESPONSE_SUCCESS, RUNNING etc.
Request counters increase with expected frequency. Error counter = 0.
(To have all counters works fine I had to change Modbus TCP Client's parameter OptimizationON to FALSE).
LOGO231 works fine: values in mapped I/O conform expectation
WS242 without Modbus Server, COM port and
with defined channels (for only 1 slave-id possible) works fine.
PLC Settings:
Update I/O while in stop: I see xBusy changing from FALSE to TRUE and vice versa.
Always update variables: Enabled 1
In the meantime I wrote a Function block to handle the reads and writes to the different attached RTU-devices.
It processes the parameter like (str_Modbus:=(usiSlave:=1, uiFC:=5, uiLEN:=1, uiOFFSET:=0, uiInterval:=500)) and the corresponding output, waits for the response and processes next request in a 5-state procedure. It's working for 2 gateways (stable without errors, although error recovery is included).
But nevertheless it should be possible with the Channel definitions of Codesys. Much easier to maintain :)
it works pretty well on codesys-version using device-tree and channels. heres the twist: each uid should be represented as a device, which in your case, it isn't.
on the other hand, you found a solution which already works fine.
Happy Modbus'ing
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone!
I'm facing a weird issue with CODESYS Control Win V3 x64 on a fresh Windows install.
The situation is as follows:
CODESYS Modbus TCP Server (Slave) is running and I can see live values in the mapping display of Modbus settings: GVL (e.g., 32, 42, 50).
Port 502 is LISTENING according to netstat.
When connecting via Modbus Poll or Node-RED, the connection status changes to ESTABLISHED and everything reports as fine.
The Problem: Despite the successful connection, all holding registers return 0 no matter what. It's like the OS accepts the TCP handshake, the request counter goes up but the data payload never reaches Modbus Client (in this case Node-RED or Modbus Poll).
Quick Stats:
Firewall: Completely OFF.
Unit ID: Verified & Matching.
IP: Tried 127.0.0.1 and 192.168.0.1.
Interface: Correctly bound in Ethernet Device settings.
I already tried absolutely everything from changing IP address, subnet, port, deleting the project and starting new one and even nuking my old Windows install. Since I am near completion of my bachelor thesis only thing left for me to do is connect SoftPLC to NodeRED via Modbus but this issue is driving me crazy for weeks. I do not know what to do anymore.
Are you sure you need to read holding registers? Have you tried reading input registers?
Did you check the communication with a sniffer ? (ex. Wireshark) to check if the holding get to zero by a wrong writing (client initialization?) o something else?
Hi there,
Read the above description and experienced the same: Reading coil/discrete input/input register/holding register doesn't fill the mapped I/O variable.
Any suggestions?
Defined (see attachment):
- Ethernet (with parameters according to the used Ethernet adapter of my Windows 11 laptop)
- -Modbus TCP Client
- - -LOGO231 as Modbus TCP Server
- - -WS242 as Modbus TCP Server (WaveShare Modbus TCP <-> RTU converter)
- - - -WS242_01 as Modbus Server, COM port (slave-id 1 RTU)
- - - -WS242_03 idem (slave-id 3 RTU)
- - - -WS242_11 idem (slave-id 11 RTU)
Writing coil/holding register works from a mapped I/O variable works fine.
Verification of Modbus traffic with WireShark:
QUERY to and the RESPONSE of all slave-ids are correct
Status of all defined is CONNECTED, RESPONSE_SUCCESS, RUNNING etc.
Request counters increase with expected frequency. Error counter = 0.
(To have all counters works fine I had to change Modbus TCP Client's parameter OptimizationON to FALSE).
LOGO231 works fine: values in mapped I/O conform expectation
WS242 without Modbus Server, COM port and
with defined channels (for only 1 slave-id possible) works fine.
PLC Settings:
Update I/O while in stop: I see xBusy changing from FALSE to TRUE and vice versa.
Always update variables: Enabled 1
your case looks different, the first one was an codesys modbus tcp-slave, your's an Master-Application with gateway.
I dont know this Unit, but i would say, from Point of Codesys it looks wrong configured.
Just give us more detailed configuration and the please make a sketch of the topology you're trying to realise.
Last edit: nulltrace 6 days ago
You're absolutely right. Sorry for that.
In the meantime I wrote a Function block to handle the reads and writes to the different attached RTU-devices.
It processes the parameter like (str_Modbus:=(usiSlave:=1, uiFC:=5, uiLEN:=1, uiOFFSET:=0, uiInterval:=500)) and the corresponding output, waits for the response and processes next request in a 5-state procedure. It's working for 2 gateways (stable without errors, although error recovery is included).
But nevertheless it should be possible with the Channel definitions of Codesys. Much easier to maintain :)
it works pretty well on codesys-version using device-tree and channels. heres the twist: each uid should be represented as a device, which in your case, it isn't.
on the other hand, you found a solution which already works fine.
Happy Modbus'ing