Você está na página 1de 100

EasyPLC v.

5 Help Manual

v.1.3

Table of Contents
INTRODUCTION 1. General Description
1.1 EasyPLC Programs Group 1.2 EasyPLC Installation & Minimum requirements 1.3 Demo vs. registered version 1. !o" to #egister EasyPLC

2. EasyPLC Editor
2.1 Program Inter$a%e 2.2 !ard"are Con$iguration 2.2.1 &irtual PLC CP' Parameters 2.2.2 I() Devi%es 2.2.2.1 *dd a +e" Driver 2.2.2.2 #emove a Driver. 2.2.2.3 *vaila,le Drivers 2.2.2. !o" to Develop an EasyPLC Driver. 2.3 -o$t"are -tru%ture 2.3.1 &aria,les 2.3.2 Program Modules 2.3.2.1 Init 2.3.2.2 Main. 2.3.2.3 .un%tions 2.3.2. Common *rea 2.3.3 Data /lo%0s 2.3. Plugins 2. Languages 2. .1 2. 2. 2. 2. 2. 2. 2. 2. 2. 2. 2. 2. 2. 2. 2. .2 2. .3 2. . Ladder .1.1 Conta%ts .1.2 Coils .1.3 -egments .1. #ead(1rite *nalogi%(Digital I() .1.2 'sing varia,les .1.3 Comparator .1.4 Counters .1.5 6imers .1.7 Data /lo%0s .1.18 .un%tion Call .1.11 #egister 6rans$er .1.12 Comments .1.13 -9ort%uts :eys .1.1 -pe%ial Coil ;#eturn< -%ript .un%tion /lo%0s Gra$%et

2.2 !MI 2.3 Compilation & 6rans$erring logi% program to &irtual PLC 2.4 Cross #e$eren%es 2.5 Printing 2.7 Conne%tion "it9 &irtual PLC CP' 2.7.1 Lo%al & #emote %onne%tion modes 2.7.2 *vaila,le )perations 2.7.3 &ie"ing logi% programs running 2.7. -ee(.or%e &aria,les 2.18 EasyPLC Editor Customi=ation

3. Virt al PLC CPU


3.1 &irtual PLC CP' Console 3.2 )peration Modes 3.3 &irtual PLC CP' Modules 3.3.1 CP' 3.3.2 Communi%ation 3.3.3 I() Modules 3. PLC -%an Cy%le 6ime Grap9 3.2 &irtual PLC CP' Clo%0 3.3 #eset &irtual PLC CP'

!. "#I $yste% &PPENDI'


.1 EasyPLC -%ript C> Language ?ui%0 Guide .2 .un%tions E@amples

www.nirtec.com

INTRODUCTION
1. General Description
EasyPLC Sofware Suite is a group of programs that allows to make automatism control and simulation. With EasyPLC you can write logic programs like commercials PLC for multiple uses like real automatism control, domotics, simulation, initialization to the PLCs world and much more The main characteristic of EasyPLC is that it emulates the operation of a PLC, using the programming languages most used in the industrial world: Ladder, Grafcet, Logic Function Blocks and Script. You will be able to learn how to use the automatic control systems used in the industry, only with your Personal Computer, the EasyPLC software and an input/output interface or a simulated one.

A New Dimension in your PC


With EasyPLC you will be able to give a new dimension to your PC. Make your PC work with the external world; you will be able to use your PC like a PLC. The PLC's (Programmable Logical Controller) are the electronic systems that are used in the industry to control the automatic machines, Interfaces, Robots, etc with a simple graphic programming language. Use your PC (or even the old computer that is no longer used) to control relays, motors, lamps, alarms, push buttons, etc... Creating automatisms only limited by your imagination. An important characteristic of EasyPLC is simulation, if you do not have at your disposition the necessary devices to automate a system, with Machines Simulator you can create your own virtual machines and simulate them in a 3D world with real time graphics and physics.

Easy Connection
EasyPLC is designed to work with the PC ports (Serial/Parallel/USB). It is not necessary to open the computer or do complex configuration tasks, only install the software, connect the interface and begin programming.

Easy Programming Languages


EasyPLC uses a standard language in the PLC's programming world, the LADDER language, this system allows the program to be written as if they were circuits with relays, counters, timers, registers, etc... It is also possible to use the Grafcet language, Logic Function Blocks and Script Language (C# Syntax). It is not necessary to have knowledge of any programming language, EasyPLC uses a completely graphic language, for this reason you can learn it using the tutorials and example programs that are provided with EasyPLC

Applications
You can use EasyPLC to make automatisms control, PLC Training, domotics, initiation in the world of the PLC's, projects simulation and much more

1.1 EasyPLC Programs Group


EasyPLC Software Suite is composed by the following programs: EasyPLC Editor Virtual PLC CPU HMI System EasyPLC Editor is the utility to create, edit and compile the logic programs. Also is used to create the HMI Screens and to make debug and diagnosis of the logic programs, due is possible to connect with Virtual PLC CPU in order to view how the program is running. Virtual PLC CPU is the application that executes the logic programs and emulates the operation of a real PLC. HMI System is a utility used to show a graphic interface between the users and the PLC, the HMI (Human Machine Interface) are the visual system to change information in a very user friendly way.

1.2 EasyPLC Installation & Minimum requirements


To make the EasyPLC installation only is necessary to execute the file EasyPLC Setup.exe. During the installation, will be checked if the Microsoft .Net Framework 3.5 is present in your system, if not youll need a Internet connection, because the installation program will download and install this necessary component. The Minimum requirements are: Operative system: Windows XP with Service Pack 2 and Microsoft .Net Framework 3.5 Recommended: Windows 7 Hardware Processor: 400 MHz Recommended processor: 1 GHz. RAM: 96 MB Recommended RAM: 256 MB. Hard Disk Space: 290 MB

1.3 Demo vs. registered version


EasyPLC is distributed in two modes, Demo version and Registered version. The EasyPLC Demo version is available to download freely from the www.nirtec.com website. With the Demo version you can use all the EasyPLC features but only allows using the Simulated Driver and the Machines Simulator Demo Driver. You are not allowed to use real & physical input/output devices. Plugins also are not enabled. With the demo version you can check how EasyPLC and Machines Simulator work.

1.4 How to register EasyPLC


If you want to register your EasyPLC copy, please fill the order form available at: http://www.nirtec.com/Register/register.htm You must fill all the fields in the registration form and you should indicate the registration modality, single license or USB license. With the single license you can run the EasyPLC Software Suite in one single computer, with the USB license a USB Key is provided, and the suite can be executed in any computer where the key will be connected. You must to type the Software Id of your product, to obtain it, go to EasyPLC Editor, make click on menu Help -> About.

Once your request has been processed and all commercial steps have been finished, you will receive a license file (if you have chosen the single modality). You must copy this file in the EasyPLC installation folder. Then you can use the registered EasyPLC version only in the computer that you have obtained the software Id code. If you have chosen the USB License mode, you will receive a USB Key, inside, there are the entire installations program. You can execute the registered EasyPLC software in all the computers where the USB will be connected. Remenber that if you use this license you need to insert the USB Key in the computer in order to make run Virtual PLC CPU. If the key is not connected Virtual PLC CPU will close. In some systems it is necessary to run the software in Windows administrator mode, in order to allow the software to access the USB key and running in registered mode.

How to Execute EasyPLC and Virtual PLC CPU in Windows (Vista, 7) Administrator Mode. 1) Make mouse right click in the EasyPLC v.5 desktop icon:

2) Select properties:

3) Select Shortcut tab, and make click in the advanced options tab:

4) Check the Execute as Administrator check box:

5) Select the Compatibility tab, and check the Execute this program as Administrator check box.

6) Click the Accept button. Repeat the same steps for: virtual PLC CPU, Machines Simulator and Machines Simulator Editor. Then this programs always will be executed in administrator mode every time are clicked.

2. EasyPLC Editor
2.1 Program Interface

Here a screen shot of the visual interface of EasyPLC is shown. The following items are marked: Menu, from where all the Editor options can be chosen. Tool Bar, fast access to most common options. Project Explorer: here you can see/change the hardware parameters, program structure, data blocks, plugins and HMI Screens. Programming Area: there is where the logic programs will be created/edited.

10

Tool Bar items:

2.2 Hardware Configuration


Here we can configure the Virtual PLC CPU parameters and the input/output analogic/digital devices that are connected in the Virtual PLC CPU.

2.2.1 Virtual PLC CPU Parameters

11

Virtual CPU Start Mode: Stop: if selected the Virtual PLC CPU will start in Stop Mode when launched. Run: if selected the Virtual PLC CPU will start in Run Mode when launched.

Watchdog: Enabled: if this option is marked, the Virtual PLC CPU will make a control each scan cycle controlling that is smallest that the Control Time programmed. If is higher, the Virtual PLC CPU will pass to stop mode and launch a Watch Dog error message. This option is useful when must be done a very accuracy process, in order to be sure that the Virtual PLC do not have time loss.

Communication with Virtual PLC CPU: The communication between EasyPLC Editor and Virtual PLC CPU can be done in Local or Remote mode. EasyPLC Editor can connect with Virtual PLC in order to read the current status of the running program, in this way is possible to make task like debug, diagnosis or others. Local: if this option is selected, EasyPLC Editor and Virtual PLC CPU will be executing in the same computer. Remote: if this option is selected, EasyPLC Editor and Virtual PLC CPU will be executing in different computers, the computers must be connected to the same net. IP Address: the Ip Address of the computer that will be executing Virtual PLC CPU. Port: the listening port using to attend the Editor connection (remember to open this port in your Firewall).

