# Modbus Read

This function block is used to read data from a Modbus server via a specified client, offering flexibility in accessing various data types.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Enable` This boolean input activates the Modbus reading process. If false, the reading is halted.

`Modbus Client` This input provides the client needed to communicate with the Modbus server.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Data` This output contains the data read from the specified Modbus address, depending on the chosen data type.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Address` A text input field to specify the Modbus register address to read from.

`Quantity` A text input field to define how many registers or coils to read.

`Data Type` A dropdown menu to select the type of data to be read, which can include:

* Coil
* Discrete Input
* Input Register
* Holding Register

## 🎨 Features <a href="#features" id="features"></a>

`Asynchronous Communication` The block uses async functions to ensure non-blocking reads from the Modbus server, improving efficiency.

`Error Logging` If there are issues during the read process, error messages will be logged by the tool, allowing for quick troubleshooting.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. **Connect the Modbus Client**: Ensure that you connect a valid Modbus client to the `Modbus Client` input.
2. **Set Address**: Enter the desired Modbus address in the `Address` text input.
3. **Set Quantity**: Define how many items to read by entering a value in the `Quantity` text input.
4. **Select Data Type**: Use the dropdown menu to select the desired data type you want to read.
5. **Enable Reading**: Send a `true` signal to the `Enable` input to start reading from the specified Modbus address.

## 📊 Evaluation <a href="#evaluation" id="evaluation"></a>

When activated, this function block reads data from the Modbus server based on the specified parameters and returns the data.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

<details>

<summary>Understanding Addresses</summary>

Ensure the address entered is within the valid range supported by your Modbus server configuration to avoid errors during reading.

</details>

<details>

<summary>Setting Quantity Limits</summary>

Be mindful of the quantity being requested—fetching too many items at once may exceed the server limits or lead to performance issues.

</details>

<details>

<summary>Retrieving Coil States</summary>

When reading coils or discrete inputs, remember that the result will be a list of boolean states representing the coil values.

</details>

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

<details>

<summary>Error Reading from Server</summary>

If you encounter an error stating the data could not be read, ensure that the Modbus server is reachable and the client is properly configured.

</details>

<details>

<summary>Invalid Address or Quantity</summary>

Always verify that your specified address and quantity comply with the Modbus protocol and your server's specifications to prevent out-of-bound requests.

</details>
