Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Jack H.Integration and automation of manufacturing systems.2001.pdf
Скачиваний:
80
Добавлен:
23.08.2013
Размер:
3.84 Mб
Скачать

page 175

-computation instructions

-boolean instructions

-conversion

Logical

-comparisons Advanced Data Handling

-file instructions

-shift registers/stacks Complex

-PID

-communications

-high speed counters

-ASCII string functions

The reader should be aware that some functions are positive edge triggered (i.e. they only work the scan is active). while most are active any time the input is active. Some examples of edge triggered and non-edge triggered functions are listed below,

Edge Triggered

CTU, CTD

Non-edge triggered

TON, TRO, TOF, ADD, MUL, etc.

7.13.1 Program Control Structures

• These change the flow of execution of the ladder logic.

7.13.2 Branching and Looping

• These functions allow control found in languages like Fortran

IF-THEN is like MCR (Master Control Reset)

GOTO is like JMP (Jump)

page 176

SUBROUTINES is like Program Files

• MCR blocks have been used earlier, but they are worth mentioning again.

MCR

A

MCR

If A is true then the MCR will cause the ladder in between to be executed. If A is false it is skipped.

MCR

• Block of ladder logic can be bypassed using a jump statment.

JMP

A B

JMP 01

If A and B are true, the program will jump to LBL:01 to be executed. If A or B is false it is skipped.

LBL 01

• Subroutines allow reusable programs to be written and called as needed. They are different

from jump statements because they are not part of the main program (they are other program

files), and arguments can be passed and returned.

page 177

SUBROUTINES/PROGRAM FILES

 

 

 

 

A

JSR (Jump subroutine)

program file 2

 

 

Program File 3

 

 

 

 

 

 

 

Input par N7:0

 

 

 

 

 

 

 

 

Input par 123

 

 

 

 

Return par N7:1

 

 

 

 

 

A separate ladder logic program is stored in program file 3. This feature allows the user to create their own ‘functions’. In this case if A is true, then the program below will be executed and then when done the ladder scan will continue after the subroutine instruction. The number of data values passed and returned is variable.

SBR (subroutine arguments)

Input par N10:0

If B is true the subroutine will return and the values listed will be returned to the return par. For this example the value that is in

N10:1 will eventually end up in N7:1

program file 3

B

RET

 

Return par N10:1

 

 

 

• For next loops can also be done to repeat blocks of ladder logic inside a single scan. Care

must be used for this instruction so that the ladder logic does not get caught in an infinite, or long

loop - if this happens the PLC will experience a fault and halt.

page 178

A

FOR

label number 0 index N7:0 initial value 0 terminal value 9 step size 1

ADD

Source A 1

Source B N7:1

Dest N7:1

NXT

label number 0

Note: if A is true then the loop will repeat 10 times, and the value of N7:1 will be incresed by 10. If A is not true, then the ADD function will only be executed once and N7:1 will increase in value by 1.

• Ladder logic programs always have an end statement, but it is often taken for granted and

ignored. Most modern software automatically inserts this. Some PLCs will experience faults if

this is not present.

A B C

END

When the end (or End Of File) is encountered the PLC will stop scanning the ladder, and start updating the outputs. This will not be true if it is a subroutine or a step in an SFC.