training manual v23 1006 ifm

Upload: ovidiu-ciobanu

Post on 04-Feb-2018

234 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/21/2019 Training Manual V23 1006 IFM

    1/139

    Training manual 1

    R

    Controller family R360

    for CoDeSys starting version 2.3

  • 7/21/2019 Training Manual V23 1006 IFM

    2/139

    Training manual ecomatmobiletype R360

    You will find more details at: www.ifm-electronic.com

    Training Manual CoDeSys 2.3, 10/ 2006, from software version V020102

    Guarantee note

    This manual was written with the utmost care. However, we cannot assume any guarantee for the

    contents.

    Since errors cannot be totally avoided despite all efforts we appreciate your comments.

    We reserve the right to make technical alterations to the product which might result in a change

    of contents of the manual.

    http://www.ifm-electronic.com/http://www.ifm-electronic.com/
  • 7/21/2019 Training Manual V23 1006 IFM

    3/139

    IR

    What you can find in this manual

    1. What you should know...........................................................1-1

    1.1. Required previous knowledge............................................................... 1-1

    1.2. Structure of the manual.......................................................................... 1-1

    How to find your way around .................................................................... 1-1

    1.3. Overview of the documentation............................................................. 1-2

    Printed media............................................................................................ 1-2

    Electronic media ....................................................................................... 1-3

    1.4. Hardware ................................................................................................. 1-3

    1.5. Features of a PLC ................................................................................... 1-5

    Cycle......................................................................................................... 1-5

    Time response .......................................................................................... 1-7

    Watchdog.................................................................................................. 1-9

    2. Installation...............................................................................2-1

    2.1. Hardware of the PC................................................................................. 2-1

    2.2. Software setup ........................................................................................ 2-1

    2.3. Program start .......................................................................................... 2-5

    2.4. Settings.................................................................................................... 2-7

    New project............................................................................................... 2-7

    Target........................................................................................................ 2-7

    Subsequent installation of the target......................................................... 2-8

    Main program.......................................................................................... 2-10

    Directories................................................................................................2-11

    Libraries.................................................................................................. 2-13

    PLC configuration ................................................................................... 2-16

    3. The start...................................................................................3-1

    3.1. Basics and concepts .............................................................................. 3-1

    3.2. A small ecolog CoDeSys project as a start .......................................... 3-3

  • 7/21/2019 Training Manual V23 1006 IFM

    4/139

    Training manual ecomatmobiletype R360II

    Description ................................................................................................ 3-3

    The first step ............................................................................................. 3-3

    Add Program............................................................................................. 3-5

    Defining variables ..................................................................................... 3-6

    Saving..................................................................................................... 3-13

    Other languages ..................................................................................... 3-14

    Program test ........................................................................................... 3-15

    Visualisation............................................................................................ 3-19

    1.3. Online test ............................................................................................. 3-31

    Preparations............................................................................................ 3-31

    Operating system.................................................................................... 3-32Online program test ................................................................................ 3-37

    Sampling Trace....................................................................................... 3-45

    Documentation........................................................................................ 3-51

    4. Exercises ................................................................................ 4-1

    4.1. Logic functions ....................................................................................... 4-1

    Example 1! Error! ...................................................................................... 4-3

    Example 2 ................................................................................................. 4-4

    4.2. Higher-level functions ............................................................................ 4-5

    Timer and counter function ....................................................................... 4-5

    Practical application.................................................................................. 4-6

    4.3. More details............................................................................................. 4-6

    Notes......................................................................................................... 4-6

    Cycle time ................................................................................................. 4-7

    Visualisation.............................................................................................. 4-9

    5. Models..................................................................................... 5-1

    5.1. Overview.................................................................................................. 5-1

    5.2. Task Drill .................................................................................................. 5-2

    5.3. Task: Robot ............................................................................................. 5-3

    5.4. Task: Milling system ............................................................................... 5-5

  • 7/21/2019 Training Manual V23 1006 IFM

    5/139

    IIIR

    5.5. Addressing.............................................................................................. 5-6

    5.6. Other remarks ......................................................................................... 5-7

    6. Appendix .................................................................................6-1

    6.1. Buttons .................................................................................................... 6-1

    File functions............................................................................................. 6-1

    Online functions........................................................................................ 6-2

    General editing functions .......................................................................... 6-2

    Editing functions for SFC .......................................................................... 6-3

    Editing functions for LD............................................................................. 6-3

    Editing functions for FBD .......................................................................... 6-4

    Functions for sampling trace..................................................................... 6-4

    Functions for Visualisation........................................................................ 6-5

    6.2. Quick reference guide ............................................................................ 6-7

    New project............................................................................................... 6-7

    Libraries and hardware configuration........................................................ 6-8

    6.3. Saving work........................................................................................... 6-10

    'Save as...' .............................................................................................. 6-10'Project' 'Merge...'.....................................................................................6-11

    'Export project...' 'Import project...' .......................................................... 6-12

    Library..................................................................................................... 6-12

    Clipboard ................................................................................................ 6-12

    Templates ............................................................................................... 6-12

    Other steps ............................................................................................. 6-12

    6.4. Remarks for solutions.......................................................................... 6-13

    6.5. Notes on the models............................................................................. 6-14

    Declarations............................................................................................ 6-15

    Sequence................................................................................................ 6-18

    Recap ..................................................................................................... 6-18

    Program structure ................................................................................... 6-19

    Individually defined function block .......................................................... 6-21

  • 7/21/2019 Training Manual V23 1006 IFM

    6/139

    Training manual ecomatmobiletype R360IV

    7. Index........................................................................................ 7-1

  • 7/21/2019 Training Manual V23 1006 IFM

    7/139

    1-1R

    1. What you should know

    In this chapter we will give you an overview of the following points:

    What previous knowledge is required to be able towork with this manual?

    What is the structure of this manual?

    How do you find your way around this manual?

    What information do you find in this manual?

    Why this

    manual?

    Every user knows the problem: new software and new hardware. You will come

    across many unknown issues which at the beginning take up a lot of time and

    thus money.

    When you work with the system more frequently you will find that many work

    steps keep repeating themselves. You no longer concentrate on how to create a

    new project or how to declare a variable but on the process to be controlled.

    This manual therefore describes in many details, step by step, the procedure of

    creating programs and handling the hardware.

    When you use this manual as recommended, you will be able to quickly reach

    your goal to effectively use the controller system ecomatmobile.

    1.1. Required previous knowledge

    This training manual is directed at people who have some basic technical

    knowledge. Some experience in controller technology and PLC programming

    skills are useful.

    1.2. Structure of the manual

    This manual provides learning support for starters. As experience increases

    more interim steps can be skipped.

    How to find your way around

    To facilitate work with this manual we have added some helps for you.

    To be able to directly get to a certain subject use the table of contents of this

    manual.

    The index will also help you get to the term you are looking for.

    At the beginning of a chapter we are giving you a brief overview of the contents

    of that chapter.

  • 7/21/2019 Training Manual V23 1006 IFM

    8/139

    Overview of the documentation

    1-2

    Headers The header of each page on the right provides you with the title of the current

    chapter. On the left you will find the current header of second order.

    Footnotes In the footnotes of each page you will find the chapter-related number of thepage.

    Selective

    reading

    In the marginal column you will find comments which make finding certain

    paragraphs easier for you.

    There you will also find pictograms and markings the meaning of which is

    explained below

    Note Paragraphs marked with this pictogram give safety-related information. Read

    these paragraphs very carefully.

    Arrow

    Here you are given important notes to help you with the correct handling of

    ecomatmobile.

    1.3. Overview of the documentation

    Working with a controller of the ecomat R360 system requires several

    documents. A brief overview should help you to cope.

    Printed media

    Catalogue

    Overview of the units with data sheets

    Manual for the program development with CoDeSys

    Software description

    System manual ecomatmobiletype R360

    Technical description, hardware-specific function blocks

    Mounting and installation instructions

    hardware specific, are supplied with the unit

    Training manual 1

    Step-by-step introduction

  • 7/21/2019 Training Manual V23 1006 IFM

    9/139

    What you should know

    1-3

    R

    Electronic media

    Online Help For some devices the system manual is

    replaced by the online help..

    It becomes more and more familiar that theprogrammer gets information just when

    needed. The search function and the links

    make it easy to work fast and effective.

    If you prefer to browse in a printed medium

    then you may just print out the online help. It is

    formatted in a way that you should get a well

    formatted print.

    Figure 1: Online Help

    www.ifm-

    electronic.com

    Each printed medium such as this manual will become obsolete sooner or later;

    looking at the speed of technical changes, rather sooner. This also applies to

    hardware and software. To find out about the current version, please see the

    web address indicated on the left. Usually you will find there updates of thesoftware and the current version of the documentation for downloading (e.g.

    page2-4). This concerns also the online helpFigure 1.

    1.4. Hardware

    In the training manual reference will be made quite often to the hardware. To be

    noted:

    The different types of the controller ecomatmobile type R360 (e. g. CR2500,CR0020, CR0505) vary in their different hardware configurations.

    For the programming software this means:

    http://www.ifm-electronic.com/http://www.ifm-electronic.com/http://www.ifm-electronic.com/http://www.ifm-electronic.com/
  • 7/21/2019 Training Manual V23 1006 IFM

    10/139

    Hardware

    1-4

    It has to be adapted to the hardware. The process is briefly described

    below. Further information is given in the programming or system manual.

    It might be necessary to change e.g. the addresses of inputs or outputs in

    example programs.

    It would be much too complicated to write an introduction into the software for

    each type. That is why as an example the handling of the controller

    CR0020 will be described.

    When you work with another type later on, this must, of course, be taken into

    account for the examples. Another subdirectory must be set and other libraries

    must be loaded. Since the type designation, here CR0020, is also used for the

    directory and file name, e.g. subdirectory ifm_CR0020 etc., this should be no

    problem. To keep the following text clear, this will not be pointed out separately.

    When, for example, you work with the starter set of the controller CR2500,

    virtually everywhere 0020 can be replaced with 2500 in the following examples.

    The only difference is that with the starter set some steps can be skipped. Here

    some settings have already been made to facilitate the start, e.g. the operating

    system has already been loaded. No harm is done, though, if for example you

    load the operating system once again for reasons of practical training.

  • 7/21/2019 Training Manual V23 1006 IFM

    11/139

    What you should know

    1-5

    R

    1.5. Features of a PLC

    Cycle

    The advantages of a PLC as compared to a conventional contactor controller

    does no longer need to be pointed out today. Now there are also controllers

    with mechanical and electrical features which are necessary for use in mobile

    machines, e.g. protection IP 67, high mechanical stability and electrical noise

    immunity. These may also be the reasons why the reader has decided to use

    the ecomat mobile system. For those who do not yet have any experience with

    a PLC some features which sometimes present problems will be briefly

    described in this chapter.

    Cyclical

    program

    processing

    One characteristic of PLC systems is the cyclical program processing. This has

    some consequences for programming which will be briefly shown below.

    Figure2: Cyclical Program Processing

    An example is to explain why this type of programming makes sense. Let us

    assume that the following instructions are in the program:

    If the selector switch is on 0 (logical FALSE), then switch the output "move

    to the left".

    If the selector switch is on 1 (logical TRUE), switch the output "move to the

    right".

    At first glance everything seems to be clear. The switch can either be on 0 or 1.

    However, it has to be noted that such a program is processed in sequence, e.g.

    instruction after instruction. Nevertheless, sometime the following event may

    come up (this is where Murphy's law applies):

    The selector switch is on 0, therefore the output "move to the left" is

    switched.

  • 7/21/2019 Training Manual V23 1006 IFM

    12/139

    Features of a PLC

    1-6

    At that very moment somebody flips the selector switch. If the state of the input

    were enquired about again, the condition for the next program step would also

    be fulfilled: the output "move to the right" would also be switched with a possibly

    spectacular result.

    It may also come to conflicts which cannot be seen and prevented duringprogram creation.

    Unambiguous

    signal states

    Thus the meaning of cyclical program processing is for example to ensure

    unambiguous signal states during program processing. The program works

    with the process data image.

    This is also of importance for the outputs. It is e.g. possible to switch an output

    to TRUE and then again to FALSE 10 times during program processing. This

    cannot result in "chattering" of the output, i.e. constantly changing its state. The

    state is clearly defined. During program processing only the state of one bit in

    the process data image changes. The last state is switched, i.e. provided to the

    physical outputs. The only objection to be raised is that the program structure isunclear.

    Priority This may seem quite theoretical but it does have some consequences for

    practical use. The priority of instructions can be determined in the program by

    their sequence!

    If, for example, there is an instruction in the program:

    if limit switch reached, then stop drive

    then it is usually placed behind the instruction for switch-on. Usually the

    conditions for switch-on and switch-off should not be fulfilled at the same time.

    If, however, due to a malfunction this does occur, then switch-off takes priority

    (compare pages 4-2 and4-3).

    Thanks to the cyclical program processing, reliability is provided due to

    unambiguous signal states. However, other consequences have to be put up

    with.

  • 7/21/2019 Training Manual V23 1006 IFM

    13/139

    What you should know

    1-7

    R

    Time response

    Only time-

    criticalprocesses

    If the time response is uncritical, if a ms does not matter, then the comments on

    the time response do not have to be taken into account.

    Cycle time The time the controller needs for one program cycle is called cycle time.

    How long is the

    cycle time?

    There is no easy answer to this question. It makes sense that it is longer for

    long programs and shorter for short ones. It also depends on the type of

    instructions. Logical conjunctions are processed considerably faster than for

    example arithmetic operations. The answer is not clear if there are jumps, for

    example. If the condition for the jump is fulfilled, a program section is skipped.

    In that case it is not processed. The cycle is shorter. If the condition for the jump

    is not fulfilled, the cycle time becomes longer.ms Therefore only an estimate can be given here. You can expect a short time

    from an efficient system such as ecomat mobile. It is indeed in the ms range.

    For shorter programs it may be shorter, for more complex programs it may be

    several ms.

    To determine the actual value of the cycle time:page 4-7.

    Now it is easy to understand the demands on input signals.

    An input signal has to be active at least during one complete program cycle.

    If a signal is shorter it depends if it happens to come at that point of time atwhich the inputs are read. Only then will it be recognised.

    Response

    time:

    This value is often used to characterise the time response of a PLC. This is the

    time that is needed to switch a signal from an input to an output. If you expect

    the worst case, this means twice the cycle time.

    Frequency In some cases, for example when evaluating encoder signals, you also have to

    ask about the frequencies that can be processed on the input.

    If the cycle time is for example 1 ms, the cycle frequency is 1 kHz. However,

    this does not mean that the frequency on the input can be 1 kHz. To recognise

    a pulse as a pulse, a FALSE signal and a TRUE signal have to be detected;

    otherwise the pulse cannot be distinguished from a static state. The signalfrequency must be half the cycle frequency at maximum. To allow possible

    fluctuations in practical use it should be significantly lower.

    To be more precise, this is only one necessary condition. If the signal frequency

    is higher than half the cycle frequency, the pulses can no longer be processed

    accurately. If it is lower, the signal shape also has to be taken into account. If,

    for example, the cycle frequency is 1 kHz and the signal frequency is 100 Hz,

    you could think you were on the safe side. If, however, the FALSE signal is 9.5

    ms and the TRUE signal only 0.5 ms, the pulses cannot be processed

    accurately. To be on the safe side it is necessary that the FALSE as well as the

    TRUE signal, each one separately, is longer than the cycle time.

  • 7/21/2019 Training Manual V23 1006 IFM

    14/139

    Features of a PLC

    1-8

    An unfavourable signal shape does indeed occur in practical use. If, for

    example, speed is to be monitored by evaluating the pulses of a puck, the

    TRUE signal is short if the diameter of the puck is small.

    An example is shown on the left side of Figure 3.Often metal screws are used

    in a plastic disc. If the signals are not detected reliably, a metal strip can be

    used. Its length should be 1/3 to 1/2 of the circumference. The optimum mark-

    to-space ratio of 1:1 can thus be easily obtained.

    Figure 3: Target Pucks for Rotational Speed Monitoring

    Frequency

    inputs

    Usually there are only higher frequencies if encoders with a high resolution are

    used. To be able to process higher frequencies the controllers have so-called

    frequency inputs. This ensures that signals up to 50 kHz are reliably detected.

    This is an exception from the usual cyclical program cycle.

    Filtering The maximum frequency for standard inputs is limited since they have a low-

    pass filter. Thus increased protection in the event of noise against interferencepeaks is obtained. On the other hand the frequency inputs are more

    susceptible.

    Optimisation The experienced PLC programmer knows ways to optimise the cycle time for

    time-critical processes. Since this manual is an introduction we will not discuss

    this any further here.

    Bus systems Using a bus system provides many advantages. In applications for mobile

    machines CAN is used as a rule ( Training manual 2: Introduction into

    working with CAN). The time response, however, can be negatively affected. If,

    for example, the input and the output are on separate CAN modules, the

    response time increases by the time needed for the communication.

    Time-critical pulses should therefore be put directly on inputs of the controller.

  • 7/21/2019 Training Manual V23 1006 IFM

    15/139

    What you should know

    1-9

    R

    Watchdog

    A PLC monitors itself if the cycle is correctly processed. The case that a

    program cycle is not complete is dangerous. Then no inputs are read. A change

    of the state on the input, e.g. "limit switch reached" cannot be processed. The

    status of the output cannot change, e.g. the drive keeps on running although thelimit switch has been reached.

    The watchdog function exists to avoid such states. If the end of the cycle has

    not been reached within a certain time which is started with each new cycle the

    watchdog becomes active. The controller is stopped and the outputs are

    disconnected. This time does, of course, depend on a maximum possible cycle

    time. In ecomat systems it is approx. 40 ms.

    What can cause such an event?

    Causes 1. Hardware error

    If a processor fails, for example, the controller must pass into a safe state.2. Program error

    We will describe this second point here in more detail. Those who already have

    some programming experience, for example on the PC, are especially

    vulnerable to such errors. In a PC program a window can be created with the

    text "Enter value" and an input field.Then the keyboard is enquired about if a

    value has been entered. If so, the value will be processed. If not, the keyboard

    will be enquired about again until the input has been made. It does not matter if

    the user has a coffee break, a lunch break or does something else during that

    time.

    There must not be any closed loop in a PLC program; only the program cycle

    itself may be such a loop. A possible cause of an unintended closed loop may

    be a backward jump. Since this is dangerous, a warning is issued during

    compilation of the program.

    In the worst case it is possible that the communication between the PC and the

    controller is impaired. Log-in is then no longer possible. In this case the

    downloader tool (page3-36)will help.

  • 7/21/2019 Training Manual V23 1006 IFM

    16/139

  • 7/21/2019 Training Manual V23 1006 IFM

    17/139

    2-1R

    2. Installation

    2.1. Hardware of the PC

    Minimum PC with Pentium processor

    MS Windows from version 98

    128 MB RAM

    Hard disk with 100 MB available

    Mouse and additional serial interface

    We recommend to use a current version of the software (operating system) and

    hardware, e.g. Ethernet interface.

    2.2. Software setup

    Set-up The installation is started as usual. If the autostart function of the CD-ROM drive

    is active, the ecolog software installer starts. The selection will be described

    below.

    Figure 4: Installer

  • 7/21/2019 Training Manual V23 1006 IFM

    18/139

    Software setup

    2-2

    Here we are dealing with CoDeSys 2.3. This is the software for programming

    the current hardware. Therefore the programming examples below were

    created using this version.

    Figure 5: Version

    The version you use depends for example on your hardware version, on the

    version of its operating systems, etc. If you use different versions it may

    become necessary to also install different software versions. You can, of

    course, install this and other programs subsequently, for example if you want to

    work with a PDM or with CAN modules. You may also want to install the

    documentation on your PC. To be able to see or print the documentation here

    or on CD you need Acrobat Reader. These installations will not be described in

    this training manual.

    The software is installed by clicking on Setup. The individual steps will not be

    described here.

    We recommend to adopt the default settings, e.g. the directory name, pathsetc. This will save unnecessary work. This will also make it easier to

    understand the following examples.

  • 7/21/2019 Training Manual V23 1006 IFM

    19/139

    Installation

    2-3

    R

    The following directories are then on the hard disk:

    C:\Program files\ifm electronic\CoDeSys V2.3 Program file CoDeSys

    There are the directories:

    Compile temporary auxiliary files

    Documents1

    device-specific information

    Help1

    help files

    Library general libraries of 3S

    there:

    PLCConf device-specific files

    For CAN users: here are the EDS files. If other devices are to be connected via

    CAN, their EDS files have to be copied into the directory PLCConf.

    Projects2 your projects, examples

    The directories with the comment 'Temp'which are created in 'Projects'can

    be compared with an automatic backup. They can be deleted without any

    problems. The only file that is absolutely necessary is *.pro .

    Targets target systems

    there

    ifm files for ifm devices

    there

    Help ifm-specific filesand e.g.

    ifm_CR0020cfg

    there finally the directories with the configuration data files. If

    several versions are needed, they have to be in separate

    directories, e.g. the directory:

    V030002

    Library

    there: general ifm-specific files, device-specific files in turn are in

    subdirectories, e.g.:

    ifm_CR0020

    in which there is the operating system and the specific library.

    1There are the versions in German, English and French.

    2For a better overview we recommend to create a subdirectory for each project.

  • 7/21/2019 Training Manual V23 1006 IFM

    20/139

    Software setup

    2-4

    If you work with different versions, to be seen from the version number, e.g.

    V030002, it is important to remember that the versions of the configuration data

    files and of the operating system match!

    This structure may seem a bit confusing. In general you are not confronted with

    it and therefore you do not have to worry about it.

    This structure is created by CoDeSys during installation. During program

    creation CoDeSys accesses the required files and searches for them in the

    defined paths. Therefore we advise against changing the directory structure

    after installation.

    If you work on several PCs, you have to remember that it makes the exchange

    of program files easier if the same directory structure is installed on each of

    these PCs.

    What does e.g.

    V020102

    (version

    number)

    mean?

    V02 is the actual version, 01 stands for the date of the update (release), 02 for

    the patch number. The current version can be found on the web (1.3). The

    new versions are, for example, required for the new hardware versions. We

    recommend to change this version only if it is necessary. It is a lot easier, if all

    systems used are of the same version, even if it is not the latest one.

    At any rate the downloader should also be installed (page 3-33).

    Figure 6: Downloader Setup

  • 7/21/2019 Training Manual V23 1006 IFM

    21/139

    Installation

    2-5

    R

    This is an important tool. Again, not each and every detail can be discussed

    here. Usually only the function described on page 3-33 et seqq is needed. In the

    event of frequent programming it is worthwhile to study this tool in detail (

    e.g. Notes in Help concerning the downloader).

    The installation should not present any problem. We recommend to adopt alldefault settings.

    2.3. Program start

    CoDeSys is started via the icon in the start menu, for example.

    Figure 7: Program start

    Info The information is displayed for a short time. If required, it can be called up

    under menu item Help, e.g. for checking which software version (in this case

    2.3) has been installed.

    An example program is loaded.

  • 7/21/2019 Training Manual V23 1006 IFM

    22/139

    Program start

    2-6

    Error message If one or several error messages are displayed, other paths may have been

    selected during set-up. For the time being they can be ignored. Further below

    we will describe the adaptations that will have to be made.

    The example program may look like this:

    Figure 8: Example Program

    We will not deal with this any further here. The continuous work on this project

    is made easier if the one opened last is loaded automatically during program

    start-up. Therefore the example program will open here. If you do not want this,

    you can change it via 'Project' 'Options'.

  • 7/21/2019 Training Manual V23 1006 IFM

    23/139

    Installation

    2-7

    R

    Figure 9: Project Options 1

    2.4. Settings

    New project

    Before starting with the programming of the controller you would normally have

    to make some additional settings. This has to be done for a configuration only

    once at the beginning, compare page 2-19.

    In the starter set all required settings have already been made. The following

    descriptions are only for information if you work with it.

    These settings are part of each project and they are saved with it. This way you

    can easily work on projects for various hardware configurations with the same

    user interface. To show how the settings are made we open a new project via

    'File' 'new'or a new project.

    Target

    A window to create the target system will open.

    Figure 10: Target System Settings

  • 7/21/2019 Training Manual V23 1006 IFM

    24/139

    Settings

    2-8

    By clicking on the arrow symbol the selection list will open. There the

    hardware you want to work with is marked. It can be identified by the article

    number.

    Figure 11: Target System Selection

    CR0020 is marked and acknowledged with .

    When a concrete target system has been selected, the window is enlarged

    considerably. Many tabs are for functions that are not supported by thishardware. CoDeSys is a universal programming system. The most important

    tab is the one for 'Network functionality'. There the parameters for

    communication are set via CAN. This is not a topic here (Training manual 2:

    Communication with CAN).

    But it is easier to prepare us for working with CAN just now. For this reason,

    please let the options 'Support parameter manager' and 'Support network

    variables'active. Then we have to append the subelement CANopen Master in

    the PLC Configuration (Figure 30). Then the topic CAN can be ignored for

    the moment.

    What has to be done, if the article number is not displayed in the selection

    screen?

    This will only happen with new hardware. Then the respective file will be

    ordered from ifm electronic or loaded from the Internet and installed

    subsequently.

    Subsequent installation of the target

    Since this happens occasionally, the process will be briefly described. If the

    required target is already in the selection list, this section can be skipped. You

    will continue with the Section 'Main program', page 2-10.

    It has to be noted that here files are not simply copied into a directory. To avoid

    errors due to an unsuitable directory structure, the Help program

    InstallTarget.exe will be used. It is directly in the CoDeSys V2.3 directory.

    After starting InstallTarget the following window will open:

    http://scan.pdf/http://scan.pdf/http://scan.pdf/http://scan.pdf/http://scan.pdf/
  • 7/21/2019 Training Manual V23 1006 IFM

    25/139

    Installation

    2-9

    R

    Figure 12: Start Window InstallTarget

    By clicking on the 'Open...'button the usual selection screen for files will open.

    In principle a number of control systems can be programmed using CoDeSys.

    This does, however, not mean that each target can easily be installed here as

    described. Which target is programmed in which way can be taken from 3S.

    Figure 13: Selection Screen InstallTarget

    In the example the installation CD was inserted in drive (E). Then the directory

    E:\CoDeSys_V23\Targets\ifm

    http://www.3s-software.com/http://www.3s-software.com/http://www.3s-software.com/
  • 7/21/2019 Training Manual V23 1006 IFM

    26/139

    Settings

    2-10

    was opened. The files that can be seen there have the extension: TNF (for

    target information). As an example ifm_CR0020_V030002.TNF is marked and

    'Open' is clicked on. At first you cannot see a big difference. There is only a

    new entry in the left box. By clicking on the '+' next to 'ifm' the structure is

    shown in detail:

    Figure 14: InstallTarget with Systems

    In Figure 14you can see that a CR0020... is already present in the right box.

    The installation may, however, make sense if there are different versions. Thereis also to be seen that the installation directory on top still has to be adapted,

    pages 2-1 andFigure 16.

    Then the new target can be installed. When the target has been successfully

    installed, the requested one can now be selected. The next step is like in the

    previous versions: the main program is added.

    Main program

    Figure 15: New Project

  • 7/21/2019 Training Manual V23 1006 IFM

    27/139

    Installation

    2-11

    R

    The inputs in this start window are of special importance. This will be described

    in more detail further below. For the time being we select the option FBDand

    confirm it by OK.

    A remark beforehand: Do not change the name PLC_PRG!

    Directories

    Search path Since the same programming surface is used for different hardware

    configurations, the required files need to be accessible. The device-specific

    files are listed in different subdirectories. It would be confusing to provide all

    of them right from the start. First, it has to be stated in which subdirectory

    they can be found.

    This is done via the menu items: 'Project' 'Options'. Select the category

    Directoriesin the displayed dialogue box that opens (Figure 16).

    Figure 16: Set Directories

    By selecting the target some entries have already been made.

    C:\Program files\ifm electronic\CoDeSys V2.3\Library\ etc.

    A very important entry is still missing, however. In addition it has to be

    indicated where the configuration files of the project are. This entry is not

    made automatically to enable working with different version numbers.

    By clicking on the button to the right of the field the selection screen will

    open.

  • 7/21/2019 Training Manual V23 1006 IFM

    28/139

    Settings

    2-12

    Figure 17: Project Configuration Directory

    After acknowledgment with the entry has been made:

    Figure 18: Directories Created

    Starter set If you work with different hardware types in other applications or e.g. in the

    starter set, the entry has to be adapted accordingly. Example:

    CR0020

    C:\ Program files\ifm electronic\CoDeSys V2.3\targets\ifm\ifm_cr0020cfg\VXXXXXX

    XXXXXX means: The version number may be different.

    Settings which are usually not preset were already made in the starter set. This

    makes it easy to work with the device right away.

  • 7/21/2019 Training Manual V23 1006 IFM

    29/139

    Installation

    2-13

    R

    Libraries

    Predefined

    functions

    A modern programming software to IEC 61131-3 should allow the

    administration of self-created program modules. They only have to be createdonce and can then be used as often as required. Administration in CoDeSys is

    handled via libraries. Furthermore, a number of standard functions and

    hardware-specific functions have been predefined. These libraries have to be

    loaded if necessary. Standard libraries are automatically integrated.

    File size Each added library makes the project file bigger. Therefore no unnecessary

    libraries should be added. At the beginning it may be difficult to judge which

    library is necessary and which is not necessary. A hint is given by the name of

    the library. If, for example the name is ifm_CR0020_V030002.lib, you will only

    need the library if you work with the unit CR0020. As experience increases,

    differentiation is getting easier. However, the file size is only critical with very

    complex programs.

    A consequence resulting from the keyword file size affects the program

    modules created. It is unfavourable to combine them all in one library. If they

    are separated it is easier to focus on those that are actually needed.

    No menu

    active

    If no project is open, most menu items are not active which can be seen by the

    grey colour.

    To activate them a project has to be opened. This is done via the menu item

    'File' 'New'or the respective button (you will find an overview of the buttons

    in the appendix, page6-1). The procedure was described above, chapter

    2.4.To be sure let us compare:

    The top line then reads:'CoDeSys - (Untitled)*'

    The name can be assigned when saving the file.

    Step by step The menus are context sensitive. In other words: the window 'Library

    manager' only opens (of course!) when a project is open. Here it becomes

    clear what is meant by "step by step" in the instructions. Those who are not

    familiar with the system should strictly follow the instructions. As experience

    increases more interim steps can be skipped.

    CR0020 as an

    example

    Below we will show how to prepare a project for the controller CR0020 as an

    example.Entries The menu items 'Window' 'Library Manager' open a window in which no

    standard entries can be seen on the top left.

    We see the standard.lib and some CAN libraries which are linked

    automaticallay. Again CAN is not the subject now.

  • 7/21/2019 Training Manual V23 1006 IFM

    30/139

    Settings

    2-14

    Figure 19: Library Manager with Standard.LIB

    A glance at the library manager shows what kind of module it is. This also

    explains the name of the library.

    Help If during program creation you are not sure which module is needed or what

    the inputs and outputs mean you have the possibility to call help via Helpin the

    toolbar. There you will find detailed descriptions and examples. Often it is faster

    and easier to call the library manager and to mark the respective module there.

    Then you can often find the information you are looking for in the declaration

    part (Figure 22 top right). This applies in particular to the device-specific

    libraries ( Figure 22). The help would be much too extensive if all device-

    specific modules were explained there. A glance at the library manager can

    save leafing through the manual.

    More entries can be made via 'Insert' 'Additional library'.

    Figure 20: Additional Library

    The available libraries are shown on a mouse click.

  • 7/21/2019 Training Manual V23 1006 IFM

    31/139

    Installation

    2-15

    R

    Figure 21: Selection of Libraries

    There are device-specific libraries which are in the corresponding subdirectory,

    e.g. ifm_CR0020 together with other configuration data files. In addition there

    are mostly device-independent libraries which are needed for the operation of

    CAN networks, for example.

    Library

    Now a library is added as an example. As before reference is made to CR0020.

    After adding the library manager looks like this:

    Figure 22: Library Manager 2

    Right now the PWM100 module is open. It is used to activate PWM outputs

    (PWM = Pulse widths modulation, e.g. on proportional valves).

    The directory structure must be observed!

    In CoDeSys V2.3 there is also a directory

    'Library'. It includes general libraries of 3S but

    not the ifm libraries!

  • 7/21/2019 Training Manual V23 1006 IFM

    32/139

    Settings

    2-16

    We are not done yet! Programming not only requires the library files but also

    e.g. the operating system or predefined system variables. It is therefore not

    sufficient to only insert the libraries in the manager. In addition the settings

    have to be verified and possibly adapted during PLC configuration.

    PLC configuration

    CR0020 Here again we refer to the device CR0020. As mentioned above, the respective

    settings have already been made in the starter set so that we do not have to

    worry about them. For a new project for the starter set the library

    ifm_CR2500_VXXXXXX is added again. Since the features of the hardware

    versions are fixed, various variables have also been declared in advance.

    Declarations As is the case with each efficient software, variables are also declared in

    CoDeSys. Declarations, presentation, notations etc. are described in detail in

    the manual for the program development. In our manual we will describe this

    process briefly in the individual steps (e.g. page 3-44).

    Below we will describe the hardware configuration in brief.

    You click on the 'Resources' tab in the

    navigation bar and double click on 'PLC

    Configuration'(then you can also check

    if the libraries have been integrated). At

    first the respective window is empty. The

    selection screen indicates

    _not_found:(Figure 24).

    Figure 23: Navigation Bar Resources

  • 7/21/2019 Training Manual V23 1006 IFM

    33/139

    Installation

    2-17

    R

    Figure 24: PLC Configuration Empty

    If the PLC configuration had been loaded directly together with the target

    settings, it would be difficult to work with different versions. Therefore the

    hardware configuration is entered manually.

    To ensure that the next step is successful it is absolutely necessary to enter the

    path to the configuration data files in the 'Directories'option,Figure 18.

    Then the 'Extras' menu is opened and there you click on 'Standard

    configuration'.

    Figure 25: Standard Configuration

    A question is displayed:

    Figure 26: Hardware Configuration

    After acknowledgement with 'Yes'the display should change now:

  • 7/21/2019 Training Manual V23 1006 IFM

    34/139

    Settings

    2-18

    Figure 27: PLC Configuration

    If you now click on '+' next to CR0020 and then double click on '+' next to

    'Inputs/Outputs' you can see the precision with which the hardware is

    represented in the PLC configuration.

    Figure 28: PLC Configuration Open

    Variables can be declared very easily (as global).

    Figure 29: Inputs for the Declaration

    In Figure 29above is shown that a double-click on 'I00'opens a field into which

    a variable name can be entered. In the part below the figure a comment has

    been entered.

    We have already activated the CAN functions in the target system settings.

    Then the system expects that a CAN node exists. To do so we will append a

  • 7/21/2019 Training Manual V23 1006 IFM

    35/139

    Installation

    2-19

    R

    subelement. Right-click on the configuration (Figure 27). Select the CANopen

    master in "Append Subelement". This facilitates working with CAN. Now this

    appendix need not be considered.

    Figure 30: Append Subelement

    Figure 31: Subelement appended

    Ready! Preparations are now finished and the work can start!

    Now the actual programming can start. For those who find it a little hard at first

    to go through the work steps at the beginning of a new project correctly and

    completely, the procedure is summarised in the appendix, page 6-7,once again

    without any detailed explanation as above.

    Master For those who process new projects quite often it is worthwhile to save theproject as Master_CR0020_V030002, for example. The name says what it is.

    Working with a master is facilitated by the menu item 'File' 'New from

    master...'. This opens any project with the name '(Untitled)*'. The * indicates

    that the project has not been saved yet. The new name is assigned when the

    file is saved. The menu item can, of course, also be used to create a new

    version of a completed project. You will get the same result as before with 'File'

    'Save as...', see page 3-29.

  • 7/21/2019 Training Manual V23 1006 IFM

    36/139

  • 7/21/2019 Training Manual V23 1006 IFM

    37/139

    3-1R

    3. The start

    This chapter is a kind of "introductory course for CoDeSys". You will get to know

    the operation and the handling of the program, i.e. you will get a brief insight

    into almost every function of CoDeSys.

    The most important part of this introductory course is the complete creation of a

    program example directly on your PC.

    3.1. Basics and concepts

    What is

    CoDeSys?

    CoDeSys is a complete development environment for the ecomatmobile

    system.

    CoDeSys is an easy-to-handle tool for creating control programs to IEC-61131-

    3.

    What is IEC-

    61131-3?

    IEC-61131-3 is an international standard for the creation of PLC programs. It is

    important to know that only the programming language has been standardised,

    not the programming surface (window structure, presentation of values in the

    online mode, data saving, etc.). The programming languages of CoDeSys meet

    this standard.

    What is a

    project?

    In CoDeSys a project is the combination of components. These components

    solve a given control task (e.g. sequential control of a device, signal pre-

    processing for a part of a plant, ...).

    Which are the

    main

    components of

    a CoDeSys

    project?

    The main components of a CoDeSys project are:

    - POUs (executable program)

    - structures (data organisation)

    - visualisations

    What

    programming

    languages are

    available?

    CoDeSys supports the following programming languages:

    - LD (ladder diagram)

    - IL (instruction list)

    - FBD (function block diagram)- SFC (sequential function chart )

    - ST (structured text)

    - CFC (graphical function block diagram)

  • 7/21/2019 Training Manual V23 1006 IFM

    38/139

    Basics and concepts

    3-2

    How is a

    project

    defined?

    The definition of a project includes:

    The hardware configuration

    - definition of inputs and outputs

    The creation of components

    POUs

    - structures

    - visualisations

    How do I test

    my project?

    The true test of a project is the commissioning of the actual system. On the

    other hand, the simulation mode of CoDeSys has proven to be a very valuable

    possibility for testing the program.

    What is the

    simulation

    mode?

    The simulation mode simulates the program run of the controller in the PC.

    This type of test without using the control system or the plant enables the

    elimination of errors at the desk, thus saving time and nerves. This effect canbe enhanced by displaying the simulated plant by means of corresponding

    visualisation screens.

    The use of the simulation in conjunction with the versatile debug functions

    (troubleshooting functions) in CoDeSys allows a simple and efficient complete

    program test.

    Which debug

    functions does

    CoDeSys

    have?

    CoDeSys includes the following debug functions:

    Forcing (writing) of I/Os and variables

    Definition of watch windows for data presentation

    Setting of breakpoints in the simulation mode (stop of the program run)

    Execution of programs

    - as single scan

    - from breakpoint to breakpoint in the simulation mode

    Sampling Trace (diagram of variables as a function of time)

    And the

    documentation

    ?

    The complete project can be documented at any time in whole or in parts or

    can be exported into a text file.

    Conclusion This overview shows that CoDeSys as a complete development environment

    for your ecomat controller exceeds the functions of a common programmingsurface. Let's take a small project to show that we are not promising too much.

  • 7/21/2019 Training Manual V23 1006 IFM

    39/139

    The start

    3-3

    R

    3.2. A small ecolog CoDeSys project as a start

    Description

    This chapter will describe a short project demonstrating the basic steps in

    CoDeSys. The processes are more or less described like a "recipe".

    Task A lamp Cis to be ON when two switches Aand Bare closed. This really simple

    system can be shown as in Figure 32.

    Figure 32: Problem

    CoDeSys is now to

    implement and

    visualise this system.

    The first step

    The first steps usually are as follows:

    Start CoDeSys

    Open an existing project or start a new one

    For a new project: Integrate search path (directories), libraries and

    hardware configuration

    Starting a new

    project

    To start a new project select option 'File' 'New' or alternatively click on the

    button . This step was already described in 2.4,page 2-7.

    Target system

    and PLC_PRG

    Usually a new object is added via the menu.

    The main POU PLC_PRG is of particular importance. For a new project

    PLC_PRG should always be added after parameter setting of the target system

    as the next step. Therefore the windows 'Target system settings' and then

    'New POU'with the preset PLC_PRGopen automatically when a new project is

    started. FBD is already set as the language.

    The setting of the target system is not to be shown here once again. Those who

    find it difficult should study pages 2-7 et seqq. Below we will describe

    PLC_PRG in more detail.

  • 7/21/2019 Training Manual V23 1006 IFM

    40/139

    A small ecolog CoDeSys project as a start

    3-4

    As shown inFigure 15 and then again in Figure 33

    the object is to get the name PLC_PRG ,

    the type is to be programand the

    language is to be FBD.

    Figure 33: PLC_PRG as FBD

    FBD FBD was chosen because it is the language most frequently used.

    After clicking on a presentation similar toFigure 34 is displayed.

    Figure 34: PLC_PRG Window

    We have now added the module PLC_PRG to the project. PLC_PRG is

    executed cyclically and activates the modules (programs, functions, functionblocks; for details see below) called there.

    Please observe the following very important instructions:

    Allprojects must have oneand only onePLC_PRG.

    Allmodules to be directlyactivated via PLC_PRG, must be activated here,

    otherwise they will notbe executed!

    Check if all these points

    correspond

    Name: PLC_PRG

    Type: Program

    Language: FBD

  • 7/21/2019 Training Manual V23 1006 IFM

    41/139

    The start

    3-5

    R

    Point 1 has already been described. To illustrate point 2 we want to add a

    second program to the project and activate it with PLC_PRG to ensure its

    cyclical execution.

    Settings If you have not yet done so, work through the sections on pages 2-11to 2-19.

    Add Program

    Adding an

    P_AND

    Add a program with the nameP_ANDto the project with menu item 'Project'

    'Object' 'Add... '(Figure 35).

    The name must not be AND,for details about the term 'key words' see page

    3-6.

    Figure 35: Project Add Object

    A window similar toFigure 36should show.

  • 7/21/2019 Training Manual V23 1006 IFM

    42/139

    A small ecolog CoDeSys project as a start

    3-6

    Figure 36: Window POU P_AND

    Defining variables

    In the context of programming, the definition of the characteristics of a variable

    is called a declaration. Variables can be displayed as a table or a text. Below

    we will describe the text options.The selection Declarations as text is the

    default setting. It can be changed in 'Project''Options' 'Editor'if requested.

    Defining

    variables (text

    form)

    The new variablesA and Bare to be defined as binary, i.e. boolean. To do so,

    we proceed as follows:

    Move the cursor to the end of line 0002 and press the Enterkey (Figure

    37). A new empty line has been added as line 0003.

    Enter the definition as inFigure 38.

    Key word BOOL is a so-called key word. Its meaning is predefined. For example, it

    cannot be used as a name for a variable. Since CoDeSys knows the key words,

    the programmer is supported during entry. The notation, whether small or

    capital letters, is not important. After entering the text is checked and

    recognised key words are automatically represented correctly and highlighted in

    colour,Figure 38.

    Figure 37: Declarations as Text

    Move the cursor to the end of line

    0002 and press 'ENTER'. A blank line0003 shows.

    You can enlarge the upper part of the

    window by pulling down the

    separating line with the mouse.

  • 7/21/2019 Training Manual V23 1006 IFM

    43/139

    The start

    3-7

    R

    Figure 38: Declaration Entered

    There is an alternative to the declaration which will be shown shortly (Figure

    48).

    Add AND-

    operation

    Figure 39: Add box

    Mouse click on the first network (grey field with the number 0001 in the bottom

    part of the window) as shown in figure 41. The form of the cursor, here shown

    as a dotted rectangle, can be changed, if requested, via 'Project' 'Options'

    'Editor' Mark'.

    Now add the 'AND'

    by clicking on (Box) in the symbol bar or

    by activating 'Insert' 'Box (Figure 40)

    Figure 40: Menu Add Box

    Independent of the method you use, an AND box should now be added to

    network 0001 (Figure 41).

    Do not forget the semicolon

    at the end of the line!

    Network 0001 with

    dotted rectangle as

    cursor

  • 7/21/2019 Training Manual V23 1006 IFM

    44/139

    A small ecolog CoDeSys project as a start

    3-8

    Figure 41: Inserted Operator

    F2: The key Here we want to point out a possibility to help you program more efficiently andavoid typing errors at the same time: the key. When working with

    CoDeSys you often reach points requesting a selection between several input

    possibilities.

    You can see an example in Figure 41.CoDeSys has entered an ANDoperatorhere as default setting. The field with the coloured background (Windows

    standard setting is blue) signals such an option. Press to open a selection

    screen. Try it, and you will get a list of operators that can be used here or other

    boxes. You can select the requested operator by means of a double-click. This

    option saves a lot of typing and prevents typing errors! In our case the default

    setting AND is okay and you should close this selection screen by pressing

    (Figure 42).

    Figure 42: Input assistant

    Forgotten the

    settings

    A common mistake in the early stages is to open a new project and to forget the

    libraries and the hardware configuration (pages 2-13and 2-16) in the heat of

    the work. You will become aware of it when you use the Input assistant for a

    particular function block, for example. If you do not find it the reason why is that

    you probably have not linked any hardware-specific library, for example.

    If windows with such a colouredbackground appear on the

    screen, remember F2!

    Move the bar to the

    requested operator and

    select it with double

    click or 'OK'.

  • 7/21/2019 Training Manual V23 1006 IFM

    45/139

    The start

    3-9

    R

    Operands Add the operands Aand Bas inputs of the ANDoperator by replacing ???,

    Figure 43.You can also use ,Figure 44.

    Figure 43: Highlighted Input Field

    Figure 44: Input assistant for Variables

    Figure 45 shows the result.

    Figure 45: Add Operand

    The result of the operation has to be assigned to an operand. This is, for

    example, done by clicking on (Figure 46):

    A click to the right of the AND operator symbol generates a cursor (dotted

    rectangle) as shown in Figure 45.

  • 7/21/2019 Training Manual V23 1006 IFM

    46/139

    A small ecolog CoDeSys project as a start

    3-10

    Position of the

    cursor

    Here the editor is not very flexible. It happens again and again that you want to

    add an element which the editor refuses, however. In most cases the reason

    why is that the cursor is not in the right position. This is meant to prevent

    incorrect entries. You will usually find the right position of the cursor by trial and

    error.

    Figure 46: Add Operand

    Figure 47: Operand Added

    When you leave the input field (e.g. by simply clicking into the "free space") the

    system finds that variable C has not yet been defined and automatically opens awindow for the variable declaration (Figure 48).

    Figure 48: Window Declare Variable

    The entries in this window can be changed individually. In this case they are

    exact. A comment should be added.

    You should make it a matter of habit to add many comments. This is taking

    some time at the moment. However, you will save a lot of time for

    troubleshooting or modification of the program.

    After entering the comment you can acknowledge by clicking on . The

    variable declaration is now entered in the top part of our module window.

    Click on the IM - R icon and replace

    ???with C(overwriting)

  • 7/21/2019 Training Manual V23 1006 IFM

    47/139

    The start

    3-11

    R

    Figure 49: Declared Variables

    A and Bcould have been defined in the same simple and comfortable way. We

    just wanted to demonstrate the different selection possibilities for declarations.

    In Figure 49you can also see the syntax for entering comments. They can, of

    course, also be subsequently added or modified.

    Should the variable declaration window not open, the 'Autodeclararation'

    option in'Project' 'Options' 'Editor' has to be activated.

    Figure 50: Autodeclaration

  • 7/21/2019 Training Manual V23 1006 IFM

    48/139

    A small ecolog CoDeSys project as a start

    3-12

    Local In the fields class and type the default settings were simply adopted. We just

    want to point out that the variables in the example were declared locally. That

    means that the declaration only applies to the POU in which it is located, here in

    the program And. If a variable, e.g. an input, is to be used in several POUs it is

    easier to declare it as a global variable. Using the selection field type helps toavoid invalid declarations. During declaration the 'Autodeclaration' option also

    helps to prevent syntax errors which may cause confusing error messages in

    compilation, especially at the beginning.

    This completes our little POU.

    Activating

    P_AND in

    PLC_PRG

    The program P_ANDis to be activated in PLC_PRG. For this purpose activate

    the window of PLC_PRG (Figure 51) and call menu item 'Insert' 'Box'(Figure

    52).

    Figure 51: Enter program call in PLC_PRG

    At first the default box, the ANDoperator, is added. By clicking on F2the Input

    assistant opens. Select the 'User defined Programs'option on the left (Figure

    52). Then select ANDand in the box on the right. You activate P_ANDin network 0001 of PLC_PRG.

    1. Open

    PLC_PRGby

    double

    clicking2. Enter the

    program call

    Box

  • 7/21/2019 Training Manual V23 1006 IFM

    49/139

    The start

    3-13

    R

    Figure 52: Added POU

    And all this just

    for an AND?

    Of course, an AND operation can also be directly inserted in PLC_PRG. We

    have selected the way of activating the subroutine in PLC_PRG for an

    important reason. We wanted to demonstrate that all POUs (in this case POU

    P_AND) to be activated directly via PLC_PRG need to be listed there. It is

    therefore not enough to just create the POU.

    The POUs of a project are not activated automatically. They must be directly or

    indirectly activated by the PLC_PRG POU.

    Only thePLC_PRGPOU is automaticallyprocessed cyclically. That is why all

    other POUs have to be activated directly or indirectly byPLC_PRG.

    It is not sufficient for the execution of a module that it is entered in thePOU list

    of the project!.

    Saving

    At first, it will take some time for you to achieve this result. Later you will be able

    to program an easy link very fast.

    In each case it should become normal to save the result after each work step.

    This can be done e.g. via 'File' 'Save'or :

  • 7/21/2019 Training Manual V23 1006 IFM

    50/139

    A small ecolog CoDeSys project as a start

    3-14

    Figure 53: Save File

    When the project is saved for the first time, the window 'Save file as:...' opens

    automatically.

    Figure 54: Save File as...

    The directory Projectsalso opens (default). The file is now stored here. At the

    beginning it is clearer to save the files here in the default directory. For many

    projects it makes sense to create a subdirectory for each project (in Projects).

    Other languages

    And what about

    the other

    languages?

    At this point it would go too far to explain the other languages in more detail.

    Still, we want to show you our little program example in Instruction List, in

    Structured Text and in Ladder Diagram (Figure 55).

    Figure 55: Examples in Other Languages

    The CD contains further program examples giving an overview of the individual

    programming languages. They are described in detail in the manual for the

    CoDeSys program development saved on the CD as PDF file.

  • 7/21/2019 Training Manual V23 1006 IFM

    51/139

    The start

    3-15

    R

    What have we

    achieved so

    far?

    So far we have written two programs (PLC_PRG and P_AND). The subroutine

    P_AND was entered in PLC_PRG so that P_AND is now also activated by

    PLC_PRG.

    Program test

    How do we

    continue?

    Our project has now reached a stage where we can test if it meets our

    expectations. The first program test is normally carried out as follows.

    'Online'

    'Simulation

    Mode'

    Select the option 'Online' and make sure that the simulation mode is active.

    This is the case when you see a tick () before Simulation. Should that not be

    the case, click on 'Simulation Mode'(Figure 56).

    Figure 56: Simulation Mode

    'Online' 'Login' Selecting the option 'Online' 'Login'( Figure 56) or clicking on compiles

    the project. If a syntax error is detected, CoDeSys will give you a message in

    the Messages window and will refuse login. We cannot explain all possiblesyntax errors in this place. Double clicking on the error message automatically

    takes you to the faulty line. You can scroll from one error message to the next

    by pressing the F4key.

    Let's assume that the program contains no errors or that all errors have been

    corrected. In both cases the system should have logged in correctly.

    'Online' 'Start' Activate the program by 'Online' 'Start' (Figure 56) or press the F5 key or

    click on . The status line (shown below in the program window) should now

    show .

  • 7/21/2019 Training Manual V23 1006 IFM

    52/139

    A small ecolog CoDeSys project as a start

    3-16

    Display theP_Andprogram on the monitor (double click on the program name

    in the POU list on the left in the program window). The program window should

    look like Figure 57.

    Figure 57: Program Active

    If the status line cannot to be seen at all, activate it via the option 'Project'

    'Options' 'Operating range'. Just click to activate the tick .

    Change

    variable values

    As shown inFigure 57the values of the three variables A , Band C are FALSE

    (OFF). By means of the option 'Online' 'Write Values' the values can be

    changed as follows:

    Double click onFALSEat Aand Band TRUEappears as shown in Figure 58.

    This figure shows that the changes are not yet active! They have to be sent to

    the (simulated) controller first.

    ONLINE, SIM and RUN

    must now be active.

  • 7/21/2019 Training Manual V23 1006 IFM

    53/139

    The start

    3-17

    R

    Figure 58: Change Values

    This is done with option 'Online' 'Write Values'(Figure 59)or alternatively with

    the key combination + . The values of the variables Aand Bare

    now TRUE(= ON). This causes variable Cto change from FALSEto TRUE(the

    colour in the bottom part of the window changes to blue) as a result of the And

    link (Figure 60).

    The colour changes may be difficult to see on the (monochrome) printout of this

    manual. This shows that going through this manual does not replace the

    practical work with the controller. It is only meant to support you. You will get

    most benefit by putting the example in practice and trying own ideas.

    Figure 59: Write Values

    You can test other combinations of A and B in the same way, e.g. Figure 60.

  • 7/21/2019 Training Manual V23 1006 IFM

    54/139

    A small ecolog CoDeSys project as a start

    3-18

    Figure 60: Vary Values

    You should make it a matter of habit to use 'Write Values', if possible. The

    menu item 'Force Values'may be dangerous in practical use, Pages 3-18

    and4-9!

    If you like to work using the keys you had better use instead of

    simply !

    Those who want to know more about the difference should study the following

    paragraph.

    Forcing

    Besides the "manual" preset of input states, e.g. on the simulator box (3.3), it

    is also possible to force the states in the controller. This means that e.g. the

    state of an input is defined without any consideration of the actual state. When

    playing with the software without any inputs and outputs connected there is,

    however, no difference to the off-line program test in the simulation mode. In

    practice this function is more useful to the skilled user for debugging. The user

    should be skilled because forcing might start unintended processes when the

    controller is connected to the peripheral equipment. If you use this function you

    should know exactly the kind of damage that might be caused by a possible

    avoidance of safety scans in the program.

    Example When a new program or a new machine construction is tested, it is possible that

    a drive stops in an interim position without the end position having been

    reached. Then the drive has to be driven to the end position "manually". When

    the limit switch is used as a condition in a program module to stop the drive, the

    output for the drive can be set to TRUEusing 'Write Values'. As soon as the

    limit switch has been reached, the drive is stopped by the program. Here the

    program is of higher priority (also page4-9). E.g.:

    If 'Force Values'is used, the drive will no longer be stopped by the limit switch.This means that forcing the outputs should be avoided, if possible. It is only for

    inputs that forcing cannot be avoided.

  • 7/21/2019 Training Manual V23 1006 IFM

    55/139

  • 7/21/2019 Training Manual V23 1006 IFM

    56/139

    A small ecolog CoDeSys project as a start

    3-20

    Figure 62: Name Visualisation

    Figure 63: Visualisation Start Window

    Grid At first a grid is displayed in the default setting. If you do not need it, you can

    eliminate it in 'Extras' 'Settings...'.

    Drawing a

    picture

    Eighteen different types of elements can be drawn and animated with the

    visualisation. First, we will use the rectangle. The other elements are created

    and animated in the same way.

    Activate the option 'Insert' 'Rectangle'(Figure 64) or click on the button and

    draw a rectangle by

    placing the cursor on the empty screen

    pressing the left mouse key and keeping it pressed

    pulling the mouse to the bottom right until a rectangle of the required size

    appears

    releasing the mouse key.

    The result should be similar to Figure 65.

  • 7/21/2019 Training Manual V23 1006 IFM

    57/139

    The start

    3-21

    R

    Figure 64: Visualisation Insert Object

    Figure 65: Inserted Rectangle

    Context To establish a context between picture element and module variable you need

    to define a context between (visualisation) action and (variable) value.

    These entries are made in the screen 'Regular Element Configuration'. For

    entering variables can be used again. But first, the project needs to be

    rebuilt in order to generate the variable list. For this purpose, call option

    'Project' 'Rebuild all'. In this case, however, it is not necessary since we were

    logged in before (page 3-16 and the project is rebuilt automatically after login.

    Configuring

    element

    A double click on your new rectangle opens the window for the configuration of

    picture elements in the visualisation (Figure 66). For each category there are

    input fields describing the picture element. It is not necessary to make an entry

    for each field. First select the category Variables.

  • 7/21/2019 Training Manual V23 1006 IFM

    58/139

    A small ecolog CoDeSys project as a start

    3-22

    Figure 66: Variable Configuration

    To change the colour of the picture element (in this case the rectangle) movethe cursor to the field next to Change color: and press to open a screen

    for selecting variables (Figure 67). A double click on the P_AND module

    generates a list of the defined variables (Figure 68). Another double click on

    variable Agenerates a correct variable entry in the field Change color: in the

    Regular Element Configurationwindow. The assignment is now complete.

    Figure 67: List of Variables

    Double click on '+' next to 'P_And ' to

    open a list of the defined variables

    Here you can select different global

    variables of the project

  • 7/21/2019 Training Manual V23 1006 IFM

    59/139

    The start

    3-23

    R

    Figure 68: Variables of the POU

    F2 The Input assistant is particularly helpful in this context because it often

    happens that only Ainstead of P_And.A is entered. Then you will not get the

    result described further below, however. In this context we would like to remind

    you that A, for example, is a local variable. P_And.Ameans the variable A in

    the POU P_And. The assignment is thus clear.

    Interaction Interaction between the user and the variables of the system is to happen via a

    mouse click on the picture element. The state (TRUE/FALSE) of the assigned

    variable is to be changed and displayed accordingly (the so-called toggling, see

    Figure 69).

    Change colour The status of the variables is indicated by the colour of the picture element. This

    happens after the following assignment between picture element and variable

    value has been made:

    color variable FALSE

    alarm color variable TRUE

    Activate

    interaction

    Click on the category Input:

    To allow the user to change the variable value, click onToggle variable in the

    categoryInput and enter again P_And.A.

  • 7/21/2019 Training Manual V23 1006 IFM

    60/139

    A small ecolog CoDeSys project as a start

    3-24

    Figure 69: Input Toggle Variable

    Colour Select the screen'Regular Element Configuration' and click on 'Colors'.

    Figure 70: Regular Element Configuration Colors

    Click on to open the colour selection screen in the category

    Colors Figure 71. Select a colour by clicking and confirm with . As this is

    the colour for the FALSE state of the variable, we have selected grey for our

    example.

    Repeat this process for and, if requested, for the frame of the

    element . We have selected the colour green for the Alarm color

    Inside (TRUE state). However, as is usually the case with colours, this is, of

    course, always a matter of taste and discussion!

  • 7/21/2019 Training Manual V23 1006 IFM

    61/139

    The start

    3-25

    R

    Figure 71. Color Selection

    Text To give our rectangle a name, enter the letter A in the category Text. Thisdesignation is entered in the centre of the element.

    The window 'Regular Element Configuration'should now look like Figure 72.

    If this is the case, close by pressing .

    Figure 72: Regular Element Configuration: Text

  • 7/21/2019 Training Manual V23 1006 IFM

    62/139

    A small ecolog CoDeSys project as a start

    3-26

    Variable B (a

    simple copy)

    We now want to create another picture element for variable Bthat should look

    like the one for variable A. The option Copy/Pastewill be helpful. To do so:

    Click on element A

    Click on

    A copy of the element (with settings) is made (in the clipboard).

    Click on

    The copy is inserted in the picture above the original.

    Move the cursor to the new element A, press the left mouse key, drag the

    element to the requested position and release the mouse key (Figure 73

    andFigure 74).

    Figure 73: Copy Element

    Figure 74: Element Pasted and Dragged

    Now configure the second element:

    call up the element configuration with a double click,

    replace Awith Bfor variables, input and text and

    acknowledge the entry with .

    The element for variableBhas been successfully added.

    When element A is marked,

    click on the Copy icon and

    then on the Paste icon. Then

    click on the copy and drag it

    to the new position.

    Double click to set the

    new configuration

  • 7/21/2019 Training Manual V23 1006 IFM

    63/139

    The start

    3-27

    R

    Variable C Copy the element of variable Aagain for the presentation of variable C. Change

    the configuration of the new element as follows:

    Shape : ellipse

    Input : no inputColor/Alarm Color/Inside : red

    Variables/Change color : P_AND.C

    Text : C

    The display of the elements has been slightly changed as compared to A and B

    to make clear that they are different variables (inputs and outputs).

    An entry in the entry field does not make sense here because the presentation

    of the variables (of the output) is controlled by the program.

    It is an interesting option to control an output "manually" for test or maintenance

    purposes, i.e. via visualisation. However, this has to be taken into account to

    reliably avoid conflicts,Figure 130.

    Whichever way you have taken - the configuration window should look like

    Figure 75.

    Figure 75: Configuration Element C

    The visualisation window should at least resemble Figure 76 (artistic licensegranted).

  • 7/21/2019 Training Manual V23 1006 IFM

    64/139

    A small ecolog CoDeSys project as a start

    3-28

    Figure 76: Finished Visualisation

    Working with

    thevisualisation

    We can now test the newly created visualisation picture. Log in CoDeSys and

    start the program. Proceed as described before. The following points will serveas a reminder:

    'Online' 'Simulation'(''shows that the simulation is active)

    Online Login'

    Online Start'

    First click on rectangle A in the visualisation, then on rectangle B. The colours

    of the two rectangles should change to green (or to another colour, should you

    have used your artistic licence). The green colour shows that the variables now

    have the state TRUEin the program.

    If you now watch the colour of the ellipse of variable C, you will see the result ofthe programmed link the colour of the element changes to red (or to what your

    artistic license has defined). The red colour corresponds to the value TRUEof

    variable Cas a result of the AND operation (C:=A AND B).

    By clicking on the rectangles you can set the different plant states and watch

    the reaction of the program (Figure 77 and Figure 78).

  • 7/21/2019 Training Manual V23 1006 IFM

    65/139

    The start

    3-29

    R

    Figure 77: Visualisation State 1

    Figure 78: Visualisation State 2

    And now Save To save your project, use the option 'File' 'Save as...' (Figure 53).

    Figure 79: Window Save As...

    Here you enter the name of the project in the field for the file name as iscommon in Windows. The file name must have the extension .pro, so replace '*'

    by e.g. EasyandV01 and acknowledge with .

  • 7/21/2019 Training Manual V23 1006 IFM

    66/139

    A small ecolog CoDeSys project as a start

    3-30

    When the correct option is activated ( 'Project' 'Options' 'Ask for Project Info')

    is activated, a dialogue box for project information is shown automatically before

    saving (Figure 80).

    Figure 80: Project Information

    You can fill it in (or leave it).

    We strongly recommend to make abundant use of the various possibilities to

    document the project.

    Your complete project including the visualisation is now saved in the file

    Easyand.pro!

    A simple Save' instead of Save as...' would have been sufficient. We have

    described the process in detail in case that, in the heat of the work, you have

    forgotten to save before (seeFigure 53).

    But now it's time for a break and we will leave the programming system for the

    time being.

    For this purpose stop the program ( 'Online' 'Stop') (page 3-19,then log out

    ('Online' 'Logout'). Then use the option 'File' 'Exit' or the key combination

    +

  • 7/21/2019 Training Manual V23 1006 IFM

    67/139

    The start

    3-31

    R

    3.3. Online test

    We now want to load the same program into the controller and test it there.

    Preparations

    Simulator We will now work with the physical hardware. You will need to define the input

    states and watch the reaction of the outputs. That is what we use the EC 2014

    simulator for. It can be used directly for testing simple program functions. A

    different simulator box is used for the starter set.

    Starter set When working with the starter set the following section can be skipped.

    Familiarise yourself with the accessories of the simulator. It consists of:

    EC 2022

    EC 2023

    EC 2014

    Adapter RS 232

    Adapter

    a digital box with 6 switches to simulate digital inputs (two pieces).

    an analogue box with 6 pots to simulate analogue inputs.

    the actual simulator. The plug on its cable is a special version. An additional

    socket is brought out of it which permits the connection of another CAN

    component.

    an adapter, e.g. to connect the PC.

    We do not need the second adapter right now.

    To be connected to the simulator ( also the installation instructions of the

    simulator supplied):

    Supply voltage

    The 24 V power supply is to be ordered separately. It is to be connected to the

    terminals of the multi-way connector strip marked VBBand GND.

    Controller ecomat mobile R360, CR0020

    The connecting cable is firmly connected with the simulator. On the controller

    side it has a 55-pin connector used in mobile controllers to ensure the high

    protection rating.

    Control box

    To test easy program functions it is sufficient to connect the control box

    designated 0 - 5 to the socket designated 00 - 05. In addition to another control

    box an analogue box to simulate analogue input signals is also supplied with

    the simulator. It can only be connected to the first socket. Therefore it is left

    unassigned, the control box is connected to 08 -13.

    PC

    The connection is made via the supplied cable. It has a 9-pole socket on the

    side of the PC. If the PC has COM2 as a 25-pole connector, an additional

    adapter is required. It has a multi-way connector strip on the side of the

    simulator. The corresponding location on the simulator is marked RS 232/RxD

  • 7/21/2019 Training Manual V23 1006 IFM

    68/139

    Online test

    3-32

    and RS 232/TxD. Above it there is the marking CANHand CAN L to point out

    that the CAN bus can be connected to the unassigned terminals.

    A power supply is integrated in the control panel used during the trainings. As

    long as you work with the simulator, the supply voltage can be taken via the

    CAN connection because the supply voltage is on the same potential in thewhole (simulator) system.

    Operating system

    In principle, the steps for loading the operating system must be executed only

    once. When the system is delivered, no operating system is stored in the

    controller. It must be loaded only once. The procedure must only be repeated

    (again only once) when a new version of the operating system is required. This

    shows how flexible the control system is. For a PC for example the installation

    of a new BIOS requires the exchange of an EPROM. This is only successful if

    hardware compatibility was checked thoroughly. This has only changed for thecurrent version. For the ecomat R360 only the softw