api i c3 2 ilusers.isr.ist.utl.pt/~jag/aulas/api11/docs/api_i_c3_2_il.pdf · page 7 ist / deec /...

38
http://users.isr.ist.utl.pt/~jag/courses/api1112/api1112.html Slides 2010/2011 Prof. Paulo Jorge Oliveira Rev. 2011/2012 Prof. José Gaspar PLCs PLCs Programming Languages Programming Languages Instruction List MEEC 2011-2012 Industrial Industrial Automation Automation (Automa (Automa ç ç ão de Processos Industriais) ão de Processos Industriais) IST / DEEC / API

Upload: others

Post on 07-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

http://users.isr.ist.utl.pt/~jag/courses/api1112/api1112.html

Slides 2010/2011 Prof. Paulo Jorge OliveiraRev. 2011/2012 Prof. José Gaspar

PLCsPLCs Programming LanguagesProgramming LanguagesInstruction List

MEEC 2011-2012

Industrial Industrial AutomationAutomation(Automa(Automaçção de Processos Industriais)ão de Processos Industriais)

IST / DEEC / API

Page 2: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Chap. 2 – Introduction to PLCs [2 weeks]...

Chap. 3 – PLCs Programming Languages [2 weeks]Standard languages (IEC-1131-3):Ladder Diagram; Instruction List, and Structured Text.Software development resources.

...Chap. 4 - GRAFCET (Sequential Function Chart) [1 week]

SyllabusSyllabus::

Industrial AutomationIST / DEEC / API

Page 2

Page 3: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Ladder Diagram

Instruction List

Structured Text

Sequential Function Chart(GRAFCET)

LD %M12AND %I1.0ANDN %I1.1OR %M10ST %Q2.0

If %I1.0 THEN%Q2.1 := TRUE

ELSE%Q2.2 := FALSE

END_IF

1

Direita

(1) m

2

3(2) b

(3) p

4

(2) a

Carrega

Esquerda

Page 3

Chap. 3 - PLCs Programming languagesIST / DEEC / API

PLCsPLCs ProgrammingProgramming LanguagesLanguages(IEC 1131(IEC 1131--3)3)

Page 4: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 4

Chap. 3 - PLCs Programming languages

InstructionInstruction listlist

ANI1A(OI2O(ANC9AQ9))=Q9...

AI3=P9NOOM1OI4=Z9NOAC9=M1...

LDV50=CSW9PE...

IST / DEEC / API

Antique PLC

Page 5: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 5

IST / DEEC / API Chap. 3 - PLCs Programming languages

InstructionInstruction listlist

IST / DEEC / API

Reference – see Unity Pro dev. environment

Page 6: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 6

IST / DEEC / API Chap. 3 - PLCs Programming languages

InstructionInstruction listlist

IST / DEEC / API

Reference – Unity Pro

Help

Page 7: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 7

IST / DEEC / API Chap. 3 - PLCs Programming languages

InstructionInstruction listlist

PLC Program = {Sections}, Section = {Sequences}One sequence is equivalent to one or more rungs in ladder diagram.Each section can be programmed in Ladder, Instruction List, or Structured Text.

An Instruction list (IL) is composed of a series of instructions. Each instruction begins on a new line and consists of:- an Operator,- if necessary with a Modifier and- if necessary one or more Operands

IL is a so-called accumulator orientated language, i.e. each instruction uses or alters the current content of the accumulator (a form of internal cache). IEC 61131 refers to this accumulator as the "result". For this reason, an instruction list should always begin with the LD operand ("Load in accumulator command").

Reference – Unity Pro Help

Page 8: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Basic Instructions

Load

P

N

Open contact: contact is active (result is 1)while the control bit is 1.

Close contact: contact is active (result is 1)while the control bit is 0.

Contact in the rising edge: contact is active during a scan cyclewhere the control bit has a rising edge.

Contact in the falling edge: contact is active during a scan cyclewhere the control bit has a falling edge.

Page 8

Chap. 3 - PLCs Programming languages

LD

LDN

LDR

LDF

InstructionInstruction listlist

IST / DEEC / API

P

%I1.0 %Q2.0 I1.0

Q2.0

t

t

Page 9: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Store

The result of the logic function activates the coil.

The inverse result of the logic function activates the coil.

The result of the logic function energizes the relay(sets the latch).

