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.

NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

Hi Daniel,

I downloaded the 2011 version and I'm trying to use it to test a Modbus gateway.I used the example and reconfigured it for serial coms. It seems to comunicate OK and I can get the VendorName, ProductCode, and MajorMinorRevision plus more if I change to Read Regular using the Fetch Basic Objects. However, I can't seem to read the Discrete Inputs or the Input Registers. I've tried both RTU and ASCII.

The device is read only with 11 DI's (Function 02 address 0x0000 to 0x000A) and 18 AI's (Function 04 address 0x0000 to 0x0017). I can't see why it shouldn't work so any help would be appreciated.

Regards

Paul

0 Kudos
Message 11 of 527
(7,452 Views)

Hey Paul

Sounds like most of the code is working well, since Fetch Basic Objects is the most complicated function we have, but there may have been some other issues introduced. Can you:

(1) Describe what errors are occurring?

(2) Try this older library and tell me if you see the same issue: http://zone.ni.com/devzone/cda/epd/p/id/4756

Thanks,

Daniel

0 Kudos
Message 12 of 527
(7,452 Views)

Hi Daniel

We are just implementing the Modbus protocol in an embedded device and I am creating a test tool. I would like to be able to see the entire RTU frame so we can log individual packets and check our implementation. Is this possible through this API?

Thanks



Ray

0 Kudos
Message 13 of 527
(7,428 Views)

It is not currently possible with this implementation because that particular VI is password protected. I can think of a few options:

-Serial uses NI-Visa, so you can use NI I/O Trace to track all serial activity

-You can use the existing free library

-Depending on your needs I may be able to provide you with a VI you can use for this purpose. If the first two options don't work for you, let me know a little more about what information you need and what sort of format you'd be looking for.

Thanks,

Daniel

0 Kudos
Message 14 of 527
(7,428 Views)

Hello Daniel

Thanks for the information. It looks like I may have another issue which is that we wish to use the diagnostic functions (function code 08). I cannot see this functionality in either library, do you have plans to add it to the API?  Regarding my original query, the NI I/O Trace facility works but is a bit cumbersome for looking at the packets, so I will probably use the older library for tracing.

Thanks


Ray

0 Kudos
Message 15 of 527
(7,428 Views)

Hey Ray,

I sent you a PM which may help with the serial stuff, but I understand that the locked nature of the code makes it difficult to do the low level things you want to do. I'm definitely glad to hear that feedback.

Re: function code 08, there are no current plans to add that to the new api and the old library was never actively developed. This is the case because it didn't seem like this was too commonly requested. However, its actually really easy to implement the master half of the protocol in this library. Function code 08 is relatively complex, but I'd be happy to help you along that path if you're interested.

Thanks,

Daniel

0 Kudos
Message 16 of 527
(7,427 Views)

I am currently using the old Modbus library - and having some issues (vs. Ethernet/IP which I took out).

1) Does this toolkit run on cRIO hardware?

2) Any chance it might help with my CPU issue? Linked above - Indistrial Comms area on NI forums.

If any Modbus gurus have anysuggestions / answers for my question posed in the link above. I would love to hear it.

I have already tried polling the MB Ethernet Slave Demon on the other NIC (as the secondary is probably tied up with it's own master-polling-slaves data).

0 Kudos
Message 17 of 527
(7,427 Views)

I already posted in the other thread, but to answer your specific questions:
1) Yes, the toolkit runs on cRIO, but the example does not. I chose to make it use events, which makes it windows only.

2) One of the major changes to the code was improving performance, especially on the slave. So yeah, if you need faster responses at lower CPU usage, go for the new library.

Thanks,

Daniel

0 Kudos
Message 18 of 527
(7,425 Views)

Am I missing soemthing that needs to be on the cRIO target (9074)?

cRIO Software.jpg

Because it crashes and reboots when I attempt to run this very basic slave. Either within my project, or by it's self....

NewMBLibTest.jpg

If there is anything usefull in the consol crash report I have that.

0 Kudos
Message 19 of 527
(7,425 Views)

Hey S1ack,

When you say crash do you mean error or that the VI simply stops executing? If it is an error, let me know what that is--it shouldn't require anything special. If it stops executing, check your memory usage during deployment and after it starts running (via distributed system manager or the sysconfig api). It may be that you are running out of memory? I wouldn't guess this with a 9074, but with a 9072 I managed to kill off the process because I had wayyy too much stuff installed (shared variable engine, web services, etc.)...but then the 9072 has literally half the memory of the 9074. Worth a check though

Thanks,

Daniel

0 Kudos
Message 20 of 527
(7,425 Views)