MiniTrainerSchool For the MicroPLC from Lovato Electric Basics of Ladder Diagram and Function Block Diagram programming with the Lovato software LRXSW with many practical exercises on Lovato-MiniTrainer Sil o / Tan k FBD1 4 I1 Start/Stopp PWM Q1 M Silo / tank Voll Zeitrelais T1 Time rela y T1 LAD4 I2 Start Enable Q3 T01 Enable Output I4 Q2 MOD E Reset IA1 LR D 12 LR D12 2 This exercise book serves as an introduction to the world of MicroPLC LRD12 and LRD20 of Lovato Electric. It provides a modern small controller that offers many ways to implement a customercentric automation. Thanks to the various programming languages the LRD… provides something for everyone. Along with the MiniTrainer, it offers an ideal practice and learning platform for education and training. In this exercise book, the basic building blocks of the ladder diagram and function block programming can be learned with many training examples. Of course, individuals are free to reshape the exercises or expand. On the enclosed CD there is a proposed solution offered to each exercise. The exercise cards for the MiniTrainers are enclosed in two versions. On one hand, the Lovato-MiniTrainer with the LRD12 and on the other hand for the LovatoMiniTrainerXL with the LRD120, with more I / O points. Lovato Electric GmbH (Germany) Im Ermlisgrund 30, 76337 Waldbronn Tel.: +49 (0) 72 43.76 69 37-0 Fax: +49 (0) 72 43.76 69 37-9 E-Mail: info@lovatoelectric.de Web-Site from Lovato-Electric: www.lovato.co.uk Author: Klaus Machalek 1 Edition 2014 (02/14) All rights, including translation, are reserved. No part of this book may be reproduced in any form (print, photocopy, microfilm or any other process) without the written permission of the author or processed using electronic systems, duplicated or distributed. Of these, which expressly referred to in § 53, 54 of the Copyright Act except the cases are not affected. 3 Table of Contents 1. Hardware construction 1.1 Exercise equipment 1.2 Technical data of the exercise equipment 1.2.1 MicroSPS: LRD12TD024 1.2.2 MicroPLC: LRD20TD024 1.3 Lovato-MiniTrainer 1.3.1 Assignment of inputs and outputs on the Lovato-MiniTrainer 1.4 Lovato-MiniTrainerXL 1.4.1 Assignment of inputs and outputs on the Lovato-MiniTrainerXL 1.5 Selecting the programming software 7 7 7 7 8 8 9 9 10 11 2. Ladder diagram (LAD) 2.1 circuit diagram window 2.2 Creating a circuit diagram 2.3 Series circuit 2.4 Parallel circuit 2.5 Digital outputs Q/Y and markers M/N 2.6 Boolean algebra as a basis 2.6.1 Logical combinations in the LAD Editor 2.6.1.1 AND-operation 2.6.1.2 OR-operation 2.6.1.3 AND- before OR operation . 2.6.1.4 OR before AND operation Exercise: Basic circuits with the LAD Editor: LAD 1a / LAD 1b / LAD 1c 2.6.1.5 Latching Exercise: Latching: LAD2, LAD3 2.6.1.6 Priority processing - dominant 2.7 Simulation 2.7.1 Simulation on the virtual controller 2.8 Der Online-Test 2.8.1 Coupling 2.8.2 Program transfer 2.9 Time relay (timer) T 2.9.1 Configuration window of time relay (timer) 2.9.2 Setpoint input at time relay 2.9.3 Presentation of the timer in the circuit diagram LAD 2.9.4 Display of the timer on the display of LRD… 2.9.5 Change the setpoint on display?. Exercises: Time Relay T: LAD4, LAD4a, LAD4b, LAD5a, LAD5b, LAD6, LAD7 2.10 Differential Instruction D 2.11 Counter C Exercises: Counter C: LAD8, LAD8a, LAD8b, LAD9 2.12 Shift register S01 Exercises: shift register S01:LAD10, LAD11, 2.13 Analog comparator G Exercises: Analog comparator G: LAD12, LAD13, 2.14 Real Time Clock R Exercise: Real Time Clock R : LAD14 2.15 Arithmetic blocks AS (ADD / SUB) and MD (MUL / DIV) Exercise arithmetic AS: LAD15 2.16 Data register DR Exercise: Data register DR: LAD9a 2.17 Multiplexer MX 12 15 15 17 17 18 19 20 20 21 22 23 24 25 26 27 28 29 30 30 31 32 32 34 35 35 36 37 39 40 42 43 44 45 46 47 48 49 50 51 51 52 4 2.18 Text display H Exercise: Text display H:LAD16 2.19 Comments for coil and contacts 2.20 Headlines and comments in the Ladder Diagram 53 55 56 57 3. Function block diagram FBD 58 3.1 Creating a function block diagram 3.1.1 draw connections 3.2 Logic sets in the FBD-Editor 3.2.1 AND operation 3.2.2 AND NOT-operation (NAND) 3.2.3 OR operation 3.2.4 AND before OR operation 3.2.5 OR before AND function 3.2.6 OR-NOT operation (NOR) 3.2.7 Exclusive-OR (XOR) Exercises: Logic blocks: FBD1a, FBD1b, FBD1c 3.2.8 Latching function Exercise: latching function:FDB2a, FDB2b, 60 61 62 62 63 64 65 66 67 68 69 70 71 3.3 Selection menu of the Function Blocks 3.3.1 Timing relay T 3.3.2 Pulse relay Exercise: Timer relay: FBD3, FBD4a, FBD5 3.3.3 Counter C Exercise: Counter: FBD6a, FBD6b, FBD6c, FBD7a, FBD7b 3.3.4 Shift register S01 Exercise: Shift register: FBD8a, FBD8b 3.3.5 Analog comparator G Exercise: Analog comparator: FBD9a, FBD9b, FBD9c 3.3.6 Multiplexer MX Exercise Multiplexer: FBD10 3.3.7 Boolean function BL Exercise Boolean function BL: FBD11, FBD12 3.3.8 Pulse-width modulation (PWM) P Exercise PWM: FBD13, FBD13a, FBD14 3.3.9 Text H 3.3.10 Display backlight 72 72 74 75 76 78 79 79 80 81 82 82 83 83 85 85 87 87 4. Useful information 88 5 Contents of the CD Solutions In LADDER diagram (LAD) in Function block diagram (FBD) 6 1. Hardware construction 1.1 Exercise equipment Lovato Electric GmbH, the manufacturer of MicroPLC LRD12 and LRD20, offers a wide range of different devices. Starting on the number of input and output points of extensibility to the different supply voltages. In this basic course, the devices LRD12 and LRD20 will apply. Once the low cost LRD12 with the small Lovato-MiniTrainer and another with the LRD20 and the Lovato-MiniTrainerXL for more inputs and outputs. Thus, both versions offer a simple and inexpensive way to implement the exercises here used in the book and also to supplement. 1.2 Technical data of the exercise equipment 1.2.1 The MicroPLC LRD12TD024 This MicroPLC provides eight digital 24 VDC inputs in addition to the 24 VDC supply. Of these, the inputs A1 and A2 can be alternatively used as analog inputs. 8 inputs 24 VDC Power supply 24 VDC A1 and A2 digital and alternatively usable as analog inputs 0 ... 10V The display offers the representation of LAD, FBD and text. Cursor key activated as Z inputs USB interface to PC 4 relay or 4 transistor outputs Figure 1.1 LRD12TD024 Note: For the MiniTrainer can either be used the LRD12TD024 with 4 relay- or 4 transistor outputs. 7 1.2.2 MicroPLC: LRD20TD024 Firstly, this exercise utilises the larger design controller. This makes it possible to use more inputs and outputs and thus to make the exercise offer interesting and varied. The MiniTrainer now has the designation Lovato-MiniTrainerXL. Preferably, the transistor variant LRD20TD024 should be used, that way you can also use the PWM functionality better. Figure 1.2 LRD20TD025 1.3 Lovato-MiniTrainer Figure 1.3 Lovato MiniTrainer 8 1.3.1 Assignment of inputs and outputs on the Lovato-MiniTrainer: I9 IA Figure 1.5 I/O assignment of LRD12 Figure 1.4 MiniTrainer simulation field 1.4 Lovato-MiniTrainerXL The MiniTrainerXL offers in addition to the 8 latching / momentary switches (I1 to I6 / I9 and A1) or 2 push buttons (red) as the changer inputs I7 / I8 and IB / IC operate. They are as shown in the sketch, wired: I7 I8 IB IC The NC I8 and IC can be switched off via the slide switch. Thus all inputs via the interface connector are available and have no default Latching/momentary switches 24 VDC-power supply Figure 1.6 addition button on the Lovato-MiniTrainersXL By using the buttons X1 - X4 as real wire break simulations, start-stop functions can be implemented. 9 1.4.1 Assignment of inputs and outputs on the Lovato-MiniTrainerXL: I9 IA IB IC Figure 1.7 MiniTrainerXL simulation field Figure 1.8 I/O assignment of LRD20 Lovato-MiniTrainer XL Figure 1.9 Lovato-MiniTrainerXL 10 1.5 Selecting the programming software The first part of this book deals with the ladder diagram programming. In the second part of the function block is handled. The software offers comfortable implementation of control and regulation functions in the standard PLC languages: Ladder Diagram (LAD) and function block diagram (FBD). To create a new project, first the desired programming language must be selected. Either ladder programming (LAD) or function block programming (FBD). LAD=LadderDiagram=(LD) FBD = Function Block Diagram language LAD (LADDER) FBD Figure 1.10 LAD- and FBD-Button Note: A ladder diagram (LAD) is not in a function block diagram (FBD), or convertible and vice versa! 11 2. The Ladder diagram (LAD) (in the Software called „LADDER“) The corresponding button is clicked to reach the LAD Editor. LADDER LAD Picture 2.1 Start-Menu of the LRXSW for opening LAD The next step is to select the right MicroPLC. This is necessary in order to assign the right program of the controller. For this purpose, the "NEW" button is clicked. Picture 2.2 Start-Button 12 It appears in the device selection window: Picture 2.3 device Selection The selection is based on the device type identifier: Note: This choice is also possible later on in the "Operation" -> "Module System Set" Is the correct device selected via the pull-down button the LAD Editor opens. will be confirmed with OK and The Ladder Editor is divided into the following areas: circuit diagram window Operations Assignment list of contacts and coils Selection of contacts and coil 13 Information on the circuit diagram In order to interpret correctly the symbols you place the mouse on the icon, and after a moment the icon's function appears. The symbol for the outputs Q/Y and the markers M/N again shows the contact and once the coils function. Cursor keys (Z) on the MicroPLC digital inputs (I) External inputs (X) (extension) Picture 2.5 Contact- and coil function In the left window of the editor, the contacts and coils used are displayed. Clicking the button opens the complete selection table. Picture 2.6 Occupancy list Note: The individual short names (Y, M, T, C, R, G, H, ..) are explained in the relevant exercises. 14 2.1 Circuit diagram window The ladder program is created in the circuit diagram window. It can be constructed of a maximum of 300 rungs with a maximum of three contacts and one coil. If you need more than 3 contacts in a rung you need a temporary result memory, a marker M or N. 1 2 5 6 9 etc. 3 4 7 8 Indication of the remaining open spots Picture 2.7 The Schematic window 2.2 Creating a circuit diagram Use the mouse pointer to select the contact icon. As an example, we select the input. When the icon is left appears as a crayon. Using the mouse, now the contact to the right position is out in the rung. This is the "pen" and as long as provided with a prohibitory sign, as long as no contact inserted, the field is reached. Only when the prohibition sign is gone, the contact can be set. If the position is reached, the contact with the left mouse button "placed". It opens directly the selection window "Edit contact" through which you enter the parameter. Picture 2.8 describe contact 15 This window will also determine whether the contact is normally open or normally closed. A subsequent correction is possible in this menu. With OK the configured contact in the ladder diagram is visible. Note: Unless the right mouse button or the ESC key is pressed, the "pen" is retained and it may be the next position to be selected. In the toolbar, there are a lot of contacts and coils of different functions. In this book, some are handled. But experience shows that many functions even tell if you have worked through the book. Picture 2.9 Toolbar Note: In the circuit diagram the name of contacts appears different: NO (normally open) NC (normally closed) Picture 2.10 N.O.-contact Picure 2.11 N.C.-contact 16 2.3 Series circuit As a first example to three NO contacts switch the output Q01 in series: Shows the occupied contacts and coils with a star Picture 2.12 First line If you want to associate less than 3 contacts in series, one needs an "AND-Line". This function is as an icon button in the bottom toolbar: Pictue 2.13 AND-Line AND-Line Note: This connection is used instead of a contact! 2.4 Parallel circuit For this example, we use the previous example of the series circuit and add this with two parallel contacts I04 and I05. For this purpose, the software in the toolbar “OR-Line” button for the parallel branch: Picture 2.14 OR-Line OR-Line Example of a parallel circuit: Picture 2.15 parallel circuit 17 2.5 Digital outputs Q/Y and markers M/N The digital outputs and markers of MicroPLC can be set in different functions. As standard the selected output or marker is used as a dynamic coil. This means that the output or marker behaves as a contactor. Picture 2.16 discribe coils Further functions are: Set-function Reset-function P = puls-function These different opportunities are illustrated in the circuit diagram as follows: Dyn. coil: -[ = Set-coil = Reset-coil = Puls-coil = Pictur 2.17 coils Note: The function of the output can be changed at any time by double clicking on the corresponding coil function. 18 2.6 Boolean algebra as a basis The primary task of MicroPLC LRD is the linking of several NO and NC contacts after a certain logic. This logic corresponds to a series (AND circuit) or a parallel (OR circuit) in a wired contactor or relay control. The link can be specified in the LRD either Ladder Diagram function block diagram = LAD or = FBD. This plan is stored in non-volatile semiconductor memory of the LRD. It is important to note that the MicroPLC cannot detect whether an incoming signal from the outside of a make or break comes. The LRD "remembers" only if the 24 VDC voltage is applied to the inputs or not. In the circuit diagram or logic diagram, the logic state of the inputs is always queried and not the function of the actuator. 19 2.6.1 Logical combinations in the LAD Editor 2.6.1.1 AND-operation The AND-operation corresponds to the series circuit in a conventional wired contactor control that means the output is switched on when all switches are closed. The following example shows a better understanding of how an AND-operation takes place in old fashion wired contactor technology and how the implementation of the LRD12. Example: Logical AND-operation with three switches: Realization in wired contactor circuit Realization with the LRXSW: S1 S1 S2 S3 S2 I1 S3 I2 I3 LRD12 ZelioLogic2 Q1 Relay 1 H1 H1 Picture2.19 Wiring to the PLC Picture 2.18 AND-operation The output signal (H1), an AND-operation is then logic "1" when all the input signals (S. ..) have the state "1". The "1" stands for an actuated normally open or a normally closed contact is not actuated. True list: S1 S2 S3 H1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 1 Logic algebra: FBS: 0 0 0 0 1 1 1 1 S1 S2 AND S3 Presentation in the LRXSLAD: LAD Picture 2.20 AND-operation in LAD 20 H1 = S1 & S2 & S3 H1 2.6.1.2 OR-operation The OR-operation corresponds to the parallel circuit in a conventional wired relay control, that is, the output is then turned on when at least one of the switches is closed. The following example shows a better understanding of how an OR operation in old fashioned wired contactor technology and how the implementation of the LRD 12 takes place. Example: logic OR-operation with three switches Realization in wired contactor circuit S1 S2 Realization with the LRXSW: S3 S1 S2 I1 S3 I2 I3 LRD 12 Q1 Relay1 H1 H1 Picture 2.21 OR-operation Picture2.22 Wiring to the PLC The output signal (H1), an OR operation is then logic "1" if at least one or more input signals (S. ..) have the state "1". The "1" stands for an actuated normally open contact or a nonactuated normally closed contact. True list: S1 S2 S3 0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1 Logic algebra: FBS: H1 0 1 1 1 1 1 1 1 S1 S2 OR H1 S3 Presentation in the LRXSLAD: LAD Picture 2.23 OR-operation in LAD 21 H1 = S1 V S2 V S3 2.6.1.3 The AND- before OR operation The three switches to be logically combined in AND and OR. The input of this logic is based on the basic rule of Boolean algebra: Point are performed before addition and subtraction In the implementation in the wiring logic, this means: Series circuit is going on parallel circuit The following example shows the implementation a combined AND-OR circuit according to the rule above mentioned: Realization in wired contactor circuit Realization with the LRXSW: S1 S1 S2 S3 S3 I1 I2 I3 LRD 12 S2 Q1 Relay1 H1 H1 Picture 2.24 AND before OR operation True list: S1 0 1 0 1 0 1 0 1 S2 0 0 1 1 0 0 1 1 S3 0 0 0 0 1 1 1 1 Picture2.25 Wiring to the PLC Logic algebra: FBS: H1 0 0 0 1 1 1 1 1 H1 = S1 & S2 V S3 S1 S2 AND OR S3 LAD Picture 2.26 AND before OR operation in LRXSLAD 22 H1 2.6.1.4 The OR before AND operation Four switches will be connected in logic OR and logic AND: The input of this logic is also called conjunctive form. Since the Boolean rule applies here, it must be used with braces. Thus, it specifies that the OR operation is processed first. The representation in the application program corresponds to the international standard IEC 61131. The following example shows the implementation a combined AND-OR circuit following the rule above mentioned: Realization in wired contactor circuit Realization with the LRXSW S1 S1 S2 S3 S4 S2 I1 S3 I2 I3 I4 LRD 12 S4 Q1 H1 Relay1 H1 Picture2.27 OR before AND operation True list: S1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 S2 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 S3 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 Picture2.28 Wiring to the PLC Logic algebra: FBS: S4 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 H1 0 0 0 0 0 1 1 1 0 1 1 1 0 1 1 1 H1 = (S1 V S2) & ( S3 V S4) S1 OR S2 AND S3 OR S4 23 H1 Presentation in the LRXSLAD: LAD Picture2.29 OR before AND operation in LAD Exercise: Basic circuits with the LAD Editor LAD 1a / LAD 1b / LAD 1c I1 I2 LAD 1b Q1 L AD 1a I3 I1 I2 I0A I1 I4 I5 I6 Q1 I2 I3 I3 Q2 LAD 1 c Q1 Q2 I4 I6 I4 I5 I9 I5 I6 I9 I0A Q3 Q4 I9 I0A LR D12 Picture 2.30 Exercise card LAD1a LR D12 LR D 12 Picture 2.31 Exercise card LAD1b 24 Picture 2.32 Exercise card LAD1a 2.6.1.5 Latching In control engineering, the function of latching is often use, especially when using buttons will execute a stored function. A typical task is the turning on and off of a motor. The ON button is always a normally open and the OFF button always normally closed. Why the OFF button is normally closed, has something to do with the wire breakage. The VDE regulations state that in the event of a wire break in the relevant section a motor must be switched off immediately and must not be turned on. To realize a latching in the LRD12 and LRD20 the MicroPLC offers two variants. 1. The dynamic control of the output: If the result of logic operation (RLO) is on , the output is on, too. If the RLO is low , the output is low, too. Picture 2.33 dyn. latching in LAD 2. The static control of the output Latching function with SET and RESET commands. Both commands work with the rising edge. Picture 2.34 static latching in LAD 25 Exercise: Latching With these exercise cards the topic of wire breakage is practiced. For all programmable logic controllers (PLCs) you must make sure which switch or push button is installed on the machine or plant. Is it a N.O. or N.C. contact? This is important because according to VDE 0113 turn off must be by opening a circuit. By using an N.C. to the input terminal of a PLC, this always has power at the input terminal in the non-actuated state. If you were to now integrate the input by an N.C. in the schematic, so you return the signal of the external switch. This has the consequence that e.g. a motor off by opening the circuit at the input of the PLC. This can be life-threatening. Thus, we conclude that one must always think twice when you include one outside the PLC wired N.C. in the program as N.O. or N.C. to be failsafe. Exercise LAD2: Latching with dynamic triggering of Q2 (Like the classic relay and contactor control) Sel bsthal teschal tung seal-i n circui t LAD 2 Start Stop Bimetall I4 I5 Q2 I3 Q2 Bei der Programmerstellung ist auf die Drahtbruchsicherheit zu achten! In case of programming pay attention to the fail-save c ircuit Picture 2.35 Exercise card LAD2 LR D 12 Exercise LAD3: Latching with static triggering of Q2 (Like classical electronic controls via flip-flops) Sel bsthal te schaltung mit SET un d RESET Seal-in circuit wi th SET and R ESET L AD 3 Start S I3 Q2 R I5 I6 Bei der Programmerstellung ist auf die Drahtbruchsicherheit zu achten! In case of programming pay attention to the fail-save c ircuit Picture 2.36 Exercise card LAD3 LRD 12 26 2.6.1.6 Priority processing - dominant Another important overview is the priority of functions. The program processing is always from top to bottom, is in the ascending line numbering. The example shows how important it is in which line the output or marker are standing. This is also important with respect to the priority in the setting and reset command. 1a If I1 and I2 are pressed simultaneously, the RESET command has priority. 1a 1b I3 and I4 are pressed simultaneously, the SET command has priority. 1b 1c If a coil is several times assigned,it is also true that the ascending line numbers, the last assign which affects the coil to the outside. Internally, the coil of the output or marker "1" or "0" as long as no change is made in the following lines. 1c Picture 2.37 Priority processing in LAD 27 2.7 Simulation After the last link is ready, this is simulated with the help of LRXSW, i.e. tested without control (off-line). For this we change into the SIMULATION MODE: Picture 2.38 Tools in LAD Depending on the settings more windows are opened simultaneously. Since we are interested only in the inputs, the other windows can be closed. This takes place using the "View" “ By clicking on the fields, tools can show or hide! Picture 2.39 View menue By clicking the button icons in the "Input Status Tool", the corresponding switch in the LAD is displayed in green. If the rung is virtually closed, that is, from left to right is a continuous green line, then the output is also available in green. (The connecting lines "OR-Line" and "AND-Line" always appear in green) Picture 2.40 OR-Line and AND-Line 28 2.7.1 Simulation on the virtual controller In addition to simulating the circuit diagram, the controller also provides a pictorial representation of LRD12 with the connected switches and lamps. You can reach this simulation by clicking the "keypad" Run Picture 2.41 keypad button By clicking the "Run" button, the program can now be tested on the simulator. Click switch Current paths, the bold appear to be "flown through" virtual power! Outputs Picture 2.42 Keypad-Simulator With the mouse, you can also use the cursor buttons to operate virtually and thus retrieve the LRD12 the menu and use. Note: In this virtual control simulator parameters can be changed, but the function of a function block cannot. 29 2.8 The Online Test 2.8.1 Coupling Before the transfer of a program can be done in the controller, some settings must be checked, or set. These settings, bring the selected control to meet the actual control system. If this is not the case, the LRXSW recognizes and cannot connect. The exact type of control can be found on the left side wall! example: LRD12TD024 The protective cover should be pulled out and the plug inserted carefully. The cable goes from the left. Picture 2.43 Cuppling to the PC The USB programming cable is plugged into one of the USB ports of the PC. If the connection is made, and power is connected, then the coupling of the software can be made: 1. Click "Operation" 2. Click "Link COM Port" 3. Select the interface "COM port" Picture 2.45 Select Link Com Port… 4. Click Connect "link"! Picture 2.44 Link Com Port… If the coupling was successful, this is indicated by a message on the screen. Picture 2.46 Connect successfully 30 2.8.2 Program transfer The next step is to transfer the program into the controller. For this the LAD editor provides two buttons. One to write the program into the control "write" and another to read the program again from the controller back to the PC "read". Read from the LRD… write into the LRD… Picture 2.47 Read and Write Button After a safety prompt with the hint that you could possibly overwrite a program in the control (clear). Picture 2.48 Message If you confirm with "Yes", the program is transferred to the controller. Then you acknowledged with the “OK” for transfer: Picture 2.49 Transfer o.k. With the "Run" button the program starts in the controllerand with the "Stop" button, the program can be stopped anytime from the PC. Picture 2.50 Run and Stop Button If you click "Run", the system asks whether the program should be read back from the controller. This makes sense if you just want to see the online status display. Picture 2.51 Message 31 2.9 Time relay (timer) T The MicroSPS LRD… provides 30 timing relays with different possible functions. The button "T" is chosen from the lower function selection panel to open the configuration window for the functions and their settings. Picture 2.52 Tools 2.9.1 Configuration window of time relay (timer): Selection of 30 possible timer addresses: 01…09, 0A…0F, 10…19,1A…1F Function of the output coil of the timer (Output Type): –[ = Dynamic coil (in the example selected) P = Pulse output Picture 2.53 Timer select Function of the timer depending on the output coil (Output Type): Mode 0 – 6 for : –[ Mode 7 for : P Mode 0: internal coil (like a marker) Mode 1: On-delay timer Flow diagram Picture 2.54 Timer mode1 Mode 2: ON-delay timer with reset input. If the enable is off, the timer stops. Only if the Enable is "ON" the time is running on again. Picture 2.55 Timer mode2 32 Mode 3: OFF-delay timer.If the rising edge of Enable (0 -> 1), the output is "ON". Time is running only when the Enable flank falls (1 -> 0). If Enable is turned on again during the running time, the actual value is set to "0". The timer can be restarted. Picture 2.56 Timer mode3 Mode 4: OFF-delay timer. When a falling edge of Enable (1 -> 0), the output is "ON" and the time is running out. If Enable is turned on again during the running time, the Actual value of the timer is reset to "0". The timer can be restarted. Picture 2.57 Timer mode4 Mode 5: Synchronous flasher (1:1) (ON-time = OFF-time) The output of the timer flashes while the Enable "ON". Picture 2.58 Timer mode5 D Mode 6: Synchronous flasher (1:1) M (ON-time = OFF-time) The output of the Ö timer flashes once to Enable an edge G change from 0 - done> 1. The output D flash until an edge change from 0 -> 1 F at the Reset input is done. Picture 2.59 Timer mode6 Mode 7: Asynchronous flasher (1: n) (ON-time is not equal the OFF-time) The output of the timer flashes while the Enable "ON". Picture 2.60 Timer mode7 33 2.9.2 Setpoint input at time relay The input for the time functions are also included in the menu window of the timer corresponding to the mode that is set. By default, the time base is set to 10ms. That the smallest default value for the timer is 10 ms. The time base from … to 0,01 … 999,9 s 0,1 … 9999 s 1 … 9999 s 1 … 9999 min „PresetValue“ Setpoint input with consideration of the time base (SEConds or MINuntes) Picture 2.61 Timer parameter "Preset Type" is used when the target value from another block comes. So, for example, is "A" for analog input or "C" for a counter output. If setpoint "Preset Value" is specified, the Preset Type = "N" (Not) For the asynchronous flasher (Mode 7) Two setpoints are required. Accordingly, two setting ranges (T01 and T02) are provided. Picture 2.62 Timer mode7 34 2.9.1 Presentation of the timer in the circuit diagram LAD If the timer is configured, it is shown in the circuit diagram as follows: Mode (0…7) Current value Setpoint Picture 2.63 Timer in LAD In the run status of the timer is displayed as follows: Current value Picture 2.64 Timer in Run 2.9.4 Display of the timer on the display of LRD… In addition to the status display on the screen, it is particularly convenient when for example you can read the value of the timer and the controller. This is often a great help for setup or troubleshooting. For this purpose, proceed as follows: If the controller is in Run mode, it comes with pressing the button in the following menu: Picture 2.66 LRD… Menue The cursor key leads to the circuit diagram. There you go using the arrow keys on the corresponding block and confirm . Use the key to get back into the schematic. Picture 2.67 LRD-Display Timer in Run 35 2.9.5 Change the setpoint on display? Many times it happens in the everyday life of a machine or system that a value needs to be adjusted, but there is no PC for set-point modification. For this the controller offers, thanks to its built-in display among other things, the possibility to change settings. The change is ALWAYS in STOP mode. Picture 2.67 LRD-Display: in Stop mode With the keys is now the timer component T1 called: 1. Press the key. 2. Go with the Cursor-key up and confirm. 3. Use the cursor button to repeatedly tap to the left until the position is reached at which point the value is to be changed. 4. Pressing the button, the position is confirmed and the cursor line below the number flashes. 5. Use the cursor keys and now the new value can be set. 6. If the value is correct, you confirmed with 36 and leave the menu with Exercises: Time Relay T LAD4: With the exercise card " Time relay T1" first we test all the modes of a timer! Zeitrelais T1 Time relay T1 LA D4 I2 Start T01 Enable Q2 Output I4 MOD E Reset LR D 12 Picture 2.68 Exercise card LAD4 LAD 4a: Based on the adjacent exercise card is a reflector light barrier (I02) four monitoring lights (Q1 ... Q4) switch for 10s. To switch on it is enough if, for example, a person shortly interrupts the light barrier. With each new interruption of the photocell, the timer is restarted. Which mode is useful here? ? LAD 4b: The interrupt pulse of the light barrier is to be fixed at 0.2 s. Picture 2.69 Exercise card LAD4a+b LAD 5a + b Lic ht la mp lu z Q1 Q2 Lüfter fan ven ti lad or LAD 5 a: A toilet light and fan control is to be implemented using the LRD…. If someone enters the bathroom and switched on the light, after 4s the fan runs on as well. Only when the toilet is left and the light is switched off, the fan runs for 8s and then switches off. LAD 5b: In addition to LAD 5a, the fan should now run after 20 s, when the toilet is used for longer than 20 seconds and the light is longer than 24s on. S5 Schalter swi tch in te rruptor Toi letten -Li cht-Lüfte rsteu erun g Toi let -Li ght-an d-Fan Co ntrol Co ntrola dor de l a lu z y el ven ti lad or de un ba ~ no LR D 12 Picture 2.70 Exercise card LAD5a+b 37 I1 Le uchtfeue r / Navi gatio nal l igh t Q1 I2 Westerheversand I3 Q2 Büsum Q3 Helgoland LAD 6 - Lighthouse: On the North Sea coast are navigation beacons for safe orientation. These can be seen from a distance and in the dark they have different identifiers to see which beacon is which. They are the broken fire (Oc), the common-mode fire (iso) and the flashing light (LFI). These three identifiers will now be realized with the help of exercise LAD6 card. 1) Lighthouse from Westerheversand - Oc(3) 15: 01 234 5 6 LR D 12 Picture 2.71 Exercise card LAD6 15s 3 dark phases of 1s and the two pauses of 1 s. Then is permanent light. The repeat is done every 15s. 2) Lighthouse from Büsum- Iso 6s: 0 3 6s On 3s and off 3s 3) Lighthouse from Helgoland- LFI 5s: 0 5s all 5s a flash fire <1s (600ms) Ampel / Traffic light LAD 7 LAD7: In metropolitan areas, side road access to highways is controlled in heavy traffic with a traffic light. The traffic light shows RED when the main switch I01 is turned on. An induction loop in the road surface before the traffic light detects an incoming vehicle. With 1s delay starts the traffic light cycle, which also takes 1 sec each for the individual phases. At the end of the traffic light cycle the lights are back on RED. If the induction loop is connected constantly, so the traffic lights cycle runs through the 1 sec intervals. LR D12 Picture 2.72 Exercise card LAD7 38 2.10 Differential Instruction D The "positive" pulse is for one program cycle "ON" if the series contact switches from OFF -> ON. Picture 2.73 D puls when ON The same function but with the opposite sign is the inverse of the "D" contact. Picture 2.74 D-puls when OFF 39 2.10 Counter C Like the timer, the counter is also a function block that needs to be configured only. The MicroPLC offers 30 counter blocks, each with 8 different modes. Picture 2.75 counter parameter Mode 0: internal coil (like a marker) Mode 1: up-down counter without overflow. If the setpoint = actual counting up is blocked. The counting is stopped if the actual value = 0. The actual value is non-retentive. It loses its value when you turn off the controller. Setpoint input (0 ... 999999) Variables specification (for example: the result of arithmetic) Note: In LAD circuit diagram ONLY be linked the counting coil and the switching output of the counter. The specification of the counting direction (Direction set) and the reset Input of the counter value can be selected in the configuration window and displayed as in the example: "Low" = "0" = no specification The representation in the LAD editor provides the following information: Mode Direction Counting coil Actual value Setpoint Switching output of the counter Reset Input Picture 2.76 counter in LAD If you want to reset the counter and / or changing direction, then the menu offers various options: Low = not specified for example: Reset Input I = Input base unit X = Input expansion unit Z = cursor keys (arrows) as inputs etc 40 Picture 2.77 Reset Input of the counter Mode 2: up-down counter with overflow. If the setpoint = actual value of the count input is not locked. The counter continues to count. The actual value is non-retentive. It loses its value when you turn off the controller. Example, in the LAD representation: Picture 2.78 counter mode2 Picture 2.79 counter in stop Note to "reset input" and "Direction Set" in Mode 2: • • "Reset input" has two functions. When pressed while counting the reset, the current value of the counter is set to "0". When pressed while counting down the reset, then the setpoint "Preset Value" is set! If the setpoint is reached when counting, the output switches the counter to "ON". Now, if the direction is switched, the output switches to "OFF" and again until the actual value = "0", the output is switched to "ON". Now, if the direction switched again, the output switches back to "OFF" until the setpoint is reached again. Mode 3: Like Mode 1, but the actual value is retentive. It stores its actual value when you turn off the controller. Mode 4: Like Mode 2, but the actual value is retentive. It stores its actual value when you turn off the controller. Mode 5: Like Mode 2, but with the reset value is always set to "0", irrespective of the direction. Mode 6: Like Mode 5 but retentive. Mode 7: High-speed counter, which is used either as pure up counter on the highspeed counter inputs I1 or I2. Mode 8: 1 KHz-speed counter, which is used either as pure up counter on the highspeed counter inputs I1 or I2. Picture 2.80 counter in Run mode 41 Exercises: Counter C I1 Puls I2 I3 Direction Zä hler C01 c ounter C01 LAD8 Q1 LAD8 Should be tested before the following exercises are done with the exercises card "counter C01", all modes. Reset Mode Preset Value Picture 2.81 Exercise card LAD8 I1 Sollwertvorgabe mit Vor-Rückwärtszähler setpoint via up-down counter LAD8a/8b / FBD7a /7b Q1 START Preset Value LAD8a: Using an up-down counter of the setpoint value for a timer from 0 to 50 sec ... be adjustable. As the setting buttons Z keys are used. With Z01 is forward (UP), with Z03 backward (DOWN) counted. LAD8b: Extension The setpoint and the actual value of the timer should be displayed on the display of the LRD. Timer 2 Counter Setpoint UP DOWN Actual value Min=0 Max=50 LR D20 Picture 2.82 Exercise card LAD8a+b fa hrt I1 Ein en tra nce rt I2 Ausfah exi t Par khaus / Park ing gar age LAD 9 FREI / FREE BELEGT / BUSY I3 Geschlossen /closed LAD9: A car park entrance is controlled by display. A total of 20 parking spaces available. If all are occupied, the display shows "Busy". Otherwise, the display is set to "FREE". The caretaker also has the option, regardless of the allocation to close the driveway with a roller door. Is the roller door down, the display shows "CLOSED" on. Contact entrance Contact exit Contact door below Display “FREE“ Display „BUSY“ Display „CLOSED“ LR D12 Picture 2.83 Exercise card LAD9a+b 42 : I01 : I02 : I03 : Q01 : Q02 : Q03 2.12 Shift register S01 The function block "shift register" is a bit shift register and is available once. It can max. be 8 steps high. Number of shift increments „Select 1-8“ „Pulse Coil“ „Start Coil“ Picture 2.84 Shift register in LAD The start-coil defines the first step in the shift register. It can be an output (Q, Y) or relays (M, N). If you have chosen a variable, all outputs or markers that are defined with "Select 1-8", assigned. The clock-coil "Pulse Coil" defines the shift clock. It can be any variable in NO or NC function. Picture 2.85 Parameter of S01 „Start Coil“ In this example, the outputs Q1-Q4 are occupied by the shift register. Q01 Q02 Q03 Q04 The shift register operates as a shift register ring. This means in this example that the fourth time clock with the output Q01 I02 back "ON". 43 Exercises: shift register S01 I1 Start Schiebere giste r / Shiftre giste r LA D 10 LAD10: We have a shift register with eight steps. The training card shows all necessary variables. The shift register shifts first from M01 to M08. The markers then drive the outputs Q1 ... Q8. Since the LRD12 has only 4 physical outputs, the remaining 4 outputs are virtually visible on the display. The shift clock (T1) of 1s becomes active when I1 is actuated. After 8 steps of shift clock starts again while I1 is switched off. Q1 S01 Start M01 Coil T1 Q2 M02 Q3 Pulse coil M03 M04 M05 M06 M07 M08 LR D20 Q4 Q5 I1 Start Schiebere gister / Shiftregister LAD 1 0 Q6 Q7T1 Q8 Picture 2.86a Exercise card LAD10 for LRC20 Q1 S01 Start M01 Coil M02 Pulse coil Q2 M03 M04 Display M05 Q3 M06 M07 M08 Q4 LR D12 Picture 2.86b Exercise card LAD10 for LRC12 LAD11: In this exercise, the shift register is to be extended from LAD10 as traffic light control. Once I1 is turned on runs the traffic lights cycle from according to the diagram. I1 Start S01 A mpel m it Schie be register Tr affic light with shiftre giste r LAD 11 1 2 3 4 5 6 7 sec. LR D12 Picture 2.87 Exercise card LAD11 44 2.13 Analog comparator G The 24VDC base unit LRD12 provides two analog inputs A1 and A2. The analog value from 0 to 10V is applied to an analog to digital converter on the inputs, and converted into a binary number. The converted value can be compared via the analog-comparator block G with different values. The analog comparator values offers 8 modes Mode 0: is always an internal coil. Mode 1: (Ay-Ref.) <= Ax <= (Ay+Ref.) Ax and Ay can be assigned differently. With the direct assignment to the potentiometer of the MiniTrainer we can easily try out the formula. Ax = e.g.: A01 Ay = e.g.: A02 Example: If the reference value is set to 03:00 and the potentiometer A2 to 6V, the output of the analog comparator switched on by turning the potentiometer A1 of at 3V and at 9V. Picture 2.88 Parameter of Ax Mode 2: (Ax <= Ay) The output of the block "G" is "1", if the analog value of A1 is less than or equal to the value of A2. Ax = Adjustable example: A1 Ay = A2 The other functions: Mode 3: (Ax> = Ay) Ax greater than, equal Ay Mode 4: (Ax <= Ref.) Ax less than, equal a fixed value Picture 2.89 Parameter of Ay Mode 5: (Ax >= Ref.) Ax greater than, equal a fixed value Mode 6: (Ax = Ref.) Ax equal a fixed value Mode 7: (Ax> <Ref.) Ax smaller or larger but not equal to a fixed value. 45 Exercises: Analog comparator G Q1 Analogwer teve rgle ic he r A na log c om pa rator LA D12 LAD12: Using the analog comarator G in mode 1, to switch Q1 when the difference between A01 and A02 is <= 3V. For checking the status display is used to display the LRD... Mode 1 A1 A2 LR D12 Picture 2.90 Exercise card LAD12 Wass ertank Wa ter tank LAD 13 /1 5 Q1 ON/OF F Q2 50°C Heizung heating Q3 LAD13: The temperature of a water tank is to be kept at 50 ° C -2 ° C. I1 is used as the main switch. The heating is controlled by Q2. The temperature curve of the sensor corresponds to the sketch. If the temperature is above 55 ° C or below 45 ° C then the alarm rings (Q3). °C 90 55 50 45 Alarm A1 LR D12 0 ? ? ? 10V Picture 2.91 Exercise card LAD13/15 Note: If you use LRD20 , the outputs are differently: LRD12 LRD20 Q1 = Q1 Q2 = Q3 Q3 = Q5 46 2.14 Real Time Clock R The clock module in small controllers, such as the MicroPLC represents a fixed function in many applications. It can be used to realize time-, and date-dependent switching functions. The Real Time Clock (RTC) provides in MicroPLC LRD… four different modes: Mode 1: weekly timer The daily set on and off time applies for the set period every day. The entry is in hours and minutes (00:00 to 23:59) MO TU WE TH FR SA SU Picture 2.93 RTC mode 1 Mode 2: weekly timer The selected on time may be at a different day than the off time. The set period applies max. for one week. The input is as in Mode 1 MO TU WE TH FR SA SU Picture 2.92 RTC menu Picture 2.94 RTC mode 2 Mode 3: Year time switch The set switch-on is on a day and is always at 00:00 clock. The off time is usually on a different day at 23:59 clock. The period may extend over several years. ON OFF Picture 2.95 RTC – Mode 3 47 Mode 4: pulse clock On Thursday (TU) at 16:25 clock for a period of 14 sec, the output of the real-time clock is switched "ON". Picture 2.96 RTC – Mode 4 Exercise: Real Time Clock R Real Time Clo ck RTC LAD14 Q1 LAD14: The outdoor advertising (Q1) of a shoe shop will be switch on and off automatically over the real time clock. The times are set as follows: Mon-Fri at 7:00 A.M. ON and at 6:30 P.M. OFF Thu additionally at 7:00 P.M. ON and at 10:30 P.M. OFF Day Monday Tuesday Wednesday Thursday Friday ON OFF 7:00 a.m. 6:30 p.m. 7:00 a,m, 6:30 p.m. 7:00 a.m. 6:30 p.m. 7:00 a. m. 6:30 p.m. 8:00 p. m 10:30 p.m. 7:00 a. m. 6:30 p.m. LR D20 Picture 2.97 Exercise card 14 48 2.15 Arithmetic blocks AS (ADD / SUB) and MD (MUL / DIV) If you want to compare different values or limit values in a particular area, then you have to rely on the arithmetic. The four basic arithmetic operations are divided into two functional blocks. First, the addition (ADD) and subtraction (SUB) and on the other hand, the multiplication (MUL) and the division (DIV). Picture 2.98 Tools ADD / SUB MUL / DIV Example: The example shows a timing of a timing relay that between 10 and 50 seconds over the potentiometer A1 should be adjustable: If we assume that the analog input A01 from 0 ... 1023 has been set, then the result for the delta of 40s (10 ... 50s), the following formula (MD01): Result = A1 x 10 = V1 * V2 / V3 256 Analog input A1 multiplied (MUL) with 10, divided (DIV) by 256 V1 * V2 / V3 This requires the MD01 module with the entries for V1, V2 and V3: Picture 2.99 MD function With the next formula (AS01) is added to the offset of 10s the result of MD01 added: Picture 2.100 AS function 49 The result is now as required between 10 .... 50. If we now have the time base of the timer set to "sec", then the task is complete and can be tested with the simulator: Picture 2.101 Simulation of arithmetic Exercise arithmetic AS Wass ertank Wa ter tank LAD 13 /1 5 Q1 ON/OFF Q2 50°C Heizung heating LAD15: In addition to LAD13 the temperature is shown on the online display on the PC's screen. In the next step, if the chapter "Text display" has been processed, the temperature should be displayed on the display of the LRD (LAD16). Q3 Alarm A1 Picture 2.103 Online status display LR D12 Picture 2.102 Exercise card LAD13/15 °C 90 50 0 ? ? ? 10V Picture 2.104 What is the voltage at which Temperature at the analog input? 50 2.16 Data register DR In contrast to markers (M and N) in which one can store only one bit (0/1), max offer. 225 data register values also with the option to save. These data registers are to be parameterized in other blocks. Example: The result of an arithmetic calculation is to be displayed on the screen of the controller. 1 Step: The result is stored in the data register DR01. 2. Step: In the HMI / Text editor of this DR01 is included in the display Picture 2.105 DR menu Picture 2.106 Content of DR to the text display Exercise: Data register DR fa hrt I1 Ein en tra nce rt I2 Ausfah exi t Par khaus / Park ing gar age LAD 9 LAD9a: FREI / FREE BELEGT / BUSY I3 Geschlossen /closed Is in addition to the display of the LAD9 now LRD... take over the display and the remaining free parking spaces is shown FREE LR D12 Picture 2.107 Exercise card LAD9 Note: Display of remaining free parking Exercise 2.108 Text on the Display of the LRD… 51 Picture 2.109 Online display 2.17 Multiplexer MX Each of the 30 Multiplexer blocks offers the possibility to assign up to 4 variables to a setpoint input. The query of the variables is binary, using two bits. Example: A timer T01 to run at 4 different times depending on the application. The four variables (setpoints) are to be pre-selected by the two inputs I1 and I2. Prefix: I1 I2 Setpoint 0 1 0 1 0 0 1 1 1 10 100 200 I Picture 2.110 Multiplexer Menu Depending on the combination of the switches I1 and I2 corresponding to the setpoint, it is assigned to the timer. The timer module T01 at the setpoint input, the reference to the multiplexer module is entered MX01. Bild 2.111 Multiplexer in LAD 52 2.18 Text display H The MicroPLC offers the possibility of process-dependent texts with and without displaying variables together with the built-in display. For this the text module H is called in the program. Block-No.: 1 up 1F = 30 Text displays Picture 2.112 Text block Mode 1: MicroPLC with display Mode 2: MicroPLC without display, that means for an external display To enter text you will see in the menu bar of the software, the button "HMI / text" to be "clicked". Picture 2.113 To enter Text It opens the following menu: Note: The display of the LRD ... offers 4 lines with 16 characters each. Picture 2.114 Text input menu 53 2 1 4 3 Picture 2.115 Text input 1 If the display is activated (hook set), the user can view the SEL button to select the text. Use the ESC key, the text is cut off again. 2 Here, the variable can be with their unit select (Timer / counter / clock and analog comparator). 3 Here, the coil state of I, M, X and Z are shown. If you select the representation with the operand, then it is displayed as follows: e.g.: I01(unit) If no operands are selected e.g. "I01", only the state is shown: 4 „Analog Display Set“ : Here, another menu opens in which the amplification factor (gain) (1 ~ 999) and / or the offset (-50 ~ +50) is set. Picture 2.116 a+b Variable input 54 The example will now show how the analog input A1, with a gain of 100, and an offset of 50 in the display is visible. With the input I1, the variable to be displayed on the display of LRD12. The program is as follows: Picture 2.117 Text block in LAD Once the program is created, the HMI / Text window is opened and provided with the following entries: 1. step The gain and offset of A1 defined: (e.g. Gain = 100 and Offset = 50) 2. step a) Where the value should appear in the "HMI / Text" menu, enter text and click the cursor to the position. b) Then click on the selection window of the analog inputs and "A1" to select. Picture 2.118 Analog Set - menu a) b) 3. step Possibly one more text to add. 4. step Transfer and storage in the control Picture 2.119 Embed variable in the text Exercise: Text display LRD 16: As a supplement to LAD13 and LAD15 the temperature is shown in addition to the display of the LRD. Picture 2.120 Display in the LRD… 55 2.19 Comments for coil and contacts In practice, it often is not appropriate to use the coil and contacts with the names in the schematic. An appropriate comment increases the clarity and the reference to the machine and plant. Under the menu item "Edit" you will find the "Symbol ..." If you click on "Symbol ..." you open a selection window in which you can select the desired coil and contacts and provide comments. Text input Picture 2.121 open Text Input Picture 2.122 Text Input These then appear on the LAD chart below the contact and the coil. Picture 2.123 Text representation 56 2.20 Headlines and comments in the Ladder Diagram In a project it is very important that some program sections are commented. This makes the start-up and later troubleshooting much easier, thus saving costly downtime of a machine or system. For commenting the software offers the button "Note" Pictures 2.124 Comment Input Button If you have clicked this button, it will be like a coil or a contact to the location of the circuit diagram set. Then open the window for entering the text. There are 4 lines of 50 characters each available to you. Pictures 2.125 Comment Input Menu Note: Each comment is always uses one line in the ladder diagram. Picture 2.126 Comment representation 57 3. Function block diagram FBD If you want to create this project in function block language you have to click the button "FBD" just after opening the software. Function block diagram FBD Picture 3.1 Start Menu of the LRXSW to FBD One comes directly into the selection menu for the control. As in the LAD editor, we select the correct device LRD12TD024 Picture 3.2 Device selection menu 58 Click "OK" to return into the FBD editor. If the operating window is too small, it can be adjusted either under the "View" menu, "Zoom In" or drag the "Zoom Out" larger or smaller, or you can use the zoom function button: Picture 3.3 Zoom function If the operating windows are multiplied, that is made possible by on-click of the button. Working window Picture 3.4 Customize the working window To make all the icons visible click the button Picture 3.5 All symbols Like in the LAD editor most of the symbols in the respective chapters are explained. 59 3.1 Creating a function block diagram With the mouse pointer you select a logic symbol. As an example, we select the input. When the icon is selected it will appear on the field of work on mouse-pointer following logic symbol . When it is directed to the appropriate location, click on the left mouse button and the proper logic symbol is "stored". This is now stored with each click until you press the right mouse button or selecting a different icon. If you want to delete a logic icon again, it is clicked with the right mouse button. The following menu appears: Picture 3.6 Delete Or can be deleted with the "delete" key. With a double click of the left mouse button on the icon, a menu selection where one operand number appears. May change (input number) and store an operand text (icon). Picture 3.7 Parameter Input 60 In addition to the operand text, it is possible to store a general comment and to displace it with the mouse. To do this click with the right mouse button in the free field of work. The following window appears: Picture 3.8 To comment entry If you click "Insert Comments" first appears next to the mouse pointer a "T". You position it by clicking the left mouse button, the input window appears: Picture 3.9 Comment Input This comment is always displaced by clicking it with the left mouse button. It is marked with four red corners and can be moved around now. If you want to delete it again one uses the "Del" key on the PC keyboard. This also applies to all the logic symbols and connections. 3.1.1 Draw connections If you have placed at least two logic modules, you can connect them logically. For this, the link button is clicked and dragged to the field of work. Now you go with the mouse pointer to the quasi-dependents of the wiring to the module input or output. Whether you have "hit" the corresponding input or output can be recognized by a small square. One click and the connection can be drawn. Picture 3.10 Draw connections Note: If you have a straight logic symbol placed you can directly drag the link without having to click on the link button. 61 3.2 Logic sets in the FBD-Editor 3.2.1 AND operation The AND operation corresponds to the series circuit in a conventional, wired contactor control, the output is switched on when all switches are closed. Example: Logical AND operation with three digital inputs The output signal (H1), an AND operation is then "1" when all the input signals (S. ..) have the state "1". The "1" stands for an actuated normally open N.O. or a normally closed N.C. contact is not actuated. True list: S1 S2 S3 H1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 1 Logic algebra: FBS: 0 0 0 0 1 1 1 1 H1 = S1 & S2 & S3 S1 S2 S3 H1 H1 This "AND" supplies at the output (H1) for a cycle length a "1". The block can also be used as pulsemodule! Picture 3.11 AND-operation FBD Picture 3.12 AND operation in FBD 62 3.2.2 AND NOT-operation (NAND) The NAND operation corresponds to the series circuit in a conventional-wired contactor control, the output is turned off when all the switches are closed. Example: Logical NAND with three digital inputs The output signal (H1) of a NAND is always "0" if all the input signals (S. ..) have the state "1". The "1" stands for an actuated normally open or a normally closed contact is not actuated. True list: S1 S2 S3 H1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 1 1 Logic algebra: FBS: 0 0 0 0 1 1 1 1 S1 S2 S3 H1 = S1 & S2 & S3 H1 This "NAND" the output only delivers a "1" if a pulse of the input "0". Picture 3.13 NAND operation FBD Picture 3.14 NAND operation in FBD 63 3.2.3 OR operation The OR operation corresponds to the parallel circuit in a conventional wired voltage control, that is, the output is turned on when at least one of the three switches is closed. Example: Logical OR operation with three digital inputs The output signal (H1), an OR operation is then logic "1" if at least one or more input signals (S. ..) have the state "1". The "1" stands for an actuated normally open contact or a non-actuated normally closed contact. True list: S1 S2 S3 0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1 Logic algebra: FBS: H1 0 1 1 1 1 1 1 1 S1 S2 S3 H1 = S1 V S2 V S3 H1 Picture 3.15 OR operation FBD Picture 3.16 OR operation in FBD 64 3.2.4 AND before OR operation The three switches to be logically combined in AND and OR: The input of this logic is based on the fundamental rule of Boolean algebra: Point are performed before addition and subtraction In the implementation in the wiring logic, this means: Series is going on in parallel Example: It shows the implementation of a combined AND-OR circuit according to the rule mentioned above: True list: S1 0 1 0 1 0 1 0 1 S2 0 0 1 1 0 0 1 1 S3 0 0 0 0 1 1 1 1 Logic algebra: FBS: H1 0 0 0 1 1 1 1 1 H1 = S1 & S2 V S3 S1 S2 H1 S3 Picture 3.17 AND before OR operation FBD Picture 3.18 AND before OR operation in FBD 65 3.2.5 OR before AND function The four switches to be logically combined in OR and AND: The input of this logic is also called conjunctive form. Since the Boolean rule applies here, must be used with braces. Thus, it specifies that the OR operation is processed first. The representation in the application program corresponds to the international standard IEC 61131. Example: It shows the implementation of a combined AND-OR circuit according to the rule mentioned above: True list: S1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 S2 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 S3 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 FBS: S4 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 H1 0 0 0 0 0 1 1 1 0 1 1 1 0 1 1 1 Logic algebra: H1 = (S1 V S2) & ( S3 V S4) S1 S2 H1 S3 S4 Picture 3.19 OR before AND operation FBD Picture 3.20 OR before AND operation in FBD 66 3.1.4 OR-NOT operation (NOR) Three switches should be logically linked in NOR: The representation in the application program corresponds to the international standard IEC 61131. Example: It shows the implementation of a combined NOR circuit according to the truth table: True list: Logic algebra: FBS: S1 0 1 0 1 S2 0 0 1 1 S3 0 0 0 0 H1 1 0 0 0 0 1 0 1 0 0 1 1 1 1 1 1 0 0 0 0 S1 S2 H1 S3 Picture 3.21 OR-NOT operation FBD Picture 3.22 OR-NOT operation in FBD 67 H1 = S1 V S2 V S3 3.2.7 Exclusive-OR (XOR) The most used exclusive OR circuit, the Exclusive-OR circuit having two inputs. It differs to the OR operation to the effect that the output only becomes "1" when one of the two inputs are "1". If both inputs are "1", the output is "0". With such a circuit you can realize an interlocking of two input signals very simply. Example: Logical Exclusive-OR operation with two switches True list: S1 0 1 0 1 S2 0 0 1 1 Logic algebra: FBS: H1 0 1 1 0 S1 H1 S2 Picture 3.23 Exclusive-OR operation FBD Picture 3.24 Exclusive-OR operation in FBD 68 H1 = (S1 & S2) V ( S1 & S2) Exercises: Logic blocks FBD1a, FBD1b, FBD1c: These logical links provides a good introduction to the FBD language of LRD12 or LRD20 from Lovato Electric FBD 1c FBD 1b I1 Q1 & I2 NA ND I3 I3 & I4 I2 I2 >1 = >1 = I3 Q2 Q2 I4 I4 & I5 NOR I5 I5 >1 = =1 I6 I6 I6 LR D12 Picture 3.25 Exercise card FBD1a & LR D12 LR D12 Picture 3.26 Exercise card FBD1b 69 Picture 3.27 Exercise card FBD1c 3.2.8 Latching function In control engineering, the latching function is often used. Especially when using buttons will execute a stored function. A typical task is the on and off of a motor. The ON button is always a contact and the OFF button always an opener. Why the OFF button is normally closed, has something to do with the wire breakage. The VDE regulations state that in the event of a wire break, the relevant section (e.g. a motor) must be switched off immediately and must not be turned on. To realize a latching function in the MicroSPS offers the LRD ... two variants. 1. The dynamic control of the output: If the result of logic operation (RLO) = 1, then the output = 1 If the RLO = 0, the output = 0. Picture 3.28 Dyn. latching function 2. The static control of the output: Latching function with commands SET and RESET . Both commands work with the positive edge. Picture 3.29 Static latching function In both examples, it is ensured that while pressing both buttons ON and OFF, the output = 0. The wire breakage is protected , as in the case of a wire break in the "OFF" line drops the output in any case. 70 Exercise: latching function Sel bsthal tu ng /seal-i n-circu it I3 Sta rt >1 = & Q2 I4 FBD2a: Latching with dynamic control of Q2. (As in the contactor technology) Sto pp I5 S I6 R Q3 FBD2b: Latching static drive of Q3. (As with the conventional electronic controls on the flip-flops) Bei der Programmerstellung ist auf die Drahtbruchsicherheit zu achten! In case of programming pay attention to the fail-save circuit LR D12 Picture 3.30 Exercise card FBD2a+b 71 3.3 Selection menu of the Function Blocks In the FBD editor, the MicroPLC provides the same function as building blocks in the LADDER editor. Timer(Tx) Counter(Cx) RTC(x) ADD/SUB(AS) MUL/DIV(MD) multiplexer(MX) Analog ramp(AR) data register(DR) PID controller(PID) Picture 3.31 Function blocks in FBD 3.3.1 Timing relay T Start (Enable) input Setpoint input "t" switching output actual value actual value: setpoint value: Picture 3.32 Timer-Function block in FBD Double-click on the block to reach the following window: The timer offers 8 modes: Time base: 0,01s / 0,1s / 1s / 1 Min. time base Setpoint time: 0,01s up 9999 Min. actual value setpoint value Picture 3.33 Timer-Function block Note: The setpoint "Preset Value" of a timer can also come from an analog input or other device. More in "processing analog values" 72 Mode 0: Internal coil (like a marker) Mode 1: On-delay timer Enable Output Picture 3.34a Timer Mode 1 Mode 2: On-delay timer with reset input. If the enable is off, the timer stops. Only if the enable is switch "ON" again the timer continues to run. Enable Output Reset Picture 3.34b Timer Mode 2 Mode 3: OFF-delay timer. The rising edge of Enable (0 -> 1), the output is "ON". Time is running out only when the enable the edge falls (1 -> 0). If enable is turned on again during the running time, the value is set to "0". The timer can be restarted. Enable Output Reset Picture 3.34c Timer Mode 3 Mode 4: OFF-delay timer. If a falling edge of Enable (1 -> 0), the output is "ON" and the time is running out. If enable is activated again during the elapsed time, the actual value of the timer is reset to "0". The timer can be restarted. Enable Output Picture 3.34d Timer Mode 4 73 Mode 5: Synchronous clock generator The synchronous clock starts with the rising edge (0->1) and stops at the LOW edge (1 -> 0) to enable. The ON-time and OFF-time on the output are the same. Enable Output Picture 3.34e Timer Mode 5 Mode 6: Synchronous clock generator with reset Enable Output Reset Picture 3.34f Timer Mode 6 Mode 7: Asynchronous clock generator The asynchronous clock starts with the rising edge (0 ->1) and stops at the LOW edge (1 -> 0) to enable. The ON-time "t1" and the OFF-time "t2" at the output are equal. Enable OFF Output OFF ON ON OFF t1 t2 ON OFF OFF ON OFF Picture 3.34g Timer Mode 7 3.3.2 Pulse relay A special function of the timing relay is the pulse relays or latching relay. This function is shown in the diagram of the button: Example: With the switch I1 can be the output by briefly pressing on Q1. A new brief press of I1 Q1 turns off again. Q1= ON Picture 3.35 Pulse relay Q1= OFF Q1 74 Exercise: Timer relay I2 FBD3: With this exercise card all the modes of the timing relay with internal setpoint (e.g. 10 s) should be implemented. Enable I4 Q2 Reset Mode 1... 7 Pre Value: 10.00 Cur Value Picture 3.36 Exercise card FBD3 I1 Wend e-Ste rn-Dreieckscha lter reversin g sta r-delta swi tch FBD 4 Sicherung fuse I2 STOPP Stop Q1 Rechtslauf clockwise I3 Rechts right turn Stern star Q2 FBD4a: This motor controller uses information given on the training card inputs and outputs. The change from clockwise to anti-clockwise rotation is only about stop and vice versa. The time is 5 seconds. I4 Links left turn Linkslauf anti-clockwise Q3 Dreieck delta Q4 LR D12 Picture 3.37 Exercise card FBD4a Ampel / Traffic light LAD 7 FBD5 (like exercise LAD7): In metropolitan areas, side road access to highways is controlled in heavy traffic with a traffic light. The traffic light shows RED when the main switch I01 is turned on. An induction loop in the road surface before the traffic light detects an incoming vehicle. With 1s delay starts the traffic light cycle, which also takes 1 sec each for the individual phases. At the end of the traffic light cycle the lights are back on RED. If the induction loop is connected constantly, so the traffic lights cycle runs through the 1 sec intervals. LR D12 Picture 3.38 Exercise card FBD7/5 75 3.3.3 Counter C As with the timer the counter is a system component that needs to be configured simply. The MicroPLC offers a total of 30 counter blocks, each with 8 different modes. The presentation in the FBD editor provides the following information: Counting input Counting direction Setpoint switching output actual value actual value setpoint value Picture 3.39 Counter in FBD Counter-No.: The counter of LRD... Offers, like in the Ladder diagram, 8 different modes: Mode 0: internal coil (like a marker) Picture 3.40a Counter mode1 Mode 1: up-down counter without overflow. If the setpoint = actual value the counting input is disabled. The actual value is non-retentive. It loses its value when you turn off the controller. Setpoint input (0 ... 999999) Variables specification (e.g.: the result of arithmetic) Note: Compared with the LAD circuit diagram, the counting coil, the output of the counter, the counting direction and reset of the counter value in the FBD program be linked as shown in the example: 76 Mode 2: up-down counter with overflow. If the setpoint = actual value of the count input is not locked. The counter continues to count. The actual value is non-retentive. It loses its value when you turn off the controller. Note to "Reset Input" and "Direction Set" in Mode 2 • • "Reset input" has two functions. During counting up the reset is switched on, the current value of the counter is set to "0". When pressed while counting down the reset, then the setpoint "Preset Value" is set! If the setpoint is reached when counting up the output switches of the counter. Now, if the direction is switched, the output switches to "OFF" and again until the actual value = "0", the output is switched to "ON". If the direction is switched on again, the output switches back to "OFF" until the setpoint is reached again. Example: Mode 2 Picture 3.40b Counter Mode 2 Mode 3: Like Mode 1, but the actual value is non-volatile. It stores its actual value when you turn off the controller. Mode 4: Like Mode 2, but the actual value is non-volatile. It stores its actual value when you turn off the controller. Mode 5: Like Mode 2, but with the reset value is always set to "0", regardless of the direction. Mode 6: Like Mode 5, but non-volatile. Mode 7: High-speed counter, which is used either as pure forward counter of the fast inputs I1 or I2. Mode 8: 1 KHz-speed counter, which is used purely as an up-counter on the inputs I1 and I2. 77 Exercise: Counter FBD6a: The counter C1 is to be counted on the input I2 forward. If the value reaches 12, the counting should be interrupted. Only after the counter is reset by I6, I2 can be recounted again. Which mode is used to set? zählen CNT I2 Count Richtung Sollwert pre value = 12 Direction Mode 1 ... 8 I4 Q3 C1 löschen I6 Reset C1 Zähler / counter FBD 6a/6b/6c LR D12 Picture 3.41 Exercise card FBD6a/6b/6c I1 Sollwertvorgabe mit Vor-Rückwärtszähler setpoint via up-down counter LAD8a/8b / FBD7a /7b Q1 START Preset Value FBD6b: The exercise FBD6a is extended by the I3. With I3 can change the direction of the counter. a) How does Q3 behave when changing direction at the switching output of the counter? b) What happens if it is actuated while counting the reset? FBD6c: Like the exercise FBD6b, now to be automated changes of direction. If the counter reaches the value 12, it automatically switches to count down. If the counter value reaches the value "0", it switches back to counting up. It is changing until the count clock of 0.5 Hz is switched off by I02. FBD7a: Using an up-down counter of the target value for a timer from 0 to 50 sec ... To be adjustable. As the adjustment buttons Z keys are used with Z01 is forward (UP), with Z03 backward (DOWN) counted. FBD7b: Extension The setpoint and the actual value of the timer should be displayed on the display of the LRD. Timer 2 Counter UP DOWN Min=0 Max=50 LR D20 Picture 3.42 Exercise card FBD7a+b 78 3.3.4 Shift register S01 The function block "shift register S01" is a bit shift register and is available once. It can maximum be 8 steps high. Enable Sift input Picture 3.43 Shift register in FBD The start-coil "Start Coil" defines the first step in the shift register. It can be an output (Q, Y) or relays (M, N). If you have decided on a variable, all outputs or marker that have been defined with "Select 1-8", assigned. Picture 3.44 Shift register menu In this example, the outputs Q1-Q4 are occupied by the shift register The shift register operates as a ring shift register. This means in this example that the fourth time clock with the the input I02 the output Q01 is "ON" again. Exercise: Shift register „Start Coil“ Q01 Q02 Q03 Q04 Picture 3.45 Exercise FBD8a FBD8b: Create accordance with the exercise FBD5 with shift register. 79 3.3.5 Analog comparator G The 24VDC base unit LRD ... offers two analog inputs A1 and A2. The analog value of from 0 to 10V is applied to an analog to digital converter on the inputs, and converted into a binary number. The converted value can be compared over the analog values to comparator block G with different values. The analog comparator values offers 8 modes, the mode 0 is always an internal coil. Mode 1: (Ay-Ref.) <= Ax <= (Ay+Ref.) Ax and Ay can be assigned different. With the direct assignment to the potentiometer of the MiniTrainer you can easily try out the formula. Example: Ax = A01(0…10V) Ay = e.g.: 7V Ref.= 2V d.h.: 5V <= Ax <= 9V Picture 3.46 Example Analog comparator If the reference value is set to 2V and you turn the potentiometer A1, then the output of the analog comparator is switch on at 5V, and switch off at 9V again. Mode 2: (Ax <= Ay) The output of the block "G" is "ON" when the analog value of A1 is less than or equal to the value of A2. A1 A2 Ax = Adjustable example via the potentiometer A1 Ay = Adjustable example via the potentiometer A2 Picture 3.47 Potentiometer on the MiniTrainer(XL) Additional functions: Mode 3: (Ax> = Ay) Ax greater than, equal Ay Mode 4: (Ax <= ref) Ax less than, equal a fixed value. Mode 5: (Ax >= Ref.) Ax greater than, equal a fixed value. Mode 6: (Ax = Ref.) Ax equal a fixed value. Mode 7: (Ax> <ref) Ax smaller or larger but not the same. 80 Exercise: Analog comparator Ana log werteverg lei cher Anal og compa rator FBD 9a +b Q1 0,5Hz FBD9a+b: a) Two analog values to be compared. Once the comparator output is ON, Q2 is on and Q1 flashing at 0.5 Hz. Q2 Ax >= Ay (Mode …) b) In this exercise AI01 should be compared to a constant value of 25 according to the sketch (mode ....). Ai01 >= Ai02 Ai01 500 01 02 LR D12 Picture 3.48 Exercise card FBD9a+b Q2=“1“ 0 Wende -Stern -Drei eckscha lter re versin g star-d elta swi tch FBD 9c I1 Sicherung fuse Q1 Rechtslauf clockwise I2 STOPP Stop I3 Rechts right turn Stern star Q2 value= 25 FBD9c: This motor controller is using the informations given from the training card inputs and outputs. The change from clockwise to anti-clockwise rotation is only about stop and vice versa. The star to delta transition time is variably adjustable via the analog input A1 between 5 and 20s. I4 Links left turn Linkslauf Q3 anti-clockwise A1 5 20s Note: Since the potentiometer A1 is not of MiniTrainer very accurate, the maximum value in result cannot be achieved exactly 20s. Dreieck delta Q4 LRD12 Picture 3.49 Exercise card FBD9c 81 3.3.6 Multiplexer MX Each of the 30 multiplexers provide the ability to assign up to 4 variable to a setpoint input. The query variable is binary, using two bits. The program example will illustrate this: The timer T01 to run at 4 different times depending on the application. The four variables (setpoints) are to be preselectable by the two inputs I2 and I3. Prefix: (Vorwahl) I2 I3 0 1 0 1 0 0 1 1 Setpoints V1…3 10 15 20 25 Depending on the switch combination of I2 and I3 the corresponding setpoint is assigned to the timer T01. The setpoint input of the timer module T01 is connected to the output of the multiplexer block MX01. Picture 3.50 MX function block Picture 3.51 Exercise Multiplexer FBD10 82 3.3.7 Boolean function BL The MicroPLC offers a Boolean logic unit. The standard block can be 4 digital input signals combined (16 possibilities). Input 1 Input 2 Input 3 Input 4 Output Picture 3.52 BL function block in FBD The 16 possibilities are represented in binary code: Picture 3.53 BL Binary code The output of the block is one bit and can be optionally specified with "1" or "0". Example: Using the BL block to create a code lock. The code consists of a number between 0 and 9 (1 decade). If the code is correct, the output Q01 of 0.5 s will be "ON". 0 2 2 2 1 2 4 =2 =4 =8 Picture 3.54 Exercise code lock FBD11 83 Exercise: Boolean Functions I2 I3 =1 Q3 FBD12 Based on the training card you will be programming a Boolean block for an exclusive OR with 4 inputs. That is, the output of Q01 is "1" if only one input is "1". I4 I5 XOR mit 4 Eingängen XOR with 4 inputs FBD12 LR D20 Picture 3.55 Exercise card FBD12 84 3.3.8 Pulse-width modulation (PWM) P The MicroSPS with transistor outputs offers the option of the digital output Q01 via the pulse width modulation block (P) to drive. The PWM block offers two modes: Mode 1: Enable Sel 1 Sel 2 Level 0 Q01 Picture 3.57 P function block in FBD (Mode 1) Pulse width modulation is a convenient way to have a digital output, e.g. a frequency converter to control a motor in the speed or control. Picture 3.56 P Menu Mode 1 To get to know this function, you can realize a simple link. It performs both analog signals A1 and A2 of the MiniTrainers as set values (preset value) to the module. This is done by setting the variable type "A" by selecting the "Preset Type". Where A1 is the time in milliseconds (ms) for the frequency and A2, the time indication for the high signal also in milliseconds. Selection of profiles Note: "T" must be always greater than "t" and can not be "0", that is, A01 must always be greater than A02. Picture 3.58 P Menu Mode 1 If you choose, however, the variable Type "N" then constant values can be used (0. 32767) for the profile of "T" and "t" to enter. Select 1 is always the profile that is activated by enable. The two inputs Sel1 and Sel2 of the PWM module allow an additional two profiles retrieve. FBD 13: I1 = Enable = Select 1 = T= 200ms t=50ms I2 = Select 2: T= 400ms t=50ms I3 = Selekt 3: T= 400ms t=10ms I4 = Stop 85 Mode 2: In Mode 2, a frequency PF is output (in Hz) for a predetermined time period PN. Enable Q01 Picture 3.59 P function block in FBD (Mode 2) FBD 13a For testing the function both analog inputs of the MiniTrainers are used: Picture 3.60 PWM funktions Exercise: PWM Sil o / Tan k FBD1 4 I1 Start/Stopp PWM Q1 M Silo / tank Voll Enable Q3 IA1 FBD14: This exercise is to regulate a pump for filling a tank. The level is recorded as a measure via the analog input IA1. The tank is emptied through the manual outlet, the filling level and the analog value is lowered and falls to 0V. With the input I1, the system is switched on and off. The pump controller consists of the release of Q3 and the PWM - output Q1. If the level reading reached IA1 the value of 9.5 V, the release of Q3 is removed. The fuller the tank, the slower the pump. If the tank is empty, the pump runs at full speed. If the tank is full, the speed is zero. LR D12 Picture 3.61 Exercise card FBD14 IA1= ~10V 0V ~0,5Hz …………………….~500Hz (PWM) 86 3.3.9 Text H The text block can be used 30x. Mode1 means with display and Mode2 means without display Enable Picture 3.62 H Text block The editor for text entry is located, as in the LAD editor, in the "Edit" menu -> "HMI / Text" Picture 3.63 Text Input 3.3.10 Display backlight The display of the LRD ... can remain switched on for the program. For this, the menu offers "Operation" in the stop mode or in offline mode from the submenu: "Module System Set ..." the possibility of program-related backlight Picture 3.64 To adjust the backlight Picture 3.65 Display backlight 87