NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

Daniel,

Thanks for all the hard work on this. I finally had time to implement this for my slave side functions, I was using the IOServer. The results went quite smoothly with a not earth shattering reduction in CPU total utilization of about 10-5% (I think you mentioned this way back in the thread). But I also gained a big boost in flexibility.

I have not yet converted my master stuff from the old library. If it aint broke... etc.

again, thanks much.

0 Kudos
Message 291 of 507
(1,088 Views)

Glad to hear everything is working well for you. Yeah, you definitely won't see a huge benefit on the slave side for serial, but the tcp version will have much better latency than the I/O server...I've seen it drop from ~20 ms per request to <1 ms.

0 Kudos
Message 292 of 507
(1,086 Views)

Hey guys!

Thanks for this wonderful library!

I'm testing it out on the Modbus Simulator provided by NI. I'm a bit confused on how to read 32 bit floating point numbers.

1) When I read the holding registers it appears as if I'm getting a rounded number of the Analog Input I'm trying to read. The first analog input register is at 0 (the actual value is 49.3), and it returns 49 in the first element of the array. I also looked through this thread and tried to use the join numbers VI and swap the bytes, but I can't get the 49.3.

2) Looking through this thread, I've tried to use the VI - Read Input Registers, but I don't get any values through it

I'd appreciate if someone could test this out and get back to me...thanks!

0 Kudos
Message 293 of 507
(1,086 Views)

Is it safe to assume you're talking about the demo box?

http://digital.ni.com/public.nsf/allkb/A9C037C838B203FA86256A180078BE15

If so (2) is because I don't think the demo box supports input registers, just holding registers and coils.

For (1), thats going to depend on the device. I've never used the demo box. Typically I've seen it one of two ways:

-Values are encoded as a single-precision float across two registers

-Values are truncated and then manipulated into integer form. For example you might see 49.3249 converted into 4932. Since this is just a demo box I'm guessing its truncating it to 49.

In either case I wouldn't worry about what the simulator does too much because its going to change. Every modbus device is a little bit different.

0 Kudos
Message 294 of 507
(1,086 Views)

Hey smithd!

No that's a hardware component I believe. If you go into LabVIEW -> Find Examples -> Modbus Simulator it's present in software.

But yes I understand what your saying completely...it's best to try it on the device. I'll give it a go!

Thanks, Shivam

Date: Mon, 17 Aug 2015 11:07:32 -0500

From: web.community@ni.com

To: saxenashivam@hotmail.com

Subject: - Re: NI LabVIEW Modbus API Discussion

Community

Re: NI LabVIEW Modbus API Discussion

created by smithd in NI Labs - View the full discussion

Is it safe to assume you're talking about the demo box?

http://digital.ni.com/public.nsf/allkb/A9C037C838B203FA86256A180078BE15

If so (2) is because I don't think the demo box supports input registers, just holding registers and coils.

For (1), thats going to depend on the device. I've never used the demo box. Typically I've seen it one of two ways:

-Values are encoded as a single-precision float across two registers

-Values are truncated and then manipulated into integer form. For example you might see 49.3249 converted into 4932. Since this is just a demo box I'm guessing its truncating it to 49.

In either case I wouldn't worry about what the simulator does too much because its going to change. Every modbus device is a little bit different.

Reply to this message by replying to this email -or- go to the message on Community

Start a new discussion in NI Labs by email or at Community

0 Kudos
Message 295 of 507
(1,086 Views)

ah ok, I don't seem to have that example but yeah, you're better off talking to your hw directly.

0 Kudos
Message 296 of 507
(1,086 Views)

Hi Smithd, Hi everybody (sorry for my English)

First, thanks for all your work for this API.

I have used it successfully to create a Modbus RTU Master or Modbus IP Master or Modus IP Master with a gateway (with unit ID).

My new goal is to create a Modbus RTU over TCP master : an RTU protocol but an TCP transport.

Modbus over TCP Create Master.png

My question is : if I modify an Instance of the Modbus Master RTU (Create RTU Master.vi) with the TCP network protocol to replace the Serial transport, will this work to communicate with my slave device?

Modbus over TCP Create Master code.png

I can't debug my code, because I’m waiting to have my device in few weeks.

Many Thanks

Luc

banniere Luc Livre NXG Champion.png

Luc Desruelle | Mon profil | Mon blog LabVIEW
Auteur livre LabVIEW : Programmation et applications - Introduction à LabVIEW NXG
Certified LabVIEW Architect (CLA) & Certified TestStand Developper (CTD)
LabVIEW Champion

0 Kudos
Message 297 of 507
(1,086 Views)

It should do. I believe I tested it with the API talking to itself and it worked, so that might be something for you to verify. However, like you I never had the chance to test with a real device.

You may find it to have more timeouts than you are expecting, as RTU is not a very good protocol design. Basically it looks for a pause in data and that is the end of the packet. Because this is nonsensical over TCP, if you run RTU over TCP it looks for a CRC match in the incoming data. This is technically unreliable, as there may be other points within the stream where the CRC check is valid. If you encounter a timeout, I'd recommend just retrying.

Message 298 of 507
(1,086 Views)

thank you for the answer. I will test when I have the device.

I will keep you informed. Thank you a lot.

Luc

banniere Luc Livre NXG Champion.png

Luc Desruelle | Mon profil | Mon blog LabVIEW
Auteur livre LabVIEW : Programmation et applications - Introduction à LabVIEW NXG
Certified LabVIEW Architect (CLA) & Certified TestStand Developper (CTD)
LabVIEW Champion

0 Kudos
Message 299 of 507
(1,086 Views)

Finally I found a “Modbus RTU over tcp” device. 

So I have tested the code...... and....  It works!!

It’s really a great API.

A+ luc Desruelle (MESULOG)

banniere Luc Livre NXG Champion.png

Luc Desruelle | Mon profil | Mon blog LabVIEW
Auteur livre LabVIEW : Programmation et applications - Introduction à LabVIEW NXG
Certified LabVIEW Architect (CLA) & Certified TestStand Developper (CTD)
LabVIEW Champion

Message 300 of 507
(1,086 Views)