NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

Beautiful solution with the one master instance that splits up in two wires, I will try it!

The sensors are specified with a response time of absolute maximum 100 ms so 500 ms timeout should suffice, I think.

I do not which of the calls that fails, I will test more as soon as I get network access to my equipment again.

0 Kudos
Message 81 of 527
(4,756 Views)

Good point about the Modbus Protocol Maximum.  But you must also consider the Maximum number of R/W registers that the slave can accept / process.  This is often limited by the size of comm buffers on the slave device and is often much less than the Modbus protocol Max.

0 Kudos
Message 82 of 527
(4,756 Views)

Thank you very much for this example of how to detect the event of the master sending a request to the slave. I've been trying to trigger a slave event whenever the master updates the holding registers.

Could you please explain one thing?

-  In your example you use "Write Single Holding Register.VI" for the master with an address input of 55 and loop counter data.

The Master read and Slave Read both use an address of 500, and correctly read. It doesn't seem to matter what value is used for the Master write address - The value given to the Construct Model.VI  used for creating the slave seems to set the write address for the master.   

What am I missing?

Does creating the class and the overrides as suggested affect the ability to address the registers from the master?

Thanks,

Dave

0 Kudos
Message 83 of 527
(4,756 Views)

James780 wrote:

Good point about the Modbus Protocol Maximum.  But you must also consider the Maximum number of R/W registers that the slave can accept / process.  This is often limited by the size of comm buffers on the slave device and is often much less than the Modbus protocol Max.

Definitely true. The implementation of the master performs no checking on that information for that very reason.

0 Kudos
Message 84 of 527
(4,756 Views)

DWS23 wrote:

Thank you very much for this example of how to detect the event of the master sending a request to the slave. I've been trying to trigger a slave event whenever the master updates the holding registers.

Could you please explain one thing?

-  In your example you use "Write Single Holding Register.VI" for the master with an address input of 55 and loop counter data.

The Master read and Slave Read both use an address of 500, and correctly read. It doesn't seem to matter what value is used for the Master write address - The value given to the Construct Model.VI  used for creating the slave seems to set the write address for the master.   

What am I missing?

Does creating the class and the overrides as suggested affect the ability to address the registers from the master?

Thanks,

Dave

Ah yeah looking back the example is more confusing than I intended.

The data model I wrote internally has a "counter register" which is set to 500. It also internally stores the count value. The count value is incremented as part of the "Execute Function" override. It just so happens that the function we are using to increment the counter is setting another register (#55) to a counting value. If you notice, pressing the send command calls two modbus functions, a write and a read. This calls execute function.vi twice, which increments the counter by 2. This is why the counter value increments by two. You could set register 55 to anything if you want to, register 500 will still count upwards. Because the bottom loop calls the slave function "read holding registers", it doesn't call "execute function.vi" and therefore doesn't increment the counter. This functionality is obviously pretty useless by itself, but is there to show where you put things and what gets called when. Basically "execute function.vi" gets called by the slave any time that any master sends a request. Creating a slave data model allows you to intercept the request and do something differently if you would like--either incrementing a counter or overriding a whole function code. If you want to override function behavior, call Modbus Data Unit.lvclass:Deconstruct PDU using the "modbus request" input on "execute function.vi". Let me know if you have additional questions.

Thanks,

Daniel

0 Kudos
Message 85 of 527
(4,756 Views)

hello sir..

I am very new to labview.i have to read sensors using modbus in labview.If i can get some basic idea of doing this then i would really appreciate.

Thanku

shikha

0 Kudos
Message 86 of 527
(4,756 Views)

mona1490 wrote:

hello sir..

I am very new to labview.i have to read sensors using modbus in labview.If i can get some basic idea of doing this then i would really appreciate.

Thanku

shikha

Skim through this:

http://www.ni.com/white-paper/7675/en/

Then read your devices manual. That should tell you how the device uses the data types and function codes described.

Once you know what you need to do to get data from your device, take a look at the example. It will show you how to use the library to use those function codes from LabVIEW.

Thanks,

Daniel

0 Kudos
Message 87 of 527
(4,756 Views)

Hey all--update to the version in post #75. Should work a little better, but still in testing.

0 Kudos
Message 88 of 527
(4,756 Views)

Hello Smithd

I am using this library to create two slave servers in one cRIO-9074 with different port no's i.e. 502 & 4676. Is it possible to have two servers. I did same experiment with DSC library but it seems only one can work in parellel. But i wonder is it possible through this library. If yes please post the sample program. I activated second port of cRIO with different subnet

Primary : 169.254.66.100/255.255.0.0

Sec       : 169.253.66.1/255.255.0.0

Your answer will be a great help

Thanks

Varun

0 Kudos
Message 89 of 527
(4,756 Views)

Hi Varun,

The modbus slave instance has a "port" input you can use to configure where the slave is listening. You shouldn't have to do anything else to make it work--just create two instances. The issue you'll find is that each instance has its own memory space--ie if someone writes to the slave on port 502 it is *not* the same data as whats on port 4676. Is that an issue?

Thanks,

Daniel

0 Kudos
Message 90 of 527
(4,756 Views)