Function code: Read Input Registers - Because we are reading analog input values Starting Address: or B - From the table in the communications specification Quantity: 1 - Because we are reading 1 register.
![labview modbus example labview modbus example](https://www.tinkerforge.com/en/doc/_images/SolidStateRelay_Bricklet_LabVIEW_Example_Simple.vi.png)
We can see that the starting address for process variables are B in Hex, which is in decimal. The analog inputs are called "Process Variables". In the Watlow MLS communication specification, under the Modbus communication chapter we can find the table shown below. Since we are trying to read analog input 1 in this case, we need to find out the starting address for the analog inputs. Next you will have to enter information about the register you are trying to access. These parameters have to be set on the controller and entered on the front panel of this example program. For this example, we will use a baud rate of and a slave address of 1.
#Labview modbus example how to#
Information on how to navigate to these settings is located in the setup chapter chapter 4 of the Watlow MLS user guide. To set parameters or determine the current values for parameters on the Watlow MLS, you have to navigate through the menus on the controller interface. For example, if you wanted to read analog input 1 on the Watlow MLS controller, you would first have to make sure you are using the correct baud rate and slave address for the Watlow controller. Both of these documents can be found on the Watlow web site. Generally, to figure this out, you will need to use the documentation for your Modbus device to figure this out.
![labview modbus example labview modbus example](https://www.halvorsen.blog/pictures/programming/labview/labview_example.png)
The most challenging part of communicating with a Modbus device is figuring out what address to use and figuring out what to use for some of the other parameters. The main parameters that will need to be changed are the Function Code and Starting Address. This example can be modified very easily to write any outputs or read any inputs that the Modbus device makes available.
![labview modbus example labview modbus example](https://documentation.help/Modbus-LabVIEW/MBEthernetSlaveDemonVIFlowchart.gif)
In this example, you will see that communicating with a Modbus device will involve initializing the port we are using, then using the query command, and finally closing the Port.
#Labview modbus example serial#
Since Modbus is a serial communications protocol, the VISA driver can be used to send data over the serial port to communicate with a Modbus device.