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

page 184

before (binary)

N7:0 0000000000000000 N7:1 1101101101010111 N7:2 0000000000000000 N7:3 1101100010111011 N7:4 1010101010101010 N7:5 0000000000000000

MOV source 130 dest N7:0

MOV source N7:1 dest N7:2

MVM source N7:3 mask N7:4 dest N7:5

after (binary)

N7:0 0000000010000010 N7:1 1101101101010111 N7:2 1101101101010111 N7:3 1101100010111011 N7:4 1010101010101010 N7:5 1000100010101010

7.14 MATH FUNCTIONS

These functions use values in memory, and store the results back in memory (Note: these functions do not use variables like normal programming languages.)

Math functions are quite similar. The following example adds the integer and floating point number and puts the results in ‘F8:36’.

page 185

ADD

source A N7:04 source B F8:35 destination F8:36

• Basic PLC-5 math functions include,

ADD(value,value,destination) - add two values SUB(value,value,destination) - subtract MUL(value,value,destination) - multiply DIV(value,value,destination) - divide NEG(value,destination) - reverse sign from positive/negative CLR(value) - clear the memory location

• Consider the example below,

page 186

ADD

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

ADD source A 1

source B N7:3 dest. N7:3

SUB

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

MULT

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

DIV

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

NEG

source A N7:4 dest. N7:7

CLR dest. N7:8

DIV

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

DIV

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

addr.

before

after

N7:0

10

10

N7:1

25

25

N7:2

0

35

N7:3

0

1

N7:4

0

-10

N7:5

0

250

N7:6

0

2

N7:7

0

10

N7:8

100

0

F8:0

10.0

10.0

F8:1

25.0

25.0

F8:2

0

2.5

F8:3

0

2.0

Note: integer values are limited to ranges between - 32768 and 32767, and there are no fractions.

• As an exercise, try the calculation below with ladder logic,

page 187

N7:2 = -(5 - N7:0 / N7:1)

• Some intermediate math functions include,

CPT(destination,expression) - does a calculation ACS(value,destination) - inverse cosine COS(value,destination) - cosine ASN(value,destination) - inverse sine SIN(value,destination) - sine ATN(value,destination) - inverse tangent TAN(value,destination) - tangent XPY(value,value,destination) - X to the power of Y LN(value,destination) - natural log LOG(value,destination) - base 10 log SQR(value,destination) - square root

• Examples of some of these functions are given below.

page 188

given A = ln B + eC acos ( D)

assign

A = F8:0

B = F8:1

C = F8:2

D = F8:3

LN

SourceA F8:1

Dest. F8:4

XPY

SourceA 2.718

SourceB F8:2

Dest F8:5

ACS

SourceA F8:3

Dest. F8:6

MUL

SourceA F8:5

SourceB F8:6

Dest F8:7

ADD

SourceA F8:4

SourceB F8:7

Dest F8:7

SQR

SourceA F8:7

Dest. F8:0

page 189

It can also be done with a compute expression

CPT

Dest. F8:0

Expression

SQR(LN(F8:1)+XPY(2.718,F8:2)*ACS(F8:3))

• For practice implement the following function,

 

 

y + log ( y)

x = atan

y

------------------------y + 1

• Some functions are well suited to statistics.

AVE(start value,destination,control,length) - average of values STD(start value,destination,control,length) - standard deviation of values SRT(start value,control,length) - sort a list of values

• Examples of these functions are given below.

page 190

AVE

File #F8:0

Dest F8:4 Control R6:1 length 4 position 0

STD

File #F8:0

Dest F8:5 Control R6:2 length 4 position 0

 

 

 

SRT

 

 

 

File #F8:0

 

 

 

 

 

 

Control R6:3

Addr.

before

after

length 4

position 0

 

 

 

F8:0

3

1

 

 

F8:1

1

2

 

F8:2

2

3

 

F8:3

4

4

 

F8:4

0

2.5

 

F8:5

0

1.29

 

• There are also functions for basic data conversion.

TOD(value,destination) - convert from BCD to binary FRD(value,destination) - convert from binary to BCD DEG(value,destination) - convert from radians to degrees RAD(value,destination) - convert from degrees to radians

• Examples of these functions are given below.