Set Parameters Button: use this button to accept a configuration, useful when theres no project on the Editor and the objective is to connect with Virtual PLC CPU to upload a program. Virtual PLC CPU Properties: Here is showed the information about the Computer microprocessor performance. These values will change in function of the computer microprocessor. Its highly recommended to use computer with more that one microprocessor in order to have the best performance. PLC Scan Cycle Speed: The Fastest: if selected the Virtual PLC CPU will run the logic program at the maximum speed available by the system. Limit to: if selected the Virtual PLC CPU will run the program at the selected speed, this means for example that if 10ms is selected, the cycle time will be ten milliseconds, then each loop of the logic program will be executed every 10 ms. Useful when we must to use hardware devices with limited speed transfer rates.

Disable Safe Mode Program Execution: if selected the program will execute the logic program without internal errors check, could be faster but if an error appears the Virtual PLC CPU will crash. Frequency Signals: the Virtual PLC CPU can generate an internal frequency signal (square wave) with a time base programmed by the user. The output signal is applied to the selected variable in Variables node. The maximum number of frequency signals are 25.

12

2.2.2 I/O Devices


In this node you can add all the Hardware devices connected in the computer where Virtual PLC CPU will be running. To use a particular hardware you must select the available driver, once selected, this driver will be added to the I/O Devices node, making click on the Driver Node you can configure it and test it (only in registered version).

Always a new Driver is added, is necessary to click it and configure it, in order to be able to use in your project.

There are some Drivers that offers some configurations options, others not. If the driver have this possibility, make click on the Configure Button, a new window will appear where is possible to parameterize it.

13

Clicking in the Test Button is possible to test directly the device if is connected to the computer (only in the registered version). Click the Exit from test Mode Button to exit from this mode. A useful option is the possibility to disable any driver. If you uncheck the Driver Enabled mark, this driver will be not processed by Virtual PLC (useful for test porpoises or when the physical device is not present).

14

2.2.2.1 Add a new Driver


In order to add a new device to your Project, you can make click on the I/O Devices node and click on Add new Device contextual menu. Also is possible form the EasyPLC menu -> Hardware -> Add new Hardware. Then the Add New I/O Device screen will appear:

If you click on each Driver, a description about this driver will be refreshed on the description area.

Click Ok button to add this driver to your Project.

2.2.2.2 Remove a Driver

If you want to eliminate an existing driver, click it in the I/O Devices node, press right mouse button and select Remove Device form the contextual menu.

15

2.2.2.3 Available Drivers


