Вы находитесь на странице: 1из 57

T.C.

Chang

Chapter 7. PROGRAMMABLE LOGIC CONTROLLER

Dr. T.C. Chang School of Industrial Engineering Purdue University

6/29/2012

7- 1

T.C. Chang

FUNCTIONS OF CONTROLLERS
1) on-off control, 2) sequential control,

3) feedback control, and


4) motion control.

6/29/2012

7- 2

T.C. Chang

CONTROL DEVICES
1) mechanical control - cam, governor, etc., 2) pneumatic control - compressed air, valves,etc. 3) electromechanical control - switches, relays, a timer, counters, etc, 4) electronics control - similar to electromechanical control, except uses electronic switches. 5) computer control.
7- 3

6/29/2012

T.C. Chang

PROGRAMMABLE LOGIC CONTROLLER


Invented in 1968 as a substitute for hardwired relay panels.
"A digitally operating electronic apparatus which uses a programmable memory for the internal storage of instructions by implementing specific functions such as logic sequencing, timing, counting, and arithmetic to control, through digital or analog input/output modules, various types of machines or processes. The digital computer which is used to perform the functions of a programmable controller is considered to be within this scope. Excluded are drum and other similar mechanical sequencing controllers." National Electrical Manufacturing Association (NEMA)

6/29/2012

7- 4

T.C. Chang

VENDORS
MODICOM - GOULD ALLEN-BRADLEY GE SQUARE-D etc.

6/29/2012

7- 5

T.C. Chang

PLC
CPU Input Input Module

Flag
System Output User Ladder Diagram Output Module

Working memory registers

6/29/2012

7- 6

T.C. Chang

An Large Size PLC


The main module measures 19 x 20 x 14.5. have upto 10,000 I/O points supports all functions expansion slots to accommodate PC and other communication devices.

Allen-Bradley PLC-3

6/29/2012

7- 7

T.C. Chang

A Small Size PLC


Measures 4.72x 3.15 x 1.57. 32 I/O points Standard RS 232 serial communication port

Allen-Bradley MicroLogix 1000

6/29/2012

7- 8

T.C. Chang

SWITCHES
No n-lo c king Lo c king

No rma lly Ope n

No rma lly Clo s e d

SPDT
Multiple Thro w

P1

DPST
Multiple P o le

P2

Bre a k-be fo re -ma ke

Ma ke -be fo re -bre a k

6/29/2012

7- 9

T.C. Chang

TERMS
Throw - number of states

Pole - number of connecting moving parts (number of individual


circuits). SPDT A serial switch box (A-B box) has two 25 pin serial ports to switch from. A B Output DPST

Input

Knob How is this switch classified?


6/29/2012

7- 10

T.C. Chang

TYPES OF SWITCHES
Selector switches Pushbutton switches Photoelectric switches Limit Switches Proximity switches Level switches Thumbwheel switches Slide switches RATING:

24 Volts AC/DC 48 Volts AC/DC 120 Volts AC/DC 230 Volts AC/DC TTL level (Transistor-to-transistor 5V) Isolated Input

6/29/2012

7- 11

T.C. Chang

RELAYS
A switch whose operation is activated by an electromagnet is called a "relay"
contact

coil

input

Relay coil
R1

Output contact

R1

6/29/2012

7- 12

T.C. Chang

COUNTER
Digital counters output in the form of a relay contact when a preassigned count value is reached.
input Re giste r

Accumulator re se t conta ct output

Input Re se t Output Count


6/29/2012

12

1
7- 13

T.C. Chang

TIMER
A timer consists of an internal clock, a count value register, and an accumulator. It is used for or some timing purpose.
Clock

Accumulator re se t Re giste r

conta ct Contact output


Clock Reset Output Count 0 1 2 3 4 5

Time 5 seconds.
6/29/2012

7- 14

T.C. Chang

AN EXAMPLE OF RELAY LOGIC


