Software Manual Function Blocks: V230-21-G23 Rev: 12/04
Software Manual Function Blocks: V230-21-G23 Rev: 12/04
Function Blocks
V230-21-G23 Rev: 12/04
No part of this document may be used for any purpose other than
for the purposes specifically indicated herein nor may it be
reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying and/or
recording, for any purpose without written permission from
Unitronics.
The information appearing in this document is for general
purposes only. Unitronics makes no warranty of any kind with
regard to the information appearing in this document, including,
but not limited to, implied warranties of merchantability and/or
fitness for a particular use or purpose. Unitronics assumes no
responsibility for the results, direct and/or indirect, of any misuse
of the information appearing in this document nor for any use of
the Unitronics products referred to herein in any manner
deviating from the recommendations made in this document.
Unitronics assumes no responsibility for the use of any parts,
components, or other ancillary appliances including circuitry other
than as recommended hereunder or other than that embodied in
the Unitronics product.
Unitronics retains all rights to its proprietary assets including, but
not limited to its software products which are copyrighted and
shall remain the property of Unitronics. Copyright protection
claimed includes all Forms and matters of copyrightable materials
and information legally allowed including but not limited to
material generated from the software programs which are
displayed on the screen of the Unitronics products such as styles,
templates, icons, screen displays, looks, etc. Duplication and/or
any unauthorized use thereof are strictly prohibited without prior
written permission from Unitronics.
All brand or product names are used for identification purpose
only and may be trademarks or registered trademarks of their
respective holders.
Unitronics reserves the right to revise this publication from time to
time and to amend its contents and related hardware and
software at any time. Technical updates (if any) may be included
in subsequent editions (if any).
VisiLogic Function Blocks
VisiLogic Function Blocks
Table Of Contents
FBs Library ................................................................................................................................................................ 6
PID FB........................................................................................................................................................................ 8
PID with Autotune.................................................................................................................................................. 8
PID Configuration .................................................................................................................................................. 9
PID Function Parameters .................................................................................................................................. 9
Run Auto-Tune..................................................................................................................................................... 12
Auto-tune Parameters...................................................................................................................................... 12
Run PID................................................................................................................................................................ 13
Pause Integral & Derivative Calculation .............................................................................................................. 13
Read Control Components ................................................................................................................................... 14
Error Integral ........................................................................................................................................................ 15
General Background: How PID Works ................................................................................................................ 16
About PID and Process Control ...................................................................................................................... 16
Inside the PID Function .................................................................................................................................. 17
Trends FB................................................................................................................................................................. 20
How Trends Works............................................................................................................................................... 20
Trends QuickStart................................................................................................................................................. 21
Linearizing Values .......................................................................................................................................... 22
Refreshing the LCD screen ............................................................................................................................. 22
Configuration........................................................................................................................................................ 23
Configuration Parameters ............................................................................................................................... 23
Trend Fill & Draw Loop: Track a Single Value................................................................................................... 26
Loop Init ......................................................................................................................................................... 26
Loop: Fill ........................................................................................................................................................ 26
Loop: Draw..................................................................................................................................................... 26
Advanced-Trends: Style ....................................................................................................................................... 28
Configuration Parameters ............................................................................................................................... 28
Advanced-Trend Draw Graph .............................................................................................................................. 30
Draw Trend Parameters .................................................................................................................................. 32
Draw Axis ................................................................................................................................................................ 33
Configuration........................................................................................................................................................ 33
Draw ..................................................................................................................................................................... 37
Clear ..................................................................................................................................................................... 38
Loadcell.................................................................................................................................................................... 39
Loadcell Quickstart......................................................................................................................................... 39
FB Operations ................................................................................................................................................. 39
Loadcell Hardware Configuration ........................................................................................................................ 40
Configuring a Loadcell ................................................................................................................................... 40
Loadcell: Configuration........................................................................................................................................ 41
Scan ...................................................................................................................................................................... 43
Calibration ............................................................................................................................................................ 43
Calibrating Points ........................................................................................................................................... 43
Calibrate Point FB .......................................................................................................................................... 45
Save Calibration.............................................................................................................................................. 45
Tare & Zero .......................................................................................................................................................... 45
Tare & Zero .................................................................................................................................................... 46
Setup..................................................................................................................................................................... 47
VisiLogic Function Blocks
FBs Library
Unitronics offers an FB library for advanced functions, such as SMS messaging and MODBUS
communications. FBs that are currently installed in VisiLogic are listed under the FB's menu.
Note • You must use a condition (RLO) to activate any FB that requires Configuration in your
application, such as MODBUS or SMS.
To install an updated FB library, select Update from the Web from the FBs menu or Help menu, then follow the
on-screen instructions. Note that at the end of the download, you must close and then restart VisiLogic. The new
FBs will appear on the FBs menu.
To enable Live Update, you can select to use a proxy server in Project Properties.
FB Library
Versions Used
VisiLogic Function Blocks
PID FB
The PID FB enables you to use system feedback to continuously control a dynamic process. The purpose of
PID control is to keep a process running as close as possible to a desired Set Point. VisiLogic's PID FB includes
auto-tune.
FB Operations
PID Configuration
Run PID
Error Integral
The picture below shows the elements of a basic PID application with Auto-tune.
After Auto-tune runs, the P, I, and D values are automatically written to the Configuration parameters and the
Auto-tune vector is also filled with the Auto-tune parameters.
VisiLogic Function Blocks
Note • Note that, once you have run Auto-tune, you can back up the P, I, and D values, the sample time
(ST), and the 32 MI-long Auto-tune vector into a Data Table. You can then transfer these values to
another Vision controlling an identical system, in order to run PID without tuning the loop.
PID Configuration
To place a PID Configuration:
Select PID Configuration from the FBs menu, then place the function in the net; the PID parameter box opens.
The Select Operand and Address box opens; prompting you to link operands to the PID parameters.
Note • To enable PID, values must be provided for:
Set Point
Input Range:PV Low Limit & PV High Limit
Output Range:CV Low Limit & CV High Limit
These values are used to Auto-tune the loop.
After Auto-tune runs, the P, I, D and Sample Time values are automatically written to the Configuration
parameters.
SP: MI SP is the target value for the process. In a heating system, this is the temperature value set for
Set Point the system. Note that the Set Point and Process value must be given in the same type of units
(degrees Celsius, bars, meters per second, etc.)
PV: MI PV is the feedback from the process. PV is output from the process and input to the PID
Process Value function. In a heating system, the temperature measured by a temperature sensor provides the
PV.
Kp: MI Use this parameter to define the proportional band, in units of 0.1%. The proportional band is a
Proportional Band percentage of the total Process Value (PV). It is a range defined around the Set Point. When the
PV is within this range, the PID function is active.
VisiLogic Function Blocks
Ti: MI Use this parameter to define the integral time, in units of 1 second. Integral action responds to
Integral Time the rate of change in the controller’s CV output relative to the change in Error. The integral time
you set is the amount of time, as calculated by the controller, required to bring the process to Set
Point.
Td: MI Use this parameter to define the derivative time, in units of 1 second. Derivative action responds
Derivative Time to the rate and direction of change in the Error. This means that a fast change in error causes a
strong response from the controller. The derivative action ‘anticipates’ the PV’s value in
relation to the Set Point and adjusts the CV accordingly, thus shortening the PID function’s
response time.
ST: MI Use this parameter to define the intervals between PID function updates, in units of 10mSecs.
Sample Time
Action: MB Select Off to activate Reverse Action (control type = heating), ON to activate Direct Action (
0: Heat, 1: Cool control type = cooling ).
Input Range: MI Use this parameter to define the lower limit for the Process Value.
Process Value
Low limit
Input Range: MI Use this parameter to define the upper limit for the Process Value.
Process Value
High limit
Output Range: MI Use this parameter to define the lower limit for the Control Value.
Control Value
Low limit
Output Range: MI Use this parameter to define the upper limit for the Control Value.
Control Value
High limit
CV: MI CV is the output from the PID function. CV is output from the PID function and input to
Control Value the process. Note that this output signal may be an analog or time-proportional variable
value.
Status Messages MI
Value Message
Initialized to 0 when
Configuration is
activated.
>=0 FB status OK
<0
-4 Integral has reached maximum of 100,000. PID will not allow the
Integral value to increase any further.
-5 Error in Auto Tune vector addresses, ex., the vector exceeds the final
address in the MI data type.
-6 Set Point less then Input low range or Set Point more then Input high
range.
Auto-tune MI
parameters The start of a 32 MI-long Auto-tune vector that contains the Auto-tuned parameters.
Note • Note that, once you have run Auto-tune, you can back up the P, I, and D values, the sample time
(ST), and the 32 MI-long Auto-tune vector into a Data Table. You can then transfer these values to
another Vision controlling an identical system, in order to run PID without tuning the loop.
VisiLogic Function Blocks
Run Auto-Tune
The Run Auto-tune operation uses the Configuration's parameters:
Set Point
Input Range:PV Low Limit & PV High Limit
Output Range:CV Low Limit & CV High Limit
These values are used to Auto-tune the loop. After Auto-tune is run, the Auto-tune MB turns ON, and all of the
Auto-tune parameters are written into the Autotune Parameter MI vector that is defined in the PID
Configuration.
Note • Note that, once you have run Auto-tune, you can back up the P, I, and D values, the sample time
(ST), and the 32 MI-long Auto-tune vector into a Data Table. You can then transfer these values to
another Vision controlling an identical system, in order to run PID without tuning the loop.
Auto-tune Parameters
Parameters: Type Function
Inputs
Stage # The number of Stages aids the system to determine accurate Auto-tune parameters. The Default
is 3. The higher the number of stages, the longer the Auto-tune time, however choosing a lower
Stage may result in less accurate Auto-tune parameters.
Auto-tune Done MB After Auto-tune is run, the Auto-tune MB turns ON, and all of the Auto-tune parameters are
written into the Autotune Parameter MI vector that is defined in the PID Configuration.
VisiLogic Function Blocks
Run PID
In order to run a PID loop, the Run operation must be included in the application following the PID
Configuration. In order to Auto-tune the loop, the PID Run must be suspended.
Resolution Factor # This is the value used to factor the PID control values.
Error Integral
You can read and write to the Integral Value.
Use this operation to store the current error in the linked ML.
Use this to initialize or change the error value while the application is running.
VisiLogic Function Blocks
PID control enables you to minimize overshoot and damp the resulting oscillations.
Taking the output signal from the process, called the Process Variable (PV),
Comparing this output value with the process Set Point. The difference between the output Process Variable and
the Set Point is called the Error signal.
Using the Error signal to regulate the controller output signal, called the Control Variable (CV), to keep the process
running at the Set Point. Note that this output signal may be an analog or time-proportional variable value.
In the figure below, a system is regulated according to temperature.
VisiLogic Function Blocks
All of the PID functions are activated by changes in the process Error, the difference between the Process Value
and the process Set Point value (E = SP – PV).
Proportional Band
The proportional band is a range defined around the Set Point. It is expressed as a percentage of the total
Process Value (PV). When the PV is within this range, the PID function is active.
Note • The proportional band may exceed 100%. In this case, PID control is applied over the entire system
range.
Proportional Action
Proportional action begins after the PV enters the proportional band; at this point, the Error is 100%. The action
outputs a value that is in direct linear proportion to the size of the Error value.
A broad proportional band causes a more gradual initial response from the controller. Typically, Set Point
overshoot is low; but when the system stabilizes, oscillations around the Set Point tend to be greater.
VisiLogic Function Blocks
A narrow band causes a rapid response that typically overshoots the Set Point by a greater margin. However,
the system does tend to stabilize closer to the set point. Note that a proportional band set at 0.0% actually forces
the controller into On-Off mode.
The drawback of proportional control is that it can cause the system to stabilize below set point. This occurs
because when the system is at set point, Error is zero and the control value output is therefore pegged at zero as
well. The majority of systems require continuous power to run at set point. This is achieved by integrating
integral and derivative control into the system.
Direct action causes the output to change in the same direction as the change in Error, meaning that a positive
change in Error causes a positive change in the proportional band’s output. Reverse action creates an inverse
change in the output, meaning that a positive change in Error causes a negative change in output.
Integral Action
Integral action responds to the rate of change in the controller’s CV output relative to the change in Error. The
integral time you set is the amount of time, as calculated by the controller, required to bring the process to Set
Point. Note that if you set a short integral time, the function will respond very quickly and may overshoot the
Set Point. Setting a larger integral time value will cause a slower response. Integral time is sometimes called
Reset.
The controller’s CV output may reach and remain at 100%, a condition called saturation. This may occur, for
example, if the process is unable to reach Set Point. This causes the Error signal to remain stuck in either the
positive or negative range. In this situation, the integral action will grow larger and larger as the Error
accumulates over time. This is called integral "wind up", which can cause the controller to overshoot the set
point by a wide margin.
This situation can be prevented by setting an MB to clear the accumulated Integral error when saturation is
occurs.
VisiLogic Function Blocks
Derivative Action
Derivative action responds to the rate and direction of change in the Error. This means that a fast change in
error causes a strong response from the controller.
The derivative action ‘anticipates’ the PV’s value in relation to the Set Point and adjusts the controller’s CV
output accordingly, thus shortening the PID function’s response time.
VisiLogic Function Blocks
Trends FB
Trends Ladder functions enable you to display a vector of dynamically changing values on the Vision screen
in response to application conditions. The values input to Trends may come from:
Registers
Data Tables.
To provide background axes for Trends, you can either use the HMI utility Draw Static Axis, or the advanced
Draw Axis functions. Trends operations are located on the FBs toolbar.
FB Operations
Configuration
Advanced-Draw
The location and length of the Trends vector, which is the vector of values that the application
uses to draw the Trends graph.
The size of the Drawing Area
The graph's location on the screen.
Fill & Draw Loop: Track a Single Value automatically tracks a single, dynamic value such as a temperature
value.
The advanced operation Trend Draw Graph enables you to draw an array of values within the vector, by setting
the array length and the offset from the start of the vector.
By default, the graph is drawn as a 1-pixel high single line of connected points. Trends Style enables you to
control the default appearance of the graph line (point height and width in pixels, and connecting line type).
VisiLogic Function Blocks
Trends QuickStart
The figures below show all of the basic elements required to track a single "Temperature" value. Each second, a
single value is stored in the Trends vector. When the application draws the Trends graph on the LCD, each point
is the graph line represents a single value in the vector.
VisiLogic Function Blocks
Linearizing Values
Linearizing Data Table values ensures that the Trends graph will fit into the drawing area. To do this, read each
value from a Data Table, linearize and then store it in the MI that provides the value for the Fill Loop function.
If, for example, within the Data Table, the 'temperature' value range is 40-2000, set the 'x' parameters in the
Linearization function from 40-2000. If, within the Trend Configuration, the area height is set to 200, set the 'y'
parameters range from 0-199.
Note that SB 26, Exiting OS Draw Mode, turns ON for 1 cycle after OS draw. OS Draw Mode means that the
controller's Operating System takes control of the LCD screen:
For detailed information on each Trends operation check the Related Topics listed below and the Trends Sample
applications located in :::\ProgramFiles\Unitronics\VisiLogic\Examples.
VisiLogic Function Blocks
Configuration
Use the Trends Configuration to set the parameters the controller uses to draw the Trends graph on the LCD.
You must link each Trends operation to a Configuration.
Set the Data Source to define the Trends vector, the vector that contains the values to be drawn in the Trends
graph. This vector can be from within the PLC operands, or from values in the PLC's Data Tables.
Note • The Configuration must be scanned during each PLC program cycle (even if the activating
condition is OFF). It should therefore be placed in the main routine and activated once, at power-up
(SB2). The net containing the Configuration must not be jumped via label.
Configuration Parameters
Parameter Type Function
Value Message
VisiLogic Function Blocks
3 X & Y origins are not within the area of the Vision screen; Trend
graph cannot be drawn.
4 Drawing area height exceeds the area of the Vision screen; Trend
graph cannot be drawn..
8 The linked Data Source Type is not legal (operand or Data Table);
Trend graph cannot be drawn.
9 The linked Data type is not legal (byte, integer, long); Trend graph
cannot be drawn
15 Loop Fill/Draw is active, but the Loop has not been initialized with
Loop Init.
Turns ON, When Draw is activated, and remains ON when Draw operation is
drawing.
Turns OFF when the operation finishes drawing.
----------------------------------------------------------
Do not use the state of 'Function in Progress' together with the Fill & Draw
operation.
VisiLogic Function Blocks
Loop: Draw and Fill automatically adapt the number of values on-screen to the Drawing Area, which is set in
the linked Configuration. When the operations reaches the last operand in the Trends vector, they return to the
beginning.
Note • Do not use the state of the Configuration's 'Function in Progress' MB together with the Fill & Draw
operation. Since the Fill and Draw operation automatizes the pointer action with the vector,
Loop Init
When you activate this operation, it initializes the Loop: Fill & Draw pointers, causing it to return to the first
operand in the Trends vector.
Loop: Fill
This operation has a single parameter: Fill Value. The Fill register is linked to the value that the function stores
in the Trends Vector. The first time Loop: Fill is called, the operation stores the value in the Fill register into the
first operand in the Trends vector. Each time this operation is activated after this, the value in the Insert Value
operand is stored into the next consecutive operand. The value is then represented as a point in the Trends Loop
graph.
When the last value has been stored, Loop: Fill returns to the beginning and stores the value into the first
operand This process continues until Loop: Init is called.
Loop: Draw
This operation has no parameters. The first time Loop: Draw is called, the operation draws the first value in the
Trends Vector as the first point on the graph. Each time this operation is activated after this, it draws the next
consecutive value in the vector.
VisiLogic Function Blocks
When the last value has been drawn, Loop: Draw returns to the first value and begins again. This process
continues until Loop: Init is called.
VisiLogic Function Blocks
Advanced-Trends: Style
This operation enables you to set the appearance of the Trends graph.
The figure below shows what part of the Trends graph are affected by the different parameters.
Configuration Parameters
Parameter Type Function
Point width MI,ML, DW, or Sets the width, in pixels, of each individual point.
Constant Range of Values: 1-10 pixels. Default: 1.
Point Height MI,ML, DW, or Sets the height, in pixels, of each individual point.
Constant Range of Values: 1-10 pixels. Default: 1.
Space between MI,ML, DW, or Sets the space between points; this is limited by the size of the Drawing Area and
points Constant Vision screen dimensions. Default: 0.
Space style MI,ML, DW, or Use this parameter to connect the points in the graph. Default: 0.
Constant
Value Style
0 No line
VisiLogic Function Blocks
1 Simple line
3 Steps
How many values will be represented from within the Trends vector.
The offset of those values from the start of the Trends vector.
Each value in the Trends vector is represented by a single point on the graph.
Use the Draw: Number of Values parameter to determine how many values, within that vector, will be
represented at each program scan. Each time the Trend Draw is activated, all of the points in Number of Values
are refreshed, according to the Data Offset.
Data Offset MI,ML, DW, or Sets the offset number, from the beginning of the vector, of values to be read.
Constant
Draw: Number MI,ML, DW, or The number of values to be represented at each program scan.
of Values Constant Note • All points must be able to fit on the screen.
If, for example, in Trends Configuration, the point width is set at 1 pixel and the space
between points is set to 0, and Trends Draw is set to represent 200 values, the
resulting graph line will be two hundred pixels long on the LCD screen.
In order to display all 200 values, the Drawing Area Width must therefore be set to a
minimum of 200 pixels
Clear Trend MB When this MB is ON: at each scan, before the trend graph is drawn, the function
Before Refresh clears any pixels that are occupying the locations of new points in the Trends graph.
The location of the Trends graph is in accordance with the parameters in the Trend Configuration. The Trends
Configuration below sets a Trends Vector of 1000 MIs.
VisiLogic Function Blocks
The following Draw Graph operation will draw 200 values on the screen; which 200 values are drawn depends
on the value in the parameter Data Offset in Trend Vector.
VisiLogic Function Blocks
Data Offset MI,ML, DW, or Sets the offset number, from the beginning of the vector, of values to be read.
Constant
Draw: Number MI,ML, DW, or The number of values to be represented at each program scan.
of Values Constant Note • All points must be able to fit on the screen.
If, for example, in Trends Configuration, the point width is set at 1 pixel and the space
between points is set to 0, and Trends Draw is set to represent 200 values, the
resulting graph line will be two hundred pixels long on the LCD screen.
In order to display all 200 values, the Drawing Area Width must therefore be set to a
minimum of 200 pixels
Clear Trend MB When this MB is ON: at each scan, before the trend graph is drawn, the function
Before Refresh clears any pixels that are occupying the locations of new points in the Trends graph.
VisiLogic Function Blocks
Draw Axis
Use this function to place x and
y axes, including ticks, on the
Vision screen in response to
Ladder conditions.
FB Operations
Configuration
Draw
Clear
Configuration
The Draw Axis Configuration sets the parameters the controller uses to draw the axis on the LCD. Each Draw
Axis operation is linked to a Configuration.
VisiLogic Function Blocks
Axis Type Constant This sets the axis direction. Select between:
X axis (horizontal).
Y axis (vertical).
Status MI If the axis or ticks are not drawn when the Draw operation is called, check the value of the
Status MI.
VisiLogic Function Blocks
The first 4 (LSB) bits of the MI act as a bitmap to indicate the messages listed below.
Bit Message
Each axis, whether x or y, that is drawn on screen requires a separate Draw Axis Configuration. In addition, note
that in order to obtain an axis with different tick heights, you must superimpose one axis on top of another.
The example below shows a horizontal axis that is composed of 2 separate Draw Axis Configurations. Note that
the parameters supplying coordinates are identical; the tick height and spacing are different.
VisiLogic Function Blocks
VisiLogic Function Blocks
Draw
To display the axis on screen:
Clear
To clear the axis from the screen:
Note • The Draw Axis Clear clears the last axis drawn.
This means that if the application:
Draws an axis,
Redraws the same axis, but after changing the Configuration's parameters, changing
the location/appearance of the axis,
Runs Clear Draw Axis
The result is that only the axis drawn in Step 2 will be cleared.
This means that you must run Clear Draw Axis before redrawing an axis.
VisiLogic Function Blocks
Loadcell
Loadcell FBs, located on the FB menu, enable you to include an I/O module that is connected to a loadcell or
strain-gauge in your control application. Unitronics I/O expansion loadcell modules are intelligent I/O modules
that are capable of receiving analog values directly from loadcells.
IO-LC1 offers 1 Loadcell input; IO-LC3 module offers 3 Loadcell inputs. Each IO-LCx module is capable of
providing excitation for up to 12 loadcells.
The Loadcell FBs enable you to calibrate the loadcell. You can also tare and zero the loadcell, compensate for
deadload and scale movement, and set the input range.
Once you connect the loadcell and calibrate at least 2 points, you can begin to run a loadcell application. The
loadcell input can be read in 6 different ways:
Gross weight
Net weight
Net Min. Weight
Net Max. Weight
Scaled to uV/V
Raw Value
Most applications will require only the Gross or Net weight. Raw Value and uV/V readings may be useful for
troubleshooting purposes.
Loadcell Quickstart
FB Operations
Configuration
Scan
Calibration
Setup
Advanced
Note • Both negative and positive (signed and unsigned) values can be processed by the I/O-LCx and the
support software, enabling a range of applications.
• This feature is not supported by the V120-12 series.
VisiLogic Function Blocks
Configuring a Loadcell
The number of Loadcell tabs in the Hardware Configuration window depends upon the loadcell module.
In use Select 'In Use' to enable the loadcell for the application.
Note • A loadcell marked 'in use' can be suspended according to application conditions
via the Advanced Calibration function Enable/Disable loadcell. This may be done to
shorten the application's calibration time.
Resolution ML, Selecting High enables you to link the input value to an ML, Normal to an MI.
MI
LC Input Value(s) MI, When the application runs, these registers contain the weight value input to the controller
ML from the I/O LCx.
When you select two values, you link the first value to a single register. The second value
is automatically linked to the next register.
The default representation mode for the first register is Net Weight, and Gross Weight for
the second register.
Excitation AC is the default, recommended Excitation method. You may select the DC option if
your application requires.
Loadcell: Configuration
All Loadcell operations run through a Loadcell Configuration placed in the control program. Each
Configuration is linked to a specific Loadcell input on the I/O expansion module.
Loadcell Configuration is generally a Power-up task. The Loadcell Configuration FB is located on the
FB's>Loadcell menu.
I/O Module DIN Links the Configuration with the correct I/O expansion module according to its DIN rail
Location location in Hardware Configuration.
Note • If the module is not located in the entered location, the LC Command Status Messages
MI will display 6, Communication Error (I/O module does not exist)
Note • If the selected Loadcell is not marked 'In Use', the LC Command Status Messages MI
will display 11, Illegal parameter
LC Command MI
Status Messages Is reset to 0 when a command is activated.
Updated at the end of all operations using the Loadcell Configuration.
Indicates error status for all loadcell operations processed by the Configuration
Current value always shows the most recent error status.
Value Message
0 Function in Progress
VisiLogic Function Blocks
5 Timeout Exceeded
11 Illegal parameter
17 Signal is out of range (this value occurs when the Out of Range bit is ON)
18 Illegal weight (Occurs during calibration, if the raw value of weight being
calibrated is too close to the raw value of an already calibrated weight;
minimum distance is 256 or 100 Hex)
20 Not calibrated (This value appears when less than 2 points have been
calibrated)
21 EEPROM Protection Error (Indicates when too many Save Calibration FBs
are run too frequently. Check the activating conditions for the Save
Calibration FB, and whether your application contains loops)
Function in MB This bit is ON when the module is processing a command. Use this as a condition bit for
Progress Loadcell operations to avoid conflicts.
Turns ON when: Turns OFF when:
Command is being processed. Configuration is first activated.
Command Status Messages MI is 0. Command Status Messages MI is 1.
VisiLogic Function Blocks
LC Function LC
Success in Progress Command Status Messages
Bit
Command 0 1 0
Issued
Success 1 0 1
Error 0 0 >1
Scan
A Scan FB must be included for every Loadcell Configuration in a Loadcell application. When an application
contains more than 1 Loadcell Configuration in the Ladder, the Scan FB displays the Select Name drop-down
list, enabling you to link the desired Configuration.
Calibration
Calibration parameters include calibrated points, input range settings, tare and zero values. These may be burned
to the module's EEPROM using the Save Calibration FB. Before you can begin to implement a Loadcell
application, you must calibrate at least two points, although up to 12 points may be calibrated; all other
calibration parameters are optional. However, note that if the application requires you to set Input Range/Gain,
you must make these settings before you calibrate points. Setting the Input Range/Gain after calibrating points
invalidates these points.
Calibrating Points
A Calibration Point matches a Raw Value with a Weight value. These points are used to linearize the input
value.
To calibrate points, connect the controller to the loadcell via the I/O-LCx. Initial calibration is generally
performed with known weights as shown in the following figure. After calibration has been performed,
advanced calibration enables points to be added or edited via the ladder without weight being physically placed
on the loadcell.
VisiLogic Function Blocks
Note • If the application requires you to set Input Range/Gain, you must make these settings before you
calibrate points. Setting the Input Range/Gain after calibrating points invalidates the calibrated
points.
• Zero does not have to be calibrated.
• Points do not have to be calibrated in any particular order.
• All calibrated points must be separated by a raw value minimum of 25 (100 Hex).
• Calibration is an immediate operation; motion is not checked before the operation is carried out.
• Calibration should be performed with greater accuracy than is required by the application. For
example, in an application that requires 100g accuracy, calibrate in units of 10g, then round off the
represented value by 10.
• The highest Calibrated Point weight value should 80–100% of the scale capacity.
• Calibration cannot not be performed if the selected representation mode is uV/V.
• During calibration, increase filter depth by:
- Increasing Settling Time.
- Disabling other Loadcells.
VisiLogic Function Blocks
Calibrate Point FB
The Calibrate Point FB is located on the FB's>Loadcell>Calibration menu.
Point Number Constant, A Calibration Point matches a weight value with a raw value. The raw value is acquired as an
MI input from the loadcell when the application is run.
Calibrate to MI, ML This provides the weight value that is matched to the raw value
Weight
Save Calibration
When you save the calibration, calibrated points, tare, zero, and input range are burned into the module's
EEPROM memory. This protects the calibration in the event of a power outage, reset, or power-up. To preserve
any changes made to calibrated points, input range settings, tare and zero values, use Save Calibration any time
these parameters are edited.
When Zero is applied, only the gross weight will be zero at the beginning of a weighing session.
Acquire Tare and Acquire Zero are both located on the FB's>Loadcell>Tare & Zero menu.
Acquire Tare: In this method, the tare value is acquired from the scale. The objects comprising the tare, such as
a pallet or materials container, are placed on the scale, and Acquire Tare is activated.
Acquire Zero: The scale must be empty to acquire Zero. Acquire Zero is not related to the Auto-Zero Tracking
function, which enables the module to compensate for the accumulation of undesired material on the scale in the
course of operations.
Note • Loadcell Name determines from which loadcell the tare/zero will be acquired. After the tare has
been acquired, the tare value will be applied to that loadcell.
• Use the Save Calibration FB to save Tare and Zero values to the module's EEPROM memory.
• Tare and Zero cannot be acquired when running uV/V mode.
• If the Motion Band FB is activated, the tare value cannot be acquired until the scale is stable.
Although only the FBs relating to tare are pictured in the following figures, the figure apply to both Tare and
Zero FBs.
Tare/Zero MI, ML, Edit Tare/Zero enables the tare value to be acquired from a register or constant value within
Value or the controller.
Constant You can also use Edit Tare/Zero to change a loadcell's existing tare/zero value.
VisiLogic Function Blocks
Read Tare/Zero MI, Reads the current tare or zero value applied to the linked loadcell input into the linked register.
ML
Setup
Setup FBs provide additional parameters that you may require for your application. Setup FBs include Motion
Band, Filter & Rounding, and Auto-Zero, and are located on the FB's>Loadcell>Setup menu.
Note • The Setup FBs need to be activated only once, at power-up. They are not saved to EEPROM.
Motion Band
When the weight on the scale changes, the scale needs time to stabilize.
The Motion band determines the amount of weight change the module uses to decide if the scale is in motion.
Bit 0, of the MI that is linked to LC Hardware Status Messages in Hardware Configuration, is the In-motion
indicator. Bit 0 is ON when the scale is in motion, and OFF when the scale is steady.
As the module reads the signals from the loadcell(s) it calculates the weight value. If a weight change falls
within the Motion Band, Bit 0 turns OFF.
In the figure below, the in-motion indicator (Bit 0) turns ON when the weight change is below 100 grams, or
more than 500 grams. When the weight change falls within the band (100 to 500), Bit 0 turns OFF.
- at Power-up
- or when the scale is not calibrated.
• In order for the In-Motion indication to function properly, the filter Active Band must be equal or
higher than the In-Motion Tolerance. Refer to the Filter and Rounding function for description and
power-up defaults.
• If the Motion Band is active, the tare/zero values cannot be acquired when the scale is in motion.
LC Motion MI, ML, Provides a value for the weight band. A weight change that falls outside this band turns the In-
Band or motion bit ON. When the weight change is inside the band, the bit turns OFF.
Constant
Settling Time MI,or The time, in units of 10msec, that the filter requires to settle to the final reading.
Constant Note • The default settling time is 1 second, the minimum time 1 is 12.5 milliseconds, and the
maximum is 24 seconds.
• A value of zero disables the filter.
• Settling time rises with the number of active loadcells.
VisiLogic Function Blocks
Active Band MI, ML, The band of weight changes in which the filter is active.
or The filter is turned off by weight changes that exceed the active band. This allows a rapid
Constant response to large weight changes. When the weight changes become smaller than the active
band, the filter turns on.
An active band of zero forces the filter to be always active.
Note • If the Motion Band is on, the filter's Active Band must be equal or higher than the
Motion Band.
Note • Once Auto-Zero tracking is activated, it stays active until the function is suspended by the
application.
• Auto zero tracking will not function in uV/V representation mode.
LC Time: MI, ML The time in which, in units of 10 mSec, the scale must be stable in order to trigger
Scale Stable, 10 mS or Auto-Zero Tracking.
units Constant Note • Initializing this parameter to 0 will turn off Auto Zero Tracking and clear the
accumulated offset.
• Power-up default: 0 (auto zero tracking is off).
• To clear the auto zero tracking offset, initialize this parameter to 0, and then
enter a new time value.
LC Tracking band, MI, ML This determines the maximum distance from the point of the last zero (auto or manual)
Weight from last or in which auto-zero tracking is activated [weight units].
Auto-0 Constant
VisiLogic Function Blocks
LC Tracking Range, MI, ML This determines the maximum weight from the point of the last calibrated zero in
Weight from Calib. 0 or which auto-zero is activated.
Constant
Loadcell: Configuration FB
All Loadcell operations run through a Loadcell configuration placed in the control program. Each Configuration is
linked to a specific Loadcell input on the I/O expansion module.
Value Message
0 Function in Progress
5 Timeout Exceeded
11 Illegal parameter
17 Signal is out of range (this value occurs when the Out of Range bit is ON)
18 Illegal weight (Occurs during calibration, if the raw value of weight being
calibrated is too close to the raw value of an already calibrated weight;
minimum distance is 256 or 100 Hex)
20 Not calibrated (This value appears when less than 2 points have been
calibrated)
VisiLogic Function Blocks
1 Input Value Range Input value is out of range Input value is in range
Linked to I/O module's Out of Range LED Possible causes:
indicator 1 or more signal wires are disconnected
A/D input voltage is out of range
3 Loadcell Calibration Status When less than 2 points are calibrated At least 2 points are calibrated
Linked to I/O module's Out of Range LED When the input power is not supplied, the indicators blinks rapidly
indicators
Note • Bits 6 & 7 are linked to Outputs 0 & 1, located on the I/O module. Bit 6 is related to Output 0, Bit 7 to Output 1.
Bits 6 & 7 can be used to monitor the setpoint output's status from within the Ladder application.
The I/O module itself controls the setpoint function of the outputs. The module turns the outputs ON and OFF when the current
loadcell input value reaches setpoint. Since the function is based in the firmware of the expansion module, when the output's
status changes as a result of reaching/departing from setpoint, the status change is not registered by the Ladder application.
Examples
When setpoint output 1 is assigned to load cell channel 0, Bit 7 of load cell 0 status will indicate the state of output 1.
When setpoint output 0 is assigned to load cell channel 2, Bit 6 of load cell 2 status will indicate the state of output 0.
SB91 I/O Exp. Module--Command buffer is full ON when an I/O is processing a command. OFF when an I/O is idle.
VisiLogic Function Blocks
Note • The Edit and Read Calibration Point functions contain parameters which accept the raw and weight
values from existing Calibration Points. These parameters must be linked to the same type of
registers, MI or ML, used to calibrate the original Calibration Point.
Edit Calibration Point: value via operand or constant
A Calibration Point matches a raw value to a weight value. You can use Edit Calibration Point to change these
values.
Note • The loadcell will stop functioning if deleting a point causes the number of Calibration Points to be
less than 2.
• To prevent your changes from being lost at power-up, reset, or in the event of power outage, use the
Save Calibration FB to burn the changes to the module's EEPROM.
LC Calibration MI or The number of the Calibration Point that you wish to edit.
Point Number Constant
LC Raw Value MI, or This register contains the new raw value for the Calibration Point.
ML
LC Calibrate to MI, or This register contains the new weight value for the Calibration Point.
Weight ML
Note • If the point being read is not in use, both returned values will be -32768 (0x8000) for integer and -
8388608 (0x800000) for long.
VisiLogic Function Blocks
LC Calibration MI or The number of the Calibration Point that you wish to read.
Point Number Constant
LC Raw Value MI, or This register contains the current raw value of the Calibration Pointt.
ML
LC Calibrate to MI, or This register contains the current weight value of the Calibration Point.
Weight ML
Note • The loadcell will stop functioning if a deleted point causes the number of Calibration Points to be
less than 2.
• To prevent your changes from being lost at power-up, reset, or in the event of power outage, use the
Save Calibration FB to burn the changes to the module's EEPROM.
LC Calibration MI or The number of the calibrated point that you wish to delete.
Point Number Constant
Clear Calibration
This deletes all calibrated points, tare, zero, and input ranges from the module's memory. However, Clear
Calibration does not erase the values from the EEPROM. They may be retrieved from the EEPROM by resetting
the controller.
To delete all values from the EEPROM, run Clear Calibration followed by Save Calibration.
During Calibration, the Disable All Other Loadcells FB can be used to increase filter depth for a specified
settling time by eliminating the delay caused by channel change (approx. 300ms) and thus ensuring faster and
more accurate calibration.
To prevent channel changing from wasting settling time, use this function to disable all other loadcells except
for the one you are currently calibrating.
VisiLogic Function Blocks
Enable All Other Loadcells re-enables all loadcells in the expansion module.
Note • After this FB is run, and the Command Status Messages MI linked to the selected Loadcell
Configuration indicates 1, updated values for all of the enabled channels are already available at
their linked operands. This indication can be used to trigger a process, such as calibration.
• Disabled Loadcells: the Command Status Messages MI linked to the selected Loadcell
Configuration The status bit "Value not valid" will rise in the disabled load cells' status word.
Setpoint
Each digital output located on the I/O module is associated with a setpoint. The I/O module itself controls the
setpoint function of the outputs. The module turns the outputs ON and OFF when the current loadcell input
value reaches setpoint. Setpoint activity is therefore not linked to the program scan. Each output may be
assigned a setpoint.
Since the function is based in the firmware of the expansion module, when the output's status changes as a result
of reaching/departing from setpoint, the status change is not registered by the Ladder application. To monitor the
outputs' status, this MI provides a bitmap indicating status messages; Bit 6 is related to Output 0, Bit 7 to Output
1.
Therefore, use Bits 6 & 7 of the LC Hardware Status Messages MI to monitor the outputs' status, from within
the Ladder application.
Note • Once the Setpoint is activated, it cannot be changed by setting the output via the Ladder application.
The setpoint remains OFF, regardless of its N.O./N.C.setting, when the loadcell input value is:
- invalid (i.e., powered off, LC disabled, out of range, loadcell not calibrated.
- In uV/V mode.
Examples
When setpoint output 1 is assigned to load cell channel 0, Bit 7 of load cell 0 status will indicate
the state of output 1.
When setpoint output 0 is assigned to load cell channel 2, Bit 6 of load cell 2 status will indicate
the state of output 0.
Bit Description Turns ON when: Turns OFF when:
LC Value Constant Set the input value mode for the setpoint:
Mode 0 - Net
1 - Gross
2 - Net Min
3 - Net Max
LC MI, ML, Sets a band in which the output will not chatter due to overshoot or vibrations.
Setpoint or
Hysteresis Constant
Deactivate Setpoint
Use this to suspend the activity of a particular setpoint.
Via Change Representation mode, you can 'read' the value as:
VisiLogic Function Blocks
Gross weight
Net weight
Net Min. Weight
Net Max. Weight
Scaled to mV
Raw Value
LC Value to Constant Select the value for which you want to change the representation mode.
Represent
Note • When, after Change Representation Mode runs, the LC Command Status Messages MI returns '1',
the requested value is already in its linked operand. This means that you can use the '1' status to
trigger a process which relies on this specific representation value.
The mV/V rep. mode indicates the actual applied differential input voltage in
micro-volts per every volt of the excitation, regardless of the user-selected input
range and DAC (offset) compensation.
Setting one of the values representation modes to mV/V will force both values to
be represented in mV/V (the rep. mode of the other value will not be overwritten).
It takes approximately 330msec to change between mV/V and other different
representation modes.
• The A/D raw value is affected by the user-selected input range (gain and DAC (offset)
compensation). To cancel this effect, use the Clear Calibration command to set default calibration.
To return to the last saved calibration, reset the controller (no need to re-power-up neither the unit
nor the controller).
As soon as the scale becomes stable, meaning that the In-motion bit is OFF, the Net Min and Max values will be
set to the net value.
VisiLogic Function Blocks
This method is intended to use only for diagnostic purposes,such as when using a DC milli-voltmeter.
Note • Changing the excitation mode may add an offset to the A/D measurements. Therefore, the system
should be calibrated using the same excitation mode the loadcell will work with.
• In general, the working excitation mode should be set via Hardware Configuration.
• The Change Excitation command overrides the hardware configuration excitation setting until the
next system reset / power-up.
• Changing excitation mode may cause a momentary conversions-break (about 300msec) due to filter
reset.
LC Excitation MI or 0=DC
mode Constant 1=AC
Input Range
The Input Gain parameter sets the amplification range for the input signal.
The Offset parameter is generally used to compensate for the deadload; particularly in cases where the combined
weight of deadload and payload exceed the A to D converter input range.
Input Range and Offset are considered part of the loadcell's calibration. To burn these values into the module's
EEPROM memory and protect them in the event of a power outage, use the Save Calibration FB.
Set Gain FB
This FB limits the input range. The gain is applied to the signal after offset compensation.
Setting the Set Gain MB to 0 limits the input range to ±20mV (Default setting), setting it to 1 (or any other
value) limits the input range to ±80mV.
VisiLogic Function Blocks
Set Offset
This FB sets the offset compensation, which is applied to the input signal before the gain. By default, the offset
is set to 0mV (no offset).
Possible values are in the range of ±31, where: 1LSB X 0.5mV/V (= 2.5mV at exactly 5V excitation). Hence, the
maximum offset compensation is ±15.5mV/V (= ±77.5mV at exactly 5V excitation).
To calculate the offset value, measure the differential voltage at the input, between the -SG and +SG terminals,
and then calculate the offset value according to 1LSB X 0.5mV/V.
If, for example, the differential voltage at the input is 10mV, use -4 as the offset value.
Read Gain
Reads the input range Gain.
Read Offset
Reads the input range Offset.
Note • Changing Gain or Offset requires you to recalibrate and save all calibrated points.
• If the application requires you to set Input Range/Gain, you must make these settings before you
calibrate points. Setting the Input Range/Gain after calibrating points invalidates the calibrated
points.
• Offset values out of the ±31 range will be truncated and no error will be returned.
• The uV/V rep. mode uses its own input range settings and therefore is not affected by the command.
VisiLogic Function Blocks
GPRS FB
GPRS is a wireless data transmission service offered by some cellular providers. When a Unitronics' PLC is
connected to a GPRS modem, the PLC can establish a data connection with a remote PC connected to the
Internet and transmit IP packets of data over the GPRS cellular network.
You can then use your PC to access the PLC via VisiLogic, Remote Access or other communication .dll, as well
as log PLC data via the DataXport utility.
Note • The PLC must be connected to a GPRS modem. GPRS service must be supplied by the user's
cellular service provider.
• To enable any GPRS operations to run, the PLC application must include GPRS Configuration and
GPRS Run FBs.
• Unitronics has tested the following GPRS modems with Unitronic's PLCs:
• The PLC must initiate the GPRS data link by calling the PC.
A sample application showing how to establish PC-PLC communications is available for both Sony
Ericsson and Wavecom modems. This application is intended to be used as a template, for you to
simply copy and adapt to your own requirements. Sample applications are located under
Help>Examples.
• Wavecom modems do not support the End Call function. In order to end a call, use the Unregister
from Network function, and then re-register if required.
• The Sony Ericsson GT47 GPRS modem must be used in conjunction with an appropriate cable and
5 pin connector.
Using GPRS
The PLC's Ladder application must contain the conditions and elements shown below.
VisiLogic Function Blocks
FB Name Purpose
COM Port Init FB Configure this FB to initialize the PLC COM Port connected to the GPRS-modem. Within
the COM Init FB, select the GSM modem type, and then the actual GPRS modem type, such
as the Sony Ericsson GT47.
COM Port Init is usually a Power-up task.
Note• To learn how to prepare the modem for PLC use, check the topic PLC-side Modems.
GPRS Configuration The Configuration is linked to the serial port initialized via the COM Port Init FB. Note• The
activating conditions should include the appropriate Modem Initialized SB for the COM Port.
GPRS Connect must follow the GPRS Configuration. Connect provides the parameters that enable
Connect to Network the PLC to connect to the Internet via the cellular network.
GPRS Run
Start Call
End Call
GPRS Configuration
The GPRS Configuration must be included in all GPRS Ladder applications.
The Configuration is linked to the serial port connected to the GPRS modem and initialized via the COM Port
Init FB.
Note • The activating conditions should include the appropriate Modem Initialized SB for the COM Port.
Port Number Constant Click the drop-down arrows to view available ports; click the port you want to use.
Status Messages MI The value of the linked MI indicates GPRS status messages.
Call Status MB This bit turns ON when the remote device has been accessed and the GPRS connection is
established.
VisiLogic Function Blocks
Name Select the name of the GPRS Configuration that Connect will use to connect to the
GPRS network.
Registered by MB Turns ON when the PLC is assigned an IP address and registered by the GPRS
Network network.
IP Address MI When the PLC registers on the GPRS network, it is assigned a dynamic IP address.
This is the start of a vector that contains the IP address that is assigned to the modem
when the modem registers with the GPRS network. The vector is 4 MIs long. The low
byte of each MI provides the number for an octet within the IP address.
If, for example, the IP address is linked to MI 0, and the low bytes of MI 0 to MI 3
contain the values 192, 198, 192, 45, the IP address will be 192.198.192. 45.
APN Server Constant or MI The name of the APN (Access Point Name) Server given by your GPRS service
provider.
Dial Number Constant or MI This parameter is required by some GPRS service providers and GPRS modem
(optional) manufacturers.
User Name Constant or MI This parameter is required by some GPRS service providers and GPRS modem
(optional) manufacturers.
Password Constant or MI This parameter is required by some GPRS service providers and GPRS modem
(optional) manufacturers.
VisiLogic Function Blocks
GPRS Run
This FB must be included in all GPRS applications.
Start Call
This FB provides the Port and IP address of the remote device, enabling the PLC to call the remote device and
establish a data communications link.
Name Select the name of the GPRS Configuration that Connect will use to connect to the
GPRS network.
End Call
This FB ends the current data communications sessions with a remote device, but does not terminate the
connection to the GPRS network.
Note • Wavecom modems do not support the End Call function. In order to end a call, use the Unregister
from Network FB, and then re-register to the network if required.
VisiLogic Function Blocks
A value of -1(FFFF)signifies a modem error. This may be due to a weak signal; try repositioning the antenna. If
this has no effect, check the modem.
GPRS: Configuration FB
Status Messages MI
Value Message
Initialized to 0 when GPRS:
Configuration is activated.
0 No message
51 Modem Timeout
IP Address MI This is the start of a vector that contains the IP address that is assigned to the modem
when the modem registers with the GPRS network. The vector is 4 MIs long. The low
byte of each MI provides the number for an octet within the IP address.
If, for example, the IP address is linked to MI 0, and the low bytes of MI 0 to MI 3
contain the values 192, 198, 192, 45, the IP address will be 192.198.192. 45.
VisiLogic Function Blocks
SI Description Value
185 GSM Signal Quality The value is written during COM Init of the GSM modem. The value
is updated whenever the user uses the GSM Signal Quality FB.
A value of -1(FFFF)signifies a modem error. This may be due to a
weak signal; try repositioning the antenna. If this has no effect, check
the modem.
SBs 120-125 register the signals that each port receives from the DTR and DSR pins of a serial communication cable.
The DTR SBs 120, 122, and 124 are also used by the OS to control the DTR signal during RS485 serial communications, and
during GPRS communications using the Sony Ericsson GPRS modem.
SB100 GPRS modem Call Remote device begins End Session succeeds OS
connected GPRS incoming call is Disconnect from Network
answered succeeds
SB 120 DTR COM Port 1 DTR signal present DTR signal absent OS, may also be reset by
(signal output from user
PLC)
SB 121 DSR COM Port 1 DSR signal present DSR signal absent OS
(signal input to PLC)
SB 122 DTR COM Port 2 DTR signal present DTR signal absent OS, may also be reset by
(signal output from user
PLC)
SB 123 DSR COM Port 2 DSR signal present DSR signal absent OS
(signal input to PLC)
SB 124 DTR COM Port 3 DTR signal present DTR signal absent OS, may also be reset by
(signal output from user
PLC)
SB 125 DSR COM Port 3 DSR signal present DSR signal absent OS
(signal input to PLC)
VisiLogic Function Blocks
SMS Messaging FB
About SMS messaging
SMS messaging is a feature offered by cellular telephone services. SMS-enabled controllers can use SMS
messaging to send and receive data to and from a cell phone or other cellular device. Both fixed text and
variable data can be communicated. This feature can be used to transmit data and for remote diagnostics.
Note that SMS messages can also be sent and received when the controller is in On-line Test (Remote Access)
mode.
SMS messaging is featured in several sample applications; these may be found by selecting VisiLogic Sample
Projects from the Help Menu.
In order to use this feature, you must connect an SMS-enabled PLC to a modem that supports connection to a
cellular network.
SMS messaging is subject to the limitations of cellular networks, such as network availability.
VisiLogic Function Blocks
Note that SMS messages are limited to the English character set.
Initialize one of the controller's communications ports using a COM Init FB.
Note • Communications cannot flow through the port during initialization. To avoid conflicts in your
program, use the Modem Initialization Status SBs.
Place an SMS Configuration FB into your application. Link it to the port initialized via the COM Init FB. The
SMS Configuration will use this port to receive and send messages.
The SMS Configuration contains a list of SMS messages and phone numbers.
Note • COM Init and SMS Configuration must appear in the application and be activated before any
SMS operations are activated. If this is not done, the application will not work.
To enable the controller to receive messages, place an SMS Scan FB in your application and link it to a
Configuration. When activated, this causes the controller to scan the GSM modem's SIM card for incoming
SMS messages
To enable the controller to send SMS messages, place an SMS Send FB in your application and link it to a
Configuration. You can then either send one of the messages in that Configuration or create one for that specific
Send FB.
In either case, the port defined in the Configuration will be used to send the message.
FB Operations
SMS: Configuration
SMS: Scan
SMS: Send
Select SMS Configuration from the FBs menu and place the function in your application.
Note • The condition that activates the SMS Configuration must turn ON for a single program scan
(positive transition recommended).
• The appropriate Modem: Initialized SBs [80 (COM 1),SB 82 (COM 2), SB 84 (COM 3)] must
turn ON before activating an SMS Configuration using that COM port; the SBs should be used as
an activating condition.
The SMS configuration must be scanned during every program cycle--after the Configuration is activated. One
way to ensure this is by placing the configuration in the first subroutine of the main module.
Note • An SMS Scan generally uses a direct contact as an activating condition. This enables the
configuration to continually 'listen' for incoming messages. When the controller registers that a
Scan has been activated, the MB linked to Modem Busy (GSM) turns ON, turning OFF only after
the Scan is complete.
Note • When the positive transition contact used to activate the Send FB rises, the MB linked to Modem
Busy (GSM) turns ON.
The rest of the logic in the net is processed whether or not the Send operation is completed.
• Operands linked to SMS FBs, such as Modem Busy (GSM), should be assigned Power-up
Values; bits should be reset, and registers initialized to 0.
• When an SMS message is sent, the Modem Busy (GSM) MB remains ON until the message has
cleared the SIM card.
When a Send operation is in progress, the modem is busy. If another Send operation is activated
while the modem is busy, the second Send operation will not be activated and the message will
not be sent--even after the modem is no longer busy.
Examples
Sample applications may be found in the VisiLogic Examples folder. This folder contains field-tested VisiLogic
(.vlp) sample applications. You can open this folder via the Help Menu.
SMS: Configuration
An SMS Configuration contains a list of SMS messages with attached variables and a phone book that is unique
to that configuration. SMS Configuration is also where you define Message Properties.
VisiLogic Function Blocks
Note • Although the PLC can send Binary Text, Numeric, and List of Texts variables, it can only receive
Numeric variables.
Binary Variable
This type of variable displays different text in the SMS variable field according to the status of a bit operand.
VisiLogic Function Blocks
Number Variable
This type of variable contains numbered lines of text. You link the Variable to an operand. The value within
that operand 'points' to the number of a line within the list. When the operand value is equal to a particular line
number, the text of that line is shown in the Display.
VisiLogic Function Blocks
Message Properties
This defines how the PLC deals with a specific SMS message that is received by the system. Note that a SMS
Scan FB must be placed in the Ladder to enable the PLC to check a specific SMS Configuration for received
messages.
VisiLogic Function Blocks
Phone Book
Click on a line to either:
Indirect Vector
Each register byte contains 1 character. Note that the byte actually contains the ASCII value of the desired
numeral. For example, the ASCII value of 1 is 049.
To work with international phone numbers, use the full GSM format, including the '+' in front of the country
code.
SMS: Scan
To enable the controller to receive messages, place an SMS Scan FB in your application and link it to a
Configuration. When activated, this causes the controller to scan the GSM modem's SIM card for incoming
SMS messages.
VisiLogic Function Blocks
Before you can receive an SMS, you must initialize a COM port to use a GSM modem, create an SMS
Configuration, and set conditions as explained in Using SMS Messaging.
Note • Communications cannot flow through the port during initialization. To avoid conflicts in your
program, use the Modem Initialization Status SBs.
• Although the PLC can send Binary Text, Numeric, and List of Texts variables, it can only receive
Numeric variables.
• Use an MB activated by the SMS Configuration FB to activate the Scan, as shown in Using SMS
Messaging
When the PLC receives a message, the Message Properties defined in the SMS configuration for that message
define how it will be processed.
VisiLogic Function Blocks
SMS: Send
To send an SMS, place an SMS Send operation in your Ladder application. Before you can send an SMS, you
must initialize a COM port to use a GSM modem, create an SMS Configuration, and set conditions as explained
in Using SMS Messaging.
Note • Communications cannot flow through the port during initialization. To avoid conflicts in your
program, use the Modem Initialization Status SBs.
• If the SMS Configuration is busy, messages cannot be received. Avoid conflicts by using a
negative contact, linked to the Configuration's FB in Progress MB, as an activating condition for
SMS: Send.
VisiLogic Function Blocks
Note • You can send only one SMS message at a time, but you may send it to multiple phone numbers.
• The Send Status MB turns on if there are more than one Send operations, and the PLC has not
finished processing the first Send before the second Send is activated. In this case, Modem Busy
MB of the SMS: Configuration bit will be ON, causing the Send Fail Bitmap to contain a value
of -1.
Select from Opens the list of messages contained in the linked Configuration.
Configuration To select a message to send, click it; the message will be highlighted.
Note • When you create messages in a Configuration, VisiLogic does not allow you to begin a message
with a fixed text character that is not a numeral (0-9) or a number sign (#). These limitations do
not apply to messages that you compose in an SMS Send FB, or to Indirect Messages. These may
begin with variables or with any alphanumeric character.
• Phone Indexes is based on the Phone Book in the linked SMS configuration. Index numbers are 0
to 8, note that 0 is the index of the last number called.
• SB 184 SMS: Transmission Succeeded and 185 SMS: Transmission Failed are both reset when
any message is sent to any phone number. After the message has been processed, the Relevant
SB will turn ON.
SMS Variables
Variables can be included in Configuration or Send FB messages. A single SMS message can contain both fixed
text and up to 10 variables. Note that SMS variables are not related to HMI variables.
Although the PLC can send Binary Text, Numeric, and List of Texts variables, it can only receive Numeric
variables.
Binary Variable
This type of variable displays different text in the SMS variable field according to the status of a bit operand.
The value currently visible is the last value sent.
Numeric Variable
This type of variable contains numbered lines of text. You link the Variable to an operand. The value within
that operand 'points' to the number of a line within the list. When the operand value is equal to a particular line
number, the text of that line is shown in the Display.
VisiLogic Function Blocks
A value of -1(FFFF)signifies a modem error. This may be due to a weak signal; try repositioning the antenna. If
this has no effect, check the modem.
Create and download a project to your PLC that includes an SMS Configuration, set Message
Properties, and define conditions as described in the topic Using SMS Messaging.
Write an SMS message in your cell phone.
Send the message to the PLC's GSM modem
Note • You can only send messages that are already part of an SMS Configuration in the PLC.
• If the Limit to Authorized Phone Numbers option is selected in the SMS configuration, the cell phone
number must be in the list .
The fixed text in your cell phone is identical to the message in the PLC's SMS Configuration in
every detail: spaces, characters--and note that characters are case-sensitive.
You bracket variable values with number signs (#) as shown below. These signs '#' do not count
as spaces.
The variable field in the SMS message is big enough to hold the value.
The figure below shows the same SMS message: as it appears on a cell phone display, and as it appears in the
PLC's SMS Configuration.
VisiLogic Function Blocks
When you send this message from your cell phone, the value 110 will be written into the variable in the PLC.
Select 'Acknowledge' in Message Properties, the ACK box is checked as shown below.
Use your cell phone to send the message "Holding Temperature:#110#" to the PLC.
The PLC receives this SMS message; AutoAcknowledge causes the PLC to immediately return the message to
your cell phone, together with the current variable value.
You can now view this SMS message on your cell phone display, together with changes in the variable value.
Note that although the PLC can send SMS messages that include Numeric, Binary, and List variables, the PLC
can only receive Numeric variables.
VisiLogic Function Blocks
SMS Operands
Operands linked to SMS FBs should be assigned Power-up Values; bits should be reset, and registers initialized
to 0.
SMS: Configuration FB
Status Messages MI Updated at the end of all operations using the SMS: Configuration; Send, Scan, and
Initialized to 0 when SMS: Check GSM Signal FBs.
Configuration is activated. Indicates error status for Send, Scan, and Check GSM Signal FBs.
Current value always shows the most recent error status.
Value Message
0 No error
1 Message received from a phone number that is not in the phone book,
or the number is not in the correct format
4 (Scan only)The SMS message received does not exist in the SMS
configuration
SMS Scan FB
SMS: Send FB
Send: Fail Bitmap MI Provides a bitmap that indicates the index number of a phone number that cannot be
reached.
If, for example, bit #3 in the register is not 0, the 3rd number in the phone book could
not be reached.
The bits are initialized to 0 when the Send FB is activated. As calls are made, each
failure causes the relevant bit to turn ON.
Note that:
- Phone Indexes is based on the Phone Book in the linked SMS configuration. Index
numbers are 0 to 8, note that 0 is the index of the last number called..
- a value of -1 indicates that the Modem Busy MB of the SMS: Configuration was ON
when the Send attempt was made.
VisiLogic Function Blocks
When the Send process begins, for each and every message, both SB 184 and 185 are OFF. After the message is
sent, the relevant bit turns ON, indicating the success or failure of that message.
SI Description Value
185 GSM Signal Quality The value is written during COM Init of the GSM modem. The value
is updated whenever the user uses the GSM Signal Quality FB.
A value of -1(FFFF)signifies a modem error. This may be due to a
weak signal; try repositioning the antenna. If this has no effect, check
the modem.
SDW Description
MODBUS
MODBUS enables you to establish master-slave communications with any connected device that supports the
MODBUS protocol. Any controller in the network may function as either master or slave using any of the
controller's existing COM Ports.
Within a MODBUS network, you can use standard MODBUS commands to read and write bit and register data;
you can also read and write data to Vision controller Data Tables.
Synchronize the communication port settings of master and slave devices. This is done by
placing COM Port Init FBs, set with identical parameters, in the ladder application of both
master and slave.
Include at least 1 MODBUS Configuration FB in the ladder application of both master and slave.
The port you select must be the same port selected in the COM Port Init FB.
The condition that activates the Configuration must turn ON for a single program scan (positive
transition recommended).However, the MODBUS configuration must be scanned during every
program cycle--after the Configuration is activated. One way to ensure this is by placing the
configuration in the first subroutine of the main module.
Enable slave devices to be accessed by placing a Scan_EX FB in the slave's Ladder application.
The figure below shows the elements required to carry out a Read Coils Operation.
Note that the operand addresses in slave PLCs are indirect addresses (pointers).
VisiLogic Function Blocks
Note • The operand addresses in slave PLCs are indirect addresses (pointers).
FB Operations
Operations are grouped under MODBUS on the FB's menu.
VisiLogic Function Blocks
MODBUS: Configuration
MODBUS: Scan
MODBUS: Configuration
A MODBUS Configuration FB must be included in both master and slave Ladder applications as shown below.
Port Number Constant Click the drop-down arrows to view available ports; click the port you want to
use.
Network ID Constant This number identifies the device on the network. You can either assign an ID
via an MI, or directly via a constant number. The unit ID range is from 0-255.
Do not assign the same ID number to more than one device.
Time out Constant or MI This is the amount of time a master device will wait for an answer from a slave.
Time out units are defined in 10 msecs; a Time out value of 100 is equal to 1
second.
Retries Constant or MI This is the number of times a device will try to send a message.
Function in Progress MB This bit is ON when MODBUS is active. Use this as a condition bit for
MODBUS operations to avoid communication conflicts.
VisiLogic Function Blocks
Note • Indirectly addressed parameters in a MODBUS Configuration FB are only read when the
Configuration is called. Since a Configuration is generally called as a power-up task, if, for
example Retries has been indirectly addressed, and the linked MI is updated, the new value will
not be read into the Configuration. The value will only be updated until the Configuration is
called.
• While a master attempts to send a command, the Function In Progress bit is ON. The number of
attempts that the master will make is the number in Retries +1, where '1' is the initial access
attempt.
• When a master attempts to access a slave device, and the slave does not answer,- the Function In
Progress bit will turn ON. This bit will remain on according to the following:
(the number of retries + 1) x (Time Out), where '1' is the initial access attempt. Note that the
Time Out parameter is in units of 10 msec.
The Ladder application below enables the controller act as a MODBUS master and read coils in a slave PLC.
The Scan_EX operation in the final net enables the controller to also act as a slave.
VisiLogic Function Blocks
MODBUS Versions previous to V2.01 offered only the Scan FB. Scan is still supported for older, working
applications. When MODBUS operations accessed double registers (5100 addresses and higher), using odd
addresses, such as 5101, there were incompatibility issues.
When ScanEX receives an input parameter in the 32-bit range (for example, 5100{ML}), it automatically takes
double-register values.
If, for example, ScanEX receives a Read Register(6) request for 5100, it returns the values in 5100 and 5101. If,
however, ScanEX receives Read Register(6) request for 5101, it returns Status Message #2-- since 5101
provides the 'high' bytes of the 32-bit register, it is not a legal address.
Slave ID Constant or MI The ID of the slave device containing the coils to be read (data source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of coils to be read (data source).
VisiLogic Function Blocks
Master: Start of Vector MB This is the start of a vector of MBs that will contain the coils' status in
the master (data destination).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Use this command to read the status of a selected group of inputs in a slave device and write them into a vector.
The inputs's status is written into a vector of MBs in the master PLC.
Slave ID Constant or MI The ID of the slave device containing the inputs to be read (data
source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of inputs to be read (data source).
or DW Note • Check topic Slave Address Tables
Master: Start of Vector MB This is the start of a vector of MBs that will contain the inputs' status in
the master (data destination).
VisiLogic Function Blocks
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The ID of the device containing the registers to be read (data source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of registers to be read (data source).
or DW Note • Check topic Slave Address Tables
Master: Start of Vector MI This is the start of a vector of MIs that will contain the registers' values
in the master (data destination).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
VisiLogic Function Blocks
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The ID of the device containing the registers to be read (data source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of registers to be read (data source).
or DW Note • Check topic Slave Address Tables
Master: Start of Vector MI This is the start of a vector of MIs that will contain the registers' values
in the master (data destination).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
VisiLogic Function Blocks
Slave ID Constant or MI The ID of the device containing the registers to be read (data source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of registers to be read (data source).
or DW Note • Check topic Slave Address Tables
Master: Start of Vector MI This is the start of a vector of MIs that will contain the registers' values
in the master (data destination).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
VisiLogic Function Blocks
Slave ID Constant or MI The ID of the device containing the registers to be read (data source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of registers to be read (data source).
or DW Note • Check topic Slave Address Tables
Master: Start of Vector MI This is the start of a vector of MIs that will contain the registers' values
in the master (data destination).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The ID of the device containing the coil to be forced (data source).
Slave Address Constant, MI, ML, The address of the coil to be forced (data target).
or DW Note • Check topic Slave Address Tables
Value to Force M, SB, I, O,T This MB is located in the master PLC; this MB contains the status to be
forced ( data source). If, for example, the status of this MB is OFF, the
status of the coil in the slave will be forced to OFF.
Note • A MODBUS command cannot read/write more than 1900 bit
operands at one time. In addition, 0 is not a legal length.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The ID of the device containing the register to be preset (target).
Slave: Operand Address Constant, MI, ML, The address of the register to be preset (target).
or DW Note • Check topic Slave Address Tables
Value to Preset Constant, MI, SI, This is the address of the register containing the value in the master
ML, SL, DW, PLC (source). This value will be written into the slave's register, the
SDW or T register that is to be preset.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The ID of the slave device containing the coils to be forced (target).
Slave:Start of Vector Constant, MI, ML, The start of the vector of coils to be forced (data target).
or DW Note • Check topic Slave Address Tables
Master: Start of Vector MI, SB, I, O,T This is the start of a vector of MBs that will contain the coils' status in
the master (data source).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The ID of the device containing the registers to be preset (target).
Slave: Start of Vector Constant, MI, ML, The start of the vector of registers to be preset (target).
or DW Note • Check topic Slave Address Tables
Master: Start of Vector Constant, MI, SI, This is the start of a vector of MIs that will contain the registers' values
ML, SL, DW, in the master (data source).
SDW or T
Preset: Vector Length Constant, MI, ML, The length of the vector of registers in both master and slave.
or DW Note • A MODBUS command cannot read more than 124 16-bit
integers, 62 double registers, or 64 float registers at one time. In
addition, 0 is not a legal length.
• If, within the Slave: Start of Vector parameter, the selected
register type is a 32-bit double register (slave addresses 5100 and
greater)the preset vector length must be doubled as well.
If, for example:
- Slave: Start of Vector parameter is set to 6300, and
- You wish to preset 4 registers, for a total of 16 bytes
- You must set the Preset Vector length to 8.
Note that this means that, in these cases, the Preset: Vector Length
parameter will always be an even number.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The ID of the device containing the register to be preset (target).
Slave: Start of Vector Constant, MI, ML, The address of the register to be preset (target).
or DW Note • Check topic Slave Address Tables
Master: Start of Vector MI, SI, ML, SL, This is the address of the register containing the value in the master
DW, SDW or T PLC (source). This value will be written into the slave's register, the
register that is to be preset.
Preset: Vector Length Constant, MI, ML, The length of the vector of registers in both master and slave.
or DW Note • A MODBUS command cannot read more than 124 16-bit
integers, 62 double registers, or 64 float registers at one time. In
addition, 0 is not a legal length.
• If, within the Slave: Start of Vector parameter, the selected
register type is a 32-bit double register (slave addresses 5100 and
greater)the preset vector length must be doubled as well.
If, for example:
- Slave: Start of Vector parameter is set to 6300, and
- You wish to preset 4 registers, for a total of 16 bytes
- You must set the Preset Vector length to 8.
Note that this means that, in these cases, the Preset: Vector Length
parameter will always be an even number.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
To determine the byte number of a data table cell, hold the cursor over the data table cell. A Tooltip opens,
displaying the byte number.
Note • A MODBUS command cannot read/write more than 242 DT bytes at one time.
In addition, 0 is not a legal length.
Slave ID Constant or MI The ID of the slave device containing the coils to be read (data source).
Slave: DT Start of Vector Constant, MI, ML, The start of the vector of bytes to be read (data source).
VisiLogic Function Blocks
or DW
Slave: DT Offset in Vector Constant, MI, ML, Offset from the Slave: DT Start of Vector
or DW
Master: DT Start of Vector Constant, MI, ML, This is the start of a vector of bytes that will contain the data read from
or DW the slave.
Master: DT Offset in Vector Constant, MI, ML, Offset from the Master: DT Start of Vector
or DW
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The ID of the slave device to which the data will be written (data
VisiLogic Function Blocks
target).
Slave: DT Start of Vector Constant, MI, ML, The start of the vector of bytes to be written into (data target).
or DW
Slave: DT Offset in Vector Constant, MI, ML, Offset from the Slave: DT Start of Vector
or DW
Master: DT Start of Vector Constant, MI, ML, This is the start of a vector of bytes, in the master, that will contain the
or DW data to be written to the slave (data source)
Master: DT Offset in Vector Constant, MI, ML, Offset from the Master: DT Start of Vector
or DW
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Note that you must use a condition (RLO) to activate the MODBUS Configuration and SCAN _EX.
VisiLogic Function Blocks
Slave Addressing
Slave Address Tables
Coils
MODBUS Command Number
8000 MB 3000-4095
VisiLogic Function Blocks
Note • Note that in order to access MBs 3000-4095, you address as follows: to access MB 3012, request
slave address 8012.
4000 SI 16 bit
5100 ML 32 bit
6100 SL 32 bit
7700 MF 0 32 bit
Examples
The examples below show that:
MODBUS addressing systems start at 1.
Vision addressing start at 0.
Bit Operands
Read a 10-bit vector of inputs in a slave Vision controller, starting at Input 20, via Read Coils ( MODBUS
COMMAND #1)
VisiLogic Function Blocks
Write a 3-bit vector of outputs in a slave Vision controller, starting at Output 8, via Force Coils (MODBUS
COMMAND #15)
Registers
Read a 9-register long vector of 16-bit integers in a slave Vision controller, starting at MI 32, via Read Holding
Registers (MODBUS COMMAND #03)
Note • If, within the Slave: Start of Vector parameter, the selected register type is a 32-bit double register
(slave addresses 5100 and greater)the preset vector length must be doubled as well.
If, for example in the VisiLogic Preset Holding Registers FB:
Slave: Start of Vector parameter is set to 6300, and
You wish to preset 4 registers, for a total of 16 bytes
You must set the Preset Vector length to 8.
Note that this means that, in these cases, the Preset: Vector Length parameter will always be an
even number.
Read a 9-register long vector of 32 -bit integers in a slave Vision controller, starting at SL 32, via Preset
Holding Registers (MODBUS COMMAND #16)
Write a 6-register long vector of 16-bit integers in a slave Vision controller, starting at MI 32, via Preset
Holding Registers (MODBUS COMMAND #16)
VisiLogic Function Blocks
Note • When MODBUS (Serial) is configured to a port linked to a modem, the MODBUS function checks
SI 100 Maximum Time Delay between characters (units 2.5ms) MODBUS + Modem. If SI 100 =
1, a time interval of up to 2.5 msecs is permitted between characters, if SI 100 contains 2, the
permitted interval is 5 msecs ( n x 2.5 = interval. Note that the application must update SI 100
before the MODBUS configuration is activated.
VisiLogic Function Blocks
# Status Message
0 Status OK
4 Master--Time Out
The amount of time the master will attempt to establish a MODBUS session
5 No Communication
The MODBUS session cannot be established.
Note • Messages 4 & 5. TimeOut and Number of Retries are defined in the Configuration. A Retry is an attempt to
establish a MODBUS session.
If, for example, TimeOut is defined as 2 seconds, and number of Retries as 3:
- the controller will try to establish the session once, and will continue to try for 2 seconds.
- If the first attempt fails, the Status Message value will be 4, Master TimeOut.
-The controller will try twice more, for a total of 3 retries over 6 seconds.
- If all attempts fail, the Status Message value will be 5.
-If any attempt succeeds, the Status Message will be 0.
9 Slave ID =0
An attempt does to communicate with Slave ID 0.
* Messages 6, 7, and 11mean that the master has found incompatible elements in the data sent between master and slave.
Total Sessions DW
Acknowledgements DW
SI Description Value
100 Maximum Time When MODBUS (Serial) is configured to a port linked to a modem, the MODBUS
Delay between function checks SI 100. If SI 100 = 1, a time interval of up to 2.5 msecs is permitted
characters (units between characters, if SI 100 contains 2, the permitted interval is 5 msecs ( n x 2.5
2.5ms) MODBUS + =interval.
Modem Note that:
- The power-up value is 1,
- the application must update SI 100 before the MODBUS configuration is
activated.
VisiLogic Function Blocks
MODBUS IP
If your controller comprises an Ethernet card, you can use MODBUS IP commands with any connected device
that supports the MODBUS protocol.
Within a MODBUS network, you can use standard MODBUS commands to read and write bit and register data;
you can also read and write data to Vision controller Data Tables.
Any controller in the network may function as either master or slave via the controller's Ethernet port.
Ethernet uses star topology.
V2xx Vision OPLCs can be ordered with or without an Ethernet port. The Ethernet port enables you to
implement communications via TCP/IP, such as MODBUS over TCP. To check if your Vision controller was
supplied with an installed Ethernet port, first check the device’s model number. In addition, note that the
Ethernet port is an RJ-45-type port that is lined with metal.
Unitronics currently supports both TCP and UDP, as explained in the topic About Ethernet. This topic also
contains general information about Ethernet, IP addressing, sockets, and ports.
Using MODBUS
Before using a MODBUS IP operation in your application, you must:
Assign IP addresses to both master and slave devices. This is done by placing Ethernet Card Init
FBs in the ladder application of both master and slave.
Include at least 1 MODBUS Configuration FB in the ladder application of both master and slave.
The condition that activates the Configuration must turn ON for a single program scan (positive
transition recommended)
However, the MODBUS configuration must be scanned during every program cycle--after the
Configuration is activated. One way to ensure this is by placing the configuration in the first
subroutine of the main module.
Enable slave devices to be accessed by placing a Scan FB in the slave's Ladder application.
The figure below shows the elements required to carry out a Read Coils Operation.
VisiLogic Function Blocks
Note that the operand addresses in slave PLCs are indirect addresses (pointers).
VisiLogic Function Blocks
FB Operations
MODBUS IP Operations are located on the FBs menu.
MODBUS: Configuration
MODBUS: Scan
MODBUS: Configuration
A MODBUS Configuration FB must be included in both master and slave Ladder applications as shown below.
MODBUS IP Operations are located on the FBs menu.
Port Number Constant Click the drop-down arrows to view available ports; click the port you want to
use.
Network ID Constant This number identifies the device on the network. You can either assign an ID
via an MI, or directly via a constant number. The unit ID range is from 0-255.
Do not assign the same ID number to more than one device.
Time out Constant or MI This is the amount of time a master device will wait for an answer from a slave.
Time out units are defined in 10 msecs; a Time out value of 100 is equal to 1
second.
Retries Constant or MI This is the number of times a device will try to send a message.
Function in Progress MB This bit is ON when MODBUS is active. Use this as a condition bit for
MODBUS operations to avoid communication conflicts.
Note • Indirectly addressed parameters in a MODBUS Configuration FB are only read when the
Configuration is called. Since a Configuration is generally called as a power-up task, if, for
example Retries has been indirectly addressed, and the linked MI is updated, the new value will
not be read into the Configuration. The value will only be updated until the Configuration is
called.
VisiLogic Function Blocks
• While a master attempts to send a command, the Function In Progress bit is ON. The number of
attempts that the master will make is the number in Retries +1, where '1' is the initial access
attempt.
• When a master attempts to access a slave device, and the slave does not answer,- the Function In
Progress bit will turn ON. This bit will remain on according to the following:
(the number of retries + 1) x (Time Out), where '1' is the initial access attempt. Note that the
Time Out parameter is in units of 10 msec.
Vision Slaves
In order to access Vision Controllers as slave devices and implement MODBUS commands, you must enter the
IP addresses of the slave devices in the MODBUS IP configuration. This means that you must first assign IP
addresses to each slave. This is done via the Ethernet Card Init FB, which must be configured as described in the
topic Using_Ethernet.
Note • Slave IP addresses can also be linked to an MI vector, note that the vector is 4 MIs long. The low
byte of each MI provides the number for an octet within the IP address.
If, for example, the IP address is linked to MI 0, and the low bytes of MI 0 to MI 3 contain the
values 192, 198, 192, 45, the IP address will be 192.198.192. 45.
The Ladder application below enables the controller act as a MODBUS master and read coils in a slave PLC.
The same PLC can also act as a slave, if a Scan_EX operation is included in the application.
VisiLogic Function Blocks
MODBUS Versions previous to V2.01 offered only the Scan FB. Scan is still supported for older, working
applications. When MODBUS operations accessed double registers (5100 addresses and higher), using odd
addresses, such as 5101, there were incompatibility issues.
When ScanEX receives an input parameter in the 32-bit range (for example, 5100{ML}), it automatically takes
double-register values.
If, for example, ScanEX receives a Read Register(6) request for 5100, it returns the values in 5100 and 5101. If,
however, ScanEX receives Read Register(6) request for 5101, it returns Status Message #2-- since 5101
provides the 'high' bytes of the 32-bit register, it is not a legal address.
VisiLogic Function Blocks
Slave ID Constant or MI The IP address of the slave device containing the coils to be read (data
source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of coils to be read (data source).
or DW Note • Check topic Slave Address Tables.
Master: Start of Vector MB Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The IP address of the slave device containing the inputs to be read (data
source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of inputs to be read (data source).
or DW Note • Check topic Slave Address Tables.
Master: Start of Vector MB This is the start of a vector of MBs that will contain the inputs' status in
the master (data destination).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The IP address of the device containing the registers to be read (data
source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of registers to be read (data source).
or DW Note • Check topic Slave Address Tables.
Master: Start of Vector MI This is the start of a vector of MIs that will contain the registers' values
in the master (data destination).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The IP address of the device containing the registers to be read (data
source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of registers to be read (data source).
or DW Note • Check topic Slave Address Tables.
Master: Start of Vector MI This is the start of a vector of MIs that will contain the registers' values
in the master (data destination).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The IP address of the device containing the registers to be read (data
source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of registers to be read (data source).
or DW Note • Check topic Slave Address Tables.
Master: Start of Vector MI This is the start of a vector of MIs that will contain the registers' values
in the master (data destination).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The IP address of the device containing the registers to be read (data
source).
Slave: Start of Vector Constant, MI, ML, The start of the vector of registers to be read (data source).
or DW Note • Check topic Slave Address Tables.
• If, within the Slave: Start of Vector parameter, the selected
register type is a 32-bit double register (slave addresses 5100 and
greater)the preset vector length must be doubled as well.
If, for example:
- Slave: Start of Vector parameter is set to 6300, and
- You wish to preset 4 registers, for a total of 16 bytes
- You must set the Preset Vector length to 8.
Note that this means that, in these cases, the Preset: Vector Length
parameter will always be an even number.
Master: Start of Vector MI This is the start of a vector of MIs that will contain the registers' values
in the master (data destination).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The IP address of the device containing the coil to be forced (data
source).
Slave Address Constant, MI, ML, The address of the coil to be forced (data target).
or DW Note • Check topic Slave Address Tables.
Value to Force M, SB, I, O,T This MB is located in the master PLC; this MB contains the status to be
forced (data source). If, for example, the status of this MB is OFF, the
status of the coil in the slave will be forced to OFF.
Note • A MODBUS command cannot read/write more than 1900 bit
operands at one time. In addition, 0 is not a legal length.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The IP address of the device containing the register to be preset
(target).
Slave: Operand Address Constant, MI, ML, The address of the register to be preset (target).
or DW Note • Check topic Slave Address Tables
Value to Preset Constant, MI, SI, This is the address of the register containing the value in the master
ML, SL, DW, PLC (source). This value will be written into the slave's register, the
SDW or T register that is to be preset.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The IP address of the slave device containing the coils to be forced
(target).
Slave:Start of Vector Constant, MI, ML, The start of the vector of coils to be forced (data target).
or DW Note • Check topic Slave Address Tables.
Master: Start of Vector MI, SB, I, O,T This is the start of a vector of MBs that will contain the coils' status in
the master (data source).
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The IP address of the device containing the registers to be preset
(target).
Slave: Start of Vector Constant, MI, ML, The start of the vector of registers to be preset (target).
or DW Note • Check topic Slave Address Tables.
VisiLogic Function Blocks
Master: Start of Vector Constant, MI, SI, This is the start of a vector of MIs that will contain the registers' values
ML, SL, DW, in the master (data source).
SDW or T
Preset: Vector Length Constant, MI, ML, The length of the vector of registers in both master and slave.
or DW Note • A MODBUS command cannot read more than 124 16-bit
integers, 62 double registers, or 64 float registers at one time. In
addition, 0 is not a legal length.
• If, within the Slave: Start of Vector parameter, the selected
register type is a 32-bit double register (slave addresses 5100 and
greater)the preset vector length must be doubled as well.
If, for example:
- Slave: Start of Vector parameter is set to 6300, and
- You wish to preset 4 registers, for a total of 16 bytes
- You must set the Preset Vector length to 8.
Note that this means that, in these cases, the Preset: Vector Length
parameter will always be an even number.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The IP address of the device containing the register to be preset (target).
Slave: Start of Vector Constant, MI, ML, The address of the register to be preset (target).
or DW Note • Check topic Slave Address Tables.
VisiLogic Function Blocks
Master: Start of Vector MI, SI, ML, SL, This is the address of the register containing the value in the master
DW, SDW or T PLC (source). This value will be written into the slave's register, the
register that is to be preset.
Preset: Vector Length Constant, MI, ML, The length of the vector of registers in both master and slave.
or DW Note • A MODBUS command cannot read more than 124 16-bit
integers, 62 double registers, or 64 float registers at one time. In
addition, 0 is not a legal length.
• If, within the Slave: Start of Vector parameter, the selected
register type is a 32-bit double register (slave addresses 5100 and
greater)the preset vector length must be doubled as well.
If, for example:
- Slave: Start of Vector parameter is set to 6300, and
- You wish to preset 4 registers, for a total of 16 bytes
- You must set the Preset Vector length to 8.
Note that this means that, in these cases, the Preset: Vector Length
parameter will always be an even number.
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Operands.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
To determine the byte number of a data table cell, hold the cursor over the data table cell. A Tooltip opens,
displaying the byte number.
Note • A MODBUS command cannot read/write more than 242 DT bytes at one time.
In addition, 0 is not a legal length.
Slave ID Constant or MI The ID of the slave device containing the coils to be read (data source).
Slave: DT Start of Vector Constant, MI, ML, The start of the vector of bytes to be read (data source).
or DW
Slave: DT Offset in Vector Constant, MI, ML, Offset from the Slave: DT Start of Vector
or DW
Master: DT Start of Vector Constant, MI, ML, This is the start of a vector of bytes that will contain the data read from
or DW the slave.
Master: DT Offset in Vector Constant, MI, ML, Offset from the Master: DT Start of Vector
or DW
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
by storing 0 into the selected DW.
Slave ID Constant or MI The ID of the slave device to which the data will be written (data
target).
Slave: DT Start of Vector Constant, MI, ML, The start of the vector of bytes to be written into (data target).
or DW
Slave: DT Offset in Vector Constant, MI, ML, Offset from the Slave: DT Start of Vector
or DW
Master: DT Start of Vector Constant, MI, ML, This is the start of a vector of bytes, in the master, that will contain the
or DW data to be written to the slave (data source)
Master: DT Offset in Vector Constant, MI, ML, Offset from the Master: DT Start of Vector
or DW
Status Messages MI Shows a message number. To check status and diagnose errors, check
the MODBUS Status Messages.
Total Sessions DW This is the number of times the master PLC will attempt to access the
slave device. Note that this is a simple incremental counter. Initialize it
VisiLogic Function Blocks
Note that you must use a condition (RLO) to activate the MODBUS Configuration.
The slave PLC Ladder application must include the elements shown below.
Step 2: Scan
To enable the master PLC to access the slave, include a MODBUS Scan FB in the slave's application.
VisiLogic Function Blocks
Slave Addressing
Coils MODBUS Command Number
8000 MB 3000-4095
Note • Note that in order to access MBs 3000-4095, you address as follows: to access MB 3012, request
slave address 8012.
4000 SI 16 bit
5100 ML 32 bit
6100 SL 32 bit
7700 MF 0 32 bit
VisiLogic Function Blocks
Examples
The examples below show that:
MODBUS addressing systems start at 1.
Vision addressing start at 0.
Bit Operands
Read a 10-bit vector of inputs in a slave Vision controller, starting at Input 20, via Read Coils ( MODBUS
COMMAND #1)
Write a 3-bit vector of outputs in a slave Vision controller, starting at Output 8, via Force Coils (MODBUS
COMMAND #15)
Registers
Read a 9-register long vector of 16-bit integers in a slave Vision controller, starting at MI 32, via Read Holding
Registers (MODBUS COMMAND #03)
Note • If, within the Slave: Start of Vector parameter, the selected register type is a 32-bit double register
(slave addresses 5100 and greater)the preset vector length must be doubled as well.
If, for example in the VisiLogic Preset Holding Registers FB:
Slave: Start of Vector parameter is set to 6300, and
You wish to preset 4 registers, for a total of 16 bytes
You must set the Preset Vector length to 8.
Note that this means that, in these cases, the Preset: Vector Length parameter will always be an
even number.
Read a 9-register long vector of 32 -bit integers in a slave Vision controller, starting at SL 32, via Preset
Holding Registers (MODBUS COMMAND #16)
the Read: Vector Length parameter to 18 ( 2x9, in order to fit the 32-bit SL registers ). Within
the slave Vision controller, VisiLogic will read SL 32 - SL 41.
SCADA as the MODBUS master
In the SCADA application, set the Slave: Start of Vector parameter to 406133, and the Read:
Vector Length parameter to 18, enabling the Master device to read SL 32 - SL 41 within the
slave Vision controller.
Write a 6-register long vector of 16-bit integers in a slave Vision controller, starting at MI 32, via Preset
Holding Registers (MODBUS COMMAND #16)
# Status Message
0 Status OK
4 Master--Time Out
The amount of time the master will attempt to establish a MODBUS session
5 No Communication
The MODBUS session cannot be established.
Note • Messages 4 & 5. TimeOut and Number of Retries are defined in the Configuration. A Retry is an attempt to establish a
MODBUS session.
If, for example, TimeOut is defined as 2 seconds, and number of Retries as 3:
- the controller will try to establish the session once, and will continue to try for 2 seconds.
- If the first attempt fails, the Status Message value will be 4, Master TimeOut.
-The controller will try twice more, for a total of 3 retries over 6 seconds.
- If all attempts fail, the Status Message value will be 5.
-If any attempt succeeds, the Status Message will be 0.
9 Slave ID Mismatch
The Slave ID master sends a command to a slave unit whose IP, as defined in the Configuration, does not match the
slaves's index number.
* Messages 6, 7, and 11 mean that the master has found incompatible elements in the data sent between master and slave.
VisiLogic Function Blocks
Total Sessions DW This is the total number of times the master PLC attempts to access the slave
device, whether the attempt is successful or not, including Retries. Note that
this is a simple incremental counter.
This must be initialized by the user, by storing 0 into the selected DW.
Communication Protocol FB
Via the Communication Protocol operations, you can enable your controller to exchange data with external
devices, such as frequency converters, bar-code readers, and printers via a Vision COM port.
How the Protocol FB communicates data between Vision controllers and other devices
A device, such as a magnetic card reader, may use its own proprietary protocol. If you know the protocol's
structure, you can use the Protocol FB to structure messages accordingly. This enables a Vision controller to
exchange data with the device using the device's own protocol.
Note that before you can use Protocol operations, you must configure the COM port to be connected to the
external device in accordance with the device's requirements. This is done by placing a COM Port Init FB in
your Ladder application.
Basic Example
The example below shows how a Vision controller can, via COM port 2, read Register 25 within a device that
has the ID number of 01. The device uses the simple protocol shown below.
Device Protocol
STX 1 STX 02(hex) All messages must begin with the STX character
Unit ID 2 ID# range = 0-99 All messages must contain the ID number of the device
that the controller is communicating with
Checksum 2 Sum 8
Checksum
VisiLogic Function Blocks
A COM Init FB to initialize the serial port that will be linked to the device.
A Protocol Configuration FB set to use the serial port.
A Protocol Send FB, which enables the controller to send data request messages to the device.
A Protocol Scan FB, which enables the controller to receive data response messages from the
device. Note that in order to receive new messages, you mustclear the communication buffer
after each message by using the Reset Buffer FB.
COM Init and Configuration
Since COM Port 2 is connected to the device, the application initializes and configures COM 2 at Power-up.
Note • In order to receive new messages, you must clear the communication buffer by using the Reset
Buffer operation. You can save the contents of the buffer at any time by using the Copy Buffer
operation.
• Maximum message length is 500 characters; a message may include up to 50 variables. Note that
with in the body of a message, no section--whether text or variable--may exceed 255 characters.
Below, the application enables the Vision to receive a response to Command 03. Note that Buffer reset follows
the Scan.
VisiLogic Function Blocks
Note that the Scan message contains a Data Response field that is long enough to contain the contents of a
register.
For more information regarding Protocol operations, refer to the topics below.
FB Operations
Configuration
Scan
Send
Reset Buffer
Note • Reset Buffer must be used in the Ladder application to enable new messages to be received.
VisiLogic Function Blocks
Protocol: Configuration
You create messages and attach variable data in Protocol Send and Scan operations. Each operation is linked to
a Protocol Configuration. When a Send operation is called in your program, the Configuration determines which
COM port is used for outgoing messages; when a Scan operation is activated, the PLC monitors that COM port
for incoming messages.
Note • The Configuration should be placed in the Main Routine, before any other FB operations. If the
configuration is not active, Protocol operations will not be processed.
• Before you place this FB in your Ladder, you must use a COM Port INIT FB to configure a COM
port.
Parameter Function
Name Identifies the configuration. You use the name to link Protocol Send and Scan
operations to a configuration.
COM Port Determines which port is used for communicating the configured protocol.
Function MB Link an MB; this MB will be ON when the Configuration is processing Scan or Send
in Progress operations.
Status MI If errors occur when the Configuration is used for a Send or Scan operation, the value
of the linked MI indicates which error has occurred.
VisiLogic Function Blocks
Protocol: Scan
A Protocol Scan operation contains messages. Activating the Scan causes the PLC to check if it has received
any of the messages contained within the Scan. The PLC can only receive messages that are contained in a Scan
FB.
Note • In order to receive new messages, you must clear the communication buffer by using the Reset
Buffer operation. You can save the contents of the buffer at any time by using the Copy Buffer
operation.
• Maximum message length is 500 characters; a message may include up to 50 variables. Note that
with in the body of a message, no section--whether text or variable--may exceed 255 characters.
Parameter Function
Number of Bytes MI This holds the number of bytes currently in the buffer. It is initialized by the system
Received when a different message is received.
Index of Received MI This holds the index number of the received message. It changes when another
Message message enters the system.
The value in the linked MI is valid only when the Session Complete bit in ON.
During this time, the linked MI contains the index number of the last valid incoming
message.
Once a valid message has been received, the first incoming character of any message
causes -1 to be written in the linked MI.
Start of Text Check Start Of Text to use an STX parameter to indicate the beginning of a message.
(STX) Length:
Enter the number of bytes required by the external device's protocol to mark STX.
STX Character: Click a 'byte' box and select an ASCII character.
Terminators Select one of the terminator parameters to indicate where the message ends.
End of Text The ETX parameter indicates where the message ends.
(ETX) Length:
Enter the number of bytes required by the external device's protocol to mark ETX.
ETX: Click a 'byte' box and Select an ASCII character.
Message
- If your protocol requires a checksum as part of the End of Message,click the End of Message button to define
checksum placement and format.
- Use the options to configure the checksum according to the requirements of your particular protocol.
Message Selecting this causes the function to use the length of a data block alone to determine its end.
Length
Silence: This defines the length of a silent period that signals the end of a message.
Duration Note that the duration of a silent 'counter' unit is approximately 1mS.
(mS)
Note • Scan Length can be defined for each message via the drop-down box that follows Message index #.
Scan Length causes the Scan FB to use the length of a message--including header and terminator--to
define whether an incoming message is legal.
This parameter overrides Start Of Text and Terminator settings.
If you use Scan Length, arrange the messages in ascending order, for example, message #0 may
contain 3 bytes, #1 may contain 4 bytes, #2 may contain 6 bytes, etc.
Protocol Messages
Messages can include:
Fixed Text
This text does not change.
Variables
These variables may be received by the PLC: Numeric, Stream, and Checksum.
VisiLogic Function Blocks
Control Characters
These can be added according to protocol requirements.
Example
Note that the Scan message contains a Data Response field that is long enough to contain the contents of a
register.
VisiLogic Function Blocks
Note that if a Scan operation contains more than one message with identical variables that use the same format,
the PLC will overwrite the variable values as they are received.
To enable the PLC to differentiate between the messages and their attached variables, include fixed text and/or
control characters within the message.
VisiLogic Function Blocks
Protocol: Send
Each Protocol Send operation is linked to a particular Configuration; outgoing messages are sent via the COM
port selected in that Configuration. Send is located on the FBs menu.
Start of Text Check Start Of Text to use an STX parameter to indicate the beginning of a message.
(STX) Length:
Enter the number of bytes required by the external device's protocol to mark STX.
STX Character: Click a 'byte' box and select an ASCII character.
End of Text The ETX parameter indicates where the message ends.
(ETX) Length:
Enter the number of bytes required by the external device's protocol to mark ETX.
ETX: Click a 'byte' box and Select an ASCII character.
VisiLogic Function Blocks
Advanced Button
VisiLogic Function Blocks
Protocol Messages
Messages can include:
Fixed Text
Fixed text must be included if there is more than one message in a Scan. This enables the PLC to identify the
message.
Control Characters
These can be added according to protocol requirements.
Variables
These variables may be sent by the PLC: Binary, Numeric, Stream, List of Texts, Checksum, Date, and Time.
Example
Below, the Vision sends a data request to Unit 01. The request is Command 03, Read Register, and the register
is Register 25.
VisiLogic Function Blocks
This operation copies whatever information is in the buffer at the time the operation is called.
• Maximum message length is 500 characters; a message may include up to 50 variables. Note that
with in the body of a message, no section--whether text or variable--may exceed 255 characters.
Copy Format
1->1
Select this to copy the low byte (first 8 bits) of each received register value currently in the buffer to a vector
defined in the PLC.
VisiLogic Function Blocks
2->1
Select this to copy both low and high bytes of each received register value currently in the buffer to a vector
defined in the PLC. Note that this is an entire 16-bit register, and the first 2 bytes of a 32-bit register.
4->1
Select this to copy all 4 bytes of each 32-bit register currently in the buffer into a defined vector.
VisiLogic Function Blocks
Note • Note that the Session Complete bit turns OFF automatically when the Reset Buffer operation runs.
• Maximum message length is 500 characters; a message may include up to 50 variables. Note that
with in the body of a message, no section--whether text or variable--may exceed 255 characters.
VisiLogic Function Blocks
Variables
Variables enable you to send and receive a variety of dynamic data from your process.
The PLC sends messages via the Configuration linked to the Send operation. These are the types of variables
that can be attached to an outgoing message.
Binary text
Use this type of variable to send text based on the status of a linked bit.
Numeric
Use a Numeric variable to send a vector of registers. You can send register values as Binary, Hex as ASCII, or
Decimal ASCII. The variable field automatically adjusts to fit the size of the data to be sent.
VisiLogic Function Blocks
Stream
Use Stream to send a vector of registers to a target device.
Format
The format determines which bytes are sent from within a register.
1->1
Select this to send the low byte (first 8 bits) of each register in the vector.
VisiLogic Function Blocks
2->1
Select this to send both low and high bytes from each register in the vector. Note that this is an entire 16-bit
register, and the first 2 bytes of a 32-bit register.
4->1
Select this to send all 4 bytes of each 32-bit register in a vector.
VisiLogic Function Blocks
List of texts
This type of variable contains a list of numbered lines of text. The value within the linked operand 'points' to the
number of a line within the list. When the operand value is equal to a particular line number, the text of that line
is included in the variable.
Selecting the Define Length option enables you to make all of the text lines a uniform length, regardless of the
number of characters a specific line may have. If a text line is shorter than the defined length, empty spaces will
be added; if the text line is longer than the defined length, excess characters will be cut off.
Checksum
Via this variable, you can calculate a checksum and attach it to a message. Use the options to configure the
checksum according to the requirements of your particular protocol.
Date
Use this variable to send the current date according to a selected format.
Time
Use this variable to send the current time according to a selected format.
VisiLogic Function Blocks
To correctly identify incoming variables, use either Scan Length, or include fixed text.
Note • Scan Length can be defined for each message via the drop-down box that follows Message index #.
Scan length causes the Scan FB to use the length of a message to define whether an incoming
message is legal.
This parameter overrides Start Of Text and Terminator settings.
If you use Scan Length, arrange the messages in ascending order, for example, message #0 may
contain 3 bytes, #1 may contain 4 bytes, #2 may contain 6 bytes, etc.
• If a Scan operation contains more than one message with identical variables that use the same
format, the PLC will overwrite the variable values as they are received.
To enable the PLC to differentiate between the messages and their attached variables, include fixed text and/or
control characters within the message.
Numeric Receive
Use a Numeric variable to receive a vector of registers. You can receive register values as Binary, Hex as
ASCII, or Decimal ASCII.
VisiLogic Function Blocks
Receive Stream
Use Stream to receive a vector of register values from an external device and copy them into a defined vector of
registers within the PLC.
Note • A vector is read either until the end of the defined vector length, or until a 'null' character is encountered.
By adding a null character to the end of the stream, you can mark the end of a data string. This can prevent other
data, that might be present in a vector, from being added to the data string when the vector is read.
Format
1->1
Select this to copy the low byte (first 8 bits) of each received register value to a vector defined in the PLC.
2->1
Select this to copy both low and high bytes of each received register value to a vector defined in the PLC. Note
that this is an entire 16-bit register, and the first 2 bytes of a 32-bit register.
4->1
Select this to copy all 4 bytes of each 32-bit register into a defined vector.
VisiLogic Function Blocks
Checksum
Via this variable, you can process the checksum of an incoming message. Use the options to configure the
checksum according to the requirements of your particular protocol.
ASCII table
VisiLogic Function Blocks
Checksum Configuration
Use the options to configure the checksum according to the requirements of your particular protocol.
Format Select the data representation method: Decimal ASCII, Hex as ASCII, or Binary.
Calculate The two Offset parameters determine the delimiters of the data to be calculated for checksum.
Offset
Calculation This is the type of calculation that will be performed on the data defined above.
Type SUM
Adds all of the data bytes in the selected cells into one sum.
XOR
Calculate checksum using exclusive-OR operation.
VisiLogic Function Blocks
CRC-16
Calculates checksum according to CRC-16.
VisiLogic Function Blocks
2's complement
This is calculated as follows:
Checksum = 0
For Stardoms to Endorses do
Checksum = Checksum + Netherworlds
End For
Checksum = (Checksum XOR 0xFFFFFFFF) + 1
Checksum This determines the length of the field which will hold the calculated checksum result.
Length Example
If the result is 7563 and the 16-bit modulus method is selected, the results stored in checksum fields of different
lengths as follows:
(7563 =1D8B)
VisiLogic Function Blocks
Advanced: From Value and To Value determine a range for the checksum result ;if the final value falls within these limits, the function can
Set Limits automatically add a set value to the calculated checksum.
VisiLogic Function Blocks
2 Send: COM Port busy The COM port that is selected in the active Protocol Configuration
cannot currently be accessed.
3 Send: Invalid Message Index The message that is referenced in the Send operation does not exist.
4 Send: Invalid Operand Type The message references an operand type that does not exist in the
system.
5 Send: Invalid Operand Address The message references an operand address that does not exist in the
system.
7 Send: Format Error The message contains variable fields that are not long enough for the
attached variable data.
258 Receive: Invalid message The received message does not exist in the system.
259 Receive: Checksum Error The message may have been corrupted during transmission.
Examples
Basic Example
How does the Protocol FB communicate data between Vision controllers and other
devices?
A device, such as a magnetic card reader, may use its own, proprietary protocol. If you know the protocol's
structure, you can use the Protocol FB to structure messages accordingly. This enables a Vision controller to
exchange data with the device using the device's own protocol.
The example below shows how a Vision controller can, via COM port 2, read Register 25 within a device that
has the ID number of 01. The device uses the simple protocol shown below.
Device Protocol
Parameter name Length (bytes) Value Comments
STX 1 STX 02(hex) All messages must begin with the STX character
Unit ID 2 ID# range= 0-99 All messages must contain the ID number of the device
that the controller is communicating with
Checksum 2 Sum 8
Checksum
A COM Init FB to initialize the serial port that will be linked to the device.
A Protocol Configuration FB set to use the serial port.
A Protocol Send FB, which enables the controller to send data request messages to the device.
A Protocol Scan FB, which enables the controller to receive data response messages from the
device. Note that in order to receive new messages, you mustclear the communication buffer
after each message by using the Reset Buffer FB.
COM Init and Configuration
Since COM Port 2 is connected to the device, the application initializes and configures COM 2 at Power-up.
VisiLogic Function Blocks
Note • In order to receive new messages, you must clear the communication buffer by using the Reset Buffer
operation. You can save the contents of the buffer at ay time by using the Copy Buffer operation.
Below, the application enables the Vision to receive a response to Command 03. Note that Buffer reset follows
the Scan.
VisiLogic Function Blocks
Note that the Scan message contains a Data Response field that is long enough to contain the contents of a
register.
Data exchange is performed using the Mitsubishi communication protocol, via VisiLogic's communication
Protocol FB. By modifying the FB's parameters, you can exchange data between Vision controllers and external
devices using many different protocols.
http://www.meau.com/eprise/main/Web_Site_Pages/Public/Documents_Downloads/P-DD-Technical-Manuals,
entering SH(NA)3197-B under Title, and then pressing Search. Note that this manual is in .pdf format and
requires you to have Adobe's Acrobat Reader installed on your system.
VisiLogic Function Blocks
The manual includes complete protocol requirements. The elements used in the sample application to implement
the Mitsubishi protocol are presented below.
Read Commands
Write
Station ID #
Each converter is assigned a station number. Station numbers are transmitted in hexadecimal.
The FB shown below is located in Net 8 within subroutine: Send command to Mitsubishi. Note how the
messages in the Protocol Send FB are configured to conform to the Mitsubishi message structure.
VisiLogic Function Blocks
Scan
The FB shown below is located in Net 3 within subroutine: Check answer after sending. Note how the messages
in the Protocol Send FB are created to conform to the Mitsubishi message structure.
Error codes
The Mitsubishi protocol uses an error code to determine if data is transmitted correctly.
When a converter receives a message, it replies by sending a message to the controller, according to the table
below.
VisiLogic Function Blocks
VisiLogic Function Blocks
MB as PWM
The PWM FB enables you to control the change in the status of a selected MB, causing it to function like a
PWM (Pulse Width Modulation) output at a resolution of 2.5 milliseconds (in relation to the total scan time).
You can place the PWM FB directly on the left Ladder rail to cause it to run continuously. PWM is located on
the FBs menu.
Parameter Function
Cycle Time The total cycle time. One unit of cycle time is equal to 2.5 msec.
Duty Cycle The ratio of the "on" period of a cycle to the total cycle period, expressed as a tenth of a percent of the
total Cycle Time.
Output The MB you select will function as the PWM output. It will be turned ON and OFF according to the
input parameters.
Example
If the Cycle Time parameter is 800; the total PWM cycle time will be 2000mSec (800 x 2.5 = 2000mSec).
If the Duty Cycle parameter is 255; the selected MB will be ON for 25.5% of the total Cycle Time (25.5% of
2000 = 510mSec), and OFF for 74.5% of the total Cycle Time (74.5 of 2000= 1490mSec)
VisiLogic Function Blocks
Filter FB
Filter, located on the FB menu, enables you to take from 4 to 16 values and calculate an average. You can
influence the average by configuring the function to:
Note • The values are not allocated memory, but are stored and calculated independently within the
function block.
• Certain analog inputs can also be filtered via Hardware Configuration settings.
How Filter works
The Filter Configuration holds the parameters that determine how the input values are averaged. The input value
is taken from the linked Filter Calculate function.
In the figure below, Filter Calculate is linked to the configuration Filter_1. In this configuration, Parameter 1:
Filter type is Dynamic Average; Parameter 2: Number of Values is 8; and Parameter 3: Discard Values is 2.
ML 0 provides the input values. Each time Filter: Calculate is activated, the value in ML 0 is copied to the
vector of the linked Filter Configuration,. In this example, 8 values are collected. As each new value is input,
the oldest value is shifted out.
Since Discard Values is 2, the 2 lowest and 2 highest values are discarded. The remaining values are summed,
and then averaged (30+40+50+60=180/4). The result is 45, which is output to ML 1.
FB Operations
Filter: Configuration
Filter: Calculate
VisiLogic Function Blocks
Filter: Configuration
The Filter Configuration holds the parameters that determine how the input values are averaged, therefore it
must be activated before the Filter: Calculate function is called.
Filter Type: Dynamic Average Each input value is given equal weight.
Calculates the average of all
the current input values
Order-weighted More weight is given to the newer input values. (FIFO)
Average
Number of Values 4-16 Defines the values in the vector as well as the divisor for calculating
the average.
Discard Values 0-4 Removes the minimum and maximum input values according to the
selection. For example, selecting the number '3' cause the 3 lowest and
3 highest values to be discarded before the average is calculated.
Filter: Calculate
Each time the Calculate function's activating condition is turned ON, the function's Input parameter is copied to
the vector of the linked Filter Configuration, the average is calculated, and the result is placed in the linked
output operand.
Note • The output value is overwritten each time the function is activated.
• The vector is not allocated PLC memory. The values are stored in the function
VisiLogic Function Blocks
VisiLogic Function Blocks
Next Event
Previous Event
Clear Current
Clear All
Events: Count
Events: Loopback
Track Events
Examples
Sample applications may be found in the VisiLogic Examples folder. This folder contains field-tested VisiLogic
(.vlp) sample applications. You can open this folder via the Help Menu.
Events: Scan
Use the Events: Scan to define a vector of MBs and locate the first positive bit within that vector. Once you
have defined a vector of MBs using the Events Scan FB, you can perform other actions within that vector using
Event operations.
Note • Place the Scan FB directly on the left-hand Ladder rail; this ensures that all of the Events functions
will run continuously.
VisiLogic Function Blocks
Active MB MI, ML,DW Contains the location of the Active MB, relative to the beginning of the defined
Location: Offset in vector.
Vector Note • If no MB is active, the value in the linked register will be -1.
Next Event
Once a vector of MBs has been defined using the Event Scan FB, the Scan finds the first active MB in the
vector.
Use the Next Event operation to move to the next active MB in the vector, in the direction of the Most
Significant Bit.
VisiLogic Function Blocks
Previous Event
Once a vector of MBs has been defined using the Event Scan FB, the Scan finds the first active MB in the
vector.
Use the Previous Event operation to move to the previously active MB in the vector, in the direction of the Least
Significant Bit.
VisiLogic Function Blocks
Clear Current
Use the Clear Current operation to reset a currently active MB.
VisiLogic Function Blocks
Clear All
This operation causes all of the active MBs in an Event vector to be reset.
Events: Count
This shows the number of MBs currently ON within the vector defined by the Events Scan.
VisiLogic Function Blocks
Events: Loopback
When Loopback is activated by power flow, the focus of the Events moves to the beginning of the vector.
Track Events
This FB enables you to keep track of Rise and Fall events as they happen.
Rise Events:
Each time an MB rises in the Events vector, the Rise Event MB in Track Events turns ON for a
single cycle, and the Rise Location MI contains the location of the active MB, relative to the
beginning of the Events vector. If two MBs rise during a single cycle, the Rise Event Location
MI will show the events in two consecutive cycles.
Fall Events:
Each time an MB falls in the Events vector, the Fall Event MB in Track Events turns ON for a
single cycle, and the Fall Location MI contains the location of the active MB, relative to the
beginning of the Events vector. If two MBs fall during a single cycle, the Rise Event Location
MI will show the events in two consecutive cycles.
Note that Track events can only monitor an vector that, as defined in the Events Configuration, does not exceed
255 MBs in length.
VisiLogic Function Blocks
To use BAS, you must initialize the PLC COM port to 9600, 8n1.
BAS Operations
Configuration
Scan
Open Session
Configuration
The BAS Configuration must be included in the application. In addition, Scan is required in order to enable the
PLC application to receive BAS messages; the Open Session operation must also be included in the application.
Configuration Parameters
Parameter Type Function
Port # Constant Enter the number of the PLC serial port that connects the PLC to the BAS
network.
Router ID Constant If the BAS card is accessed via a router, select the ID number.
Time Out MI or Constant Amount of time the PLC will wait for a reply, units of 10 mS.
Retries MI or Constant Number of times the PLC will attempt to send a message.
Function in Progress MB Turns ON when the PLC sends a BAS data request, remains ON either until the
Time Out is exceeded or until a message is received in answer to the data
request. Use this MB as a condition to send a message.
Retries Made MI or Constant Number of times the PLC has attempted to send a message.
VisiLogic Function Blocks
Value Message
9 Illegal Command
The command received does not match the command in the data
request message
11 (Receive) TimeOut
An answer was not received before the timeout set in the BAS
Configuration.
Open Session
In order to run BAS operations, you must include Open Session in the application; it may be activated as a
power-up task.
Scan
To enable the controller to receive messages, place an BAS Scan FB in your application and link it to a
Configuration. When activated, this causes the controller to scan the Com port for incoming BAS messages.
Before you can receive a BAS message, you must initialize a COM port.
Digital I/Os
VisiLogic Function Blocks
Card ID MI or Constant Enter the ID number of the card to be read from/written to.
Result MB Read: Writes the current status of the I/O to the selected MB.
Write: Writes the current status of the MB to the selected I/O.
Analog I/Os
Card ID MI or Constant Enter the ID number of the card to be read from/written to.
Result MF Read: Writes the current value of the I/O to the selected MF.
Write: Writes the current value of the MF to the selected I/O.
VisiLogic Function Blocks
Index
ASCII ...................................................................157 MODBUS ...............95, 105, 108, 112, 121, 131, 135
Auto tune ..................................................8, 9, 12, 13 network ...................95, 105, 108, 112, 121, 131, 135
axis ...................................................................37, 38 Operands................................................................ 85
barcode .................................................................140 Phone book ............................................................ 73
buffer ....................................................145, 154, 156 Phone numbers ...................................................... 73
building.................................................................189 PID..........................................8, 9, 12, 13, 14, 15, 16
communication ...... 95, 105, 112, 121, 131, 140, 144, print ..................................................................... 140
145, 150, 154, 156, 169
printer .................................................................. 140
configure...........................9, 144, 145, 150, 154, 156
protocol.................140, 144, 145, 150, 154, 156, 169
CSI........................................................................189
SB .......................................................................... 85
CV ................................................8, 9, 12, 13, 14, 15
scan ...................................................................... 145
Data Tables.................................23, 26, 30, 105, 131
send...................................................................... 150
Display .................................................23, 26, 28, 30
send, Advanced.................................................... 150
environment..........................................................189
SI 85
FB ....... 13, 14, 15, 140, 144, 145, 150, 154, 156, 169
SMS ..........................................70, 71, 77, 79, 83, 85
Function....................................................................6
Trend ..............................................21, 23, 26, 28, 30
graph...............................................21, 23, 26, 28, 30
Troubleshooting........................................77, 85, 169
GSM .................................................................83, 85