1.61k likes | 1.83k Views
IEC61131-3 Training. Agenda. Introduction to the standard Using the workbench Programming languages - Ladder Diagram (LD) - Function Block Diagram FBD) - Structured Text (ST) - Instructions List (IL) - Sequential Function Charts (SFC) 4. Exploring the OCS using IEC61131
E N D
IEC61131-3 Training IEC61131-3 Training Course
Agenda • Introduction to the standard • Using the workbench • Programming languages • - Ladder Diagram (LD) • - Function Block Diagram FBD) • - Structured Text (ST) • - Instructions List (IL) • - Sequential Function Charts (SFC) • 4. Exploring the OCS using IEC61131 • - high speed counter • - serial communications • - CompactFlash for data-logging • - PID • - Ethernet • 5. Appendices IEC61131-3 Training Course
Introduction to the standard • The wide range of different programming techniques and languages for industrial applications and PLCs meant that one had to spend a lot of time and money training staff. • The industrial community and the IEC recognised this problem and looked at the complete design of PLCs, including hardware design, installation, testing, documentation, programming and communications. • During the 1990s the IEC published various parts of the IEC61131 standard (see appendix) • The IEC recognises the need for an ‘open systems’ approach to build large systems using equipment from different manufacturers. IEC61131-3 Training Course
Deficiencies of ladder programming Conventional ladder programming has a number of deficiencies: • Ladder symbols vary between different PLC products • Poor facilities for structured or hierarchical program decomposition • Limited facilities for software reuse • Poor facilities for addressing and manipulating data structures • Limited facilities for building complex sequences • Limited control over program execution • Facilities for arithmetic operations are cumbersome IEC61131-3 Training Course
Features of IEC61131-3 Encourages well structured “top-down” or “bottom-up” development • Allows a program to be broken down into functional elements including functions, function blocks and programs. Requires strong data typing • Reduces programming errors Support for full execution control • different parts can scan at different rates under “task” control Full support for describing sequences • Complex sequential behaviour can be easily broken down using SFC to describe steps and transitions IEC61131-3 Training Course
Features of IEC61131-3 Support for defining data structures • Associated elements can be passed between different part of a program as a single entity. Improves program readability and ensures associated data is always accessed correctly. Flexible language selection • 3 graphical and 2 textual languages for expressing different parts of a control application. Standardised languages and methods of program execution • A wide range of technological problems can be programmed as vendor-independent software elements. IEC61131-3 Training Course
Sequential Function Charts • A graphical language for depicting sequential behaviour of a control system. • It is used for defining control sequences that are time and event driven. • This is an extremely effective graphical language for expressing both the high level sequential parts of a control program as well as programming low-level sequences, e.g. to program an interface to a device. IEC61131-3 Training Course
A high level textual language that encourages structured programming. It has a syntax that strongly resembles PASCAL and supports a wide range of standard functions and operators. The standard includes a formal syntax definition of ST Structured Text IEC61131-3 Training Course
Instructions List A low level “assembler like” language that is based on similar instruction list languages found in a wide range of today’s PLCs. IEC61131-3 Training Course
A graphical language for depicting signal and data flows through function blocks (re-usable software elements). FBD is very useful for expressing the interconnection of control system algorithms and logic. Function Block Diagram IEC61131-3 Training Course
Ladder diagram • A graphical language that is based on the relay ladder logic (a technique commonly used on current generation PLCs. • However, the IEC Ladder Diagram language also allows the connection of user defined blocks and functions and so can be used in a hierarchical design. IEC61131-3 Training Course
Benefits of IEC61131-3 • Provides a variety of languages for solving different types of industrial control problem. • Encourages the development of quality software through well structured design, the use of encapsulation and information hiding. • Its use will allow the same control software to be developed for different PLC products. • Formalisation of re-usable software, especially function blocks should result in improving the productivity of system designers through the provision of off-the-shelf solutions. • Programming tools are emerging that offer support for the complete PLC software life-cycle. IEC61131-3 Training Course
The IEC workbench A new look to OCS programming IEC61131-3 Training Course
Using the workbench • Launch the IEC workbench from Cscape using the IEC61131 button IEC61131-3 Training Course
The main window The main workbench window contains the following buttons: 1. Always on top pin:ensures that the main window is always visible 2. Program list button:opens the program list window containing all the programs and sub- programs present in the project. 3. Variables editor button:opens the variables editor window containing all the variables used in the project grouped by global, retain, and program locals 4. Window list box:gives a quick access to a specific open window 5. Compile button:compiles the project ready or download to the target; any errors will be shown in the build window 6. Connect to target button:puts the workbench into debug mode and monitors variables and program state on the target 7. Watch window button:opens the watch window containing the list of specific variables to monitor 8. Screens editor button:opens the standard Cscape screen editor after a successful compilation, i.e. there are no errors in the program 9. I/O configuration:opens the standard I/O configuration that allows the user to select the target configuration 10.Network configuration:opens the Cscape Network configuration allowing the user to set networked data exchanges up 11.Download button:opens the Cscape smart download window allowing the user to specify which parts of the project need to be downloaded to the target 12.The traffic light buttons: have the same functionality as in the standard Cscape workbench. Switching the target between different operational modes (RUN, Do I/O, Stop) IEC61131-3 Training Course
3. Variables editor button 2. Program list button 4. Window list Box 5. Compile button 1. Always on top pin 7. Watch window button 8. Screen editor button 12. “Traffic lights” buttons 6. Connect to target button 9. I/O configuration button 10. Network configuration button 11. Download button IEC61131-3 Training Course
The program list • The program list window contains the list of programs and subprograms in the project. • To add a new program/sub-program click on the New Program button. • A right click in the program list allows to create new programs but not sub-programs and offers a short cut to other program manipulations. • The execution order is the order in which the programs appear in the list. IEC61131-3 Training Course
The variables editor • The variable editor lists all the variables declared in each program and sub-program as well as global variables. • To help in the program documentation descriptions can be added to the variable definition. IEC61131-3 Training Course
Workbench panes The variable editor enables you to create/ change variable declaration in place. The information pane guides you to the most important links in the help. It also enables you to quickly navigateamong the programs and sub-programs of the application. The library of blocks shows the list of available functions and blocks from the library and the project. The build pane shows the result of the compilation. IEC61131-3 Training Course
Constant expressions • Boolean (BOOL) • Reserved keywords TRUE and FALSE • Small integer (SINT) • Signed 8 bit value (-128 to 127) • Must be prefixed with “SINT#” • Integer (INT) • Signed 16 bit values (-32768 to 32767) • Must be prefixed with “INT#” • Double integer (DINT) • Signed 32 bit values (-2147483648 to 2147483647) • Default type does not need a prefix IEC61131-3 Training Course
Constant expressions • Real (REAL) • Single precision floating point values • Always require a “.0” at the end of the number • USE “F” or “E” separators for specifying the exponent • Time of day (TIME) • Time constant expressions represent duration less than 24hours • Must be prefixed with “T#” or “TIME#” • “h” for hours, “m” for minutes, “s” for seconds and “ms” for milliseconds • Example: T#3h42m15s30ms IEC61131-3 Training Course
Programming languages Languages adapted to expressing solutions to different problems IEC61131-3 Training Course
Ladder diagram (LD) “Programming with contacts and relays” IEC61131-3 Training Course
LD - Power rails • The power rail on the left represents the TRUE value and initiates the rung state. • The power rail on the right receives connections from the coils and has no influence on the execution of the program. IEC61131-3 Training Course
LD - Contacts • Contact types: Normal: The rung state on the right is the boolean AND between the rung state on the left and the associated variable. Negated: The rung state on the right is the boolean AND between the rung state on the left and the negation of the associated variable. Positive pulse: The rung state on the right is TRUE only when the rung state on the left is TRUE and the associated variable changes from FALSE to TRUE (rising edge). Negative pulse: The rung state on the right is TRUE only when the rung state on the left is TRUE and the associated variable changes from TRUE to FALSE (falling edge). IEC61131-3 Training Course
LD - Coils Coil types: Normal: The associated variable is forced to the value of the rung state on the left of the coil. Negated: The associated variable is forced to the negation of the rung state on the left of the coil. Set: The associated variable is forced to TRUE if the rung state on the left is TRUE (No action is the rung state is FALSE). Reset: The associated variable is forced to FALSE if the rung state on the left is TRUE (No action if the rung state is FALSE). Positive edge pulse: The associated variable is TRUE for one cycle when the rung state changes from FALSE to TRUE. Negative edge pulse: The associated variable is TRUE for one cycle when the rung state changes from TRUE to FALSE. IEC61131-3 Training Course
Insert contact before selection Insert contact after selection Insert contact in parallel with selection Insert FB before selection Insert FB after selection Insert FB in parallel with selection Insert jump Insert a coil Insert a new rung Insert a comment line LD - Editor Shift rung right IEC61131-3 Training Course
LD - Exercise 1 • Create a simple LD program that: • Sets bOut1 to TRUE when bIn1 is FALSE and bIn2 is TRUE • Sets bOut2 to TRUE when bIn3 is TRUE and (bIn4 is FALSE or bIn5 is TRUE) IEC61131-3 Training Course
LD - Exercise 1 (a solution) IEC61131-3 Training Course
LD - Block call • Blocks are connected to the rung with their first input and output. • This implies that special “EN” and “ENO” input and output are added to the block if its first input and output are not boolean. IEC61131-3 Training Course
LD - Exercise 2 • Create a simple LD program that has the following actions on the rising edge of bOn: • Val4 = Val1 + Val2 + Val3 • Val6 = Val4 - Val5 IEC61131-3 Training Course
LD - Exercise 2 (a solution) IEC61131-3 Training Course
LD - Jump/Label • Each rung may begin with a label. • Labels are used as destination for jump instructions. IEC61131-3 Training Course
LD - Exercise 3 • Create a simple LD program that does the following: • If Val1 > Val2 then dResult = Val1 - Val2 • Else dResult = Val2 - Val1 IEC61131-3 Training Course
LD - Exercise 3 (a solution) IEC61131-3 Training Course
Function Block Diagram (FBD) “It looks like electronic schematic capture” IEC61131-3 Training Course
FBD - Data flow • A function block diagram is a data flow between constant expressions or variables and operations represented by rectangular blocks. • The data flow is going from left to right and top to bottom. IEC61131-3 Training Course
Selection button Insert a function block Insert a variable Insert a comment Draw an arc Insert a corner Insert a break Insert a label Insert a jump Insert a left power rail Insert a contact Insert an OR bar Insert a coil Insert a right power rail FBD - Editor IEC61131-3 Training Course
FBD - Exercise 1 • Create an FBD program that does the following: • Result1 = In1 + In2 + In3 • Result2 = In1 * In2 * In3 IEC61131-3 Training Course
FBD -Exercise 1 (a solution) IEC61131-3 Training Course
FBD - Instance • The name of the operation or function, or the type of function block is written within the block rectangle. • For a function block call, the name of the called instance must be written above the block rectangle. • A function or operation has no memory, a function block may have internal memory. This is reflected by the need for an instance name. IEC61131-3 Training Course
FBD - Boolean negation • On boolean connections, one can use a connection link terminated by a small circle indicating the negation of the data flow. IEC61131-3 Training Course
FBD - Jump / Label • Labels are used as a destination for jump instructions. • A jump to a label branches the execution of the program to the functions following the label. IEC61131-3 Training Course
FBD - Return • Jump to the RETURN label effectively terminates the execution of the current program. IEC61131-3 Training Course
FBD - Exercise 2 • Create an FBD program that sets bRun to TRUE 5 seconds after the following conditions are TRUE: • bEmergencyStop is FALSE • bStart is TRUE • Use the TON100MS function block IEC61131-3 Training Course
FBD - Exercise 2 (a solution) IEC61131-3 Training Course
FBD - Ladder diagram • LD symbols may also be entered in FBD language and linked to FBD objects. IEC61131-3 Training Course
Structured Text (ST) “It’s a bit like PASCAL” IEC61131-3 Training Course
ST - Comments (* My comment *) a := d + e; (* A comment can also be on several lines *) b:= d * e; c := d - e;(* Inline comment*) • Begin with “(*” • End with “*)” • Anywhere in the program • Several lines • Cannot be nested IEC61131-3 Training Course
ST - Expressions • Each statement describes an action and may include evaluation of complex expressions. • An expression is evaluated: • from left to right; • according to the default priority order of operators • the default priority can be changed using parenthesis • Arguments of an expression can be: • declared variables • constant expressions • function calls IEC61131-3 Training Course