For a process control, it is desired to have the process start (by turning on a motor) five seconds after a part touched a limit switch. The process is terminated automatically when the finished part touches a second limit switch. An emergency switch will stop the process any time when it is pushed.
L1 LS1 R1 TIMER R2 PB1 LS2 R1

R1

PB1 LS1

LS2

PR=5

TIMER 5

Motor R2

R1

6/29/2012

7- 15

T.C. Chang

PLC ARCHITECTURE
Programmable controllers replace most of the relay panel wiring by software programming.

Progr am Loade r Printe r

PC Switche s

Proce ssor Casse tte Loade r EPROM Loade r Pe riphe rals M emory

I/O M odule s

M achine s

Powe r Supply

Exte r nal De v ice s

A typical PLC
6/29/2012

7- 16

T.C. Chang

PLC COMPONENTS
1. Processor Microprocessor based, may allow arithmetic operations, logic operators, block memory moves, computer interface, local area network, functions, etc. Measured in words. ROM (Read Only Memory), RAM (Random Access Memory), PROM (Programmable Read Only Memory), EEPROM (Electric Erasable Programmable ROM), EPROM (Erasable Programmable Read Only Memory), EAPROM (Electronically Alterable Programmable Read Only Memory), and Bubble Memory.

2. Memory

6/29/2012

7- 17

T.C. Chang

3. I/O

PLC plug-in periphery COMPONENTS Modular


AC voltage input and output, DC voltage input and output, Low level analog input, High level analog input and output, Special purpose modules, e.g., high speed timers, Stepping motor controllers, etc. PID, Motion

4. Power supply AC power


5. Peripheral hand-held programmer (HHP) CRT programmer operator console

printer
simulator EPROM loader graphics processor

network communication interface


modular PC
6/29/2012

7- 18

T.C. Chang

Discrete I/O
AC Voltage I/O DC Voltage I/O numerical input and output special-purpose modules, for example, highspeed timers, and stepping motor controllers

6/29/2012

7- 19

T.C. Chang

Analog I/O
Analog inputs: Flow sensors Humidity sensors Potentiometers Pressure sensors Temperature sensors Analog outputs: Analog meters Analog valves and actuators DC and AC motor drives
6/29/2012

7- 20

T.C. Chang

Some Special I/O


Thermocouple input
Low level analog signal, filtered, amplified, and digitized before sending to the processor through I/O bus.

Fast input
50 to 100 microsecond pulse signal detection.

ASCII I/O
Communicates with ASCII devices.

Stepper motor output


Provide directly control of a stepper motor.

Servo interface
Control DC servo motor for point-to-point control and axis positioning.

PID control
The Proportional Integral Derivative is used for closed loop process control.

Network module
6/29/2012

7- 21

T.C. Chang

A Hand Held Programmer

An Allen-Bradley hand-held programmer for MicroLogix 1000

6/29/2012

7- 22

T.C. Chang

LADDER DIAGRAM
A ladder diagram (also called contact symbology) is a means of graphically representing the logic required in a relay logic system.

Rail
start PB1 emergency stop PB2 R1

Rung

R1

R1 A

6/29/2012

7- 23

T.C. Chang

PLC WIRING DIAGRAM

A B

Input 01 02 03 20 01 20

PLC 02 20

Output 11 12 C

11

External switches

Stored program

6/29/2012

7- 24

T.C. Chang

Input Connections

AC

DC

TTL

6/29/2012

7- 25

T.C. Chang

Output Connections

AC

DC

TTL

6/29/2012

7- 26

T.C. Chang

SCAN
A PLC resolves the logic of a ladder diagram (program) rung by rung, from the top to the bottom. Usually, all the outputs are updated based on the status of the internal registers. Then the input states are checked and the corresponding input registers are updated. Only after the I/Os have been resolved, is the program then executed. This process is run in a endless cycle. The time it takes to finish one cycle is called the scan time. In some controllers the idle state is eliminated. In this case, the scan time varies depends on the program length. Output Input begin Idle Scan cycle

Resolve logic
6/29/2012

7- 27

T.C. Chang