By default the following drivers are provided with EasyPLC: Joystick: allows using a compatible Windows Joystick to read two axes (X and Y) like two analogic inputs and the buttons like digital inputs. Machines Simulator Drivers, there are two drivers inside this category: o Machines Simulator Demo: This driver must be used to communicate with Machines Simulator DEMO software. In Demo version only are allowed to use 12 Digital Inputs and 12 Digital Outputs. Analogic I/O are not allowed o Machines Simulator: This driver must be used to communicate with Machines Simulator software. Nirtec Drivers: Driver for the Nirtec USB 15I16O card (see http://www.nirtec.com/services/USB_Interf.htm) Parallel Port Driver: this driver uses the PC parallel port to manage the digital I/O provided by this port. In total are: 5 inputs and 8 outputs. Phidgets: Driver for the Phidgets InterfaceKit cards. Serial Drivers: This driver provides 8 inputs and 8 outputs, sending/receiving only one byte in binary mode. Simulation Drivers: driver for Simulation purposes. Use this driver for test your logic programs (available in Demo). When this driver is active, a window appears where is possible to force the inputs (marking the checkboxes) and see the output status. TCP/IP Drivers: o TCP/IP Client: use this driver to manage digital I/O form other Virtual PLC CPU connected via TCP/IP (or also any third parties programs). The Virtual PLCCPU program using this Driver must to be executed after the Virtual PLC program using the TCP/IP Server Driver. o TCP/IP Server: use this driver to manage digital I/O form other Virtual PLC CPU connected via TCP/IP (or also any third parties programs). The Virtual PLC CPU program using this Driver must to be executed before the Virtual PLC program using the TCP/IP Client Driver. o TCP/IP_HTML_Server: use this driver to manage digital I/O from any Web browser program connected via TCP/IP with the same pc where is executing Virtual PLC.

Simulation Driver running with Virtual PLC CPU Available Drivers on request: Siemens Drivers: communication driver between Simatic S7 - PLCSIM and Virtual PLC CPU. With this driver you will be able to communicate your Step 7 logic programs directly with Virtual PLC without any additional hardware. Create your Step 7 programs and use Machines Simulator to test it, simple, fast and secure, no additional hardware are needed (expensive PLC's, I/O cards, connections interfaces,...) only your PC and the following software: Siemens Simatic Step 7 v.5.4 (SP3) Siemens S7-PLCSIM v.5.4 EasyPLC Software Suite Simatic S7-PLCSIM EasyPLC Driver

For more information please consult the www.nirtec.com site

2.2.2.4 How to Develop an EasyPLC Driver


Please refer to the EasyPLC v.5 SDK Guide.

16

2.3 Software Structure


2.3.1 Variables
The variables are a very important entity in EasyPLC programming. The variables are the elements used to make operations (comparisons, assignments, etc). Using variables is clearer to read the programs, if we chose adequate names, we can understand better the logic program. The variables can be linked with the internal PLC objects like digital/analogic inputs/outputs, counters, timers or data blocks. Variables without linked PLC elements are managed totally by the programmer. The variable types could be: bool: holds one of two possible values, true or false int: holds 32-bit signed integers. The smallest possible value of an int variable is -2,147,483,648; the largest possible value is 2,147,483,647. long: holds 64-bit signed integers. The smallest possible value of a long variable is 9,223,372,036,854,775,808; the largest possible value is 9,223,372,036,854,775,807. float: holds a 32-bit signed floating-point value. The smallest possible value of a float type is approximately 1.5 times 10 to the 45th power; the largest possible value is approximately 3.4 times 10 to the 38th power. double: holds a 64-bit signed floating-point value. The smallest possible value of a double is approximately 5 times 10 to the 324th; the largest possible value is approximately 1.7 times 10 to the 308th. String: represents a string of Unicode characters. It allows easy manipulation and assignment of strings.

Linked variables take automatically the data type of the linked PLC element, being impossible to change their type. Its possible to add a description for each variable, then will be easiest to debug the logic programs.

17

Clicking in the Address column of each variable, is possible to assign easily this variable with the available PLC objects like analogic/digital I/O, CPU frequency signals, data blocks, counters or timers. Once the user makes click on the column button, the Select Address window will appear, from there, is possible making double click to select the item to link with the variable.

From Variables Tool Bar are available the following tools: Delete Variable: use it to delete variables. Copy Variable. Paste Variable. Import Variables: with this option is possible to import variables from external sources. The following options are available: o Import from Machines Simulator: an ios file (exported from Machines Simulator) can be selected, then automatically are created the analogic/digital input/outputs used in Machines Simulator installation. o Import from csv file: the csv file must follow this format: variable name, address, type, description. Fields must be separated by comma or point and comma. Here an example is showed:
Automatic;I.0.0;bool;variable for automatic mode Manual;I.0.1;bool;variable for manual mode Motor_ON;i.0.2;bool;motor is on Motor_OFF;i.0.3;bool;motor is off switch_1;i.0.4;bool;part detection text;;string;user text

Delving into the variables


Variables represent storage locations. Every variable has a type that determines the values to be stored in the variable. The value of a variable can be changed through assignment or through use of the ++ and - operators. Variables are values that can change as much as needed during the execution of a program. One reason you need variables in a program is to hold the results of a calculation. Hence, variables are locations in memory in which values can be stored. The variable names follows the C language criteria, this is: A variable can: Start with a "_". Contain both upper case and lower case Unicode letters. Case is significant.

An variable cannot: Start with a numeral. Start with a symbol, To have a keyword name (check Keywords in Appendix). Have more than 511 characters.

18

2.3.2 Program Modules


Programs are composed by sequences. Sequence is the minimum programming unit. The sequences can be programming in several languages like Ladder, Script, Logic Blocks or Grafcet. In order to have a structured programming method, EasyPLC provides tools to sequence the logic programs.

2.3.2.1 Init
The sequences inside the Init Program node only will be executed once, when the program starts. Useful to program initialization routines.

2.3.2.2 Main
The sequences inside the Main Program node will be executed cyclically and in the order showed in the node tree. Using the jump tools will be possible to change the sequences order if the program requires it.

2.3.2.3 Functions
In this node are programmed the functions, the functions are sequences called from the Init or Main sequences. Functions also can be called from others functions. Functions can return a value or not. Only the functions written in Script language can return a value, using the return keyword. The functions written in Ladder or Function Blocks cant return any value.

19

In order to insert a sequence in the Init or Main Program Module, click it and press right mouse button, click Add Sequence on contextual menu. Also from the EasyPLC menu -> Program -> Add new Init Sequence or Add new Main Sequence. The Create New Sequence window will appear, there you can write the sequence Name (without spaces) and the sequence language. Pressing Accept button, the new sequence will be created.

To insert a new function click in the Functions Program node, press right mouse button, click Add Function on contextual menu. Or from the EasyPLC menu -> Program -> Add new Function. The Create New Function window will appear, there you can write the function Name (without spaces), the sequence language, the returned data type and the parameters passed to this function with their data types. Pressing Accept button, the new function will be created.

Only functions written in Script language can return a value (with the return keyword)

20

A special function is available, the Exit function. When you create a function called Exit (must be without parameters and void returned value), Virtual PLC CPU will call this function when pass to Stop Mode. This feature could be useful to call to finish routines (for hardware or software unloads tasks). In order to software reusability, Functions can be exported or imported to use in other programs, you can refer to Appendix 4.2 to learn more about this feature and to view some functions examples usage with different languages.

2.3.2.4 Common Area


The common area is designed to declare all the program components that will be common (visible) for all the sequences available in the program. Here is possible to declare global variables or user defined types, like structures or classes. The common area is a sequence written in Script code. To call it, select the Program node, next click right mouse button on it, and select Common Area from the contextual menu.

Once the common area is declared, will be available like an icon in the Program tree.

21

2.3.3 Data Blocks


The Data Blocks are a collection of data items that can be selected by indices computed at run-time. The data blocks may be declared as the same type as variables (see page 15). The Data Blocks typically are used to store values and make operations with them. Having a vector-type structure, it is possible to access elements by index. To create a new Data Block, select the Data Blocks node, make right click with mouse and select Add Data Block from the contextual menu.

Once the Data Block is created must to be parameterized, type the Data Blocks name, type and length (the number of elements that contain this data block). Then press Create Data Block button to create it. The Non Volatile attribute is used to store the Data Block value when the Virtual PLC pass to stop mode and when finish. The data blocks marked with this attribute will maintain the last value stored when Virtual PLC pass to Run Mode also if is closed and re launched. Is possible to initialize the data blocks with the values typed in the Value field.

22

2.3.4 Plugins
The Plugins are an extensibility tool that adds specific abilities to EasyPLC. These libraries can be created by the users allowing any kind of customization giving more power to the language, or creating special functions to communicate with third party devices or softwares. Please refer to the EasyPLC v.5 SDK guide, in order to know more about this item. All the plugins libraries must to be copied in the EasyPLC Plugins folder.

To add a new Plugin, select the Plugin node, and make right click, next select Add Plugin from the contextual menu.

Then you must select a valid EasyPLC Plugin dll file, if the library is a valid EasyPLC Plugin library, a new node will be added to the Plugins node. Making click on the new plugin node, will show all the methods information, about their name, parameters, and returned value.

23

2.4 Languages
2.4.1 Ladder
The Ladder is a programming language that represents a program by a graphical diagram based on the circuit diagrams of relay-based logic hardware. It is primarily used to develop software for Programmable Logic Controllers used in industrial control applications. Then Ladder allows making programs in a graphic way like you where connecting circuits with relays, counters, timers, sequencers, etc... The basic elements of a Ladder program are the contacts and the coils. The programs written in Ladder are compound by segments. A segment its a contact/coil group. The contacts are the conditions that are evaluated to make an action, the coils are the actions. Now lets see the EasyPLC Ladder structure.

24

Ladder Tool Bar

The Ladder tool bar offers the followings tools: Add Contact: adds a new open contact in the selected cell position. Add negate Contact: adds a new closed contact in the selected cell position. Add Comparator: adds a new comparator contact in the selected cell position. Add Coil: adds a new coil in the selected cell position. Add Set Coil: adds a new Set coil in the selected cell position. Add Reset Coil: adds a new Reset coil in the selected cell position. Add Trigger Upper Coil: adds a new Upper Trigger coil in the selected cell position. Add Trigger Down Coil: adds a new Lower Trigger coil in the selected cell position. Add Jump coil: adds a new Jump coil in the selected cell position. Serialize Coil: adds a new coil serialized with the current selected coil. Add Counter Coil: adds a new Counter coil in the selected cell position. Add Timer Coil: adds a new Timer coil in the selected cell position. Add Data Block Coil: adds a new Data Block coil in the selected cell position. Add Function Call: adds a Function call in the selected cell position. Add Register Transfer: adds a new Register Transfer in the selected cell position. Add Jump Label: adds a new Jump Label in the selected cell position. Add Comment: adds a new Comment in the selected cell position. Add Header Text: adds a header Text coil in the selected row position. Add Cable: adds a new wire connection in the selected cell position Cable Down: makes a connection with the lower cell. Cable Up: makes a connection with the upper cell. Delete Connections: deletes the current connection in the selected cell. Add Space between Segments: adds space between segments in the current selected cell Reduce Space between Segments: erases space between segments in the current selected cell. Move segment to right: move the segment to the right adding a wire in the current selected cell. Zoom Out: reduces the zoom. Zoom In: increases the zoom Standard view: set the segments size to the standard one. Selection Tool: allow to select segments for copy/paste operation. Copy: copy the current selection. Paste: paste the last selection.

25

2.4.1.1 Contacts
Ladder has contacts that make or break circuits to control coils. Each coil or contact corresponds to the status of a single bit in the PLC memory. Unlike electromechanical relays, a ladder program can refer any number of times to the status of a single bit, equivalent to a relay with an indefinitely large number of contacts. So-called "contacts" may refer to physical ("hard") inputs to the programmable controller from physical devices such as pushbuttons and limit switches via an integrated or external input module, or may represent the status of internal storage bits which may be generated elsewhere in the program (Variables).

The Contact shows two areas, the elements area and the Operation area, depending what type the variable assigned to the contact, is possible to type and see different information in the contacts area. In the previous picture we see a segment with five contacts, there are: I.0.0: this means the digital input number 0.0 this is the input number 0 from the diver number 0. Due digital inputs are Boolean conditions no additions information is shown in the operation area. PushButton: this is a variable linked with the digital input 1 of driver number 0, all the linked variables will show in the operation area the linked element between brackets. num: is a variable of numeric value, in order to evaluate the contact, is necessary to type the condition that will allow the contact activation, this will be that the num variable will be grater that 20. cont: is a variable linked with the counter number 2, the contact activation condition will be greater than 12. tim: variable linked with Timer number 1, like the Timer elements are Boolean conditions, this contact will be activated when the timer 1 reaches the programmed time.

Contacts can be set as negated, then will be activated if the activation condition is false.

2.4.1.2 Coils
Each segment of ladder language has one coil at the far right. Also is possible to connect more that one coil in the same segment (serialize coils). The "coil" (output of a segment) may represent a physical output which operates some device connected to the PLC, may represent an operation with variables or a call to other element in the program. The coils could be activated in several ways, in EasyPLC exists the following coils type:

Level Coils: these coils are activated by level, this means, the coil status is always true while the segment is true. If the segment is false, the coils status is always false. Set Coils: used for Boolean variables, if the segment is true, the coil will set to true the variable assigned, if is false nothing is done. Reset Coils: used for Boolean variables, if the segment is true, the coil will set to false the variable assigned, if is false nothing is done. Trigger Up Coil: these coils are activated by upper flank, this means, the coil status is true only the first time the segment pass from false to true. Trigger Down Coil: these coils are activated by lower flank, this means, the coil status is true only the first time the segment pass from true to false. Jump Coil: used to jump to a label in any sequence. Serialize Coil: sets a coil serialized with the selected one, then when the segment condition will be true, this new coil also will be activated.

26

The Coils shows two areas, the elements area and the Operation area, depending what type the variable assigned to the coil, is possible to type and see different information in the coils areas. In the left picture a segment with four coils is shown, there are: O.0.1: this means the digital output number 0.1 this is the output number 1 from the diver number 0. Due digital outputs are Boolean conditions no additions information is shown in the operation area. Delay: variable linked with Timer number 1, when this coil will be activated, the timer number 1 will be initialized with value 100 milliseconds. PartCounter: is a variable linked with the counter number 2, when the coil is active, will increase in one unit the value of counter 2. Value: numeric variable, when coil will be active, will add 2 to the current variable value.

Making double click on the contacts/coils Description and Operation area is possible to edit their values in order to modify it.

Ladder assistant tools for writing operations with contacts/coils


When a contact or coil is created or edited, is possible to type directly the operation or use the assistant wizard, for use it, click on the help button on the wizard tool.

The assistant help contains tour tabs, the first tab (Help) explain the possible operations for the current contact/coil and shows some examples, the second tab (Variables) shows the available variables on our project, making double click on the selected variable, is added to the text operation without writing, the third tab (Functions) shows the available contact/coils functions to write in the operations area, and the last one (Plugins) shows the available plugins defined in our project.

27

The available operations for contacts and coils are different, due contacts operations always are of comparison type (must return a Boolean value), and coils operations are assignments. All operations must be done following the syntax of C programming language.

2.4.1.3 Segments
A segment is a group of Boolean conditions that ends in one o more coils. The writing of segments should always be from left to right and from up to down. Imaginarily, the current continues the sense from left to right

Using the contacts, coils and wirings tools is possible to create the desired segments. The wiring tools are: Cable Left: allows drawing a horizontal wire of one grid unit. Cable Down: draws a wire from the current position to one lower grid position. Cable Up: draws a wire from the current position to one upper grid position. Cable Eraser: deletes any connection in the current cell.

The ladder draw area is designed like a grid, divided in cells. In each cell position an element can be draw (contact, coil or cable). Writing segments must be done in order form left to right, is not allowed to insert an element in an empty location.

28

2.4.1.4 Read/Write analogic/digital Inputs/Outputs


There are several possibilities to carry out the task: Calling directly the analogic/digital inputs/outputs. Using linked variables.

Lets see some examples: For a fast way, in the ladder programming area, make click on the first cell, then the selection dotted square will be shown:

Press Insert Key or make click in the ladder tool bar contact button.

A text area appears over the contact, also a wizard windows appears in order to select the element to assign to this contact. Type I.0.0 in the contact text area and press Enter Key.

29

Now we have created the first contact that will be active when the input number 0 from the Driver 0 (Simulated) will be active. Now were using the variables linked method. Go to the Variables node in the Project Explorer, and in the last empty row, column Variable Name, type the name of your variable (NewInput in the example), now click on the Address button, the Select Address window appear to select the element. Select the desired one (I.1.0 in the example).

Once selected, the Address Button will show the linked element with the created variable.

Now, go to the ladder programming area, and select the cell following to the last created contact, press Insert Key or make click in the ladder tool bar contact button. When the wizard window appears, select the new created variable, and make double click.

30

Then the Input number 0 from the second driver will be assigned to the new contact.

Now you know the two modes to assign digital inputs to the contacts. This is the same for the digital outputs and analogic inputs and outputs, applying also in the coils. For the outputs is used the syntax: O.X.Y (where X is the driver number and Y the output number). For the analogic inputs is used the syntax: AI.X.Y (where X is the driver number and Y the output number). For the analogic outputs is used the syntax: AO.X.Y (where X is the driver number and Y the output number). Following the example, now select the cell at the right of the last contact, and press Shift key + B key or make click in the ladder tool bar coil button, then write O.0.2 and press Enter Key. Now you have created a new segment, where the digital output number 2 from the driver number 0, will be activated if are actives digital input number 0 from driver 0 and digital input number 0 from driver number 1, if some of this inputs are deactivated, the output also.

31

2.4.1.5 Using variables


In Ladder language there are several ways to declare and use variables. The possibilities are: 1. Declare first the variable in the Variables Table and then use it in the wizard window. (as seen on the previous item) 2. Using the wizard Ladder window to create a new one. 3. Typing directly the new variable name in the contacts/coils text area. Example of mode 2: Create a new Contact, and press Create New Variable button on the right side of the wizard window.

In the New Variable window type your new variable name

Then the Create New Variable window appears, there you can customize your variable like link it with any available element, or if is not a linked variable you can define the variable type. Also is possible to insert a description about the variable.

Once the OK button is pressed, the new variable is added to the Variables project table, and is visible in the ladder wizard window. You can make double click in order to assign it to the selected contact.

32

Example of mode 3: In the text area of a Contact or Coil, write your variable name, if this variable do not exists, the New Variable Window appears in order to create it, once accepted, this variable will be added to your project, being available at the ladder wizard window, making double click will be assigned to the selected contact or coil.

Fast access to created variables


When typing a variable name in a contact/coil, a combo box appears showing the matches starting with the same words typed, you can click in the combo in order to assign to the contact/coil.

Operation with Variables


All the operation with variables must be done following the C language Syntax. In the following example there are three contacts that carry out comparison operation with variables, if all comparisons are true (segment true), three assignments of variables take place in the coils. Look how variable T1 (int type) is compared with 1 value ( == ), Value (float type) is checked grater that 45 and DelayTime (long type) must be different from variable WaitTime (long type). If the segment is true, variable IntVar (int type) is assigned with value, variable T2 (int type) is incremented in one unit (++) and variable Message (string type) is assigned with the string HELLO.

33

2.4.1.6 Comparator
The comparator is a contact element designed to make comparisons easily between variables or data blocks elements. To create a comparator make click in the ladder tool bar comparator button. To make comparisons, click in the combo box to select the comparison operation, this could be equal (==), different (!=), greater than (>), minor than (<), greater or equal (>=), minor or equal (<=). Click in the IN1 text filed, the wizard window appears, making double click over the desired variable will assign to the fist comparison operator, the same operation for the second operator (IN2). In the example two variables are compared is are equal will activate the coil, assigning the value 125 to the variable Value.

IMPORTANT: variables compared MUST BE of the SAME TYPE. Also is possible to write a constant in the second operator (IN2)

To make comparisons with Data Blocks, is possible to use the variables linked with each element, or if is necessary, is possible to use the function ReadDB(id, elem), that will return the element number elem from the data block number id. Is required that the first parameter will be a numeric constant, but the second parameter can be a variable.

34

2.4.1.7 Counters
EasyPLC offers a special variable (long type) used to make counter operations, the counters can be used by several ways in the contacts/coils. Counter Coils To add a new Counter coil press on the Ladder Tool bar Counter Coil You can type in the Id text area the counter number, and in the Increment text area the quantity to the counter must to be incremented when the coil is active. The counter will increase their value only in the upper trigger of the segment activation.

If the Counter has linked a variable, the variable name will be shown.

Counter also can be written using the standard coils, using the syntax CNT.X, where X is the counter number. Clicking in the coils operation area is possible to customize the counter operation.

Be careful with the coil type used, in the previous example, a standard coil has been using, this coils works in level mode, this means that while the segment condition is true, the coil will be executing the counter operation. The most common counter coil usage is to use a triggered coil, in the next example, when the output 0.1 is active the counter number 1 will increment their value in 5 units, but only once, the counter will not be updated since the output 0.1 will be deactivated and activated again.

Counter Contacts To add a new Counter contact press on the Ladder tool bar coil, then type the variable name linked with the counter or use the syntax CNT.X, where X is the counter number. After, you can type the counter comparison operation, the syntax must be done in C programming syntax. .

35

2.4.1.8 Timers
EasyPLC offers a tool to control time, this is the Timer. By default the timers works for retard to the connection. According to the following segments the timer 1 level signal would be:

Timer Coils To add a new Timer coil press on the Ladder Tool bar Timer Coil You can type in the Id text area the timer number, and in the Time text area the timer countdown time (could be a numeric value or a variable of Long type). In the upper trigger of the segment activation the timer will start to count, when the timer countdown arrives to zero the timer will have a true value.

Timers also can be written using the standard coils, using the syntax TMR.X, where X is the timer number. Clicking in the coils operation area is possible to customize the timer countdown time. Be careful with the coil type used, in this example, a standard coil has been using, this coils works in level mode, this means that while the segment condition is true, the coil will be executing the timer loading value operation. The most common timer coil usage is to use a triggered coil.

36

Timer Contacts To add a new Timer contact press on the Ladder tool bar coil, then type the variable name linked with the timer or use the syntax TMR.X, where X is the timer number. The contact associated to the timer will be true when the timer previously has been activated and their countdown will arrive to zero.

2.4.1.9 Data Blocks


With Ladder language is possible make operations with Data Blocks. Data Blocks Coils To add a new Data Block coil press on the Ladder Tool bar Data Block Coil If you make double click on the Data Block, the Data Blocks Parameters will open in order to parameterize the coil. First select the Data Block you want to work, then select the element number. Finally select the operation you want to assign when the segment condition will be true, for instance assignations (with numeric constants or variables) or operations allowed for the type of data that make up the Data Block. If Run on Trigger is marked, the coil operation will be done once when the segment value pass form false to true, by default the coil operation will be done by level, this means the coil Data Block operation will be done while the segment condition will be true.

Data Blocks also can be written using the standard coils, using the syntax D.X.Y, where X is the Data Block number and Y the element number of the Data Block. Clicking in the coils operation area is possible to customize the Data Block element operation.

See in the example how the sum operations are performed by trigger.

37

Data Blocks Contacts To add a Data Block contact press on the Ladder tool bar coil, then type the variable name linked with the Data Block element or use the syntax D.X.Y, where X is the Data Block number and Y the element number of the Data Block. The Data Blocks comparison operations must be written in C language syntax.

2.4.1.10 Function Call


Other special coil is the Function Call. To add a Function Call coil press on the Ladder Tool bar Function Call coil. This coil allows making a call to a previously defined function, configuring the passing parameters and the returned value (if it has it). Once the coil is created, is necessary to select the function on the combo box control.

Next the Function Parameters window will open in order to parameterize the parameters passed to the function and the returned value. Clicking in the Variable button for each parameter is possible to assign it to the selected variable from the list making double click on the variable name. Also is possible to assign a constant value clicking in the Set Constant button. If Run on Trigger is marked, the Function will be called once when the segment value pass form false to true, by default the calling will be done by level, this means the calling will be done each PLC scan time cycle while the segment condition will be true.

38

When confirmed, the Function Call coil will show the information about the called function name, the passed parameters and the returned value.

If you make right click on the Function name node, is possible to change the function name, change the parameters or to delete the function.

2.4.1.11 Register Transfer


The Register Transfer coil allows making common PLC register transfer operations. To add a Register Transfer coil press on the Ladder Tool bar Register Transfer coil.

Use the Register Transfer coil for transferring the status of the selected Input register to the selected register output. Also is necessary to configure the length of the copied register.

2.4.1.12 Comments
With the Comments Ladder tool will be possible to document the Ladder programs. There are two types of comments, the text and the Header comments. To insert a comment select it from the Ladder Tool bar.

39

Making double click on the comment is possible to customize it, changing the text, Background colour, text colour, text font and message border.

Text comments can be moved in the Ladder programming area clicking on the text and moving with mouse.

2.4.1.13 Shortcuts Keys


The following short-cuts keys are available for ladder language:

Insert Key: Insert Contact. Shift + Insert Key: Insert negate Contact. Shift + B : Insert Coil. Shift + C: Insert horizontal Cable. Shift + U: Insert Upper Vertical Cable. Shift + D: Insert Lower Vertical Cable. Shift + S: Activates Selection tool. Control + C: copy current selection. Control + V: pastes current copied selection.

2.4.1.14 Special Coil (Return)


A special coil is available in Ladder language, the Return Coil. This coil allows breaking the current flow of the sequence, and jumping to the following sequence without finish the current where the return command is executed. Example:

In this example is input number 0.0 is active, the control flow of the program pass to the following sequence (Main_Sequence_2) and the second segment I.0.1 O.0.1 is not executed.

40

2.4.2 Script Language


EasyPLC sequences can be programmed using a Script language. The EasyPLC Script language uses the C# syntax. You can find more information about EasyPLC C# language in the Appendix.

Script Tool Bar

The Script tool bar offers the followings tools:

Cut text: cuts the selected text. Copy text: copies the selected text. Paste text: pastes the previously selected text. Comment: comments the selected text area.(this commented text will be not compiled). Un Comment: erases the comments of the selected commented text. Undo. Redo. Check Syntax: checks if the current sequence syntax is ok. Add Bookmark: add a bookmark in the selected position. Previous Bookmark: moves to previous bookmark position. Next Bookmark: moves to next bookmark position. Delete all Bookmarks: deletes all existing bookmarks. Find text: finds a text on the sequence. Find & Replace: replaces all the matches of the selected text on the sequence. Code Wizard: allow to insert code snippets on the current sequence, also is possible to call to the Script Wizard.

Pressing F2 Key will show the script Wizard on the current Script sequence.

In script language is possible to use the variables defined in the project to make any kind of operation. To do it Press F2 Key and from the Script Wizard window, select the variable you want to use making double click on the variable name.

41

EasyPLC Script Internal Methods


EasyPLC offers a series of internal methods in order to manage the PLC logic program. These methods are: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: ReadInput(device, number) bool int device, int number returns the state of the digital input number 'number' from device number 'device' ReadOutput(device, number) bool int device, int number returns the state of the digital output number 'number' from device number 'device' ReadAInput(device, number) float int device, int number returns the state of the analogic input number 'number' from device number 'device' ReadAOutput(device, number) float int device, int number returns the state of the analogic output number 'number' from device number 'device' WriteOutput(device, number, value) none int device, int number, bool value writes the value 'value of the digital output number 'number' from device number 'device' WriteAOutput(device, number, value) none int device, int number, float value writes the value 'value' of the analogic output number 'number' from device number 'device' ReadDB(number, elem) object int number, int elem Returns the value of the data block number 'number' element number 'elem' WriteDB(number, elem, value) none int number, int elem, object value Writes the value 'value' in the data block number 'number' element number 'elem'

42

Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description:

SetTimer(timerVariableName, v) none string timerVariableName, long v sets the timer timerVariableName with value v GetTimer(timerVariableName) bool string timerVariableName returns if the timer timerVariableName has been activated ResetTimer(timerVariableName) none string timerVariable resets the timer timerVariableName Key(key) bool int key returns the state of the passed key (ASCII value) Key('key') bool char key returns the state of the passed key (char value) PlaySound(path) none string path plays the wav file with path 'path' KeyPad("variableName") none string variableName Assigns a numeric value (double type) typed by the user to the variableName variable (declared of double type) KeyPadInt("variableName") none string variableName Assigns a numeric value (int type) typed by the user to the variableName variable (declared of int type) KeyPadLng("variableName") none string variableName Assigns a numeric value (long type) typed by the user to the variableName variable (declared of long type) KeyPadFlt("variableName") none string variableName Assigns a numeric value (float type) typed by the user to the variableName variable (declared of float type)

43

Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description:

Keyboard(variableName) none string variableName Assigns a string value typed by the user to variableName variable Plugin(pluginName, methodName, parameters) object string pluginName, string methodName, object[] parameters executes the method 'methodName' of the plugin 'pluginName' passing an array of objects 'parameters' StopPLC() none none makes a PLC Stop DriverStatus(number) bool int number returns the driver status number 'number' StartHMI() None None Launchs the HMI System application CloseApp(name) None String name Closes the name application

Plugins usage in Script Language


The declared Plugins in the Project can be called from Script language in the following way: PluginName.PluginMethod Next an example is showed:

44

2.4.3 Function Blocks Language


Function Blocks language offers other graphic programming tool. Using this graphic language programs can be written in a very easily way, selecting the items we want to use and connecting between them like components of an electrical circuit. This language should be used to program sequences that require no complications, due is very easy and fast to use but do not offer the power functions like Ladder, Script o Grafcet languages. In this language are the following tools:

Condition Block: this block represents a condition, if is true their output will be true and can activate other blocks. Action Block: this block represents an action that will be done when other block actives it. Set/Reset Action Block: like Action block but with possibility to make set/reset operations. AND Block: makes the logic AND operation of the state of their two inputs, the result is present in their output. OR Block: makes the logic OR operation of the state of their two inputs, the result is present in their output. NOT Block: makes the logic NOT operation of the state of their input, the result is present in their output. Label: inserts a text label for documentation porpoises. Zoom in Zoom out Normal Zoom. Delete Selected Block/Wire.

Creating a Function Blocks sequence.


Next an example about how to create a Function Blocks sequence is showed. Create a new Main Function Block sequence (view page 18). First make click in the tool bar Condition Block, then the mouse cursor will change to a cross shape, then make click in the F.B. programming area where you want to place the block. One placed, the F.B. wizard window will show in order to choose the variable associated with this block, make double click in the variable name you want to use.

45

Now, create other condition block and select a numeric type variable (DelayTime in the example is float type), then automatically the condition operation is filled. As you can see by default the condition is that DelayTime will be equal to zero, if you want to change the condition, click in the block and make mouse right click, a contextual menu will appear, then click Set Operation in order to change the condition operation.

Next, add a AND Block, selecting it form the tool bar.

The following operations will be to wire the two condition Blocks with the AND Block. To do it click on the first created Block, and make mouse right click, select Connect Out form the contextual menu, then the mouse cursor will change indicating that we are in edition connection mode. If the connection to the element on which the cursor is located is not possible, the cursor will have an icon shaped like a prohibition, if the connection is allowed, the icon will have a hand. If you click on the F.B empty area the block will exit from the connection edition mode and will not be connected.

46

Following the example, click on the AND Block, then the NewInput condition block will be connected with one input of the AND Block.

Repeat the same process for DelayTime condition Block.

Now we are going to add an Action Block, to do it make click in the tool bar action block and place it in the programming area. Then select a Boolean variable (for example a digital output).

47

Then make mouse right click and select from the contextual menu, Connect In, then click the AND Block.

We have written your first Function Blocks sequence!. This program will work in the following way: if the digital input associated to the variable name NewInput is true, and the variable DelayTime is greater than ten, the digital input associated with the variable MotorOn will be activated, else will be deactivated.

Clicking in the Assign Variable contextual menu Blocks is possible to change the associated variable. Clicking in the Set Operation is possible to change the condition operation (for Condition Blocks) or the action operation (for Action Blocks). For Boolean variables theres no possibility to change the operation because for condition blocks always will be checked the true condition and for Action Blocks the action to make will be to assign true or false state, in function if is activated or not. Pay attention at the Activate by trigger / Activate by Level contextual menu items of Action Blocks. If Level mode is selected, the Action Block will be executing the action each scan loop of the PLC, while their input is true. If Trigger mode is selected, the Action Block executes the action once (the first time their input is true). Probably for the next example, you wish the auto increment of the variable Value, will be done once, then you must to select Trigger mode for the Action Block.

48

The Set/Reset Action Blocks are more flexible because allow to set/reset boolean variables and take out the result in their output. In the following example, if variable NewInput is true, MotorOn variable will be set to true, also variable Data5 will be matched to three. If variable T2 is equal to zero, MotorOn variable will be set to false.

Condition and Action Blocks allows to use internal PLC functions and Plugins, in order to select it, click on the wizard window help button, here you can see help syntax examples, access to variables, functions and plugins. Make double click on the desired name to be automatically added.

49

In order to delete connections between blocks make click in the wire you want to delete, then will be marked in yellow color. Now press Delete Block/Connection tool bar button.

50

2.4.4 Grafcet
The GRAFCET (Graph of Control of Steps of Transitions) it is a normalized functional diagram that allows to make a model of the process to automate, contemplating inputs, actions to carry out, and the intermediate processes that cause these actions. It is not a language, is a design type to elaborate the pattern thinking of the direct execution of the automatism. The Grafcet Level is compound of Steps and Transitions, the steps and transitions can be programmed in Ladder, Script or Function Blocks languages. The Grafcet Levels are compound by the following elements:

Initial Step: is activated when the level starts by first time, at least one initial step must be present. Step: is a subprogram that is executed continuously while their associated transition is false. Transition: is the condition that must be true to allow the pass to the next connected step. Structural Parallelism: allows to execute simultaneously all the connected steps to their output. For the Parallelism actives their outputs its necessary that all theirs inputs conditions must be true, this is, all the process that the Parallelism has been launched, must been ended to allow their finalization. In a Grafcet level can exist all diagrams you need.

Rules that a Grafcet Level must perform:

At least an initial step should exist, (can be more than one). In a step output (normal or initial) a transition should always be connected. It is not possible to connect two transitions together or two stages together.

Available tools in Grafcet programming:

Add Initial Step: adds an initial step. Add Step: adds a new step. Add Transition: adds a new transition. Add Parallelism: add a new structural parallelism. Add Label: add a label for documentation porpoises. Zoom in. Zoom out. Normal Zoom Hide/view grid points. Delete selected item.

Creating a Grafcet sequence.


Lets see an example about how to create a Grafcet sequence. 1. Create a new Main Grafcet sequence (view page 18). 2. Click on the Grafcet tool bar Add Initial Step button. Then the mouse cursor will change to a cross shape, when click in the Grafcet programming area the Initial Step will be placed. Type 0 in the Step number window.

51

3. Click on the Grafcet tool bar Add Transition button, and place the transition down to the initial Step.

4. Click on the Grafcet tool bar Add Step button, and place the new Step down to the transition. Write 1 in the step number window.

5. Add a new transition and place it down to the last step.

6. Now we are going to connect the steps and the transitions. Click in the Initial Step in order to select it. Then make right click with mouse and click in the Connect Output form contextual menu. The mouse icon will change their shape, showing a prohibition image if the cursor is placed in a item that can not be connected, if the connection is possible, the icon image will change to a hand.

52

7. Click over the first transition, then a connection between the initial step and the transition will be done.

8. Click in the first transition, then a make mouse right click, select Connect Output from contextual menu and click over the Step number 1. Then a new connection between transition and Step 1 is done.

9. Click in the last transition, then a make mouse right click, select Connect Input from contextual menu and click over the Step number 1. A new connection between transition and Step 1 is done.

10. Now the last connection, Click in the last transition, then a make mouse right click, select Connect Output from contextual menu and click over the initial Step number 0. A connection between last transition and initial Step 0 is done. And our Grafcet diagram is totally connected.

53

11. Now is the time to write some code, click on the initial step 0, mouse right click and select from contextual menu Sequence Code -> Ladder.

12. Type Step_0 in the Step Name window.

13. A new Ladder sequence is created, write a segment like the example showed.

14. Click on the Grafcet Sequence in Main node Project. Next click in the first transition, once selected, mouse right click and select Sequence Code -> Ladder.

54

15. Write Transition_1 like in the Transition Name window.

16. As you can see automatically is created a coil labelled with Transition word. Write in this segment the conditions to enable the transition, allowing passing the control to the transition connected step.

17. Select Grafcet sequence, and click on the Step number 1, right click with mouse to show their contextual menu, and select Sequence Code -> Script. Write Step_2 in the Step Name window.

55

18. Now write the code in Script language for Step 2. In this example is assigned the value of the digital input number 2 from driver number 0, to digital output number 1 from driver number 0.

19. Click on the Grafcet sequence node, select last transition and from contextual menu click on Sequence Code -> Script.

20. Click on the Grafcet sequence node, select last transition and from contextual menu click on Sequence Code -> Script. Write Transition_3 in the Transition Name window. See how automatically a snippet code is shown, you must fill in the if() sentence the conditions to activate this transition, in Script code the Transition keyword is used to activate the transition.

56

21. Write the code in the example, here if digital input number 3 from driver 0 is active, the transition will be activated.

Now our Grafcet sequence is complete. See how in the Grafcet node from Project tree, are showed all the sequences that compounds the Grafcet sequence. You can access each sequence making double click in the Grafcet item or directly from each item in the Grafcet node.

Be careful with the Steps and Transitions names. This follows the same rules that Variables names declarations, is not allowed spaces, or not valid characters.

How this program works


The first time the program is running only is processed Step_0 and Transition_1. If input 0.0 is on, output 0.0 will be on, if input 0.0 is off, output 0.0 will be off. If input 0.1 is on, the program control flow passes to Step_1, (then Step_0 and Transition_1 will no be processed). When the program control flow is in Step_2, the status of the digital input 0.2 is passed to digital output 0.1. Also the program is executing Transition_2, then if digital input 0.3 is on, the control pass again to Step_0 and Transition_1. Program flow is repeated in this way cyclically.

57

Transitions also can be programmed in Function Blocks language. When a Transition is created in this language a new action block is created labelled with transition keyword. When this block is activated, the transition will be true.

58

2.5 HMI
In the HMI Project node are programmed the HMI screens of the project. With the HMI System application it is possible to create a visual interface between the user and Virtual PLC, for example you can show messages, images, values of the variables or data blocks, introduce values and much more. EasyPLC offers a tool to create easily screens for the HMI System program, this tool is integrated in the programming environment and allows to create the screens dragging the desired controls from the Control Tools window to the Screen creation area, after is possible to customize the controls behaviour, selecting the available options from the Controls Property grid. If you need more advanced behaviour you can write C# script code in order to customize totally the HMI Screen, controlling the controls events, timers and forms. Lets see the HMI Interface available in EasyPLC Editor.

59

HMI Tool Bar

Copy Button: used to copy the current selected control Paste Button: pastes the previously copied control. Control Properties: changes the current selected control properties, is possible to change the control order in the form, and program the control events. Delete control: deletes the current selected control Test HMI Page: This will launch the current screen in test mode in order to see the results.

Controls Tools:

Offers two tabs, one with standard windows controls and other with specialised graphical controls to add in the HMI screen. To add a control click on it in the control tool tab and then click in the Screen creation area in order to place it.

Screen Creation Area:

Here you can place and move the added controls, also is possible to change the form properties clicking on it.

Property Grid:

Used for change the selected control properties.

Script Programming Window:

Here is possible to write the C# script code for the screen behaviour customization.

Example
Now an example is showing about how to create a simple screen. 1. Create a new project, then go to Variables node and create two new variables like the example.

2. Create a new Ladder sequence and two segments like the example.

60

3. Right click on the HMI Project node, select New HMI Page.

4. Click on the new HMI Page node created, then the screen will be showed.

5. Click on the Button control from Control Tools window. The mouse cursor will change to a cross shape, then click on the screen creation area in order to place it in the desired place.

61

6. Click on the Button rectangle in order to resize it.

7. In the property grid, change the Text property, and type Automatic On, then the button text will change for the new one.

8. Now change the Linked Variable property, and select form the variables list Automatic.

62

9. Now change the Linked Variable property, and select form the variables list Automatic. 10. Click on the Label control from Controls Tools window, and place it in the screen area.

11. Click on the Label control from Controls Tools window, and place it in the screen area. Change the Text property for Value:

12. Add a new Label control and change the Text property for 0 value, change ForeColor and Font properties like in the example. Then change Linked Variable for Num.

63

13. Select the button control, and press Tool bar copy button.

14. Press Tool bar paste button. Click on the new button and place it in the new location.

Now we have finished our HMI Screen.

Now the program is showed in run mode, if the HMI Automatic On button is pressed, will activate the digital output 0.0, if the digital input 0.0 is activated the Num variable will be incremented in one unit, this value will be refreshed in the HMI label control linked with this variable.

64

The HMI System is composed by all the created screens in the HMI node project. When the HMI System application will be started, the screen with the StartUpPage property set to true will be launched. The screens also can be called with C# Script code, using the HMI.ShowHMI(screenName) method, for example using the click controls event.

65

Important tools are the external HMI Controls. These controls have a special behavior. Can be added to EasyPLC copying the necessary dll files inside the EasyPLC\ and HMILib\ folders. These controls can be made by the users, allowing a total customization of the HMI system.

The events of these controls must be programmed directly in the script code.

66

Available HMI Script Methods


EasyPLC offers a series of HMI methods in order to manage the screens using C# Script language. These methods are: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: ShowHMI(screenName) none string screenName Loads the HMI screenName passed as parameter ReadVariable(variableName) object string variableName Returns the variable value passed as parameter WriteVariable(variableName, value) none string variableName, object value Writes the variable value in the variableName ReadDB(num, element) object int num, int element Returns the element 'element' Data Block 'num' number KeyPad() double none Returns a numeric value (double) typed by the user Keyboard() string none Returns a string value typed by the user ChartPoint(variableName, chartName, legend, chartType) none string variableName, string chartName, bool legend, int chartType Draws the variableName value in the chartName Chart control. If legend true shows the legend, chartType is the Chart type (from 0 to 9) ChartPoint(serieName, value, chartName, legend, chartType) none string serieName, double value, string chartName, bool legend, int chartType Draws a serie with the passed value in the chartName Chart control. If legend true shows the legend, chartType is the Chart type (from 0 to 9) ChartFIFO(variableName, numElements, chartName, legend, chartType) none string variableName, int numElements, string chartName, bool legend, int chartType Draws the variableName variable value in the chartName Chart control in a FIFO mode, with a number of numElements X-values. If legend true shows the legend, chartType is the Chart type

Function Name: Returned Value: Parameters: Function Description:

Function Name: Returned Value: Parameters: Function Description:

67

Function Name: Returned Value: Parameters: Function Description:

ChartPoints(serieName, values, chartName, legend, chartType none string serieName, double[] values, string chartName, bool legend, int chartType Draws a serie values in the chartName Chart control. If legend true shows the legend, chartType is the Chart type (from 0 to 9) ClearChart(chartName) none string chartName Clears the Chart control MessageBox.Show("text") none string text Displays a standard Windows Message Box HMIScreen The current Form object

Function Name: Returned Value: Parameters: Function Description: Function Name: Returned Value: Parameters: Function Description: Object Object Description

Writing events for the controls


Take note how some controls have properties to link the program variables to them, in order to make operations with the variables like visualize, change or make special actions with their values. If you need more power for your HMI screens, you can use the C# script code in the controls events. Lets see an example. In the screen of the previous example, add a new button control and change the text property with Read Data Block value, then add a new Label control.

Click on the Tool Bar Control properties button, and select Events, then a list about the available events for the selected control will be shown. From the list select Click event.

68

In the below area the Script Programming Window will appear, if you press F2 key, the HMI Script code Wizard will be shown, making double click in the desired function will be added to the script programming window.

Write the code showed in the example, as you see, the Controls added in the screen can be referenced in the code with their name. The controls have some common properties like Text, Location, Name, and more that we can use in the code. Then with this program when the user presses the button Read Data Block, the Label3 control will show the value of the element number 2 of the data block number 0. The Label3 Text property is a string type, but the ReadDB function returns a object type, then is necessary to make a conversion operation, is possible to use the C# ToString() method to convert form any kind of type to string type.

69

Controls Events
The controls have some common properties and others have special ones, here is described some of the special properties. Common event for controls:

Click: event launched when the user makes click on the control.

Form control (screen)

Click: event launched when the user makes click on the form. Double click: launched when the user makes double click on the form. Form Closing: launched when the user makes closes the form. Common. This is not an event, the code writing here is available for all the controls in the screen (useful to make global variables declarations). Key Down: launched when the user pressed any key in the form. Load: launched when the form is loaded the first time.

Check Box:

Checked changed: launched when the user changes the check box mark.

Combo Box:

Selected Index changed: launched when the user changes the current combo box selected value.

Data Grid:

Cell Content Click: launched when the user makes click inside a cell.

Check Box:

Checked changed: launched when the user changes the check box mark.

Scroll Bars:

Scroll: launched when the user changes the scroll bar value.

Check Box:

Timer:

Checked changed: launched when the user changes the check box mark.

Tick: launched every tick Timer elapsed time, this time is configured in the Interval property of the timer.

Check Box:

Checked changed: launched when the user changes the check box mark.

70

HMI Configuration
The HMI offers the following configuration possibilities.

HMI Container Window


Allows setting the HMI window size, by default is maximized, this is, will be placed in all the monitor screen area. If the user wants to set a specific HMI window size, then must to check the Normal radio button, and set the window dimensions and position.

Communication with Virtual PLC


The communication between Virtual PLC CPU and HMI System can be done in local or remote modes.

Local mode: both programs are running in the same computer. Remote mode: Virtual PLC CPU and HMI System are running in different computers connected in the same net. To configure this communication mode is necessary to type the IP address and the Port of the computer that is running Virtual PLC CPU.

71

2.6 Compilation & Transferring logic program to Virtual PLC


Once the logic program is finished and before to use it in the Virtual PLC is necessary to compile it, in order to be executed by Virtual PLC. To compile a program, click in the Compile Project or Compile Project & Send form Tool Bar on click in the menu -> Program -> Compile (or Compile and Transfer). When the compilation process will end, EasyPLC will inform about the compilation state, if there are some error will show a screen indicating the sequence where the error has been found and the cause.

When the program makes the compilation, compiles each sequence one by one separately, but could be necessary if the project requires it, make a special compilation, where the program compiles the sequences all together, to do it select from menu -> Program -> Compile -> Compilation Options. Then a windows appears, where is possible to insert command line parameters for the compilation. Available commands:

\nocheck

Compile all sequences together

Once the program is compiled, is necessary to transfer it to Virtual PLC CPU, to do it, launch Virtual PLC CPU (if is not running), is possible also to launch it from EasyPLC Editor tool bar. Then EasyPLC Editor must to be connected with Virtual PLC CPU in order to transfer the logic program. Press Connect OnLine with PLC to connect, or press menu Connection -> Connect with Virtual PLC. When connected, press Transfer Program to PLC tool bar icon or from menu Program -> Transfer to PLC. A progress bar will indicate the transfer status. A faster way is possible, if you press Compile and Send from tool bar or click on menu Program -> Compile and Transfer, then automatically will be done the compilation and the transfer of the program to Virtual PLC CPU. When a compilation is made, the object code of the program is saved inside it. When the program is transferred to Virtual PLC, a new file is created in the \Slot\ folder of EasyPLC installation path. This file is called logic.cmp and has all the necessary information to run the program by Virtual PLC CPU and for HMI System (if the logic program has screens). If the program is transferred in local mode, the file is copied locally, if is transferred in remote mode, Virtual PLC will generate it.

72

2.7 Cross References


With the cross references tool is possible to find any variable in the sequences of the current project. Select the variable name from the Select Item list, and press enter key or press Find Button. When a variable is found the sequence name, language and position appears in the Cross Reference window.

2.8 Printing
The logic programs can be printed. If you want to print your program, select Program -> Print Program from EasyPLC Editor menu. The Print Program Window appears and the user can select the sequence to be printed. Also is possible to select the printer, and change the zoom factor, useful for the graphic diagrams that must to be resized in order to fill it in the page. When the sequence is selected to be printed, the preview printer window appears in order to see the final results before to be printed.

73

2.9 Connection with Virtual PLC CPU


EasyPLC Editor can be connected with Virtual PLC CPU program for:

Upload a logic program (from EasyPLC to Virtual PLC) Download a program (from Virtual PLC to EasyPLC) Make a program debug, is possible while the program is running: o See Variables values o See Data blocks values. o See Graphic sequence status: the Ladder, Function Blocks and Grafcet sequences can show how their elements are changing during the program running. o Force variables.

The communication between EasyPLC and Virtual PLC CPU can be local or remote:

Local: the communication is done in the same machine. Remote: the communication is done in different computers connected to the same net.

2.9.1 Local & Remote connection modes


To connect in local mode with Virtual PLC, the Virtual PLC CPU parameterization form Hardware node must be set to Local.

To connect with Virtual PLC CPU from other computer connected in the same net, is necessary to set the Virtual PLC CPU Hardware parameters, indicating the IP address of the computer where Virtual PLC will be running and the listening Port.

The listening Port must be opened in the Firewall software available in the computer where Virtual PLC CPU is running.

74

In order the communication between EasyPLC editor and Virtual PLC CPU will be made successfully, Virtual PLC CPU must be running. To start the communication press Connect On-Line with PLC tool bar icon or select Connection -> Connect with Virtual PLC CPU from EasyPLC Editor menu. Once connected, the Editor will show the Virtual PLC Status.

2.9.2 Available Operations


When EasyPLC Editor is connected with Virtual PLC CPU, is possible to transfer the current compiled logic program, from EasyPLC Editor to Virtual PLC CPU (Upload operation), pressing the Transfer Program to PLC tool bar icon or from menu Program -> Transfer to PLC.

75

Also is possible to transfer the program form Virtual PLC CPU to EasyPLC Editor, this is called a download program operation. To download a program, EasyPLC must be connected with Virtual PLC, then press the Transfer Program from PLC tool bar button, or select Program -> Receive from PLC in EasyPLC menu. When EasyPLC is connected to Virtual PLC CPU, is possible to change the PLC working status clicking in the tool bar buttons: An important EasyPLC feature is the possibility to see the graphic languages progress while the Virtual PLC is running the logic program, EasyPLC Editor must be connected with Virtual PLC in order to allow this feature. In the next item is explained how.

2.9.3 Viewing logic programs running


Once EasyPLC is connected with Virtual PLC CPU, select the sequence you want to see in Run mode.

76

In red color is showed the active items. Also the Variables and Data Blocks states can be read.

Using this tool is possible to debug the logic programs, and to detect software or hardware anomalies. The Script C# language is the only is one without debug mode.

77

2.9.4 See/Force Variables


With the Read/Force PLC Items tool is possible to read/write PLC elements in run time (While the logic program is executing). Click in the Force PLC Variables tool bar icon or select form menu Connection -> Force Variables. A new windows will open, where is possible to select the item to read or write. Some items like digital/analogic inputs only can be read. Click on Add New Item menu and select the item you want. In the Current Value cell is showed the current element value, to change it, type the new value in the Change Value cell and press Force button, when you want to return to the normal situation (item managed by the PLC), click in the Release button.

Read/Force PLC Items only is available when EasyPLC Editor is connected with Virtual PLC CPU

78

2.10 EasyPLC Editor Customization


Click in the Tools -> Preferences EasyPLC menu, in order to configure some of the Editor options. You can change start options selecting:

None: then the editor won't open any program when start. Last Project: the editor will open the last loaded project. Select Project: the editor will open the selected project.

Also is possible to change the Font name and size of the Ladder and Logic Blocks Languages.

79

Other important tool is the possibility to unlock the logic program, then users can not modify it, but can run it with Virtual PLC and can transfer it. To protect a program, click on the program node name with right mouse button and select Project Properties, then in the project description window, select the check box Protect Logic Program. You must to inset a password. Once finished save the program, when you restart EasyPLC the program must to be locked.

To unlock the logic program, you must to select Program -> Program Password and type in the password window the correct password.

80

3. Virtual PLC CPU


3.1 Virtual PLC CPU Console
When Virtual PLC CPU is launched, dont show any interface screen. A Tray icon is showed in the Windows notify area (where is located the clock).

If you click with mouse right button a menu appears where is possible to:

View the PLC Rack. Change PLC Mode. Exit and close Virtual PLC CPU.

Clicking in the View PLC CPU Rack, will open the visual interface of Virtual PLC CPU. From this interface is possible to make some PLC operations like:

Change the PLC working status. Reset PLC program. Launch HMI System application. See connection parameters and status. See I/O status bits. See CPU clock parameters. See PLC Cycle Time Graph.

81

3.2 Operation Modes


Virtual PLC CPU has three operation modes, Stop, Run and Busy:

In Stop mode the PLC is stopped and the logic program is not executed. In Run Mode the PLC is executing the logic program cyclically; making the PLC scan cycle: the PLC program is executed as part of a repetitive process referred to as a scan. A PLC scan starts with the CPU reading the status of inputs. The application program is executed using the status of the inputs. Once the program is completed, the CPU performs internal diagnostics and communication tasks. The scan cycle ends by updating the outputs, then starts over. The cycle time depends on the size of the program, the number of I/Os, and the amount of communication required. Busy Mode: this mode is set when EasyPLC Editor transfers a program to Virtual PLC, once the program is loaded, Virtual PLC pass to Stop mode.

3.3 Virtual PLC CPU Modules


The Virtual PLC CPU interface will show the available modules in the project created with EasyPLC Editor. Always two modules are present, the CPU and communication modules.

3.3.1 CPU
In the CPU module is possible to:

View current PLC working mode. Change PLC Mode to Run/Stop modes.

3.3.2 Communication
In the Communication module is possible to see if EasyPLC Editor is connected or not.

Yellow light in connector: EasyPLC Editor is not connected. Green Light: EasyPLC Editor connected.

In order to connect with EasyPLC Editor in remote mode, is necessary to type the IP address of the computer where is running Virtual PLC CPU, if you click on the first Status Bar icon, you will see the available computer IP address to parameterize in the Virtual PLC CPU node of the EasyPLC Hardware Project tree.

The current PLC connection mode is showed in the status bar.

82

3.3.3 I/O Modules


Also are showed the I/O modules available in our project. When Virtual PLC CPU is in Run mode is possible to see the states of the I/O making double click in the bottom module area. If you make click in the bottom area of the I/O module a message status about the communication with the driver will be shown.

3.4 Scan Cycle Time Graph


Make click in the PLC Scan Cycle Time Graph status bar icon, in order to show a graphic diagram about the current Scan time cycle of the PLC. You can see in this graphic the current speed of the PLC scan cycle in milliseconds.

The current PLC scan cycle is showed in the status bar.

83

3.5 Virtual PLC CPU Clock


Clicking in the CPU Clock properties status bar icon will be show the Computer CPU clock capabilities. These values will inform about the timer resolution of the computer used. Is recommended to run Virtual PLC in a computer with High resolution timer in order to have the faster scan cycles. The CPU Frequency and CPU clock will give us an idea about the computer capabilities to run the logic programs.

3.6 Reset Virtual PLC CPU


To make a PLC reset, click on the reset PLC menu, then a PLC Rest will be done. The Reset must be done in Stop mode. When a reset is done, the PLC executes all the following actions:

Close communication with drivers. Reset all variables. Reset all Data Blocks.

84

4. HMI System
The HMI system will show and manage all the HMI screens available in the project. These screens make up the man machine interface for the exchange of information between the plc and the user. HMI System program can be launched from:

EasyPLC Editor menu (select Connection -> Launch HMI System). Virtual PLC CPU menu (select HMI -> Launch HMI Application). Executing directly the file HMI_System.exe.

HMI System can run in local mode (in the same computer where is running Virtual PLC) or in remote mode (in a different computer connected in the same net). You must to be careful in the case HMI System is running in remote mode, because the logic program executed by Virtual PLC, located in the \Slot\ logic.cmp of the remote machine, must to be copied manually in the computer where is executing HMI System (in the location \Slot\ logic.cmp). When the program starts, will load the screen selected as default, and will be in communication with Virtual PLC CPU, executing the screens programs.

If the project does not have screens, HMI system will be empty. In the bottom status bar will display the status and connection mode of the PLC.

85

Here an example is showed of a HMI screen running with Virtual PLC CPU. Pressing the command buttons is possible to change PLC variables values, also using the chart contro,l the value of variables are showed in a graphic format.

86

APPENDIX
4.1 EasyPLC Script C# Language Quick Guide
C# is case-sensitive. Semi colon (;) is the statement separator. Data Types

Type Heading Here

Arrays

String Operations

87

DateTime and TimeSpan

Struct

Enum

88

Formating numeric and date values

89

Language Fundamentals

90

Class Definition

91

Keywords
Keywords are predefined reserved words with special syntactic meaning. The language has two types of keyword contextual and reserved. The reserved keywords such as false or byte may only be used as keywords. The contextual keywords such as where or from are only treated as keywords in certain situations

C# keywords, reserved words abstract as base bool break by byte case catch char checked class const continue decimal default delegate do double descending explicit event extern else enum false finally fixed float for foreach from goto group if implicit in int interface internal into is lock long new null namespace object operator out override orderby params private protected public readonly ref return switch struct sbyte sealed short sizeof stackalloc static string select this throw true try typeof uint ulong unchecked unsafe ushort using var virtual volatile void while where yield transition Transition

Literals
Integers hexadecimal decimal float double date char
0xF5, 0x[0..9, A..F, a..f]+ 245, [0..9]+

Floating-point values
23.5F, 23.5f; 1.72E3F, 1.72E3f, 1.72e3F, 1.72e3f 23.5, 23.5D, 23.5d; 1.72E3, 1.72E3D, ...

Dates
not possible

Characters
'a', 'Z', '\u0231'

92

Strings String
"Hello, world" "C:\\Windows\\", @"C:\Windows\"

Characters escapes in strings Unicode character \u followed by the hexadecimal unicode code point \t Tab \b Backspace Carriage return \r \f Form feed \\ Backslash \' Single quote Double quote \" \n Line feed

Constants
Constants are values that are immutable and can not change.

const
When declaring a local variable or a field with the const keyword as a prefix the value must be given when it is declared. After that it is locked and cannot change. They can either be declared in the context as a field or a local variable. Constants are implicitly static. const double PI = 3.14;

Operators Operator category Operators + - * / % Arithmetic & | ^ ! ~ && || Logical (boolean and bitwise) + String concatenation ++ -Increment, decrement << >> Shift == != < > <= >= Relational = += -= *= /= %= &= |= ^= <<= >>= Assignment . Member access [ ] Indexing ( ) Cast ? : Conditional Delegate concatenation and removal + new Object creation as is sizeof typeof Type information checked unchecked Overflow exception control * -> [] & Indirection and Address 93

Mathematic Operations
Below are the mathematical functions available for all languages.

FUNCTION
Sin(float v) Sin(double v) Cos(float v) Cos(double v) Tan(float v) Tan(double v) Asin(float v) Asin(double v) Acos(float v) Acos(double v) Atan(float v) Atan(double v) Abs(float v) Abs(double v) Pow(float v, float y) Pow(double v, double y) Log(float v) Log(double v) Log10(float v) Log10(double v) Sqrt(float v) Sqrt(double v)

RETURNS
Returns the sine of the specified angle (float) Returns the sine of the specified angle (double) Returns the cosine of the specified angle (float) Returns the cosine of the specified angle (double) Returns the tangent of the specified angle (float) Returns the tangent of the specified angle (double) Returns the angle whose sine is the specified number (float) Returns the angle whose sine is the specified number (double) Returns the angle whose cosine is the specified number (float) Returns the angle whose cosine is the specified number (double) Returns the angle whose tangent is the specified number (float) Returns the angle whose tangent is the specified number (double) Returns the absolute value of a floating-point number. Returns the absolute value of a double-precision floating-point number. Returns a specified number raised to the specified power (float) Returns a specified number raised to the specified power (double) Returns the natural (base e) logarithm of a specified number (float) Returns the natural (base e) logarithm of a specified number (double) Returns the base 10 logarithm of a specified number (float) Returns the base 10 logarithm of a specified number (double) Returns the square root of a specified number (float) Returns the square root of a specified number (double)

94

4.2 Function Examples


Functions are a very powerful tool in order to structure the programs, here are explained some examples with different languages. Here is showed a logic program with two sequences and three functions, one function is written in script language, the second in ladder and the last in logic blocks:

Function Add is written oin script code, return an integer value and are passed two parameters of integer type. Function Activate is written in ladder none is returned and is passed to Boolean values. Alarms function is written in logic blocks language, none returns and is passed three boolean values. Lets see the functions codes:

95

You can see how the parameters declared in the functions can be used in the different languages to operate with them. Now lets see how these functions can be called from other sequences (or functions):

96

In this example, in Main_Sequence_1 (Ladder) is used the special coil Function, there is possible to call to the declared functions (in any language written) and passing the parameter with variables or constants. In Main_Sequence_2 (script) is show how to call the Alarms function.

97

Functions can be exported and/or imported, to do it select from menu Program -> Export/Import Functions or from program tree in Functions node, right mouse click and select Export/Import Functions.

Functions can be exported and/or imported, to do it select from menu Program -> Export/Import Functions or from program tree in Functions node, make right mouse click and select Export/Import Functions. Then in the new window, you can export the defined functions in your program, selecting the desired one in the Export list and clicking in the Export Function to File. To import a function form other program, press Import Function from File button, then a dialog box appears to select the file that contains the previously exported function.

98

More
Please visit often www.nirtec.com web site and Nirtec forum to check for new information, updates and new articles like new tutorials or programming examples. I hope you enjoy EasyPLC Software Suite. If you have some question or doubt, please email me to: Info@nirtec.com easyplc@nirtec.com

EasyPLC Software Suite

99

Idea, Design & Programming by Rafael Izquierdo Valencia (Spain) Copyright Rafael Izquierdo 2011

www.nirtec.com
100

Você também pode gostar