EPFL, Spring 2017 3 PLC Programming
The long march to IEC 61131 PLC industry needs aggreement on • Data types (operations may only be executed on appropriate types) • Programming languages • Software structure (program organization units for modularity, encapsulation) • Execution NEMA Programmable Controllers Committee formed (USA) GRAFCET (France) DIN 40719, Function Charts (Germany) NEMA ICS-3-304, Programmable Controllers (USA) IEC SC65A/WG6 formed it took 20 years to make that standard… DIN 19 239, Programmable Controller (Germany ) IEC 65A(Sec)38, Programmable Controllers MIL-STD-1815 Ada (USA) IEC SC65A(Sec)49, PC Languages IEC SC65A(Sec)67 IEC 848, Function Charts IEC 64A(Sec)90 IEC 1131-3 Type 3 report recommendation IEC 61131-3 name change 70 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 Source: Dr. J. Christensen Industrial Automation | 2017 2
"Real-Time" languages Extend procedural languages to Languages developed for cyclic express time execution and real-time (“introduce programming constructs to ("application-oriented languages") influence scheduling and control flow”) • ADA • Ladder Diagrams • Real-Time Java • Function block diagrams • MARS (TU Wien) • Instruction lists • Forth • GRAFCET • “C” with real -time features • Sequential flow charts • etc… etc... could not establish themselves wide-spread in the control industry. Now standardized as IEC 61131 Industrial Automation | 2017 3
Matching the analog and binary world Binary World Analog World Pneumatic and electromechanical Relay control, pneumatic controllers sequencer I1 A B C P1 P2 combinatorial sequential regulation, controllers continuous processes discrete processes time constant of the control system must variables with non-overlapping values, be at least one order of magnitude smaller transition from one state to another is than smallest time constant of plant. abrupt, caused by external events. PLC Industrial Automation | 2017 4
IEC 61131-3 programming languages http://www.isagraf.com Sequential Flow Chart (SFC) Graphical languages START STEP Function Block Diagram (FBD) PUMP T1 CALC DO >=1 N ACTION D1 D1_READY AUTO IN1 OUT STEP A V MAN_ON D ACTION D2 D2_READY IN2 T2 ACT N D3_READY ACTION D3 STEP B Ladder Diagram (LD) ACTION D4 D D4_READY T3 CALC PUMP AUTO OUT IN1 OUT ACT Textual languages Structured Text (ST) IN2 MAN_ON VAR CONSTANT X : REAL := 53.8 ; Z : REAL; END_VAR VAR aFB, bFB : FB_type; END_VAR Instruction List (IL) bFB(A:=1, B:=‘OK’); A: LD %IX1 (* PUSH BUTTON *) Z := X - INT_TO_REAL (bFB.OUT1); ANDN %MX5 (* NOT INHIBITED *) IF Z>57.0 THEN aFB(A:=0, B:=“ERR”); ST %QX2 (* FAN ON *) END_IF Industrial Automation | 2017 5
Importance of IEC 61131 IEC 61131-3 are the most important automation languages in industry. 80% of all PLCs support it, all new developments are based on it. Depending on the country, some languages are more popular than others. IEC 61499 extends IEC 61131 with an event-driven model, has not established itself yet. More information: http://www.plcopen.org/pages/tc1_standards/downloads/plcopen_iec61131- 3_feb2014.pptx http://www.plcopen.org/pages/pc2_training/downloads/index.htm Industrial Automation | 2017 6
Connecting to Input/Output The inputs and outputs of the PLC must be connected to (typed) variables IN_1 OUT_1 The I/O blocks are configured to be attached to the corresponding I/O groups. Industrial Automation | 2017 7
Connecting to Input / Output All program variables must be declared with name and type, initial value and volatility. A variable may be connected to an input or an output, giving it an I/O address. Several properties can be set: default value, fall-back value, store at power fail ,… Industrial Automation | 2017 8
Function Block Diagrams • Graphical language to express programs in a way similar to electronic circuits • Using predefined and custom functions, like Matlab / Simulink • For continuous functions and combinatorial logic, may have memory (e.g. RS-flip-flops) Example 1: A & C B Example 2: external outputs external inputs Trigger & Tempo S Q Spin Running R Reset Industrial Automation | 2017 9
Function block elements parameters input signals output signals "continuously" PID set point command executing block, independent, overflow measurement no side effects The block is defined by its: • Data flow interface (number and type of input/output signals) • Black-box behavior (functional semantic, e.g. in textual form). Signals are typed connections that carry a pseudo-continuous data flow set point (set point) (set point) Industrial Automation | 2017 10
Function block rules • Each signal is connected to exactly one source. This source can be the output of a function block or a plant signal. • The type of the output pin, the type of the input pin and the signal type must be identical . Signals should flow from left to right and from top to bottom Retroactions are an exception to this rule, where the signal direction is identified by an arrow (forbidden in some editors, use global variables instead). a b x z c y Industrial Automation | 2017 11
Types of Programming Organisation Units (POUs) 1) “Functions” - are part of the base library. - have no memory . Examples: and gate, adder, multiplier, selector,.... 2) “Elementary Function Blocks” (EFB) - are part of the base library - may have a memory ("static" data). - may access global variables (side-effects !) Examples: counter, filter, integrator,..... 3) “Programs” (Compound blocks) - user-defined or application-specific blocks - may have a memory - may be configurable (control flow not visible in the FBD Examples: PID controller, overcurrent protection, motor sequence (a library of compound blocks may be found in IEC 61804-1) Industrial Automation | 2017 12
Function block library The programmer chooses the blocks in a block library, similarly to the hardware engineer who chooses integrated circuits in a catalogue. The library describes the pinning of each block, its semantics and the execution time. The programmer may extend the library by defining function block macros composed of library elements. If some blocks are used often, they will be programmed in an external language (e.g. “C”, micro -code) following strict rules. Industrial Automation | 2017 13
Library functions for discrete and continuous plants Basic blocks Basic blocks Logical operations(AND, OR, …) Summator / Subtractor Multiplier / Divider Flip-flop Integrator / Differentiator Selector m-out-of-n Filter Multiplexer m-to-n Min, Max Timer Counter Regulation Functions Memory P, PI, PID, PDT2 controller Sequencing Fixed set-point Compound blocks Ratio, multi-component regulation 2-point regulation Display 3-point regulation Manual input, touch-screen Output value limitation Safety blocks (interlocking) Ramp generator Alarm signaling Adaptive regulation Logging Drive Control Industrial Automation | 2017 14
Function block library for specialized applications MoveAbsolute Axis Axis AXIS_REF AXIS_REF Done BOOL BOOL Execute REAL CommandAborted Position BOOL REAL Velocity BOOL Error Acceleration REAL ErrorID WORD Deceleration REAL Jerk REAL MC_Direction Direction standardized blocks are defined in libraries, e.g. motion control or robotics Industrial Automation | 2017 15
Specifying the behaviour of function blocks Time Diagram: 0 T y x x y T Truth Table: x1 x2 y x1 S 0 0 previous state 0 1 0 R x2 1 0 1 1 1 1 t x dx y Mathematical Formula: K x K K xd p d i dt 0 Calculates the root mean square of the input with a filtering constant Textual Description: defined in parameter „FilterDelay“ Industrial Automation | 2017 16
Function block specification in structured text Industrial Automation | 2017 17
Execution of function blocks Segment or POU X01 A X F1 F2 (program organization unit) B F4 C X02 F3 Y Machine Code: function F1 input1 A The function blocks are input2 B output X01 translated to machine language F2 (intermediate code, IL), X01 that is either interpreted or X compiled to assembly language F3 B Blocks are executed in sequence, C X02 normally from upper left to lower right F4 X The sequence is repeated every t ms. X02 Y Industrial Automation | 2017 18
Input-output of function blocks Run-time: read write inputs outputs I X O I X O I X O time individual period execute Executed cyclically: 1. all inputs are read from memory or plant (possibly cached) 2. segment is executed 3. results are written into memory or to plant (possibly to cache) • Order of execution of the blocks does not matter • For speed it can help to impose execution order on blocks • Different segments may be assigned different periods Industrial Automation | 2017 19
Recommend
More recommend