S

R The result of the logic function de-energizes the relay(resets the latch)..

N

%I1.0 %Q2.0 I1.0

Q2.0

t

t

S

Page 9

Chap. 3 - PLCs Programming languages

Basic Instructions

ST

STN

R

S

InstructionInstruction listlist

IST / DEEC / API

Page 10: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

ANDAND of the operand with the result of the previouslogical operation.

AND of the operand with the inverted result of theprevious logical operation.

AND of the rising edge with the result of the previouslogical operation.

AND of the falling edge with the result of the previouslogical operation.

P

N

N

%Q2.0 I1.0

Q2.0

S t

t

P%I1.0%I1.0

Page 10

Chap. 3 - PLCs Programming languages

Basic Instructions

AND

ANDN

ANDF

ANDR

InstructionInstruction listlist

IST / DEEC / API

Page 11: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

OR

P

N

Page 11

Chap. 3 - PLCs Programming languages

Basic Instructions

OR of the operand with the result of the previous logical operation.

OR of the operand with the inverted result of the previouslogical operation.

OR of the rising edge with the result of the previous logical operation.

OR of the falling edge with the result of the previous logical operation.

OR

ORN

ORF

ORR

Instruction listInstruction list

IST / DEEC / API

Page 12: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 12

IST / DEEC / API Chap. 3 - PLCs Programming languages

Example:

InstructionInstruction listlist

Page 13: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

XOR

Page 13

Chap. 3 - PLCs Programming languages

Basic Instructions

...LD %I1.1XOR %M1ST %Q2.3LD %M2XOR %I1.2ST %Q2.2...

InstructionInstruction listlist

IST / DEEC / API

Page 14: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 14

Chap. 3 - PLCs Programming languages

InstructionInstruction listlist

IST / DEEC / API

The instantaneous contacts change state as soon as the timer coil is powered.The delayed contacts change state at the end of the time delay.

Temporized Relays or Timers (pneumatic)

Page 15: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Example:

Page 15

Chap. 3 - PLCs Programming languages

InstructionInstruction listlist

IST / DEEC / API

Page 16: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Characteristics:

Identifier: %TMi 0..63 in the TSX37

Input: IN to activate

Mode: TON On delayTOFF Off delayTP Monostable

Time basis: TB 1mn (def.), 1s, 100ms, 10ms

Programmed value: %TMi.P 0...9999 (def.)period=TB*TMi.P

Actual value: %TMi.V 0...TMi.P(can be real or tested)

Modifiable: Y/N can be modified fromthe console

IN Q

%TMi

MODE: TONTB: 1mn

TM.P: 9999MODIF: Y

Page 16

Chap. 3 - PLCs Programming languages

Temporized Relaysor Timers

InstructionInstruction listlist

IST / DEEC / API

Page 17: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 17

Chap. 3 - PLCs Programming languages

Temporized Relaysor Timers (PL7)

InstructionInstruction listlist

IST / DEEC / API

Page 18: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 18

IST / DEEC / API

Page 18

Chap. 3 - PLCs Programming languages

Temporized Relaysor Timers

InstructionInstruction listlist

IST / DEEC / API

Page 19: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 19

Chap. 3 - PLCs Programming languages

InstructionInstruction listlist

IST / DEEC / API

Counters

Some applications...

Page 20: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 20

Chap. 3 - PLCs Programming languages

InstructionInstruction listlist

Counters (PL7)Example:

IST / DEEC / API

Page 21: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 21

IST / DEEC / API Chap. 3 - PLCs Programming languages

LadderLadder diagramdiagram

Counters in Unity Pro

CU "0" to "1" => CV is incremented by 1CD "0" to "1" => CV is decremented by 1

CV ≥ PV => QU:=1CV ≤ 0 => QD:=1

R=1 => CV:=0 LD=1 => CV:=PVR has precedence over LD

CU "0" to "1" => CV is incremented by 1

CV ≥ PV => Q:=1

R=1 => CV:=0

NOTE: counters are saturated such that no overflow occurs

Page 22: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 22

IST / DEEC / API Chap. 3 - PLCs Programming languages

LadderLadder diagramdiagram

Counters in Unity Pro

Page 23: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Numerical Processing

Algebraic and Logic Functions (PL7)

Page 23

