MB Serial Master Query Read Holding Registers (poly).vi
The master uses this VI to read the slaves' holding registers. This corresponds to a public function code of 3 in the MODBUS protocol.
![]() | Serial Parameters are parameters that modify the way the MODBUS frame is structured. Refer to the MODBUS specification for more information about the MODBUS Frame. The Serial Parameters in LabVIEW is a cluster containing an enum (Mode) and an integer (Slave Address).
Mode RTU Data is represented in binary format. ASCII Slave Address This is the address of the slave you are communicating with. This property is usually valid for RS-485 networks, which can have multiple MODBUS devices connected to the same network. | ||||||||||||||||
![]() | VISA resource name specifies the resource to be opened. This control also specifies the session and class. For more information about VISA resource names, refer to the NI-VISA Help. | ||||||||||||||||
![]() | Starting Address is the first address location of the holding register to read. This address is sometimes referred to as offset. Refer to your device's documentation to find the holding register address mapping. Be sure to specify the correct address in the MODBUS device configuration software for the register you want to use in LabVIEW. In most MODBUS device configuration software, you must enter a name for the register you want to use. Per MODBUS convention, the register address of the slave device is calculated by subtracting 1 from the register name that you specify in the master device configuration software. The MODBUS LabVIEW library expects register addresses, not register names, so you may need to subtract 1 from the address you defined in the MODBUS device configuration software. For example, a register name defined as 2 in a MODBUS configuration device translates to register address 1 in the Holding Registers table of the LabVIEW MODBUS library, as shown below.
| ||||||||||||||||
![]() | Quantity represents how many holding registers to read from the slave. The VI returns the holding register at Starting Address and each following holding register up to Quantity. For example, if Starting Address is 0 and Quantity is 4, the VI reads holding registers from the slave at address 0, 1, 2, and 3. | ||||||||||||||||
![]() | Timeout specifies the maximum time period, in milliseconds, that the VI waits for the slave's response before throwing an error. | ||||||||||||||||
![]() |
error in describes error conditions that occur before this VI or function runs. The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. If an error occurs while this VI or function runs, the VI or function runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.
| ||||||||||||||||
![]() | VISA resource name out is the resource to which a VISA session is opened and its class. The class matches that of the VISA resource name input. For more information about VISA resource names, refer to the NI-VISA Help. | ||||||||||||||||
![]() | Holding Registers represents the data read from the slave (array of U16). | ||||||||||||||||
![]() | Exception Code is nonzero if a MODBUS error has occurred. The exception code mapping is as follows:
| ||||||||||||||||
![]() |
error out contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. Right-click the error out front panel indicator and select Explain Error from the shortcut menu for more information about the error.
|