NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

The library is included in the DSC and Real-Time modules, but not in the core product.

The labs version will remain available. It will remain exactly as maintained as it has in the past -- that is, dependent upon my availability and feedback from the community.

0 Kudos
Message 211 of 529
(1,384 Views)

Sounds good, maintanance up to now seems very good.

Regards

olja

0 Kudos
Message 212 of 529
(1,384 Views)

Hello all
i m asking how i can download data from a datalogger working as master using the modbus lib
Thanks

bilel

Keep Calm and it's gonna be alright !
0 Kudos
Message 213 of 529
(1,384 Views)

Hi Bilel,

If you are using the modbus library included in LabVIEW 2014 RT/DSC modules or the llb found here (http://www.ni.com/example/29756/en/), please create a forum post in the industrial communications group:

http://forums.ni.com/t5/Industrial-Communications/bd-p/260

If not, I would still need more information to provide assistance:

In this system, is LabVIEW the master or slave? Is LabVIEW running on the datalogger?

Is the datalogger the master or slave?

What data are you trying to move between (???) and the datalogger?

What have you tried so far?

Have you run the examples?

What was wrong with the examples?

Thanks,

Daniel

0 Kudos
Message 214 of 529
(1,384 Views)

Hi Daniel,

is there any documentation on how to create a user specific data model? I am not familiar with LV OOP, so I couldn't find my way there yet. As far as I get it, this would be the only way to define some registers for read only access or change the unit ID of a Modbus/TCP slave server.

Also It would be nice to define chunks of registers to be read at once, meaning e.g. the server will reject requests querying not all registers resembling a typecasted 64bit variable. But this is optional.

Thanks,

Simo

0 Kudos
Message 215 of 529
(1,384 Views)

this post and the one following it may help with the basic concepts.

https://decibel.ni.com/content/message/72889#72889

feel free to post back questions after you've taken a look at all that.

For LVOOP, this may help: http://lavag.org/topic/11218-excellent-intro-presentation-on-object-oriented-programming-in-labview/

As to your specific needs, I'm curious why you would want to do some of these things.

-For example, modbus already has registers defined as read-only (input registers as opposed to holding registers).

-TCP slaves don't care about the unit ID, so I'm not sure why you would want to change it. It is literally ignored by the code.

Defining register chunks does make sense to me, but it seems like this is something that would be easier to enforce from the master side. OPC servers, for example, will typically schedule requests as needed to match the data type you selected and ensure that everything is gathered coherently. I understand the desire to have an extra check, but your master may also respond poorly to getting errors thrown at it.

Anyway, let me know if this helps and what additional assistance you may need.

0 Kudos
Message 216 of 529
(1,384 Views)

Thank you for the two links. I didn't recognize the first one, though it's just one page back, sorry. But give me some time to go through them.

Meanwhile let me give you some examples for applications where I think a user defined data model would be an interesting thing:

- Unit ID in TCP slaves could be used to distinguish different subfunctions or subdevices. For example a main device could collect data from subdevices (RTU or TCP) and map each to one Unit ID. A local bus like with RTU could be realized with TCP as well using a secondary eth port. But the mapping of RTU devices was covered here before...

- You could define that parameters will be accessed through unit ID 1, control values through unit ID 2, etc..

- Imagine, you have one device with one function A, using a certain set of registers A of the device, and there is another function B with a consecutive register set B. Now I would like to ensure, that functions A and B are only called if all registers of the set are given. Also, if in an attempt to write set A, the starting registers are not given correctly (typical problem: Registers start with 0 or 1 in my new modbus tool?), I need to prevent that my device goes crazy because sets A and B are bot accessed partially.

- In my understanding, modbus allows in general any register to be called with any function code. But the application has to define, which may be red or written for a specific device. The protocol provides a suggestion with four blocks, but this is not mandatory. Also I think it's not implemented in your standard data model, is it?

- I simply would like to signal to my technician: This register you're looking at is not used any time and will never show any data by giving exception code 02 (ILLEGAL DATA ADDRESS).

0 Kudos
Message 217 of 529
(1,384 Views)

Dear Smithd,

I've read some comments here, since the conversations are large I couldn't able to find my solution. I've a requirement to use the Modbus API.

I've read the KB's on the introduction to Modbus and as of my application I need Modbus API to make it more flexible.

Requirement:

Here my desktop will be acting as a Master through Modbus TCP communication to an XGateway.

The XGateway will act as an data translator between the Master PC and the slaves in the Network.

My system status,

1. LabVIEW 2012 SP1 Licensed.

2. Windows 7 platform.

My Questions?

There are lot of versions available in Modbus API which one should I use for my system?

0 Kudos
Message 218 of 529
(1,384 Views)

gnshmrthy wrote:

My Questions?

There are lot of versions available in Modbus API which one should I use for my system?

So, you're asking that question on a thread which is a discussion of a specific modbus library. I'm biased

That having been said, if you don't have LabVIEW Real-Time or LabVIEW Datalogging and Supervisory control then you probably should be using this version of the library. The old TCP library should also work well as a master, but using the library in this thread will give you an easier upgrade path if/when you move  your code to 2014 and if you ever need to support a slave.

Message 219 of 529
(1,381 Views)

Sorry, don't think I got a notification on this.

SKauth wrote:

Thank you for the two links. I didn't recognize the first one, though it's just one page back, sorry. But give me some time to go through them.

Meanwhile let me give you some examples for applications where I think a user defined data model would be an interesting thing:

- Unit ID in TCP slaves could be used to distinguish different subfunctions or subdevices. For example a main device could collect data from subdevices (RTU or TCP) and map each to one Unit ID. A local bus like with RTU could be realized with TCP as well using a secondary eth port. But the mapping of RTU devices was covered here before...

- You could define that parameters will be accessed through unit ID 1, control values through unit ID 2, etc..

-So, a modbus slave is a representation of memory to the system. This API as is defines unit IDs on the link level. To make your proposed solution work (multiple logical slaves on a single physical slave) you'd have to transmit the unit ID with every single request, both local and remote. Another perfectly reasonable solution would be to instantiate multiple TCP slaves on different ports, which would get around the issue entirely. The standard port (502) would be read-only and then you could have a second connection on a more obscure port which would give you control access.

-I also don't like this because it feels like you're trying to add modern features to an ancient protocol running on a modern device. I understand using modbus in some cases for backwards compatibility, but for a whole new design I'd definitely move towards something more advanced like OPC UA.

SKauth wrote:

- Imagine, you have one device with one function A, using a certain set of registers A of the device, and there is another function B with a consecutive register set B. Now I would like to ensure, that functions A and B are only called if all registers of the set are given. Also, if in an attempt to write set A, the starting registers are not given correctly (typical problem: Registers start with 0 or 1 in my new modbus tool?), I need to prevent that my device goes crazy because sets A and B are bot accessed partially.

...

- I simply would like to signal to my technician: This register you're looking at is not used any time and will never show any data by giving exception code 02 (ILLEGAL DATA ADDRESS).

-I would argue the indexing issue is something you should hammer out in testing but I definitely understand the situation. This kind of behavior is exactly what the data model was intended to handle.

SKauth wrote:

- In my understanding, modbus allows in general any register to be called with any function code. But the application has to define, which may be red or written for a specific device. The protocol provides a suggestion with four blocks, but this is not mandatory. Also I think it's not implemented in your standard data model, is it?

-This is incorrect. Modbus defines function codes accessing metaphorical data but has no restrictions on the implementation of that data. In the standard data model, the data is interpreted to be literal banks of 65,535 registers, input registers, di, and coils. You could easily change the data model to have each function code accessing the same dataset, although this wouldn't make much sense. Anyway, the defined functions are what restrict access. There is no function code for writing to input registers, thus input registers are read-only, even though modbus doesn't define what those input registers actually are. On the other hand you can write to or read from holding registers, giving them r/w access. The standard data model implements all four blocks and the main function codes associated with each.

0 Kudos
Message 220 of 529
(1,384 Views)