Showing results for 
Search instead for 
Did you mean: 

Modbus not receiving data, modbus slave tool does receive, serial port issue?


I have got a PLC with a RS485 communication module just sending data (register value). On the computer side I have a RS485 to USB stick connected as COM4. With a modbus slave tool (see screenshot) I have the communication working. The screenshot shows value #0055 was received. With a LabView program I now have the problem that I don't receive any data. Just value #0000 is returned.


The strange things...

At first the LabView program did nothing. Looking for another solution I tried just some serial reading example programs with which I saw bytes being received. When switching back to my Modbus vi it suddenly was working! Did not change any settings!

Next step I replaced the connection cable with a longer cable. Restarted the vi and the vi was not working anymore. Reconnected the original short cable again and still no data in the vi. But the Modbus slave tool does show the right data! Why?


With the Modbus slave tool working the hardware must be ok, so the problem is in the software. Because I have seen the LabView vi working it means that the principle is ok, but there probable is something wrong with reading data from the serial port. But what could be the cause that the vi after stopping and starting again does not read data anymore? Has it do to with serial port allocation? 


I tried to do a lot of different things to get to figure out what is happening here. Hope someone has suggestions for me to try. Thanks.

Download All
0 Kudos
Message 1 of 6

Put an error indicator inside your while loop.  Right now you have an infinite while loop so the close connection never executes and the error out indicator never gets any data.


Something is odd in that picture has you have it set for start at 0 for 1 register, yet your Read Values array shows two elements.

Message 2 of 6

AFAIK, a Modbus slave is waiting for requests (R/W) from an external master.

So the slave is your PLC. You need to create a master to poll it.

Probably Read Holding Registers for a slave returns the content of its own data space, which is null because nobody initialized it.

LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 6

Thanks for the tip on the error indicator, I will try that.

The odd thing is that is was working for a while, did not change the settings for start and count.

0 Kudos
Message 4 of 6

Thanks for your reply. 

The PLC is the master. Had the indicated vi working for a while showing the data that was transmitted by the plc.


0 Kudos
Message 5 of 6

It has taken a while due to personal reasons but I have it working now. Problem was initialization of the usb/com port.


At the time it did not work I tried several things including changing com port, other cable, other usb to serial dongle etc. With the error check not at the right place I did not see the com initialization error. Once the error was there new com port initialization always failed. At one moment I closed LabView completely and restarted and reopened the vi. Com port could be initialized again and communication worked.

0 Kudos
Message 6 of 6