PLC Programming
Ladder Diagram - most common Structure Text Programming (ST) Functional Block Programming (FB) Instruction List (IL) Sequential Function Chart (SFC)

6/29/2012

7- 28

T.C. Chang

PLC Ladder Diagram INSTRUCTIONS


1) Relay, 2) Timer and counter, 3) Program control, 4) Arithmetic, 5) Data manipulation,

6) Data transfer, and


7) Others, such as sequencers.

6/29/2012

7- 29

T.C. Chang

LOGIC STATES
ON : TRUE, contact closure, energize, etc. OFF: FALSE, contact open , de-energize, etc.

Do not confuse the internal relay and program with the external switch and relay. Internal symbols are used for programming. External devices provide actual interface.

(In the notes we use the symbol "~" to represent negation. AND and OR are logic operators. )

6/29/2012

7- 30

T.C. Chang

AND and OR LOGIC


PB1 PB2 R1

R1 = PB1.AND.PB2

AND

PB3

PB4

R2 R2 = PB2.AND.~PB4

PB1

R1 R1 = PB1 .OR. PB2

OR

PB2

6/29/2012

7- 31

T.C. Chang

COMBINED AND & OR


R1 = PB1 .OR. (PB2 .AND. PB3)

PB1

R1

PB2

pb3

6/29/2012

7- 32

T.C. Chang

RELAY
A Relay consists of two parts, the coil and the contact(s). Contacts: a. Normally open b. Normally closed -| |-|/|-

c. Positive transition sensing


d. Negative transition sensing Coil: a. Coil b. negative coil c. Set Coil d. Reset Coil
6/29/2012

-|P|-|N|() -( )-(/)-(S)-(R)7- 33

T.C. Chang

Relay (continue)
Coil: e. Retentive memory Coil f. Set retentive memory Coil g. Reset retentive memory Coil -(M)-(SM)-(RM)-

h. Positive Transition-sensing Coil


h. Negative Transition-sensing Coil

-(P)-(N)-

(set coil latches the state, reset coil deenergize the set coil. retentive coil retain the state after power failure.)

6/29/2012

7- 34

T.C. Chang

TIMERS AND COUNTERS


Input Timers: a. Retentive on delay b. Retentive off delay c. Reset Counter: a. Counter up -(CTU)-(RTO)-(RTF)-(RST)True False True counting resume RTO counting stop RTF stop

counting stop

RTO reach PR value, output ON RTF reach PR value, output OFF


PR value in 0.1 second

b. Counter down
c. Counter reset

-(CTD)-(CTR)-

6/29/2012

7- 35

T.C. Chang

SEQUENCER
Sequencers are used with machines or processes involving repeating operating cycles which can be segmented into steps. Output Step A B C Dwell time

1
2 3 4

ON
ON OFF OFF

OFF OFF
ON OFF OFF ON ON OFF

5 sec.
10 sec. 3 sec. 9 sec.

6/29/2012

7- 36

T.C. Chang

A-B PLC
I/O points are numbered, they correspond to the I/O slot on the PLC.

For A-B controller used in our lab I/O uses 1-32 Internal relays use 033 - 098 Internal timers/counters/sequencers use 901-932 Status 951-982

6/29/2012

7- 37

T.C. Chang

PROGRAMMING EXAMPLE 1
Bar code re ader microswitch Part Stopper Conveyor

Robot

Machine

id MSI R1 C1 R2 R3 C2 R4 C3 C4
6/29/2012

description microswitch output to bar code reader input from bar code reader output robot output robot input from robot output to stopper input from machine input from machine

state 1 1 1 1 1 1 1 1 1

explanation part arrive scan the part right part loading cycle unloading cycle robot busy stopper up machine busy task complete
7- 38

T.C. Chang

SOLUTION
Input MS1 C1 C2 C3 C4 01 02 03 04 05 Pro grammable Controlle r PLC Outpu t 11 12 13 14 15 R1 R2 R3 R4

01

14

11

02

14

14

04

03

12

05

03

13

