IMD SolutionComputing LibraryShop main store

Troubleshooting

Why Node-RED reads an ifm CR0708 over Modbus TCP

Edge computing and IIoT Published 5 min read By IMD Solution engineering team

Short answer

Use the generic Modbus client nodes in Node-RED against the controller's Modbus TCP server on port 502. The register map is not published by the vendor; it is defined by the user program running on the controller, so you read it from the project or the machine builder's I/O list.

On this page
  1. Which path from Node-RED actually reaches the CR0708?
  2. Does the controller accept a TCP connection on port 502?
  3. Where is the register map, and who owns it?
  4. Does a read return the value the program holds?
  5. Does a write change the variable in the program?
  6. When should I cross-check with an independent Modbus client?
  7. Questions asked

Modbus TCP is the route from Node-RED to an ifm CR0708 ecomatController. The controller runs a CODESYS-based user program, and the only network path a generic Node-RED client can count on is the Modbus TCP server on port 502. The register map is not a vendor table: it is defined by the program in the controller, so your first job is getting the project or its Modbus address list.

Which path from Node-RED actually reaches the CR0708? #

Use the generic Modbus client nodes in Node-RED against the controller's Modbus TCP server; the other two candidates fail inside the controller, not in Node-RED. The decision is made before any configuration:

Path What it needs Outcome on this controller
NVL (node-red-contrib-nvl) Network variable lists defined identically in the program and the node Heavy CODESYS-side setup; not the short path
OPC UA An OPC UA server running in the controller Not offered on this route; a generic client cannot connect
Modbus TCP Server reachable on port 502 plus a register map The working path

Drop NVL and OPC UA. What remains is one reachability check, one register-map check, and a read and write test. If your wider flow also feeds a broker, the shape of that hand-off is covered in MQTT broker versus direct TCP from a Node-RED edge device.

Does the controller accept a TCP connection on port 502? #

The first decisive test is a TCP connect to the controller's Modbus port, 502 by default, and it must pass before any Node-RED setting matters. Test the hops in physical-to-transport order:

  • Put the Node-RED host and controller on one subnet, or confirm a route exists. Read the controller's address from its network configuration in the programming tool.
  • Ping the controller from the Node-RED host.
  • Open a TCP connection to the Modbus port, for example in Windows PowerShell: Test-NetConnection -ComputerName 192.168.1.20 -Port 502.
Result Meaning Next
Ping fails Cabling, subnet, VLAN or address mismatch Fix addressing, repeat
Ping passes, TcpTestSucceeded : False Nothing listens on the port: no Modbus TCP server enabled, or a different port Enable it in the project, below
TcpTestSucceeded : True Transport path clear Go to the register map

Where is the register map, and who owns it? #

There is no fixed, vendor-published register table for the CR0708; the addresses a Modbus client sees are defined by the user program, so the map comes from the project. Read it in this order:

  1. The original project opened in the ifm programming tool: find the Modbus configuration or the variables assigned Modbus addresses.
  2. The handover documentation from whoever wrote the program: the I/O list or Modbus address list.
  3. The CR0708 device documentation and programming manual from the manufacturer's download page, for how the server is enabled and how variables map to registers in that runtime.
Finding Next
Project available, mapping present Addresses, types and direction are defined; go to the read test
Project available, no mapping Add the mapping, download, repeat the port test
No project available Trial reads return unlabeled numbers; recover the project or the controller backup first

Does a read return the value the program holds? #

Configure the Modbus client node against the map: host is the controller address, port is the one that passed the port test, and the unit ID is whatever the project specifies, since that setting is the authority. Choose the function from the map: FC03 for holding registers, FC04 for input registers, FC01 and FC02 for coils and discrete inputs. Enter start address and length, remembering that Node-RED Modbus nodes address from 0, so a register written as 40001 in 4xxxx notation is address 0. Pick a polling rate the controller cycle can serve and read a variable whose live value you know.

