OMRON Function Block Introduction Guide R121 E1 01
OMRON Function Block Introduction Guide R121 E1 01
Please read the 'Notice' and the 'Precautions' in the User's Manual before using CX-Programmer. The Function Block Introduction Guide' describes the basic operation procedure to use Function Block of CX-Programmer. Refer to the Help or the User's Manual of the PDF file for detailed descriptions. * You need Acrobat Reader 4.0 or grater versions in your PC to display the PDF file.
Contents
Chapter 1 OMRON FB Library
1. What is a Function Block? 2. An Example of a Function Block 3. Overview of the OMRON FB Library 3-1. Benefits of the OMRON FB Library 3-2-1. Example of using the OMRON FB Library - 1 3-2-2. Example of using the OMRON FB Library - 2 3-3. Content of the OMRON FB Library 3-3-1. OMRON FB Part Files 3-3-2. Library reference 3-4. File Catalog and Where to Access the OMRON FB Library 3-4-1. Catalog of OMRON FB Library files 3-4-2. CX-Programmer installation CD 3-4-3. Accessing OMRON FB Library files from Web server 1-1 1-2 1-3 1-3 1-4 1-5 1-6 1-6 1-6 1-7 1-7 1-7 1-7
OMRON FB Library
1. 1. What What is is a a Function Function Block? Block?
Function Blocks are predefined programs (or functions) contained within a single program element that may be used in the ladder diagram. A contact element is required to start the function, but inputs and outputs are editable through parameters used in the ladder arrangement. The functions can be reused as the same element (same memory) or occur as a new element with its own memory assigned. Partial Ladder program for machine A Defining Inputs and Outputs Input Input
Output Output
Control Device 1
A1 B1 X1 An An Bn Bn
An
Bn
Xn Xn Xn TIM n #0100
TIM 1 #0100 T1 Y1 Z1 Tn
Yn Yn Yn Zn Zn Zn
Produce template
Partial Ladder program for machine A Function Block definition
Control Device 1
P_On
A1 B1
Device Control
Device Control
EN A B
ENO X Y Z
X1 Y1 Z1
ENO X Y Z
A B
P_On
A2 B2
Device Control
EN A B
ENO X Y Z
X2 Y2 Z2
Function Block definition ...This contains the defined logic (algorithm) and I/O interface. The memory addresses are not allocated in the Function Block Definition Function Block instance(invocation) ...This is the instruction that will call the function block instance when used by the ladder program, using the memory allocated to the instance.
OMRON FB Library
2. 2. An An Example Example of of a a Function Function Block Block
The following figures describe an example of a function block for a time limit circuit, to be used in the ladder. It is possible to edit the set point of the TIM instruction to reallocate the set time for turning off the output in the ladder rung. Using the function block as shown below, it is possible to make the time limit of the circuit arbitrary by only changing one specific parameter.
Ladder diagram
000.00 TIM0000 TIM 0000 #0020 001.00 001.00 000.00
By enabling the input parameter to be editable, it is possible to allow an arbitrary time limit circuit.
PULSE EN #0020 Time ENO 001.00
Timing chart
EN 000.00 001.00 2.0 sec T_FB TIM T_FB Time Q Q
OMRON FB Library
A fixed name can be named to the processes. It is not necessary to create the basic communications program.
OMRON FB Library
FB
Vision sensor
OMRON FB Library
FB
DeviceNet
Temperature controller
Generic slaves such as IO terminal PLC Inverter
Wireless
OMRON FB Library
3-3. Content of the OMRON FB Library
The OMRON FB Library consist of the following:
OMRON FB Library
3-4. File Catalog and Where to Access the OMRON FB Library 3-4-1. Catalog of OMRON FB Library files
Number of OMRON FB Part files (at the time of July 04) approx. 80
Type FA components
Target components Temperature controller, Smart sensor, ID sensor, Vision sensor, 2 dimensions bar code reader CPU unit, Memory card, Special CPU IO unit (Ethernet, Controller Link, DeviceNet unit, Temperature control unit) Position control unit Inverter Servo motor driver
PLC
approx. 95
approx. 30
The internet
Offline Operation
Explanation Explanation of of target target Program Program Opening Opening a a new new project project Import Import FB FB Library Library Creating Creating a a program program Program Program Check Check
Offline Operation
Explanation Explanation of of target target Program Program Opening Opening a a new new project project Import Import FB FB Library Library Creating Creating a a program program Program Program Check Check
Offline Operation
Explanation Explanation of of target target Program Program Opening Opening a a new new project project Import Import FB FB Library Library Creating Creating a a program program Program Program Check Check
2. 2. Opening Opening a a new new project project and and setting setting the the Device Device Type Type
Click the toolbar button [New] in CX-Programmer.
Click
!To use Function Blocks, select the following PLCs: CS1G-H, CS1H-H, CJ1G-H, CJ1H-H, CJ1M
Tool bar
Name
Contents / Function
Title Bar Menus Toolbars Section Project Workspace Project Tree Ladder Window Function Block Definition
Shows the file name of saved data created in CX-Programmer. Enables you to select menu items. Enables you to select functions by clicking icons. Select [View] -> [Toolbars], display toolbars. Dragging toolbars enables you to change the display positions. Enables you to divide a program into several blocks. Each can be created and displayed separately. Controls programs and data. Enables you to copy element data by executing Drag and Drop between different projects or from within a project. A screen for creating and editing a ladder program. Shows Function Block definition. By selecting the icons, you can copy or delete the selected Function Block definition. is shown if the file is a OMRON FB Part file. - In the case of a User-defined Function Block, is shown if Ladder, is shown if ST. Shows information such as a PLC name, online/offline state, location of the active cell.
Status Bar
Offline Operation
Explanation Explanation of of target target Program Program Opening Opening a a new new project project Import Import FB FB Library Library Creating Creating a a program program Program Program Check Check
4. 4. Import Import the the OMRON OMRON FB FB Part Part file file
Select Function Block definition icon from the project tree using the mouse cursor, right click. Select Insert Function Block, then select a Library file using mouse to navigate.
Click mouse right button -> Insert Function Block -> Library File
Double click mouse left button. -> [OmronLib] -> [Programmable Controller] -> [CPU] Select each of the above in series.
Select the necessary OMRON FB Part file in the Select Function Block Library dialog.
Offline Operation
Explanation Explanation of of target target Program Program Opening Opening a a new new project project Import Import FB FB Library Library Creating Creating a a program program Program Program Check Check
5. Program Creation
Confirm cursor position is at the upper left of Ladder Window to start programming.
Press the [C] key on the keyboard to open the [New Contact] dialog. Use the dropdownbox to select the P_On symbol.
P_On
ENT Deleting instructions z Move the cursor to the instruction and then press the DEL key or z Move the cursor to the right cell of the instruction and press the BS key. P_On is a system defined symbol. Its state is always ON. 0 of the upper digit of an address is omitted when shown. [.] (period) is displayed between a channel number and a relay number.
Offline Operation
Explanation Explanation of of target target Program Program Opening Opening a a new new project project Import Import FB FB Library Library Creating Creating a a program program Program Program Check Check
Press the [F] key on the keyboard to open the [New Function Block Invocation] dialog.
Applies Applies a a name name for for the the specific specific process process in in the the diagram. diagram.
ENT
or
ENT
ENT
Offline Operation
Explanation Explanation of of target target Program Program Opening Opening a a new new project project Import Import FB FB Library Library Creating Creating a a program program Program Program Check Check
Or
ENT
#10
Please add the following prefix for entering constants as parameters: # (Hexadecimal/BCD) Or & (Decimal)
ENT
1.00
ENT
[Generated Pulse]
ENT
Offline Operation
Explanation Explanation of of target target Program Program Opening Opening a a new new project project Import Import FB FB Library Library Creating Creating a a program program Program Program Check Check
Click
Errors Errorsand andaddresses addressesare are displayed displayedin inthe theOutput OutputWindow. Window.
Double-click Double-clickon ondisplayed displayederrors, errors, and LadderDiagram Diagram cursor cursor andthe theLadder will willmove moveto tothe thecorresponding corresponding error errorlocation, location,displaying displayingthe theerror error rung rungin inred. red.
Output Window automatically opens at program check. The cursor moves to an error location by pressing J or F4 key. z Output Window closes by pressing the ESC key.
z z
Online Operation Online Online to to transfer transfer Monitoring Monitoring Online Online Edit Edit
7. Going Online
CX-Programmer provides three methods of connecting, depending on usage.
Normal Normal online. online. Enables Enables you you to to go go online online with with a a PLC PLC of of the the device device type type and and method method specified specified when when opening opening a a project. project. Auto Auto online. online. Automatically Automaticallyrecognizes recognizes the the connected connected PLC PLC and and enables enables you you to to go go online online with with a a PLC PLC with with one one button. button. -> -> Uploads Uploads all all data, data, such such as as programs, programs, from from the the PLC. PLC. Online Online with with Simulator. Simulator. Enables Enables you you to to go go online online with with CX-Simulator CX-Simulator with with one one button button (CX-Simulator (CX-Simulator must must be be installed.) installed.)
Online/debug Online/debug functions functions when when working working online online with with CX-Simulator CX-Simulator are are explained explained in in this this guide guide (Install (Install CX-Simulator CX-Simulatorseparately). separately).
Click
Click [OK]
Click [OK]
The The CX-Simulator CX-Simulator Console Console box boxis is shown. shown. The The operating operating mode mode of of the the active active PLC PLCis is shown. shown.
The The background background color color of of the the Ladder LadderWindow Window changes changes to to gray. gray.
Scan Scan time time is is displayed displayed (except (except during during Program Program Mode). Mode).
Online Operation Online Online to to transfer transfer Monitoring Monitoring Online Online Edit Edit
8. Monitoring - 1
Change Change the the PLC PLC (Simulator) (Simulator) to to Monitor Monitormode. mode.
Click
Click [Yes].
If your program has a large volume of data, the scroll speed of the screen may become slow when monitoring. To resolve this, click the icon below to cancel monitoring, scroll to the address you want to monitor, then restart the monitor mode.
The The monitored monitored area area is is displayed displayed in in a a specified specified color. color.
The The current current values values of of parameters parameters are are shown. shown.
Online Operation Online Online to to transfer transfer Monitoring Monitoring Online Online Edit Edit
Click mouse right button and select the menu item [Set/Reset(S)] ->[Setting Value(V)] Or Double click mouse left button.
Change Change the the current current value value of of Input Input parameter. parameter. Click Click [Set] [Set] Please add the following prefix for entering constants as parameters: # (Hexadecimal/BCD) Or & (Decimal)
Or
ENT
Online Operation Online Online to to transfer transfer Monitoring Monitoring Online Online Edit Edit
Move the cursor to the rung requiring modification. You can also select multiple rungs by using the Drag & Drop facility with the mouse.
Move the cursor to a instruction you want to modify. Double click the left mouse button.
Double click
Edit the address to the required bit number (4.11 in the example)
End
ON OFF
OMRON OMRON cannot cannot guarantee guarantee the the operation operation of of a a customized customized OMRON OMRON FB FB parts. parts. Please Please be be sure sure to to check check the the process process of of your your FB FB part part sufficiently sufficiently before before customization customization and and confirm confirm the the operation operation of of each each FB FB parts parts thoroughly thoroughly after after that. that.
Caution Caution
Select the OMRON FB Part icon then right click the mouse. -> Copy
Select Function Block Definition icon and right click the mouse. -> Paste The OMRON FB Part file is pasted.
Select pasted Function Block icon and click mouse right button. -> Rename [MakeClockPulse_BCD_INV]
Note: Note: The The user user cant cant create create Function Function Block Block Definitions Definitions With With name name starting starting _ _ (underscore). (underscore). Please Please use use names names not not starting starting with with _. _.
ALT
ENT
Tick Tick the the check check box box using using the the left left mouse mouse click. click.
Opens Opens the the Function Function Block Ladder Block Ladder Editor. Editor.
Select the Function Block icon using the mouse cursor and double click the left mouse button.
The The original original OMRON OMRON FB FB Part Part file file is is also also able able to to display display its its ladder ladder program, program, but but cannot cannot be be edited. edited. Ladder Ladder Editor Editor Variable table
Select Output tab in Variable Table using the mouse cursor And click the left mouse button.
Select Select BOOL BOOL for for bit bit data. data.
ENO
ENT
INV_ENO
ENT
Execute Compile
F7
key
Result of Compilation
Del Double Double click click mouse mouse left left button button
key
Click mouse left button Function Function Block Block definition definition will will be be deleted. deleted.
Offline Operation
Explanation Explanation of of target target Program Program Create Create new new FB FB Definition Definition Entering Entering Symbols Symbols Creating Creating ST ST Program Program Creating Creating Ladder Ladder Program Program and and check check
The The data data type type should should be be set set to to REAL REAL to to store store the the data. data. REAL REAL type type allows allows values values with with 32 32 bits bits of of length, length, see see range range below:below:38 -38, -3.402823x10 -3.402823x1038 ~ ~ -1.175494x10 -1.175494x10-38,,, 0, 0, -38 38 +1.175494x10 +1.175494x10-38 ~ ~ +3.402823x10 +3.402823x1038
x x(REAL (REAL type), type), y y(REAL (REAL type), type), z z(REAL (REAL type) type) score Output score(REAL (REAL type) type) Output symbol symbol ST score := := ((x x+ +y y+ +z z)) // 3.0; 3.0; ST Program Program definition definition score
Input Input symbols symbols Substitute Substitute a a value value to to a a symbol symbol is is expressed expressed by by := := . .
Enter Enter ;; (semicolon) (semicolon) to to complete complete the the code. code.
Offline Operation
Explanation Explanation of of target target Program Program Create Create new new FB FB Definition Definition Entering Entering Symbols Symbols Creating Creating ST ST Program Program Creating Creating Ladder Ladder Program Program and and check check
Select the Function Block icon using a mouse cursor, and click the right mouse button. -> Insert Function Block(I) ->Structured Text(S)
Change Change the the Function Function Block Block definition definition name name
Select the Function Block definition icon using the mouse cursor and right click the mouse button. Select Paste. -> Rename Enter [AverageCalc_3value] Open Open Function Function Block Block ST ST Editor Editor Select Function Block definition Icon by mouse cursor and double click the left mouse button.
Note: Note: The The user user cant cant create create Function Function Block Block Definitions Definitions with with names names starting starting _ _ (underscore). (underscore). Please Please use use names names not not starting starting with with _. _.
Offline Operation
Explanation Explanation of of target target Program Program Create Create new new FB FB Definition Definition Entering Entering Symbols Symbols Creating Creating ST ST Program Program Creating Creating Ladder Ladder Program Program and and check check
Enter Enter input input symbol symbol x, x, output output symbols symbols y,z y,z by by repeating repeating the the process process above. above.
Reference: Reference: The The copy copy and and paste paste operation operation is is available available in in FB FB Header. Header. Reference: Reference: The The order order of of the the variables variables in in the the FB FB table table becomes becomes the the order order of of parameters parameters on on FB FB instance instance (invocation) (invocation) in in the the normal normal ladder ladder view. view. To To change change the the order, order, it it is is possible possible to to drag drag & & drop drop variables variables within within the the table. table.
Offline Operation
Explanation Explanation of of target target Program Program Create Create new new FB FB Definition Definition Entering Entering Symbols Symbols Creating Creating ST ST Program Program Creating Creating Ladder Ladder Program Program and and check check
5. Entry of ST program
Select the ST Editor text field in the Function Block ST Editor window.
Enter Enter text text into into the the field: field: score score := := (x (x + +y y+ + z) z) // 3.0;. 3.0;.
When the input expression is a real type calculation, please enter the constant value with decimal point and zero for single decimal places, e.g. 3.0.
Reference: Reference: User User may may type type Comments Comments in in the the ST ST program. program. Enter (* and *) both ends of comment Enter (* and *) both ends of comment strings, strings, see see below. below. This This is is useful useful for for recording recording change change history, history, process process expressions, expressions, etc. etc.
Offline Operation
Explanation Explanation of of target target Program Program Create Create new new FB FB Definition Definition Entering Entering Symbols Symbols Creating Creating ST ST Program Program Creating Creating Ladder Ladder Program Program and and check check
Refer Refer page page 2-7 2-7 for for entering entering FB FB instances. instances. Entering Entering ST ST FB FB instances instances is is the the same same as as entering entering FB FB Ladder Ladder instances. instances.
Refer Refer page page 2-9 2-9 for for program program checking. checking. The functionality is the The functionality is the same same as as for for Function Function Block Block Ladder Ladder instances. instances.
It is possible to change or add variables in the Function Block after inputting FB instance into the ladder editor. If modified, the Ladder editor changes the color of the left bus-bar of the rung containing the changed Function Block. When this occurs, please select the instance in the Ladder Editor using the mouse cursor, and select Update Function Block Instance (U) from the pop-up menu.
Online Operation
Transfer Transfer Program Program Monitoring Monitoring
7. Program Transfer
Go online to the PLC with CX-Simulator and transfer the program.
Change Change the the PLC PLC (Simulator) (Simulator) to to Monitor Monitor mode. mode. Click
Refer Refer to to page page 2-10 2-10 for for steps steps to to go go online online and and transfer transfer the the program. program. The on/off status of contacts and coils can be monitored.
Click [Yes]
Online Operation
Transfer Transfer Program Program Monitoring Monitoring
Alt
ENT
Click the button using the left mouse button, then select the following: [Symbols of type] [Name or address]
When monitoring internal variables at debug phase, always use the Watch Window. It is not possible to monitor inside a Function Block Definition.
FB Definition: OutputOfDecisionResult Input symbols: score(REAL type), setover(REAL type), setunder(REAL type) Output symbols: OK (BOOL type), overNG(BOOL type), underNG(BOOL type)
ST program: IF score > setover THEN underNG := FALSE; OK := FALSE; overNG := TRUE; (* If score > setover, *) (* Turn off underNG *) (* Turn off OK *) (* Turn on overNG *)
ELSIF score < setunder THEN (* if score =< setover and score < setunder then *) overNG := FALSE; (* Turn on overNG *) OK := FALSE; (* Turn off OK *) underNG := TRUE; (* Turn on underNG *) ELSE underNG := FALSE; overNG := FALSE; OK := TRUE; END_IF; (* if setover > score > setunder then*) (* Turn off underNG *) (* Turn off overNG *) (* Turn off OK *) (* end of IF section*)
Useful Functions
It is possible to automatically display a list of symbol names or IO comments when entering the operands of instructions. When entering the operand for contact or output (or special instructions), enter a string, and the dropdown list is automatically updated to display in symbol names or IO Comments using the defined string. Selecting the item from the list defines the operand information.. This is an efficient way of entering registered symbol information into the ladder. Example: Enter text Temperature to the edit field in the operand dialog.
Click or push [F4] key; all symbols / address having IO comment containing the text temperature are listed. See below:-
For instance, select temp_alarm01, W1.00, Temperature error of upper case of MachineA, from the list. The operand is set to be using symbol alarm01.