How To Create Function Blocks In OMRON CX-Programmer By Using Ladder Diagram
ladder diagram is graphical based programming in industrial controller such as plc. we use ladder diagram programming for making a function block. A user defined function block performs a specific task or set of tasks within a defined program. you can define your Function blocks by structured programming languages, ladder programming. in this article we discuss only how to create Function Blocks In OMRON CX-Programmer By using Ladder Digram. a function block have one or more input and output or both. these input and output can be variables, data structures, or even other function blocks. you can make a Function blocks to perform complex arithmetical operations, file input/output operations, communication control, reduced control block etc. another benefit of function block you can reuse your function block to another plc.
Create Your Omron Function Block Library
open your CX-Programmer and create a new project, enter device name, select device type and network type and press ok to continue
Select ladder programming languages for Function Block in Omron ?
now in project explorer right click on Function Block and than select insert Function block select ladder diagram.
cx programmer function block property
next set the function block property when you insert a new function block it is necessary to set some property like name of function block. when you insert a new function block a dialog will open on your screen or you can set property latter by right click on function block and then click to property. in function block general property tab enter the name of function block, author and revision of function block.
set protection of function block
when you make your function block add protection for unauthorized use. so in property of function block select protection tab and click on 'set' protection than select any one of the protection type and insert password and confirm password now your function block is protected.
set memory of function block
you can set memory of function block in memory tab of function property. you can assigned retain memory, non retain memory, timer and counter memory.
insert variables for function block
next part is to declare variables for your program these variables are as follows:
external variables: These are pre-defined variables or the variables that enable user-defined global symbols to be used.
Internals:These variables accessible only within the Function Block. Outside the function block you cannot access these variables.
input:These are variables that store data passed into the Function Block.
Outputs: these variables return the result or data.
IN OUT these variables stored data as well as return result.
define a program for function block
after all property setting now we make a program here i am making a simple push button program so i am using two input variables first is start_pb second is stop_pb and one output is motor_start. logic as shown below you can make your own logic here is only a simple logic only for demonstration. and then compile your program.
insert function block in rung
now your block is ready for use. For Inserting Function Block select a rung where you want to add your function block than use any of the of following ways
select insert option and than select Function Block Invocation.
use shortcut key 'F' for insert a function block.
from toolbar select new function block call.
set Instances for your function block
when you insert your function block a dialog will open called 'New Function Block Invocation' here you define Instances name for your function block or you can use Existing Instances. when you create new Instances, new Function Block Instance will be created in the Global Symbol Table and the memory required will automatically be allocated by the Function Block/SFC Memory Allocation mechanism. The data type of each Function Block Variable will be displayed below the name (inside the Function Block). The EN, ENO and Function Block Parameters can now be connected as appropriate.
Insert Function Block Parameters
paramaeter like input, output defined by Function Block Parameter shortcut key 'P'. and EN/ENO same as below image.
test and save function block
test your program by simulation after successfully simulation test right click on function block and save function block as file select location of function block and enter the name of function block. now you can use this function block to another program.
reuse function block program
in project explorer select function block and than right click on it and select inser function block than select from file browse file location and enter into the project now set instance name, set input output parameter than test and download to plc.