Rung 1. If part arrives and no part is stopped, trigger the bar code reader. Rung 2. If it is a right part, activate the stopper. Rung 3. If the stopper is up, the machine is not busy and the robot is not busy, load the part onto the machine. Rung 4. If the task is completed and the robot is not busy, unload the machine.
7- 39

6/29/2012

T.C. Chang

Structured Text Programming


a high level language used to express the behavior of functions, function blocks and programs In IEC 1131-3 standard, it has a syntax very similar to PASCAL strongly typed language Functions:

6/29/2012

assignments expressions statements operators function calls flow control


7- 40

T.C. Chang

Data Types
SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL short integer integer double integer long integer unsigned short integer unsigned integer unsigned double integer unsigned long integer real long real 1 byte 2 bytes 4 bytes 8 bytes 1 byte 2 bytes 4 bytes 8 bytes 4 bytes 8 bytes BOOL BYTE WORD DWORD LWORD boolean byte 16 bit bit string 32 bit bit string 64 bit bit string 1 bit 1 byte 16 bits 32 bits 64 bits

TIME time duration DATE calendar date TOD time of day DT date and time of day STRING character strings

6/29/2012

7- 41

T.C. Chang

Derived Data Types


TYPE (* user defined data types, this is a comment*) pressure : REAL; temp : REAL; part_count : INT; END_TYPE;

Structure: TYPE data_packet: STRUCT input : t : out : count : END_STRUCT; END_TYPE;


6/29/2012

BOOL; TIME; BOOL; INT;

7- 42

T.C. Chang

Variable Declarations

Local variable: VAR

I,j,k : v : END_VAR

INT; REAL;

Use VAR, VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT, VAR_GLOBAL, VAR_EXTERNAL for different variable types.

6/29/2012

7- 43

T.C. Chang

Operators and Expressions


( ) function( ) ** NOT +-*/ MOD < > <= >= = <> AND, & XOR OR parenthesized expression function exponentiation negation Boolean complement math operators modulus operation comparison operators equal not equal Boolean AND Boolean XOR Boolean OR output := (light = open) OR (door = shut); Y := X+1.0; y := a AND b;

v := (v1 + v2 + v3)/3

6/29/2012

7- 44

T.C. Chang

Condition Statements
IF a > 100 THEN
redlight := on; ELSEIF a > 50 THEN CASE dial_setting OF 1: x := 10; 2: x := 15; 3: x := 18; 4,5: x := 20; (* 4 or 5 *) ELSE x := 30; END_CASE

yellowlight := on;
ELSE greenlight := on;

END_IF;

6/29/2012

7- 45

T.C. Chang

Iteration Statements
FOR I:= 0 to 100 BY 1 DO
light[I] := ON; END_FOR I := 0; REPEAT I := I + 1; light[I] := on; UNTIL I > 100; END_REPEAT

I := 0;
WHILE I < 100 DO I := I + 1; light[I] := on; END_WHILE

6/29/2012

7- 46

T.C. Chang

Functions
FUNCTION add_num : REAL VAR_INPUT I,J : END_VAR add_num := I + J; END_FUNCTION Call a function: x:= add_num(1.2, 5.6); Built-in Functions: REAL

ABS, SQRT, LN, LOG, EXP, SIN, COS, TAN, ASIn, ACOS, ATAN, ADD, MUL, SUB, DIV, MOD, EXPT, MOVE), logic functions (AND, OR, XOR, NOT), bit string functions (SHL, SHR shift bit string left and right , ROR, ROL rotate bit string), etc.
6/29/2012

7- 47

T.C. Chang

Programs
PROGRAM example7.1 VAR_INPUT R1 := MS1 AND (NOT R4);

MSI :
C1 C2 C3 : : :

BOOL;
BOOL; BOOL; BOOL;

R2 := R4 AND (NOT C3) AND (NOT C2);


R3 := C4 AND (NOT C3); R4 := C1; END_PROGRAM

C4

BOOL;

END_VAR VAR_OUTPUT R1 : BOOL : FALSE;

