Modbus Output Data

Last updated:  June 10, 2003

Introduction
This document is one of five that describes the basic ICON program (skeleton.icn) which normally provides the framework for all ICON programs. This document describes the module named "Modbus Outputs" which sends control information to relays and actuators for feedback control. Each block contains the following functions:

  1. Provide means to override the control output values for testing.
  2. Write control output values to the Modbus I/O devices.
  3. Create an alarm if Modbus write fails and write to event file.
  4. Combine each individual Modbus alarm into one global alarm for export.
An HMI interface is created that allows the user to interface to the above program to:
  1. Set raw Modbus output override values for testing.
  2. View state of Modbus write alarm to see if proper Modbus communication is happening.
In the following sections the program is listed along with the configuration. The first line is the instruction and caption as would be listed when programming. This is followed by the general and table parameter configuration. Finally, a description of the purpose of the program is included if needed.

Module Modbus Outputs

Constant Override enable control block 1
General Parameters
Variable: override_enable1 Set to override_enable2 for the second block, etc. Value of 0 is no override, 1 enables override
Data type: Float
Mode: Capture
Table Parameters
No configuration necessary, set table length to 1

If Get override data
Table Parameters
Variable Status Expression Description
Module 0 override_enable1 If override_enable1 is set to 1 then this If block is executed. This block loads override data.

Constant Override values
General Parameters
Variable: override_values1 Set to override_values2 for the second block, etc. (Values set output values of Modbus registers for testing.)
Data type: Float
Mode: Normal
Table Parameters
Set table length to the length of the Modbus write. Values can be set from the HMI but set your descriptions as appropriate to describe each Modbus register.

Fan Get override data
General Parameters
Source: override_values1 Set to override_values2 for the second block, etc.
Destination: data_selected1 Set to data_selected2 for the second block, etc. This variable now contains the override values.
Count index: Null
Time index: Null
Time def: Null
Last period: Null.
Block size: 17 Set to length of Modbus read plus 1.
Number of indexes: 1
Direction: Multiple sources to one destination

Elseif Otherwise set actual Modbus data
Table Parameters
Variable Status Expression
Module 0 1 This block will be executed if the If block is not. This block gets actual control data and sends to Modbus output device.

MAP Import control data
General Parameters
Array: control1 Set to control2 for the second block, etc.
Direction: To Array
Table Parameters
Set table length to the length of the Modbus write. Set variables to the list of exported control variables you wish to use.

Endif

Modbus send out Modbus data
General Parameters
Parameter Example Description
Enable: Null
Status: mod_stat1 Use mod_stat2  for the second block, etc.
I/O transfer: control1 Use control2 for the second block, etc.
Com type: 2 You may select serial port 1 or 2 depending on which serial port your Modbus device is connected (usually 2).
IP address: 0.0.0.0
Port: 502
Unit Address: 255 The address of the Modbus device.
Register address: 1 Select the Modbus starting register address. For writing 1-wire devices and for most other Modbus devices you will use 1. This can only be found in your Modbus device documentation.
Command: Set multiple registers (16) Select the appropriate Modbus write command.
Register type: Unsigned integer You may pick as appropriate. It does not matter for Commands 5 and 15.
Timeout: 50
Retries: 3
Table Parameters
The table length indicates the number of items to transfer. Normally set A to 1 and B to 0 for all coefficients in all rows. You may invert digital inputs (Commands 1 or 2) with A= -1 and B=1.

Limit set status for event save
General Parameters
Input: mod_stat1 Use mod_stat2 for the second block, etc.
Result: alarm Use alarm[1] for the second block, etc.
Limit: Null
High: 4
Went high: 5 Causes an event to be written when the input goes to 1.
Window: 0
Went window: 1 Causes an event to be written when the input goes to 0 or 1.
Low: 2
Went low: 3
High limit: 1.5 (A 0 or a 1 in the input indicates correct operation. 2 or higher indicates Modbus write fail.)
High clear: 1.5
Low clear: 0
Low limit: 0

Histevt save alarm
General Parameters
Data: mod_stat1 Use mod_stat2 for the second block, etc.
Status: alarm Use alarm[1] for the second block,  etc.
Event file: 4 Pick the desired event file.
Event number: 3 Pick the desired event number.

The above instructions are repeated for each Modbus write. The following  instruction exports all the alarms for the master alarm function:

Alarm Export master alarm
General Parameters
Master: !alarm[1] The exported alarm.
Alarm: alarm
Number of alarms: 2 Set to number of Modbus writes.