LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sbRIO Modbus Slave Returns Wrong Unit ID

I have a sbRIO-9637 that I'm trying to setup as a Modbus slave. I've made a simple example (attached) that has a Unit ID of 112 and to return 3.14 (approx pi) as a single precision float (this uses two registers for a total of four bytes returned to the master) in Holding Registers with a starting address of 100. 

I'm running LabVIEW 2020 and am using the NI Modbus Library from VI Package Manager.  When I try use the NI Modbus Library master to get the value from the sbRIO it times out. In an attempt to figure out what was going on I used NI IO Trace to record to what was actually on the serial port. 

My master is sending the bytes I'd expect, see the attached files Capture.txt and Capture.nitrace.

70             Unit ID, 112 in hex

03             Read multiple holding registers

00 64        Starting address 100

00 02        Send two registers

8F 35        CRC16, I used an external tool to check it, it's correct

 

The slave on the sbRIO returns to me some unexpected data.

00             Unit ID,This should be 70

03             Read multiple holding registers

04             Four bytes will be returned

40 49 0F DA       Approx 3.14 as an IEEE 754 floating point number, I used an external tool to check it, it's correct.

DB 49        CRC16, this is the incorrect CRC if the Unit ID returning the data was actually 00, it's correct if the Unit ID was correctly set to 70, this causes the CRC check to fail

 

The Modbus master on my PC times out because it expecting a reply from Unit ID 112 and it ignores the reply from Unit ID 0.

I also used a https://fte.com/products/serialanalyzers-rs422485.aspx to monitor what was actually on the bus and it matches the above, see the file Capture-2024-06-27_145518.txt.

I've also attached a NI Max report about the SW installed on the sbRIO as well as the demo project that duplicates the problem.

 

Why does the Modbus slave return the wrong Unit ID and how do I fix it?

—Ben
Prevent your computer from sleeping programmatically!
Use Power Requests
Download from GitHub

0 Kudos
Message 1 of 5
(3,873 Views)

Ben,

 

My apologies this is taking so long.  I've escalated this within NI.

Eric Reffett | Director, Product Management | 1.512.683.8165 | ni.com
0 Kudos
Message 2 of 5
(3,766 Views)

The source is up on GitHub and the VIs aren't password protected there if that helps you debug. The VI package build is what adds the password to the VIs (it's "bestbus").

 

I'm not sure how the CRC could be calculated with the correct unit id but the unit id wouldn't be sent. The VI below shows what I'm pretty sure is called by the slave in response which shows how the unit id is placed before the PDU, The CRC is calculated, added to the end of the array, and then sent over the serial bus.

 

08-30 14_55-RTU Data Unit.lvclass_Write ADU Packet.vi Block Diagram on sbRIO Modbus Test.lvp.png

Message 3 of 5
(3,753 Views)

Thanks, it'll take me some time to set this all up for debugging. 

It is weird that it reads and writes the Unit ID in multiple places, perhaps something is getting mixed up in there. 

—Ben
Prevent your computer from sleeping programmatically!
Use Power Requests
Download from GitHub

0 Kudos
Message 5 of 5
(3,641 Views)