industrial automation course -...

54
Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 1 Industrial Automation course Lesson 2 PLC - Introduction

Upload: dangliem

Post on 10-Apr-2018

223 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 1

Industrial Automation course

Lesson 2

PLC - Introduction

Page 2: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 2

What is a PLC

PLC: Programmable Logic Controller

Processing unit able to drive the actuator due to variations acquired from the sensors connected to it

Page 3: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 3

What is a PLC

PLC: Programmable Logic Controller

In order to work, this device needs to execute task at a defined frequency, for this reason it must be real-time

What does real-time mean?

It means to know the maximum execution time of a code portion

Page 4: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 4

PLC cycle

N.B.: Usually the cycle re-launch time is defined; however, with some PLCs (for example Siemens), is a function block, with a predefined sampling time isn’t used, the execution will be in an «infinite loop», then without a known re-launch time

Inputs Acquisition

Algorithms execution

OutputsWrite

Page 5: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 5

Real-time

Each PLC maker personalizes one or more real-time operating systems, in order to allow the integration with its own devices

The most used operating systems, used in the field of industrial automation are:

•VXWorks

•QNX

•Windows embedded (or CE)

Page 6: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 6

Real-time

How does a real-time operating system work?

A real-time operating system is a deterministic system, it means that it is able to guarantee, a priori, the maximum execution time of a program.

Definitions:

•Release time: the time in which the program is available for the execution

•Deadline: the time by which the execution must be terminated

•Completion time: the execution finish time

Page 7: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 7

Real-time

Considering the PLCs, usually:

•Release time: the program is available for the next execution when the deadline is reached

•Deadline: corresponds to the re-launch time of the software

•Completion time: depends from the CPU load used in the execution of the software

Page 8: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 8

Real-time

Execution example

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Tempo [s]

Ese

cu

zio

ne

Deadline

Esecuzione

Page 9: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 9

When a PLC is necessary

Product variability

Pro

du

cts

volu

me

s

Embedded electronics

PLC

Modular PLC The PLC is useful in very

variable systems with a reduced number of pieces (or, even, in one single prototype, as the production lines) when the complexity in terms of interfaces is very high

Page 10: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 10

PLC types

μPLC Medium PLC Big PLC

In – Out <= 64Since some years with

Digital / Analogic expansion modules

64 < In – Out < 512 In – Out >=512The difference between these two PLC types is loosing importance because of the massive usage of modular

PLCs

Page 11: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 11

Structure

DIN rail

CPU

Ethernet interface (programming /

connectivity)

Powerlink

Battery

Compact Flash O.S. + Software

Interface modules

IO modules

Power supply module

Page 12: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 12

Hardware architecture

The trend, in the last years, is to bring the PLC architecture to that of a normal x86.

Generally, the used memory are:

• EEPROM that contains the O.S and the user software (now installed on removable memory as CF, SD, etc…)

•RAM that contains the software in execution and holds the variables (in some cases the RAM is kept active with the battery, in case of power supply loss)

Page 13: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 13

Hardware architecture

There are a lot of I/O boards, the most important (that can be found on the companies catalogues) are:

•Analogic In / Out (10 V, -20÷20 mA, 4÷20 mA)

•Digital In / Out (5 V-DC, 24 V-DC, 240 V-AC)

•Motor control In / Out (encoder, PWM)

•Various In (thermocouples, load cells, etc…)

• Fieldbus interfaces

Page 14: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 14

Programming

All the PLCs can be programmed with a PC (usually with a Windows O.S.)

Basically, all the companies use the Ethernet interface on the PLC

Almost all use a proprietary programming software, some of them are compatible with third part development environment (for example Codesys)

N.B.: For the Lab lectures we use B&R Automation Studio 4.0

Page 15: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 15

IEC 61131

IEC is a no-profit and non governmental organization born with the aim of to define and publish standards related to the electrical / electronic technologies (and those connected to them)

It is born on June 26, 1906 from the English IEE and the American AIEE

The headquarter was, in the beginning, in London, but since 1948 it was moved to Genève

Page 16: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 16

IEC 61131

Relating to the PLC standards, the reference norm is the IEC 61131 (that, before the numbering variation of the 1996 was called IEC 1131)

Page 17: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 17

IEC 61131

Why this norm is so important?

Because it is also a de facto standard in the industry

Because the 80% of the PLCs is based on it

Because allows to keep a coherent structure with the «rest of the world»

Page 18: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 18

IEC 61131

The norm is composed of these parts:

1. General overview, definitions

2. Hardware

3. Programming languages

4. Users guidelines

5. Communication

7. Fuzzy logic programming

8. Implementation guidelines

Page 19: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 19

Application structure

Configuration

Resource Resource

Page 20: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 20

Application structure

Configuration

Resource Resource

Program Program

FB FB

Program Program

FB FB

Page 21: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 21

Application structure

Configuration

Resource Resource

Program Program

FB FB

Program Program

FB FB

Task Task Task Task

Inputs acquisition

Algorithms execution

OutputsWrite

