Getting started with UniOP and CoDeSys integrated controller This technical note explains the sequence of steps to create a very simple CoDeSys project together with its companion Designer application. The installation procedure of the software and the UniOP target is not described in this document; please refer to TN200 and to the related documentation provided by 3S Software. The technical note assume to use CoDeSys programming software V2.3 and Designer 6.04 or above. Contents 1 Starting with CoDeSys V2.3...3 2 Preparing the Designer application...7 3 Continuing the programming...12 4 Appendix 1...15 Getting started with UniOP and CoDeSys integrated controller 1
Sn021 Ver. 1.01 2004 Sitek S.p.A. Verona, Italy Subject to change without notice The information contained in this document is provided for informational purposes only. While efforts were made to verify the accuracy of the information contained in this documentation, it is provided as is without warranty of any kind. www.exor-rd.com Getting started with UniOP and CoDeSys integrated controller 2
1 Starting with CoDeSys V2.3 1) Start the CoDeSys workbench from the start menu; by default, CoDeSys software opens the last opened project. 2) Select File / New to create a new project 3) Depending on the SCM module, select the proper target configuration from the list of available platforms; in case of an SCM03-C module, select "Exor/SITEK CoDeSys for SCM03 " as target 4) In the "New POU" dialog box displayed after the previous confirmation, select the language you want to use for the PLC_PRG Program Organization Unit (POU). This program is the main module of your project that is calling all the other POUs of your application. Please, don't change the name of this POU. 5) To complete the settings of your project, click on the "Resources" tab in the project tree open then "Workspace" with a double click Getting started with UniOP and CoDeSys integrated controller 3
6) In the "Options" dialog box, select first "Symbol Configuration", check the "Dump symbol entries" and finally, press the "Configure symbol file " button: 7) In the "Set object attributes" dialog box, the "Export variables of object" is grayed-out and need to be unchecked and marked back again. This is the final result: IMPORTANT : Please, look at appendix 1 for new information Getting started with UniOP and CoDeSys integrated controller 4
8) Double click now on the PLC Configuration item of the Resource tree: 9) In the "PLC Configuration" dialog box, right click on the "SITEK SCM03 " and select in from the "Append Sub element" the hardware configuration you need to use in your project, following pictures shows how to insert the uim05 digital inputs. Getting started with UniOP and CoDeSys integrated controller 5
10) You are now ready to start writing the PLC program; the following picture shows a very simple example using the Ladder diagram programming language: During this phase, the variables are declared automatically. Some of them are "local", others are "Global". These variables will be exported to a file that we will use in our UniOP Designer project importing them directly into it. The CoDeSys symbols used to name the variables can be exported to a text file after the project has been compiled. 11) Select menu "Project / Rebuild all" to compile the project When building the application the CoDeSys software automatically creates a file with extension.sym stored in the same project folder; this file contains all the variables declared in the project and can be used later in Designer to import them into the project. 12) If there are no errors in the project, the Message window will appear as following: Getting started with UniOP and CoDeSys integrated controller 6
2 Preparing the Designer application 1) Create a new project, select the folder and the name of the project 2) Select the UniOP model from Panel Setup and open "Project / Configure Controller " menu. In the "Configure Controller" window, select "Internal controller only" and click "Ok". In the next dialog box select CoDeSys and confirm 3) Since CoDeSys PLC does not use fixed addresses, we will need to connect the project to a tag dictionary and import the symbol file we exported during CoDeSys "build project" phase. Select then "Tools / Tag Editor'" from Designer Start now Tag Editor form the Tools menu and select "File / New"; create a new database choosing its name and its location. Right click the database icon in the tree and select "Import Tags" Getting started with UniOP and CoDeSys integrated controller 7
4) Designer will start now a quick wizard to import the CoDeSys symbol file; in the Step1 select a name for the dictionary and in the list of controller drivers make sure you have selected iplc CoDeSys corresponding to the file "D32Uplc196.dll" Click "Next" 5) In the Step 2 use the reference button to locate the CoDeSys symbol file; the file is normally store in the same folder where it was saved the PLC application Click "Next" and "Finish" to complete end the import process The Tag Editor wizard ends showing the information about the number of imported tags as shown in the following example: (number of imported tags is of course project dependant) IMPORTANT : Please, look at appendix 1 for new information Getting started with UniOP and CoDeSys integrated controller 8
6) The tag dictionary is now ready to be used in the Designer project to create the UniOP application: 7) In Designer select now Project / Configure Tag Dictionaries enable the tag support and browse for the database file created in the previous steps: Getting started with UniOP and CoDeSys integrated controller 9
8) Create your project using the normal procedure. Variables for the project can be selected from the list of imported symbols: 9) Let s now consider the following example as final result of the Designer application: What are these two buttons "1" and "2"? These buttons are Generic Buttons programmed with the macro commands for port assignment. We will use the same cable and same PC/Printer UniOP port to program both devices (HMI and iplc). The "PC port for UniOP" will assign the PC/Printer port to the UniOP for Designer programming; note that the port is automatically assigned to the UniOP when the panel is in Configuration Mode. The "PC port for SCM03C" will connect the PC/Printer port to the SCM module for CoDeSys programming. This is the macro definition for "PC port for UniOP" button Getting started with UniOP and CoDeSys integrated controller 10
And this is the macro definition for "PC port for SCM03C" button The port assignment can be also done directly from the HMI in the System Menu: - enter the command menu (press for 2 seconds on the touch screen or 2 seconds on the ENTER key on non touch screen HMI) and select "SYSTEM" - in the System menu scroll the cursor down until you reach the "PRINTER...OFF- LINE" line - Use left and right arrows to change the settings: -- "SCMxx #0 APPLICATION" when you want to download the iplc project with CoDeSys -- "OFF-LINE" when you want to download the UniOP project with Designer - Select then "EXIT" to go out of this system menu. 10) Now, you are ready to download your projects (UniOP and CoDeSys) to your HMI - Use standard procedure to download your UniOP project to the HMI with designer. - When the panel is in operation Mode, use the "PC port for SCM03C" button to reserve the PC port for CoDeSys. - In CoDeSys software, select then "Online / Login" menu to connect with the SCM module - CoDeSys will now display a message according to the status of the SCM module; if the module has already an application loaded on it the following message is displayed: - at the end of the download the PLC_PRG POU will be automatically displayed in monitor mode on the CoDeSys programming software. 11) By default the CoDeSys application is downloaded in the module RAM memory; to keep it at power cycle you need to store the project in the internal SCM flash memory; create then the Boot Project": the PLC application is stored in the flash memory and it will be automatically started at each power cycle. The boot project can be created form "Online / Create boot Getting started with UniOP and CoDeSys integrated controller 11
project" while in On Line mode. 3 Continuing the programming Each time you modify the iplc application, you need to recompile your project. Since CoDeSys uses dynamic variable allocation done at each project build, you cannot be sure that the previous internal addresses used to store the variables are still valid after the last compilation of the project. This means that Tag Dictionary needs to be upgraded each time the iplc project is re-compiled. 1) Select the "Tools / Tag editor" in Designer to re-open the Tag Editor window 2) Right click on the tag dictionary name and select "Import Tags" 3) Confirm you want to overwrite the existing tag dictionary 4) Click "Next" in the "Step 1" dialog box 5) Use the reference button to locate the new version of the ".SYM" file generated by CoDeSys. You can verify the generation date if you select the "detail" display mode Click "Next" when the right file is selected. Getting started with UniOP and CoDeSys integrated controller 12
Click "Finish" in the next window to complete the process Tag Editor reports finally the number of imported tags. Close the Tag Editor window and return to Designer Note : with last versions of Designer and TagEditor, the process is shorter because you can select at point 2) above the option "Re import tags from [.Sym file previously selected]" 6) Select now the "Project / Tag Validation" menu to check the validity of the addresses used in your UniOP project. - If Tag validation reports "All the tags match with the field address values", no additional actions are required: - sometimes however, the Tag validation process could detect changes into addresses used to store your variables and will display for example a report similar to the one in the following picture: Getting started with UniOP and CoDeSys integrated controller 13
Select the line(s) where a change is detected and right click to select "Update Field (with database values)" to adapt your UniOP project accordingly to the new iplc application. 7) The Designer project needs then to be downloaded again to UniOP. Getting started with UniOP and CoDeSys integrated controller 14
4 Appendix 1 In case you use UIMxx module defined in PLC configuration, the next message can be reported while importing into TagEd the.sym file generated by CoDeSys : This message means that two variables with same name are present in the sym file which causes double index definition in mdb file. In fact, I/O variables are defined twice in the project : - first definition in "PLC configuration" - second definition in "Global variable" If "export ALL variables" is selected as explained in section 1 point 7) above, the sym file will contain the two definition which causes the trouble during import in TagEd! To avoid this, please follow the next steps : In the "Set object Attributes" dialog, unselect the "Export variable of object" checkbox. This is the view of the current situation : Click on "POUs" section to select only this one. Pressing the "Ctrl" key on your keyboard, select then the "Global Variables" to add this section in the current selection. Finally, select again the "Export variables of object" checkbox. Getting started with UniOP and CoDeSys integrated controller 15
This is the view of the final situation. Press "Ok" to close the dialog. By this way, the "PLC Configuration" section is not exported and the sym file will not contain any double variable definition. Import ou RE import this sym file with TagEditor using usual way. Pay attention that this process must be repeated each time you add a new POU in your project or the new variables will not be exported in the sym file. Getting started with UniOP and CoDeSys integrated controller 16