To download NI software, including the products shown below, visit ni.com/downloads.
Introduction
With the release of the NI WSN-3230 and NI WSN-3231 there is a lot of excitement surrounding the many ways these nodes can be utilized. One such way is as a Modbus Master (For more information on the protocol, please visit Introduction to MODBUS). Here is one such implementation adapted from the MODBUS Library for LabVIEW.
Implementation
For those of you unfamiliar with WSN hardware, communication to and from the host is executed using Radio Messages and User-Defined Variables. With this implementation, Modbus queries are generated using Radio Messages and the slave responses are gathered and sent to the host using a User-Defined Variable of string data type.
Steps to Complete
1. Download Modbus for WSN.zip (LabVIEW 2011) and extract the files to your local machine.
2. Open Modbus Master.lvproj.
3. Re-target the WSN subVIs and Master (Node).vi to your WSN node
4. Create a User-Defined Variable on the Node that is of type string and 254 characters in length. This variable returns the slave response from the serial port on the WSN node.
5. Open Master (Node).vi and set the Modbus Response Variable constant to the newly created User-Defined Variable.
6. Build the Master (Node).vi as a WSN application.
7. Open the Master (Host).vi.
8. Set the gateway IP address, Node ID, and Modbus Response Variable appropriately.
9. Run the Master (Host).vi
10. Set the Mode/Baud Rate/Parity/Wire Mode/Turnaround Delay (time to wait for a response from the slave). Set the Slave Address.
11. For each Modbus query, set the Starting Address and Quantity for the Modbus query. Configure the Coils to Write and Registers to Write to the desired values. Use the buttons to read/write to the slave.
Description-Separate-2Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.