Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(EOD).Mechatronics.pdf
Скачиваний:
81
Добавлен:
23.08.2013
Размер:
5.07 Mб
Скачать

page 495

27. INSTRUCTION LIST PROGRAMMING

This is the most basic form of PLC programming that most resembles assembly language programming.

Until recently this was the most common programming form, but the advances in computer graphics in the 1980s made graphical programming languages (ladder logic) more popular.

27.1 INTRODUCTION

This graphical language is part of the IEC 1131-3 standard.

A simple example is given below.

Label

Opcode

Operand

Comment

 

 

 

 

START:

LD

%I:000/00

(* Load input bit 00 *)

 

AND(

%I:000/01

(* Start a branch and load input bit 01 *)

 

OR(

%I:000/02

(* Load input bit 02 *)

 

AND

%I:000/03

(* Load input bit 03 and invert *)

 

)

 

 

 

)

 

 

 

ST

%O:001/00

(* SET the output bit 00 *)

 

 

 

 

read as O:001/00 = I:000/00 AND ( I:000/01 OR ( I:000/02 AND I:000/03) )

 

I:000/00

I:000/01

 

 

 

O:001/00

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I:000/02

I:000/03

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

• A list of common mnemonics is given below. These include both the IEC 1131-3 values, and those specific to Allen Bradley controllers.

page 496

Basic Mnemonics

Ladder Equivalents

x

XIC x (examine on) LD x (load)

x

XIO x (examine if closed) LD NOT x (load not)

x y

AND y

x

OR y

y

x

OTE x (output enable)

** The operands ‘x’ and ‘y’ are a function of specific PLC’s I/O addressing schemes.

Note: the PLC works with a logical stack (like an HP calculator). Each operation can put true false values on the stack and/or pull them off. When done the output should be the last operation that pulls off a single true/false value. When there are branches in the ladder logic, more values will be on the stack.

Other Allen Bradley mnemonics include,

OTL (output latch)

OTU (output unlatch)

TOF (timer off)

TON (timer on)

CTD (count down)

CTU (count up)

• A list of the official IEC 1131-3 mnemonics is given below,

page 497

Operator

Modifiers

Data Types

Description

 

 

 

 

LD

N

many

set current result to value

ST

N

many

store current result to location

S, R

 

BOOL

set or reset a value (latches or flip-flops)

AND, &

N, (

BOOL

boolean and

OR

N, (

BOOL

boolean or

XOR

N, (

BOOL

boolean exclusive or

ADD

(

many

mathematical add

SUB

(

many

mathematical subtraction

MUL

(

many

mathematical multiplication

DIV

(

many

mathematical division

GT

(

many

comparison greater than >

GE

(

many

comparison greater than or equal >=

EQ

(

many

comparison equals =

NE

(

many

comparison not equal <>

LE

(

many

comparison less than or equals <=

LT

(

many

comparison less than <

JMP

C, N

LABEL

jump to LABEL

CAL

C, N

NAME

call subroutine NAME

RET

C, N

 

return from subroutine call

)

 

 

get value from stack

 

 

 

 

Here there are three types of modifiers, N - negates an input or output

( - nests an operation and puts it on a stack to be pulled off by ) C - forces a check for the currently evaluated results

This language uses a stack structure, like an HP calculator. When the open brackets are used the operations are pushed on the stack, closed brackets pull them back off.

An example of an instruction language subroutine is given below. This program will examine a BCD input on card I:000, and if it becomes higher than 100 then 2 seconds later output O:001/ 00 will turn on.

page 498

Program File 2:

 

 

 

 

Label

 

Opcode

 

Operand

 

Comment

 

 

 

 

 

 

 

 

 

 

START:

 

CAL

 

3

 

(* Jump to program file 3 *)

 

 

 

 

 

 

 

Program File 3:

 

 

 

 

 

Label

 

Opcode

 

Operand

 

Comment

 

 

 

 

 

 

 

 

 

 

 

TEST:

 

LD

 

%I:000

 

(* Load the word from input card 000 *)

 

 

BCD_TO_INT

 

 

 

(* Convert the BCD value to an integer *)

 

 

ST

 

%N7:0

 

(* Store the value in N7:0 *)

 

 

GT

 

100

 

(* Check for the stored value (N7:0) > 100 *)

 

 

JMPC

 

ON

 

(* If true jump to ON *)

 

 

CAL

 

RES(C5:0)

 

(* Reset the timer *)

ON:

 

LD

 

2

 

(* Load a value of 2 - for the preset *)

 

 

ST

 

%C5:0.PR

 

(* Store 2 in the preset value *)

 

 

 

 

 

 

CAL

 

TON(C5:0)

 

(* Update the timer *)

 

 

LD

 

%C5:0.DN

 

(* Get the timer done condition bit *)

 

 

ST

 

%O:001/00

 

(* Set the output bit *)

 

 

RET

 

 

 

(* Return from the subroutine *)

27.2 PRACTICE PROBLEMS

6. Write the ladder diagram programs that correspond to the following Boolean programs.

LD 001 OR 003 LD 002 OR 004 AND LD LD 005 OR 007 AND 006 OR LD OUT 204

page 499

LD 001 AND 002 LD 004 AND 005 OR LD OR 007 LD 003

OR NOT 006 AND LD

LD NOT 001 AND 002 LD 004

OR 007

AND 005 OR LD LD 003

OR NOT 006 AND LD OR NOT 008 OUT 204 AND 009 OUT 206

AND NOT 010 OUT 201

Соседние файлы в предмете Электротехника