Chap. 3 - PLCs Programming languagesIST / DEEC / API

InstructionInstruction listlist

Page 24: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Arithmetic Functions

Page 24

Chap. 3 - PLCs Programming languages

Numerical Processing

IST / DEEC / API

InstructionInstruction listlist

Page 25: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Example:

Arithmetic functions

Page 25

Chap. 3 - PLCs Programming languages

Numerical Processing

IST / DEEC / API

InstructionInstruction listlist

PL7:

Page 26: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 26

IST / DEEC / API

Example:

Arithmetic functions

Chap. 3 - PLCs Programming languages

Numerical Processing

Use of a system variable:

%S18 – flag de overflow

InstructionInstruction listlist

PL7:

Page 27: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 27

Chap. 3 - PLCs Programming languages

Numerical Processing

Logic Functions

IST / DEEC / API

InstructionInstruction listlist

Page 28: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 28

Chap. 3 - PLCs Programming languages

Example:

Logic functions

Numerical Processing

IST / DEEC / API

InstructionInstruction listlist

PL7:

Page 29: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Priorities on the execution of the operations

Page 29

Chap. 3 - PLCs Programming languages

Numerical Processing

IST / DEEC / API

InstructionInstruction listlist

Page 30: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Structures for Control of Flux

Subroutines

Call and Return

Page 30

Chap. 3 - PLCs Programming languagesIST / DEEC / API

InstructionInstruction listlist

CAL

PL7Unity Pro

Page 31: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

JUMP instructions:

Conditional and unconditional

Page 31

Chap. 3 - PLCs Programming languages

Structures for Control of Flux

IST / DEEC / API

InstructionInstruction listlist

Page 32: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Example:

Use of jump instructions

Attention to:

• INFINITE LOOPS ...

• It is not a good style ofprogramming!...

• Does not improove the legibilityof the proposed solution.

Page 32

Chap. 3 - PLCs Programming languages

Structures for Control of Flux

IST / DEEC / API

InstructionInstruction listlist

Page 33: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Halt

Stops all processes!

Events masking

Page 33

Chap. 3 - PLCs Programming languages

Structures for Control of Flux

IST / DEEC / API

InstructionInstruction listlist

Page 34: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 34

IST / DEEC / API

There are other advanced instructions (see manual)

• Monostable• Registers of 256 words (LIFO ou FIFO)• DRUMs• Comparators• Shift-registers

...• Functions to manipulate floats• Functions to convert bases and types

Chap. 3 - PLCs Programming languagesIST / DEEC / API

InstructionInstruction listlist

Page 35: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Numerical Tables

Page 35

Chap. 3 - PLCs Programming languagesIST / DEEC / API

InstructionInstruction listlist

PL7:

Page 36: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 36

IST / DEEC / API

DOLOG80PLC AEG A020 Plus:

Inputs:• 20 binary with opto-couplers• 4 analogs (8 bits, 0-10V)

Outputs:• 16 binary with relays of 2A• 1 analogs (8 bits, 0-10V)

Interface for progr.: RS232

Processador:• 8031• 2 Kbytes de RAM• 2 Kbytes EEPROM => 896 instructions• Average cycle time: 6.5 ms

Chap. 3 – Old PLCs

Page 37: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 37

IST / DEEC / API

PLC AEG A020 Plus

DOLOG80OPERANDS

• I1 to I20 Binary inputs

• Q1 to Q16 Binary outputs

• M1 to M128 Auxiliary memory

• T1 to T8 Timers (base 100ms)

• T9 to T16 Timers (base 25ms)

• C1 to C16 16 bits counters

Chap. 3 – Old PLCs

Page 38: API I C3 2 ILusers.isr.ist.utl.pt/~jag/aulas/api11/docs/API_I_C3_2_IL.pdf · Page 7 IST / DEEC / API Chap. 3 - PLCs Programming languages Instruction list PLC Program = {Sections},

Page 38

IST / DEEC / API

DOLOG80 (cont.)

Example:

AI1A(OI2O(ANC9AQ9))=Q9...

Stop = I1Start = I2Proximity Sensor = I3Reset = I4Counter= C9Internal relay = M1Motor = Q9

AI3=P9NOOM1OI4=Z9NOAC9=M1...

LDV50=CSW9PE

Legend:

Chap. 3 – Old PLCs