NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

The screen shot below is the third party device's software to verify data at each address.  What I now notice is that they require an access code of zero before pinging the device for data.  How can I configure that into labview or should that matter?  Also, I should be using the Master and not Slave Modbus VI's right?

Modbus VI_2.png

Once again I want to thank you for helping me with this, I am truely grateful!

0 Kudos
Message 261 of 527
(1,746 Views)

Master is the correct set of VIs to us, but I am not sure what the "access code" is -- thats not standard terminology I've heard before.

I'm also not sure what the final bytes are in the "query" displayed. If you take a look back at the spec you'll see that the request should be address (0x01), function (0x03), start register (0x000C), count (0x0001) and thats it. It looks like your tester is adding two additional bytes on the end. This might make it match with RTU, in which the last characters are a CRC. However, RTU is only supported over serial as it relies on a set of "start" and "end" periods of silence. Did this tester come from the company which manufactures your slave device, or is it third-party?

One note, looking at your screenshot, is that the modbus library uses the address not the "register number", meaning you'd want to wire up a value of 12 (or 0x000C) to read the value shown in your screenshot.

0 Kudos
Message 262 of 527
(1,746 Views)

Thank You everyone for your help.  I finally have success.  I reached out to the third party device company and they informed me there was a bug in my firmware.  I upgraded the firmare and turned OFF the access code verification and BAAAAMMM! successful communication.  This is a shot of my final VI.

Modbus VI Final.png

Why can't third party devices ever just work the first time!  lol

Thanks again!!

0 Kudos
Message 263 of 527
(1,746 Views)

Glad to hear it. Was the access code just a custom feature from the device, or was it implemented in modbus in some way?

0 Kudos
Message 264 of 527
(1,746 Views)

The access code was not conducted through modbus.  It was a device boot up option deep in the firmware.  It's one of those things you wish they would mention but so conveniently leave out. Probably could have saved a lot of mine as well as your time.  Thanks again

0 Kudos
Message 265 of 527
(1,747 Views)

The problem I am having is that the read input register vi seems to destroy the indexes so that they have to be created for every loop. Saving them in a shift register or analagous method does not work. Error 1556 is pushed. NI support can't figure this out either.

0 Kudos
Message 266 of 527
(1,747 Views)

Assuming you are the same customer already working with applications engineering, I've heard from the engineer handing your service request and my understanding was that the problem was resolved.

In your code you were not preserving the modbus object appropriately and therefore error 1556 was thrown on the second call of your code. As I understand it this applications engineer also explained the correct way to use the API, which would be to initialize the modbus object once and then pass the initialized object into your subVI for repeated use. In the version of the code I saw you had a case structure around the initialization code, and so you were initializing the modbus instance but then throwing that data out.

I would recommend working with the AE to restructure the code appropriately. You can also take a look at the examples included with the API to better understand the intended structure for code using it.

Thanks,

Daniel

0 Kudos
Message 267 of 527
(1,747 Views)

HI Daniel,

Thanks for the response. Just to be clear, I am aware that the code I sent Matt did not save the array of indexes between loops. We had tried to do that using various methods but no joy. I would expect that using an uninitialized shift register would preserve the index information loop to loop, but it doesn’t.

Thanks for the consult.

0 Kudos
Message 268 of 527
(1,747 Views)

Solved. It was an issue of data retention from loop to loop.

0 Kudos
Message 269 of 527
(1,747 Views)

Hello ,

I am trying communicating with a gatway Wireless / RS485 Modbus RTU with an USB interface. I tried this code but dont works . I searched the error and found this 56 , Then , I searched the VI specified READ ADU Packet and found this other error 538179. I am doing correct   investigating the errors ? I am new on Labview and need the help .

Sem título1.pngSem título2.pngthe .

0 Kudos
Message 270 of 527
(1,747 Views)