Multiple Modbus Servers to be read

Hi folks,

I`ve set up two modbus servers on Tia Portal.

Each read node is set up to each Modbus server. I can`t seem to access each one simultaneously from the same devcie?

Each one is set up to each Modbus connect values. So I dont quite get where Im going wrong?

Any help would be much appreciated.

Thank you :slight_smile:


why two modbus servers? what is the network or system architecture?

The node can be a client of these two servers, but they have the same IP, you have to change the remote port

One is for different data than the other and due to other reasons can`t be put on the same server.

The network is a router , a plc and a laptop wired connection all together.

How do you change the remote port? Would this be done on node red or through the Router?

Provided they have different ip addresses then you shouldn't need to change the port. After configuring them do they show in the node-red editor with different ip addresses?

Please export just the nodes from the image and paste them here (use the </> button at the top of the forum text entry window when pasting them).
Also tell us which modbus nodes you have installed. node-red-contrib-something probably.

[{"id":"aaffa8cb.a74e88","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"9675defc.4dfd","type":"modbus-read","z":"aaffa8cb.a74e88","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"1","quantity":"10","rate":"2","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"76526e07.93b4f","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":330,"y":180,"wires":[["d58c080b.d153b8"],["de3785a4.64b0f8"]]},{"id":"de3785a4.64b0f8","type":"modbus-response","z":"aaffa8cb.a74e88","name":"","registerShowMax":20,"x":690,"y":280,"wires":[]},{"id":"d58c080b.d153b8","type":"debug","z":"aaffa8cb.a74e88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":180,"wires":[]},{"id":"a74ef96e.e6c018","type":"modbus-read","z":"aaffa8cb.a74e88","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"2","dataType":"HoldingRegister","adr":"2","quantity":"10","rate":"2","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"3b8ccdee.108082","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":350,"y":420,"wires":[["13f20445.c87edc"],["96d2ddb4.86fd2"]]},{"id":"96d2ddb4.86fd2","type":"modbus-response","z":"aaffa8cb.a74e88","name":"","registerShowMax":20,"x":710,"y":520,"wires":[]},{"id":"13f20445.c87edc","type":"debug","z":"aaffa8cb.a74e88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":420,"wires":[]},{"id":"76526e07.93b4f","type":"modbus-client","z":"","name":"Siemens S7","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"","tcpPort":"503","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"3b8ccdee.108082","type":"modbus-client","z":"","name":"Siemens S7 Modbus 2","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"","tcpPort":"505","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"2","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

Hi Colin,

Thank you for the response, I set up the same port as suggested yet this still doesnt work. Hopefully you might be able to see any issues in the node?



So you have two servers configured with different ports (503 and 505). So exactly what symptom are you seeing?
Start node-red in a terminal and run it long enough for the problem to be seen then copy/paste the terminal output here. Paste the text in the same way as for the flow so the forum doesn't mess with it.

Hi Colin,

Yes so both modbus servers are set up for port 503 and 505 using unit id 1 and 2 respectively.

Error: {"name":"PortNotOpenError","message":"Port Not Open","errno":"ECONNREFUSED"}

The above response is what I get - I`ve tried using a modscan as well to read both registers on the same laptop. It seems that the laptop only allows one read of the serve than two at the same time.



That isn't the error you reported earlier, which you said was to do with the fact you have two servers. This problem is probably that you are running as a user that does not have permission to access those port numbers as numbers less than 1000 are normally reserved for system use. If you change them to ports 1503 and 1505 then that problem should go away.

I dont think thats the issue. Here is a picture, the below node is reading port 505 with unit ID 2. It still allows me to read them just not simultaneously and not via a different device.

Ideally what Im needing is for both ports to be read at the same time. Ive tried using a pi to read the port 503 data whilst reading the 505 port data through my laptop and again it really doesnt allow this. I`m getting the impession that only one connection can be made to the server at one time.

Any ideas?

In that case the problem is nothing to do with node-red but is a problem with the modbus servers themselves.

You haven't explained why you are using two modbus servers in the first place.

Well thats what I initially thought but theres nothing to suggest there is an issue with the modbus servers - if you look at the set up pictures above theres really nothing I could suggest as to the problem laying?

Okay sorry, so basically the project I`m working on relies on two systems assessing the same data via two modbus servers. They both hold the same data in their respected registers but they need to be separate.

Basically, PLC reads data from a device, its put into two register holders for two modbus servers, a raspberry pi needs to connect to one of the servers and then an external device, say a laptop needs to connect to the other modbus server.

Hope that fills you in

So is the end result to have node-red running on the laptop and the pi, with one talking to one server and the other talking to the second server?

If so then configure that (not both servers on both devices). Then check they both work with the other one stopped.

Yes thats the situation.

And yes, when one isn`t being used on one device , the other can connect. What I ideally want is both to be connected to each port at the same time.

Well as I said that must be a problem with the servers. The laptop and pi are not communicating in any way so they don't even know the other one is trying to talk to the other server, so it can't be a node-red issue.
To prove it run node-red on the pi talking to one server and run a different modbus client on the laptop at the same time talking to the other server.

Well my thinking was as they were all wired together through ethernet then it maybe an issue with the multiple connections reading together? So in essence they could be talking to each other

Thats exactly what Ive done and what Im saying isnt working, ive run one client on the pi, and one of the laptop and neither can work at the same time

Not sure what you mean by that. I meant that you use something other than node-red as a client to prove that the issue is not node-red related.

It isn't that since they have different port numbers and so should not be in any way related (provided the modbus server allows that). That is why you need to check it with something other than node-red to prove to yourself that it is not node-red related.

did u try to change the remote port in your DB (plc side) , remote and local they should be the same, active connection should be true.

u are using ob123 it like ob1 or its cycle? every time o adjust the parameters of the modbus (Data block) make o reboot the plc.

this is my example to ...2 modbus devices diff. IP same Port.

why u don't use s7node to connect to the plc and read the data....your plc can work like a gateway

can u make a diagram of the connections/network for we understand better