R2
R3 R4

:
: :

BOOL : FALSE;
BOOL : FALSE; BOOL : FALSE;

END_VAR

6/29/2012

7- 48

T.C. Chang

Functional Block Programming


Functional block (FB) is a well packaged element of software that can be re-used in different parts of an application or even in different projects. Functional blocks are the basic building blocks of a control system and can have algorithms written in any of the IEC languages.

6/29/2012

7- 49

T.C. Chang

An Up Counter Function Block


The algorithm in Structured Text:

FUNCTION BLOCK CTU


VAR_INPUT CU : BOOL; R : BOOL; PV : INT;

END_VAR
VAR_OUTPUT Q : BOOL;

CU R PV Q CV

: input to be counted : reset : preset value : contact output : counter value.

CV : INT; END_VAR

IF R THEN
CV := 0; ELSEIF CU AND (CV < PV) THEN CV := CV + 1; END_IF; Q := (CV >= PV); END_FUNCTION_BLOCK

6/29/2012

7- 50

T.C. Chang

A PID Control Function Block

block diagram
SP PV KP TR TD AUTO XOUT XO cycle
6/29/2012

set point sensor feedback proportional error gain integral gain derivative gain calculate output to process manual output adjustment time between execution
7- 51

Vout K p E Tr Edt Td

dE dt

control algorithm

T.C. Chang

Instruction List Programming


A low level language which has a structure similar to an assembly language. Since it is simple, it is easy to learn and ideally for small hand-held programming devices. Each line of code can be divided into four fields: label, operator, operand, and comment. e.g.

loop

LD ST ANDN

MS1 R1 C3

6/29/2012

7- 52

T.C. Chang

Operators
Operator Modifiers Description LD ST S N N load operand into register store register value into operand set operand true GT ( greater than

GE
EQ NE LE LT

(
( ( ( (

greater than and equal to


equal not equal less than and equal to less than jump to label call function block return from function or function block execute last deferred operator

R
AND & OR XOR ADD SUB MUL DIV
6/29/2012

reset operand false


N, ( N, ( N, ( N, ( ( ( ( ( Boolean AND Boolean AND Boolean OR Boolean XOR addition subtraction multiplication division

JMP C, N CAL C, N RET C, N )

Modifier N means negate. ( defers the operator. C is a condition modifier, the operation is executed if the register value is true.
7- 53

T.C. Chang

Instruction List for Example 1


PROGRAM example7.1 VAR_INPUT MSI C1 : : BOOL; BOOL; LD ANDN ST LD MS1 R4 R1 R4

C2
C3 C4

:
: :

BOOL;
BOOL; BOOL;

ANDN
ANDN ST LD ANDN

C3
C2 R2 C4 C3

END_VAR VAR_OUTPUT R1 R2 R3 R4 : : : : BOOL : FALSE; BOOL : FALSE; BOOL : FALSE; BOOL : FALSE;

ST
LD ST

R3
C1 R4

END_VAR

END_PROGRAM

6/29/2012

7- 54

T.C. Chang

Sequential Function Chart (SFC)


A graphics language used for depicting sequential behavior. The IEC standard grew out of the French standard Grafcet which in turn is based on Petri-net. A SFC is depicted as a series of steps shown as rectangular boxes connected by vertical lines. Each step represent a state of the system being controlled. The horizontal bar indicates a condition. It can be a switch state, a timer, etc. A condition statement is associated with each condition bar. Each step can also have a set of actions. Action qualifier causes the action to behave in certain ways. The indicator variable is optional. It is for annotation purposes.
6/29/2012

7- 55

T.C. Chang

SFC
Action Qualifiers:
N
R S L D P

non-stored, executes while the step is active


resets a store action sets an action active time limited action, terminates after a given period time delayed action. a pulse action, executes once in a step

SD stored and time delayed DS time delayed and stored SL stored and time limited
6/29/2012

7- 56

T.C. Chang

SFC for Example 1

6/29/2012

7- 57

Вам также может понравиться