beautypg.com

Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual

Page 136

background image

Programming

Chapter 6

6–4

Figure 6.2
Sample BASIC Module Program

u5 DIM

A(10)

u10 REM SET BTW LENGTH TO 10 WORDS

u20 PUSH 10: CALL 4

u30 REM SET BTR LENGTH TO 2 WORDS

u40 PUSH 2: CALL 5

u50 REM READ THE BTW BUFFER

u60 CALL

6

u70 REM CONVERT DATA FROM 3-DIGIT SIGNED BCD TO DB FORMAT

u80 FOR I=1 TO 10 DO

u90 PUSH(I): CALL 10: POP A(I)

u100 NEXT I

u110 REM DO A CALCULATION

u120 T=A(1)+A(2)+A(3)+A(4)+A(5)+A(6)+A(7)+A(8)+A(9)+A(10):V=T/10

u130 REM CONVERT DATA FROM DB FORMAT TO 3-DIGIT SIGNED BCD

u140 PUSH T: PUSH 1: CALL 20

u150 PUSH V: PUSH 2: CALL 20

u160 REM WRITE TO THE BTR BUFFER

u170 CALL 7

u180 REM CONTINUE TO BLOCK TRANSFER

u190 GOTO 60

u200 END

Figure 6.3
Sample PLC-2 Family Ladder Diagram

6.3.1
PLC-2 Processor Program
(continued)