Sample basic block-transfer program – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 81

Advertising
background image

Chapter
Programming Block-Transfers

5

5 -7

Sample BASIC Block-Transfer Program

This sample program assumes that the application requires a single
block-transfer-read (BTR) and a single block-transfer-write (BTW) to pass
data between the processor and the BASIC module (transfer of 64 words or
less). If the transferred data exceeds 64 words, you must program multiple
file to file moves to move different data sets to and from the block-transfer
files.

The values shown are for demonstration purposes only. Use the program
for all PLC-2, PLC-3, PLC-5 and PLC-5/250 processor ladder logic
programs shown in this chapter.

>5

DIM A(5)

>10 REM SET BTW LENGTH TO 5 WORDS

>20 PUSH 5: CALL 4

>30 REM SET BTR LENGTH TO 5 WORDS

>40 PUSH 5: CALL 5

>50 REM READ THE BTW BUFFER

>60 CALL 6

>70 REM CONVERT DATA FROM 3–DIGIT BCD TO DB FORMAT

>80 FOR I=1 TO 5

>90 PUSH (I): CALL 10: POP A(I)

>95 PRINT A(I),

>100

NEXT I

>110 REM DO A CALCULATION

>120 T=A(1)+A(2)+A(3)+A(4)+A(5):V=T/5

>125 PRINT ”AVE=”, V

>130 REM CONVERT DATA FROM DB FORMAT TO 3–DIGIT BCD

>140 PUSH T: PUSH 1: CALL 20

>150 PUSH V: PUSH 2: CALL 20

>160 REM WRITE TO THE BTR BUFFER

>170 CALL 7

>180 REM CONTINUE TO BLOCK TRANSFER

>190 GOTO 60

>200 END

Important: Use CALL 4 and CALL 5 only once, immediately after
power-up, if possible. Failure to observe this guideline could cause
random BASIC module program lockups.

Advertising