NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

The wait timer was just in there to be in there, so I could see in the log when a forced reconnection happened. I could see in the time stamp that a loop took longer, and it'd be flagged as reconnected, or potientially issue (also it happened every 100ms).

I really don't know what the core error was. I was chasing down 2. One was the base error 56 which is a masked VISA error. The other was a far lower single digital error code (I honestly can't remember off the top of my head), which simply stated I had owned the comport to long, this error happened randomly too.

I don't exactly know how this *fixed* the issue, because in all honestly I don't know what the issue was.

0 Kudos
Message 251 of 529
(1,367 Views)

I don't think that the buffer filling up was the issue here, and if it was, as smithd mentioned, just destroying and recreating the object should flush the buffer. I do create a method in my child classes to flush the buffer, although it's more of a general clean-up thing, and not a necesity. I don't think I've ever needed to flush the buffer in the middle of operation.

0 Kudos
Message 252 of 529
(1,367 Views)

Hey Everyone,

Have installed Modbus API and am trying to read data off a third party device via TCP/IP connection.  I have not been able to collect any data from the device however.  I know the IP address,port number, and holding register numbers, but always am getting error code 56 or 63.  Can someone please give me a hand figuring this out?

I have minimal training on LabVIEW, but am a quick learner.  I also have a third party program that I can use to verify that I in fact do have communications with the device.  I also know the request and response binary code to get the data.  I have tried all options for Modbus that labVIEW supports and doesn't support and nothing seems to work.  HELP

0 Kudos
Message 253 of 529
(1,367 Views)

Error 56 is an internal timeout

Error 63 is a general time out (device can't be found on the network).

Do you have the IP address and port correct?

0 Kudos
Message 254 of 529
(1,367 Views)

Yes, the IP address matches and is added to the Machine Acess list and the port matches the TCP/IP port under the VI Server Options dialog.

0 Kudos
Message 255 of 529
(1,367 Views)

If you right click on the error code and select "explain error" it will show you the meaning of the error. As valarauca said, 56 means the operation timed out (requesting data from the device). 63 means we couldn't connect in the first place because the other device actively refused the connection.

Does your device only support one connection? How are you currently using the library?

0 Kudos
Message 256 of 529
(1,367 Views)

My device supports TCP,USB,RS-232 connections.  We are using TCP to simplify connectivity with remote installations.  I have include the VI and setting I am currently using below.  Hopefully you can make out the image.

Modbus VI.png

0 Kudos
Message 257 of 529
(1,367 Views)

The VI server settings on the right are unrelated to this issue. Those settings allow for remote control of LabVIEW, and I would recommend setting them as restrictively as possible.

In this situation the error really is a timeout. Its attempting to connect and failing. New questions:

1-Which version of the library are you using? Do you have the newest version?

2-Is there an input for timeout on the "Create TCP Master" function? If so, is it set to required? If there is an input but it is not required, you do not have the newest version. This was an issue I introduced while adding the timeout. You can correct this immediately by wiring up a reasonable timeout (at least 500 ms, 5000 is more reasonable) or by upgrading.

0 Kudos
Message 258 of 529
(1,367 Views)

Correct, I am one version behind.  I added the 5000ms timeout and now receive the following error:

Error 538182 occurred at an unidentified location

 

Possible reason(s):

 

Modbus Error: Illegal Data Address. The specified data address is not an allowable address for the server.

Function 3

-For now I am going to upgrade to the latest version first, then continue to troubleshoot this new error.  However, there is no information found on NI.com for the error code.

0 Kudos
Message 259 of 529
(1,367 Views)

Anything above 538180 is a modbus error, meaning communication has been correctly established but there was an error at the protocol or application level. For example if you request to read more than 125 holding registers in a single request, you will get an error.

Ideally this would be something easy to understand, but on occasion you might need to break out the spec. For reference, you can look at page 15 here (http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf) to see that exception 2 is thrown when starting address is not OK or when starting address+quantity of registers is not OK. Thats why the response shown in LabVIEW says the data address is not allowed by the server.

So, are you sure holding register 13 exists on your device? What does the documentation say should be at that address?

0 Kudos
Message 260 of 529
(1,367 Views)