Integration of Modbus
Integration of Modbus
Integration of Modbus
In our example we have to communicate with two devices (Test Device#1 e Test Device#2) whose address are 1
and 2; for each device we want to read 3 numeric variables (Temp, Sp e Out) and 1 digital variable (Alarm).
Project creation
In this way you create a tree structure with all supervision project elements.
Protocol selection
Press button Options... and select the serial port to assign to the channel (for example COM1). It is necessary to
set serial port specifying Baud rate, Parity, Stop bits, Data bits, Time out e Query Pause (for
these parameters refer to manufacturer data device, an example is provided in the figure)
Protocol configuration
Devices declaration
Suppose you need to read the following variables (to adapt this example to a real case it is enough to modify the
gates details below).
Name Channel Device Modbus address* Variable type Gate type Unit Description
TEMP 1 1 (3:) 005 Signed Word Numeric °C Temperature - Measure
SP 1 1 (3:) 010 Signed Word Numeric °C Temperature - Setpoint
OUT 1 1 (3:) 015 Unsigned Word Numeric % Control Output - Value
ALARM 1 1 (1:) 012 Bit Digitale Internal alarm status
TEMP 1 2 (3:) 005 Signed Word Numeric °C Temperature - Measure
SP 1 2 (3:) 010 Signed Word Numeric °C Temperature - Setpoint
OUT 1 2 (3:) 015 Unsigned Word Numeric % Control Output - Value
ALARM 1 2 (1:) 012 Bit Digital Internal alarm status
* The number between brackets represents Modbus function used to read the variable (refer to protocol manual in Project Manager Help).
End result
After you have defined all numeric variables, you should see the Gate Builder main page similar to the one shown
below.
Final result
After you have defined all numeric variables, you should see the Gate Builder main page similar to the one shown
below.
Final result
After you have defined all numeric variables, you should see the Gate Builder main page similar to the one shown
below.
Template creating
Double-clicking on created template, Template Builder start in order to build the graphic page.
Click on button alongside of the Gates item in the Property Editor (Property Editor is the window on the left
side of the screen that allows to modify template elements properties).
A new windows will appear; press Add gate button, select the first numeric gate and press Ok. Repeat this
operation for each numeric, digital and alarm gate that belongs to the application.
To do this, select Frame object among the ones on the upper bar ( , it is the first on the left) and click on the
template, a void rectangle will be displayed.
The next step is to insert into the created frame a static label that is a static text; select Label object among the ones
on the upper bar ( ), then click into the frame. To modify the text displayed into the object, use Property Editor,
click alongside of the property Label and digit TEMPERATURE.
Alongside of just inserted label, position another one to visualise temperature read form the device.
To link the Label to the numeric variable TEMP, click on the button alongside of the item Gate in Property
Editor and select NUM,Temp,1 among the available gates.
Modify in addition the property Label inserting %5.0lf °C.
Every described object can be formatted and placed as you like using Property Editor.
Select Edit ) object from tool bar; and, as done before, link it to NUM,Sp,1 gate using the Property Editor.
Insert now a Gauge object ( ) alongside of the previous Label; link it to NUM,Out,1 gate using the Property
Editor.
In this way the value of the device output power will be displayed in bar format.
Insert now a Led ( ).alongside of the previous Label. To "give animation" to the object it is necessary to specify
which is the condition that make it change colour; modify Led ON conditions property linking led activation
condition to Internal_Alarm,1 (Internal_Alarm,1 == true) alarm activation. A red led will be shown in
presence of the alarm, otherwise led will be green.
To complete the template, insert now a BkBitmap object (background bitmap, ) previously created using any
graphic design software (for example Paint) and saved in project Bitmaps folder.
Code Builder is the Winlog Pro programming environment; we will use it only to define a function that will open
the main template at the application startup.
Copy and paste the following code:
// Function called at Winlog startup
//***************************************
// Open default page
//***************************************
TPageOpen("Main");
end
Project execution