EasyPLC v.5 Help Manual
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.4 How to Register EasyPLC
2. EasyPLC Editor 2.1 Program Interface 2.2 Hardware Configuration 2.2.1 Virtual PLC CPU Parameters 2.2.2 I/O Devices 126.96.36.199 Add a New Driver 188.8.131.52 Remove a Driver. 184.108.40.206 Available Drivers 220.127.116.11 How to Develop an EasyPLC Driver. 2.3 Software Structure 2.3.1 Variables 2.3.2 Program Modules 18.104.22.168 Init 22.214.171.124 Main. 126.96.36.199 Functions 188.8.131.52 Common Area 2.3.3 Data Blocks 2.3.4 Plugins 2.4 Languages 2.4.1 Ladder 184.108.40.206 Contacts 220.127.116.11 Coils 18.104.22.168 Segments 22.214.171.124 Read/Write Analogic/Digital I/O 126.96.36.199 Using variables 188.8.131.52 Comparator 184.108.40.206 Counters 220.127.116.11 Timers 18.104.22.168 Data Blocks 22.214.171.124 Function Call 126.96.36.199 Register Transfer 188.8.131.52 Comments 184.108.40.206 Shortcuts Keys 220.127.116.11 Special Coil (Return) 2.4.2 2.4.3 2.4.4
Script Function Blocks Grafcet
2.5 HMI 2.6 Compilation & Transferring logic program to Virtual PLC 2.7 Cross References 2.8 Printing 2.9 Connection with Virtual PLC CPU 2.9.1 Local & Remote connection modes 2.9.2 Available Operations 2.9.3 Viewing logic programs running 2.9.4 See/Force Variables 2.10 EasyPLC Editor Customization
3. Virtual PLC CPU 3.1 Virtual PLC CPU Console 3.2 Operation Modes 3.3 Virtual PLC CPU Modules 3.3.1 CPU 3.3.2 Communication 3.3.3 I/O Modules 3.4 PLC Scan Cycle Time Graph 3.5 Virtual PLC CPU Clock 3.6 Reset Virtual PLC CPU
4. HMI System APPENDIX 4.1 EasyPLC Script C# Language Quick Guide 4.2 Functions Examples
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 PLC’s 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 you’ll 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.
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
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.
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 there’s 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. It’s 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.
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.
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).
18.104.22.168 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.
22.214.171.124 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.
126.96.36.199 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
188.8.131.52 How to Develop an EasyPLC Driver Please refer to the EasyPLC v.5 SDK Guide.
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. It’s possible to add a description for each variable, then will be easiest to debug the logic programs.
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.
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.
184.108.40.206 Init The sequences inside the Init Program node only will be executed once, when the program starts. Useful to program initialization routines.
220.127.116.11 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.
18.104.22.168 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 can’t return any value.
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)
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.
22.214.171.124 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.
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.
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 software’s. 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.
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 it’s a contact/coil group. The contacts are the conditions that are evaluated to make an action, the coils are the actions. Now let’s see the EasyPLC Ladder structure.
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.
126.96.36.199 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 contact’s 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.
188.8.131.52 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.
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 coil’s 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.
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.
184.108.40.206 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.
220.127.116.11 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.
Let’s 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.
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 we’re 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.
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.
18.104.22.168 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.
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”.
22.214.171.124 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 (=), minor or equal ( Program Password and type in the password window the correct password.
3. Virtual PLC CPU 3.1 Virtual PLC CPU Console When Virtual PLC CPU is launched, don’t 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.
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.
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.
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.
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.
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.
APPENDIX 4.1 EasyPLC Script C# Language Quick Guide C# is case-sensitive. Semi colon (;) is the statement separator. Data Types
Type Heading Here
DateTime and TimeSpan
Formating numeric and date values
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
0xF5, 0x[0..9, A..F, a..f]+ 245, [0..9]+
Floating-point values float double
23.5F, 23.5f; 1.72E3F, 1.72E3f, 1.72e3F, 1.72e3f 23.5, 23.5D, 23.5d; 1.72E3, 1.72E3D, ...
'a', 'Z', '\u0231'
"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.
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.
Pow(float v, float y)
Returns a specified number raised to the specified power (float)
Pow(double v, double y)
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)
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. Let’s see the functions codes:
You can see how the parameters declared in the functions can be used in the different languages to operate with them. Now let’s see how these functions can be called from other sequences (or functions):
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.
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.
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: [email protected] [email protected]
EasyPLC Software Suite
Idea, Design & Programming by Rafael Izquierdo Valencia (Spain) Copyright © Rafael Izquierdo 2011