Sample program for plc-5 family processors – Rockwell Automation 1771-VHSC , D17716.5.74 Very High S User Manual

Page 55

Advertising
background image

Sample Programs

B–2

Sample Program for PLC-5 Family Processors

MUL

MULTIPLY
SOURCE A
SOURCE B

N22:103

1000.000

DEST

F23:0

3000.000

N21:0

13

1

VHSC BTR

Done Bit

This rung illustrates how to assemble the count MSD and LSD into one floating point word that can be used throughout the program. F23:0 is an

intermediate storage value and F23:1 contains the total count 0 value.

Total count = (MSD * 1000) + LSD, [F23:1 = (N22:103 * 1000) + N22:104]

N22:103 is count 0 MSD

F23:0 = (1000 * count 0)

721

ADD

ADD
SOURCE A

SOURCE B

F23:0

N22:104

DEST

F23:1

3721.000

721

3000.000

This rung illustrates how to disassemable 1 floating point word into 2 integer words that are used as the MSD and LSD for preset count 0.

This same technique can be used for the rollover value as well as the output values.

MSD = TRUNCATE (FLTPNT/1000), [N22:13 = TRUNCATE (F23:2/1000)] while LSD = FLTPNT - (MSD*1000), [N22:14 = F23:2 - (N22:13*1000]

DIV

DIVIDE
SOURCE A

SOURCE B

F23:2

2789.000

DEST

F23:3

2.789000

N21:5

13

1000.000

MOV

MOVE
SOURCE A

F23:3

DEST

N24:0

2

2.789000

1

VHSC BTR

Done Bit

FLT POINT PRESET

STORE WORD

GRT

GREATER THAN
SOURCE A

N24:0

2

2.789000

SUB

SUBTRACT
SOURCE A

N24:0

DEST

N24:0

2

2

INTEGER PRESET

STORE WORD

INTEGER PRESET

STORE WORD

SOURCE B

F23:3

SOURCE B

1

(TO NEXT PAGE)

(TO NEXT PAGE)

INTEGER PRESET

STORE WORD

Advertising