0% found this document useful (0 votes)
9 views

Module 3.4 Variables

Uploaded by

marcelodias99
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Module 3.4 Variables

Uploaded by

marcelodias99
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

Module 3.

Variables

Unity training course - V2.0 - Module 3.4 : Variables 1


Variables

 A Variable is a Memory entity of the type BOOL, WORD, DWORD,


etc., whose contents can be modified by the program during
execution.

 A Located Variable is a variable that is either mapped to an I/O


Module or is associated to a Memory reference.
For example, the variable Water_pressure is associated with
Memory Word %MW102. Water_pressure is said to be a Located
Variable.

 An Unlocated Variable is a variable which is not mapped to the I/O


or associated to a Memory reference (not possible to know its
position in memory). A variable which has no address assigned is
said to be unlocated.

Unity training course - V2.0 - Module 3.4 : Variables 3


Variables (cont)

 A Public Variable is a variable available with some Function Blocks.


These variables transfer values to the function block. They are used
for setting parameters of the function block.

 A Private Variable is a variable use by some Function Blocks.


These variables are not accessible by the application program.

 I/ODDT is the abbreviation of Input/Output Derived Data Type. The


term I/ODDT designates a structured data type representing a
channel of a PLC module. Each expert module possesses its own
I/ODDTs.

 Constants is an INT, DINT or REAL type variable located in the


constant field (%K), or variables used in direct addressing (%KW,
%KD, or %KF). The contents of these cannot be modified by the
program during execution.

Unity training course - V2.0 - Module 3.4 : Variables 4


Variables (cont)

 Each Variable has to be declared with the Variable Data Editor


before using it:

 Either independently by double clicking in the Variables & FB


Instances area of the Structural View tree...

 Or during programming with a double-click on an input / output


assignment.

 A data type must be assigned to each Variable.

 Unity Pro software provides elementary and derived data types.

Unity training course - V2.0 - Module 3.4 : Variables 5


Common Data Types and Ranges

 BOOL/EBOOL : Boolean variable must be FALSE (0) or TRUE (1).


EBOOL manage also forcing and edge detection

 WORD : Represents a “bit string 16”, meaning the length of data is


16 bits

 INT : Represents an integer value. The range of values are -32768


through 32767

 UINT : Represents an unsigned integer value. The range of values


are 0 through 65535

 REAL : Represents a floating point value. The range of values are -


3.40e+38 to 3.40e+38

Unity training course - V2.0 - Module 3.4 : Variables 6


Entering Literal Values

 Literal values are used to assign values to pins, or to assign constants