Read result Cause
Timeout or connection refused Back to the port test; no listener or a firewall blocks the port
Illegal-address or illegal-function exception 0/1 offset error, wrong register type, or unmapped address
Value returned, wrong number Off by one, wrong data type, or a 32-bit value read with reversed word order
Value matches the program Go to the write test

Does a write change the variable in the program? #

Write only to a mapped, writable variable that the program does not overwrite every scan. Modbus registers are 16-bit words; a REAL or DINT spans two consecutive registers, so write both in one FC16 request to stop the program reading a half-updated value, and use FC06 only for single-word variables. Send the test value with the same address and unit ID as the read, then watch the variable in the programming tool's online view.

Write result Cause
Exception response Address is read-only or unmapped
Accepted, value reverts The program overwrites it each cycle; use a dedicated command register
Accepted, value holds Write path confirmed

When should I cross-check with an independent Modbus client? #

When a failure's cause is unclear, run the same request from a standalone Modbus TCP master on the same host, because one test halves the candidate causes. Same host, port, unit ID, function and address: if the standalone tool succeeds, the fault is in the Node-RED node configuration; if it fails identically, the fault is in the controller program or the network. For the classic trap where one failed request freezes the next one on a shared client, see when one failed Modbus getter freezes the next getter in Node-RED.

One safety note: never trial-write to addresses you have not confirmed in the map on a controller that runs a machine; write tests belong on a non-critical variable, or with the machine in a safe state.

Questions asked

What happens if the port test to 502 fails but ping succeeds?

The controller is on the network but nothing listens on that port. Open the project, enable the Modbus TCP server in the program, download it, and repeat the port test until it succeeds before touching Node-RED.

What happens if I use the wrong register address offset in Node-RED?

You get an illegal-address exception or the neighboring variable's value. Node-RED Modbus nodes address from 0, so subtract one from any 1-based register number and retest against a variable with a known live value.

What happens if a 32-bit value shows a wrong number over Modbus?

The two 16-bit registers are combined in the wrong word order or read as separate values. Read both registers in one request and swap the word order in your conversion until the result matches the value shown in the programming tool's online view.

Why did an OPC UA client fail to connect to the CR0708?

The controller offers no OPC UA server on this route, so a generic OPC UA client cannot connect regardless of its configuration. Spend no more time on endpoint settings; move to Modbus TCP, which the controller supports.

Why does a written value revert a moment later?

The controller program overwrites that variable every scan, so the network write wins for one cycle at most. Write to a dedicated command register that the program only reads, or have the program changed to treat the register as an input.

Keep reading

  • How-to

    Modbus TCP from a third-party PLC to cloud MQTT on IOT2040

    Yes. Modbus TCP has no vendor lock: any PLC that runs a Modbus TCP server on port 502 can be polled by an IOT2040, whatever its maker. One Modbus client node in Node-RED reads the PLC on X1 and one MQTT out node publishes on X2 to the broker over TLS on port 8883; OPC UA is needed only if the PLC itself runs an OPC UA server.

    Edge computing and IIoT

  • How-to

    MQTT to Modbus TCP with Node-RED on an edge gateway

    Yes: Node-RED with the node-red-contrib-modbus package can serve MQTT data to a SCADA client as Modbus TCP. Read the RTU device in Node-RED first, give the Modbus server node a port nothing else owns, and scale each MQTT payload to one integer per holding register before the first end-to-end test.

    Edge computing and IIoT

  • Troubleshooting

    Modbus RTU over TCP fails in a Proxmox LXC container

    A passing ping from the LXC container clears the network, not the Modbus transaction. A desktop client read the same gateway with RTU-over-TCP framing while Node-RED failed, and the gateway's own configuration was at fault: match transport framing, TCP port and unit ID on both ends, keep one client connected during tests, and rebuild the gateway configuration if matched settings still fail.

    Edge computing and IIoT

Publish Flexy tags as Modbus TCP holding registers