modbus_object.ReadCoils Method

Reads one or more outputs from a MODBUS slave and returns the values in a Boolean array.

modbus_object.ReadCoils(start, number, value_array)

Prerequisites

None

Parameters

start

A required Integer expression that specifies the number of the first coil to be read.

number

A required Integer expression that defines the number of coils to be read.

value_array

A required Boolean array that receives the output values. The length of the array is changed to reflect the number of values read.

Remarks

This method issues a MODBUS/TCP Read Coils request (function 1).

A new connection to the MODBUS slave is made if none currently exists.

If any network errors occur, this method throws an exception.

Examples

Dim ep As New IPEndPoint("192.168.0.150")
Dim mb As New Modbus(ep)
Dim bool() As Boolean
mb.ReadCoils(1, 16, bool) ' Read 16 outputs

See Also

Modbus Class |modbus_object.WriteMultipleCoils  |modbus_object.WriteSingleCoil