From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus - Issues with Reading Holding Registers

I am trying to read the holding registers on a RS485 2 wire modbus power monitor (Veris Industries E50C2).I am receiving bytes from the device so there appears to be communication. However, the response string is the exact same string as my command string. For instance, I am sending the hexadecimal string 0103 0000 0005 in order to read the first 5 holding registers, but I am receiving this exact same string back via the read VISA read function. I have attached an image of my VI. I would expect to see the response as "0103 (the device ID and command) followed by the number of bytes to follow and the contents of the holding registers.

 

The VI is running on a cRIO 9012 with 9111 chassis. I am using the 9871 c-series RS485/RS422 interface module.

 

Any ideas what the issue may be?

 

Kind Regards

 

Adam

 

 

0 Kudos
Message 1 of 8
(3,875 Views)
Have you tried using the modbus functions that are available for download?
0 Kudos
Message 2 of 8
(3,853 Views)

As Dennis said, use the NI Modbus library.

 

The problem with your command structure is you forgot to append the checksum to the end.

 

There is another possible problem.  What are you using as the RS-485 port on your PC?  I know that some (many?  all?) NI brand RS-485 ports need special treatment when you use 2-wire mode.  One thing you may need to do is jumper the RX and TX pins (assuming that the port is also configurable for 4 wire RS-485).  It's possible that the port has jumpers that will do this for you automatically.  The other thing is that depending on the nature of the serial port, you might get back an echo of your outgoing command since the receiving pins may be getting a copy of the message that the transmit pins are sending out.  RS-485 ports I've used account for that by disabling the receive pins when it is in transmit mode.  But not all ports might do that.

 

Search the NI.com website for "2 wire RS-485" for some articles discussing how NI handles its RS-485 ports.

0 Kudos
Message 3 of 8
(3,842 Views)

Thank you for your replies.

 

i have indeed tried using the modbus library "read holding registers" function to no avail. I simply do not get any data back. I have tried adding a visa property node immediately following the configure serial port function, and have set the property to RS485 2-wire/auto. This, too, has proved useless. 

 

My wiring is as follows:

 

I have twisted together the Rx - and Tx - from the port on the 9871 and have connected this to the negative terminal on the modbus device which is also Rx- and Tx - . Likewise, I did the same with the positive Rx and Tx. 

 

I am using scan mode on the cRIO 9012, and I do have the drivers installed in order to support the 9871 in scan mode. 

 

I have found this forum post with another user that had the same issue. He was able to resolve his problem. 

 

http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/NI-9871-wiring-to-device-with-A-and-B-termina...

 

This document is also useful:

 

http://digital.ni.com/public.nsf/allkb/5FFDF323C35C1B5386256F1C00622596

 

 

 

 

 

0 Kudos
Message 4 of 8
(3,810 Views)

Are you able to talk to the unit using the vendor supplied software?  http://www.veris.com/modbus.aspx

If I run into problems the first thing I like to do is use the vendor software to verify the unit is communicating.

0 Kudos
Message 5 of 8
(3,783 Views)

Xtasy, 

Have you actually found a solution for your problem?

I have the very same problem right now, and tried everyting i could find online.

Before i start a new thread i wanted to ask you...

0 Kudos
Message 6 of 8
(3,629 Views)

I'm sorry to say, but i never did resolve this issue. The project has been suspended for the moment. Will post here again when I continue troubleshooting the issue again. Next step will be to test communications usings a laptop with a USB-RS485 adapter using the vendor's software.

0 Kudos
Message 7 of 8
(3,590 Views)

I indeed manage to fix the issue for myself.

I used the same method you are starting right now, i conencted the NI9871 to the rs485 adapter given by the supplier and tried sending and reading my own signals.

After much hassle and some changes to your (and my) initial vi setup as shown in your first post, everything worked out fine:

(see the attached picture)

 

1. I used the NI modbus VIs, but it worked as well with the normal visa commands and building the modbus command on your own, but  way easier with the NI VIs.

2. i added the function to resize the buffer to its maximum size (not sure if thats actually helping with anything, but better be safe then sorry).

3. Change the wire mode for the 9871 to rs485/wire2-auto with a property node.

4. remove the large delay between write and read

 

5. Last but not least, the one thing that changed the fact that i only received my own echo:

I changed the connection of the Rx+/Tx+ and Rx-/Tx- around, basically connecting the 2wire sensor the other way around the manufacturer said it should be connected to the master device.

 

(6. Recheck the amount of stop bits, all modbus device i use in my lab are using 2 stop bits, but that could be a coincidence)

 

Maybe  something of that list helps you

0 Kudos
Message 8 of 8
(3,576 Views)