LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView Program as a Modbus Slave

I need my LabView program to emulate a Modbus Slave.  I understand Modbus but am new to LabView and find the examples confusing.  The Modbus Master will send a command to read or write X registers starting at register Y.   The small read/write vi's included under the Modbus Slave API require you specify X and Y.  How do I know what X and Y are included in the Master's command.  (I would like to do this without the Datalogger & Supervising Control Module).

0 Kudos
Message 1 of 5
(1,674 Views)

Are you using the NI Modbus Library?

 

There is a Slave example in there that shows you how to set up a Modbus slave. The Modbus slave write vis are there so you can set the registers to whatever value, but all the actual Modbus communication is handled by the Modbus daemon created by the library.

0 Kudos
Message 2 of 5
(1,647 Views)

Thanks for replying.

LabView 2017 using the NI Modbus Library

I understand that the Slave Daemon is handling the communications.

In the Slave Example booleans are used to trigger some specified set/fetch actions.

Are you saying that the Slave Daemon will respond properly to commands from a Master without any of the read/write vis in the loops; that the example boolean-base actions are for demo purposes only and can be removed.

I assume the data array names in the example are those required by the Daemon.

0 Kudos
Message 3 of 5
(1,624 Views)

I haven't done much with the slave/client aspect of Modbus, and I am not quite sure what you are trying to accomplish. But the daemon will handle all the communication aspect of being a Modbus slave. Any functionality or processes that need to happen, you will have to program in. With the daemon running, you could set up some holding registers with data, and a master querying or setting data would be handled by the daemon. What that actually means for the slave you are going to have to program. I suspect you could use the slave read vi's to see what the master has done, but again, I haven't had much experience with that.

0 Kudos
Message 4 of 5
(1,600 Views)

I have a Modbus Master that is sending blocks of data to a LabView slave.

Communications are working fine.

The slave daemon sends the master a response that it received the data ok.

The data is in the slave unit but how do I get it.

The read/write vi's assume you know the data type and the starting address.  

But in the real world, you generally would not know that.

The slave daemon would know it (Modbus function code & starting address). 

You would think that you could read this and then know how to process the data.

Just venting a little.

Thanks for taking the time to respond

0 Kudos
Message 5 of 5
(1,576 Views)