Page 22: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 22

Application structure

Configuration

Resource Resource

Program Program

FB FB

Program Program

FB FB

Task Task Task Task

Global and directly represented variables

Access paths

Variabile

Access path

Communication function

Page 23: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 23

Application structure

The communication between the programs can be

• Inside the same configuration

Direct if between two function blocks of the same program

Using global variables if between two programs

•Between two configurations

Direct, using communication function blocks

Access to a shared access path

Page 24: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 24

Programming languages

In the third part of the norm (as already mentioned) five possible programming languages are defined:

• Ladder Diagram

• SFC – Sequential Function Chart

• FBD – Function Block Diagram

• Instruction List

• ST – Structured Text

N.B.: In order to guarantee the real-time execution, these languages are usually converted in low-level instructions

Graphical languages

Textual languages

Page 25: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 25

Programming languages

Common elements of the 5 IEC 61131 languages:

• Identifiers

The first character can’t be a number

It isn’t possible to use two consecutives _

Without spaces

•Keywords

PROGRAM, FUNCTION, VAR, END_, etc…

BOOL, BYTE, WORD, INT, REAL, TIME, STRING, prefix S, D, L, U, etc…

RETAIN, CONSTANT, etc…

Page 26: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 26

Programming languages

Common elements of the 5 IEC 61131 languages:

• Functions

ADD, SQRT, SIN, COS, GT, MIN, MAX, AND, OR, etc…

Page 27: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 27

Programming languages

Ladder Diagram

It is the oldest programming languages of the IEC 61131 norm

It is based on symbols that come from the electric field: Power rails, Contacts, Coils, etc…

It is called Ladder because of the graphical structure that the programs implemented in this language have

Page 28: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 28

Programming languages

Ladder Diagram

Page 29: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 29

Programming languages

SFC – Sequential Function Chart

Language derived from the IEC 848 standard

It is a sequencing oriented language, for this reason it is suitable for a top-down programming approach

It is based on: Step, Transitions, Actions, Oriented arcs

Page 30: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 30

Programming languages

SFC – Sequential Function Chart

Page 31: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 31

Programming languages

FBD – Function Block Diagram

Language derived from the IEC 167 standard

The FBD graphical representation is similar to that of the block diagram (will be explained in the Prof. Corno’s course)

Usually isn’t used a lot for the logical control

The execution depends from the position of the blocks

Page 32: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 32

Programming languages

FBD – Function Block Diagram

Page 33: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 33

Programming languages

Instruction List

It is the lowest level language of the IEC 61131 norm

It is very similar to the assembly code that ,maybe, you already saw

The level is too low to be used in the real scope, even if the Siemens «dialect» (called AWL) is used in a lot of cases

Page 34: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 34

Programming languages

Instruction List

Page 35: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 35

Programming languages

ST – Structured Text

It’s a language born from the old Pascal and Visual Basic

It must be considered as a high level languages, compared to the Instruction List

There are some tools that allow to generate Structured Text starting from high level implementation (con example Mathworks PLC Coder)

Each PLC producer has its own ST «dialect»

Page 36: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 36

Programming languages

ST – Structured Text

Page 37: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 37

Programming languages

In the context of the course we focus on:

•Graphical languages

Ladder Diagram

Sequential Function Chart

• Textual languages

Structured Text

Page 38: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 38

Tool-chain

As already mentioned, in the course we will use the B&R Automation Studio 4.0 programming environment

Before enter in the IEC 61131 languages details, let’s look at how the software is structured and how it works

Page 39: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 39

Automation Studio

During the lecture, I can save on your external hard-drives the software installer (it’s 4.7 GB), we have 30 days of real use.

Page 40: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 40

Automation Studio

Page 41: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 41

Automation Studio

Page 42: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 42

Automation Studio

Page 43: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 43

Automation Studio

Page 44: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 44

Automation Studio

Page 45: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 45

Automation Studio

In this screen it is possible to assemble via «software» the hardware configuration installed on the real PLC.

In the case of this software this activity can be done with a simple drag and drop of the modules

Page 46: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 46

Automation Studio

Let’s try to install a two analog inputs module (0 – 20 mA)

With a right click it is possible to configure the single module

N.B.: these settings are part of the Configuration

Page 47: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 47

Automation Studio

Page 48: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 48

Automation Studio

Page 49: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 49

Automation Studio

Page 50: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 50

Automation Studio

Page 51: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 51

Automation Studio

Page 52: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 52

Automation Studio

Page 53: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 53

Automation Studio

In this window the PLC scheduler is shown, as it is possible to notice the new Task is installed on

a 100 ms cyclic. It is possible to change the position or the frequency of the task using the

right click on the cyclic

Page 54: Industrial Automation course - UniBGmove.unibg.it/cologni/pages/didattica/archivio/udem2015/lectures/...Fuzzy logic programming 8. ... Direct if between two function blocks of the

Politecnico di Milano – Universidad de Monterrey, July 2015, A. L. Cologni 54

Automation Studio

Variables viewer

Variables logger