The driver supports multiple clients. The maximum number of clients has been arbitrarily chosen as 5. It can be extended if required. The multiple client drivers are useful for the following.
1. The maximum number of registers for one Modbus transaction is 125. If the numbers of I/O signals require more than 125 registers one can use multiple clients for data access from different register segments.
2. In some micro systems, more than one PLC unit with the different IP addresses may be used. The micro can concurrently communicate with all the PLC units by setting up multiple clients.
The driver provides three utility functions to the micro application module. All the functions return a status code and the data, if any.
a. Init Function
The application should first invoke this function with the following parameters: the upper and lower limit for the registers that will be used for data exchange, IP address of the PLC and the polling period. The application program specifies the frequency at which the “read register” command is to be sent to the PLC.
b. Read Function
The application module uses the Read function to retrieve the data from any register range so long as it is within the declared set. The application should first test the status code for error before updating the data field within the device record.
c. Write Function
When a high-level program sends a command (analog or digital or any) to a device, the application module encodes the command in an appropriate format and invokes the write function to post the information to the client task.