The Modbus library has been extended to take advantage of the powerful features of NG-Configurator. This page describe the functioning of the library with this tool with an example.
For description of the Modbus library, please visit this page.
Short description of NG-Configurator
NG-Configurator is an 'add-on' tool for PG5 allowing you to generate Saia PCD® program code from an Excel file. This is particularly useful for big PG5 projects, but it is fully applicable for small projects too. It is much easier to create and edit an Excel file than a Fupla file with dozen FBoxs spread over several pages. When the 'build' of the PG5 program is started, the NG-Configurator automatically compiles the Excel file and everything is downloaded in the Saia PCD®. For a general description of the NG-Configurator, visit this page.
Functioning of NG-Configurator with Modbus
The FBox 'Master Link' and 'Slave Station' still need to be placed and configured in a Fupla file. The SEND and RCV requests are defined in an Excel file rather than placing FBoxs in a Fupla file. Doing this you get a much better overview of your communication tasks.
Another big advantage is the special 'BUFFER' function allowing you to read a big number of data in a single transaction and to convert them locally in different formats. See the detailed description at the bottom of this page.
The Excel file is divided in two parts. One sheet for the SEND requests and one for the RCV requests. Each row corresponds to one request.
Here are the description of some columns :
- The mode, cyclic or single execution.
- The name of the Master FBox Driver.
- The request execution flag. May be a symbol of an absolute flag address.
- The Modbus function.
- The variable address on the Master device. (New symbols can be define in the Excel file)
- The number of consecutive variable to send or receive.
- A format conversion. (2x16 to 32 bits / Float to Int / etc...)
- The name of the Slave Station FBox.
- The variable address on the Slave device.
- An error flag. It is set to high if the request fails.
- Update flag indicating the reception of new values.
For example, the request defined in row 4 can be executed the flag 'Enable01'. It will transfer the variable 200 from the Slave device to the register 'Symbol01' on the Master.
The BUFFER function
This function allows you to transfer a great quantity of variables from the Slave device to the Master in one single request. After the transmission is done, it is possible to apply different conversion for each variable. And finally, each variable can be stored anywhere in the Master. The advantage of the BUFFER function compared to the previously described transmissions is that there are far less communication between the devices. The communication efficiency is improved. Here is an example, row 8 to 11.
|Row 8 :||Reads 8 variables of 16 bits in one single Modbus request and save them in a temporary buffer.|
|Row 9 :||Extract the variable 100 (1 x 16 bits) and copy it in a 32 bits register 'Symbol03'.|
|Row 10 :||Extract the variables 104 and 105 (2 x 16 bits), combine them into 32 bits, convert the result from Float (IEEE format) to Float (Saia PCD® format) and copy it in the register 'Symbol04'.|
|Row 11 :||Extract the variables 106 and 107 (2 x 16 bits), combine them into 32 bits, convert the result from Float (IEEE format) to Integer without decimal and copy the result in the register 300.|
You may have noticed that the variables from 101 to 103 are not converted and stored. If the variables in the Slave device are not perfectly consecutive, it is not a problem, you can ignore some of them.
This a really simple example but you can transfer up to 127 variables in one single request and have as many different format as you need.