Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Jack H.Automating manufacturing systems with PLCs.2005.pdf
Скачиваний:
261
Добавлен:
23.08.2013
Размер:
5.34 Mб
Скачать

plc basic functions - 15.22

 

 

 

addr.

data (binary)

 

 

 

N7:0

0011010111011011

 

 

 

N7:1

1010010011101010

 

 

 

N7:2

0010010011001010

after

 

 

N7:3

1011010111111011

 

 

 

 

 

 

N7:4

1001000100110001

 

 

 

N7:5

1100101000100100

Figure 15.23 Boolean Function Example

AND

source A N7:0 source B N7:1 dest. N7:2

OR

source A N7:0 source B N7:1 dest. N7:3

XOR

source A N7:0 source B N7:1 dest. N7:4

NOT

source A N7:0 dest. N7:5

15.4DESIGN CASES

15.4.1Simple Calculation

Problem: A switch will increment a counter on when engaged. This counter can be reset by a second switch. The value in the counter should be multiplied by 2, and then displayed as a BCD output using (O:0.0/0 - O:0.0/7)

plc basic functions - 15.23

Solution:

SW1

CTU

 

Counter C5:0

 

 

 

 

 

 

Preset 0

 

 

 

 

 

 

 

 

 

 

 

 

MUL

 

 

SourceA C5:0.ACC

 

 

SourceB 2

 

 

Dest. N7:0

 

 

 

 

 

MVM

 

 

Source N7:0

 

 

Mask 00FF

 

 

Dest. O:0.0

SW2

RES C5:0

 

 

 

 

 

 

Figure 15.24 A Simple Calculation Example

15.4.2 For-Next

Problem: Design a for-next loop that is similar to ones found in traditional programming languages. When A is true the ladder logic should be active for 10 scans, and the scan number from 1 to 10 should be stored in N7:0.

Solution:

 

 

A

GRT

 

 

MOV

 

 

 

 

 

 

 

 

 

 

 

 

SourceA N7:0

 

 

Source 0

 

 

 

 

 

 

 

 

SourceB 10

 

 

Dest N7:0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LEQ

 

 

 

 

 

 

 

 

ADD

 

 

SourceA N7:0

 

 

SourceA N7:0

 

 

 

 

 

 

 

SourceB 10

 

 

SourceB 1

 

 

 

 

 

 

 

Dest. N7:0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 15.25 A Simple Comparison Example

plc basic functions - 15.24

15.4.3 Series Calculation

Problem: Create a ladder logic program that will start when input A is turned on and calculate the series below. The value of n will start at 1 and with each scan of the ladder logic n will increase until n=100. While the sequence is being incremented, any change in A will be ignored.

x = 2( n – 1)

Solution:

A

A

B3:0

B3:0

B3:0

A = I:000/00 n = N7:0

x = N7:1

B3:0

MOV

Source A 1

Dest. N7:0

B3:0

LEQ

Source A N7:0

Source B 100

CPT

Dest. N7:1 Expression

2 * (N7:0 - 1)

ADD

Source A 1

Source B N7:0

Dest. N7:0

Figure 15.26 A Series Calculation Example