to variables, and are not meant to be changed by the program.

 You can enter literal values as


 Base 2 (binary) 2#1111111111111111
 base 8 (octal) 8#177777
 base 10 (decimal) 65535 (no 10# needed)
 base 16 ( hex) 16#FFFF

All of the above values are equal, they were just entered differently

Unity training course - V2.0 - Module 3.4 : Variables 7


Variable Names

 Max. length 32 characters, may start with number

Unlocated
 Tag names without a hardware address
 Unlocated variable cannot be set cyclically. If you need to set
variable cyclically in your project use located variables

Located
 Tag names with a hardware address (State RAM)

Constants
 Write protected variables
 Use to assign a fix value to a variable

Unity training course - V2.0 - Module 3.4 : Variables 8


Direct Addressing

 Every direct address has a reference that indicates its position in the
sequence and whether it is an input address (read only) or an output
address (read / write).
 0x / %Qx area = bit outputs (discrete) - example 1: 000001 is
discrete Output 1 - example 2: %Q00001 is Output Bit 1

 1x / %Ix area = bit inputs (discrete) - example 1: 100017 is


discrete Input 17 - example 2: %I00017 is Input Bit 17

 3x / %IWx area = register inputs, - example 1: 300300 is


register input 300
- example 2: %IW000300 is Input Word 300

 4x / %QWx area = register outputs, - example 1: 400029 is


register output 29 - example 2: %QW00029 is Output Word 29

Unity training course - V2.0 - Module 3.4 : Variables 9


Variables and FB Instances Directory

 To access the variables (elementary and derived)


and the function block instances

Unity training course - V2.0 - Module 3.4 : Variables 10


Editing Variables

 Types definition and instances declaration in ONE TOOL

Identifier

Unlocated
Double-click on variables
cells to enter in
edit mode
Data Type

Located
variable

Unity training course - V2.0 - Module 3.4 : Variables 11


Filtering

 Direct filtering on general type (EDT, ...) or variable names


 Funnel filter using variable properties (Type, Comment,
Address,...)

Unity training course - V2.0 - Module 3.4 : Variables 12


Configure the columns to display
 Configure the columns to display
 Column configuration (customization) displays the variable parameters as the
user wants.

1
Columns can be moved using the
2 . 1
buttons on the right

A check in front of the column


2 displays the column

Unity training course - V2.0 - Module 3.4 : Variables 13


Data Properties (cont)
 Even if the columns are not displayed, all the parameters
of a variable can be shown in the Data Properties window.

Unity training course - V2.0 - Module 3.4 : Variables 14


Edit Data Type

 The type of data can be selected from a list of previously used types 1
 or directly from the Variable type selection by clicking on […] button 2

1 2

Unity training course - V2.0 - Module 3.4 : Variables 15


IODDT

 To map a complete I/O structure from a module channel to one


variable name

Unity training course - V2.0 - Module 3.4 : Variables 16


Editing Derived Function Blocks (DFB)

 To define a user function block type

Unity training course - V2.0 - Module 3.4 : Variables 17


Editing Function Blocks (EFB, DFB)

 To use a function block instance

Unity training course - V2.0 - Module 3.4 : Variables 18


Derived Data Type

 To define an array or structure type

Unity training course - V2.0 - Module 3.4 : Variables 19


Variables Types (DDT)

 To use an array or structure instance

Unity training course - V2.0 - Module 3.4 : Variables 20


Export Functions

 Options allows you to export a whole


section with all used:

1 Derived Data Types (DDT)


2 Derived Function Block (DFB)
3 Sub routines

1 2

Unity training course - V2.0 - Module 3.4 : Variables 21


Export Functions (cont)

 Instances of DDT or DFB can be exported


with the associated types for a reusing in
the new program

1 Derived Data Types (DDT)


2 Derived Function Block
(DFB)

1 2

Unity training course - V2.0 - Module 3.4 : Variables 22


Import Functions

 Use the wizard to change the naming


of variables, section, ... or the mapping
addresses
 The import is provided for all or a
part of the application.

 Two import modes are provided with


Unity Pro :
 Direct import, import the module
just like it was exported.
 Import with the wizard (1), to
modify the naming of Variables,
Sections or Functional Module,
and changing the mapping
addresses.

Unity training course - V2.0 - Module 3.4 : Variables 23


Adding a variable on the Fly

 A variable can be created directly from any


editor :
 When an undeclared variable is entered.
A pop-up dialog is launched allowing the
creation of the variable

 The Data Properties window can be used to


display and modify object attributes inside the
editors
 The window is updated on the selection
of a different object

Unity training course - V2.0 - Module 3.4 : Variables 24


I/O Objects

 New service available in the hardware


configuration

 Select and display all the objects


managed by a module or CPU

 Create IODDT or topological EDT


variable(s) in one click

 Presymbolize a set of IODDT variables or


topological EDT variables

 Display the I/O objects used by the


application

Unity training course - V2.0 - Module 3.4 : Variables 25


I/O Objects Editing

1 Select the kind of object

2 Update the grid

3 Select some of them

4 Define a prefix

5 Create the variables

Unity training course - V2.0 - Module 3.4 : Variables 26


I/O Objects Ergonomics

 I/O objects mapped (located) to a variables or used in the program


are in bold
 It is Possible to focus on the variables used in the application: click
on Filter on usage button

Unity training course - V2.0 - Module 3.4 : Variables 27

You might also like