The text of a manual · part 14 of 17
1771-DB Basic Module User Manual, pages 131 to 140
Pages 131 to 140 of 167
The original document is the PDF (943 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Allen-Bradley 1771-DB
Page 131
Chapter 5 Operating Functions
5.12.5 Reset Print Head Pointer – CALL 99
You can use CALL 99 when printing out wide forms to reset the internal print head character counter and prevent the automatic CR/LF at character 79. You must keep track of the characters in each line. You can solve this problem in revision A or B modules using DBY(1 6H) =0 Example: u10 u20 u30 u40 u50 u60
REM THIS PRINTS TIME BEYOND 80TH COLUMN PRINT TAB (79), CALL 99 PRINT TAB (41), “TIME, ”, PRINT H, “:”, M ,“:”,S END
5.12.6 Print the Argument Stack – CALL 109
CALL 109 prints the top 9 values on the argument stack to the console. No PUSHes or POPs are needed. Use this information as a troubleshooting aid. It does not affect the contents of, or pointer to the stack.
5.12.7 Print the Peripheral Port Output Buffer and Pointer – CALL 110
CALL 110 prints the complete buffer with addresses, front pointer and the number of characters in the buffer to the console. No PUSHes or POPs are needed.
5.12.8 Print the Peripheral Port Input Buffer and Pointer – CALL 111
CALL 111 prints the complete buffer with addresses, front pointer and the number of characters in the buffer to the console. No PUSHes or POPs are needed.
5–94
Use this information as a troubleshooting aid. It does not affect the contents of the buffer.
Use this information as a troubleshooting aid. It does not affect the contents of the buffer.
Page 132
Chapter 5 Operating Functions
5.12.9 Reset the Peripheral Port to Default Settings – CALL 119
CALL 119 resets the peripheral port to the following default settings: 8 bits/character 1 stop bit No parity DCD off XON-XOFF off No PUSHes or POPs are needed.
5–95
Page 133
Chapter 6
Programming
6.1 Chapter Objectives
After reading this chapter you should be able to: program your BASIC Module for use with a programmable controller. use block-transfer to communicate with a programmable controller. This chapter shows the BASIC programming and ladder logic needed for use with your processor. It also gives you sample programs.
6.2 Block-Transfer with the BASIC Module
Your BASIC Module communicates with any processor that has block-transfer capability. Your ladder logic program and BASIC program work together to enable proper communications between the module and processor. The BASIC Module is a bi-directional block-transfer module. Bi-directional means that the module performs both read and write block-transfer operations. You transfer data (1 to 64, 16 bit words) from your module to the processor’s data table with a block-transfer-read (BTR) instruction. You transfer data (1 to 64, 16 bit words) to your module from the processor’s data table with a block-transfer-write (BTW) instruction. Important: The module’s read and write instruction enable bits must not set at the same time. Your program must toggle requests for the read and write instructions as shown in the sample programs.
6.2.1 Block-Transfer-Write and Block-Transfer-Read Buffers
The BASIC Module processor maintains a block-transfer-write (BTW) buffer containing the values of the last BTW sent by the host processor. You initialize this buffer using a CALL 4. You transfer data to the BASIC Module’s buffer using CALL 6 or CALL 3. This buffer freezes and does not change when CALL 6 or CALL 3 completes. This double buffering and freezing ensures that the data does not change during processing by the BASIC Module. The BTW buffer remains unchanged and is accessed repeatedly by any of the data access routines provided. An additional CALL 6 or CALL 3 changes the BTW buffer contents.
Page 134
Chapter 6 Programming
6.2.1 Block-Transfer-Write and Block-Transfer-Read Buffers (continued)
The BASIC Module also maintains a block-transfer-read (BTR) buffer that is the value of the next block, read by the host processor. The BASIC program initializes this buffer using CALL 5 and transfers the data to the BASIC Module processor (for subsequent transfer to the host processor) when CALL 7 or CALL 2 executes. You should complete the building of the read buffer before initiating its transfer.
6.3 Block-Transfer with PLC-2 Family Processors
The following sample programs use block-transfer instructions. The Mini-PLC-2 (cat. no. 1772-LN3) and PLC 2/20 (cat. no. 1772-LP1,-LP2) processors use multiple GET instructions to perform block-transfers. Refer to the processor user’s manual for an explanation of multiple GET block-transfers.
6.3.1 PLC-2 Processor Program
This sample program (figure 6.1 and 6.3) 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 (i.e. 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.
6–2
Page 135
Chapter 6 Programming
6.3.1 PLC-2 Processor Program (continued)
Refer to figure 6.1 for the sample ladder logic and figure 6.2 for the corresponding BASIC program. The values shown in figure 6.2 are for demonstration purposes only. Use the program shown in figure 6.2 for all PLC-2, PLC-3 and PLC-5 processor ladder logic programs shown in this chapter. Figure 6.3 is an actual sample program. Figure 6.1 Sample PLC-2 Family Ladder Logic
6.3.1.1 Rung Description Rungs 1 and 2 – The first two rungs of the sample program toggle the requests for block-transfer-writes (BTW) and block-transfer-reads (BTR). The interlocks shown do not allow a BTR and BTW instruction to enable at the same time. Rung 3 – When a BTR successfully completes, its done bit sets, enabling the file-to-file move instruction. The file-to-file move instruction (FFM) moves the BTR data file (File CCC-DDD) into a storage data file (EEE-FFF). This prevents the programmable controller from using invalid data if a block-transfer communication fault occurs.
6–3
Page 136
Chapter 6 Programming
6.3.1 PLC-2 Processor Program (continued) u5 u10 u20 u30 u40 u50 u60 u70 u80 u90 u100 u110 u120 u130 u140 u150 u160 u170 u180 u190 u200
Figure 6.2 Sample BASIC Module Program
DIM A(10) REM SET BTW LENGTH TO 10 WORDS PUSH 10: CALL 4 REM SET BTR LENGTH TO 2 WORDS PUSH 2: CALL 5 REM READ THE BTW BUFFER CALL 6 REM CONVERT DATA FROM 3-DIGIT SIGNED BCD TO DB FORMAT FOR I=1 TO 10 DO PUSH(I): CALL 10: POP A(I) NEXT I REM DO A CALCULATION T=A(1)+A(2)+A(3)+A(4)+A(5)+A(6)+A(7)+A(8)+A(9)+A(10):V=T/10 REM CONVERT DATA FROM DB FORMAT TO 3-DIGIT SIGNED BCD PUSH T: PUSH 1: CALL 20 PUSH V: PUSH 2: CALL 20 REM WRITE TO THE BTR BUFFER CALL 7 REM CONTINUE TO BLOCK TRANSFER GOTO 60 END Figure 6.3 Sample PLC-2 Family Ladder Diagram
6–4
Page 137
Chapter 6 Programming
6.4 PLC-3 Family Processors
You can use the following ladder logic program with PLC-3 or PLC-3/10 processors. This program assumes that your application requires a single BTR and BTW to pass data between the processor and the BASIC Module (i.e. 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. Refer to Figure 6.4 for the sample ladder logic and Figure 6.2 for the corresponding BASIC program. You can use the BASIC program with any processor. Values shown in the program are for demonstration purposes only. Figure 6.5 is an actual sample program. Figure 6.4 Sample PLC-3 Family Ladder Logic -Single Data Set
6–5
Page 138
Chapter 6
Programming
6.4
PLC-3 Family Processors
(continued)
6-6
Figure 6.5
Sample PLC-3 Family Ladder Diagram
RUNG NUMBER RM1
| s0003 t - XOR wo ---nn----- + +- KOR ----------- +| l |--) [ + AXORB=R +-+ AXORB=R_ +( | 03 | A: weoo1:0030 | | A : wB001:0020 || | | 0000000010000100] | 0000000000000000| | | {| B : wBo0c1:0030 | | B : wBoo1:0020 |] | | 0000000010000100| |. oo000000000000001 | | {| R : wB001:0030 | | R : weo01:0020 {| | { 0000000010000100| | o0000000000000001 | | + + + +{ RUNG NUMBER RM2 | wBO001:0020 +- BIW ------------ + cnTL | 2 [+----] { + -+ BLOCK XFER WRITE +-(LE)--| tl 15 | | RACK : 002 | o2 | f|+- EQU ~------- +| | GROUP : 1 | cntL | [++ A=B ++ | MODULE : 1=HIGH +-(DN) | | | Ao: wB001:0030 | | DATA: FB002:0150 | 05 = | | {| 0000000010000100| | LENGTH = 10 | cnt. | | | B: wBO001:0020 | | CNTL: FB001:0030 +-(ER) | | | oo00000000000000]| + + 03 | 1 | | { 1 | | | | + + RUNG NUMBER RM3 | wp001:0030 +- BTR ---~-------- + CNTL | 3 | 5) [ --+ BLOCK XFER READ +-(LE)--| | 05 | RACK : 002 | | | | GROUP : 1 | cnrL | | | MODULE : 1=HIGH +-(DN) | | | DATA: FB002:0220 {| 15 | | | LENGTH = 2 | cntL | | | CNTL: FB001:0020 +-(ER) | | te-------+--------- + 13 |
Page 139
Chapter 6 Programming
6.4.1 Rung Description for Sample PLC-3 Family Ladder Logic – Single Data Set
Rung 1, Rung one is true only at power-up. It uses status word 3, bit 3 (the AC power loss bit of the PLC-3) to zero the control file of both the BTR and BTW. Rungs 2 and 3, During normal program execution the BTW and BTR instructions are alternately executed. The done bits of each instruction enable the next block-transfer instruction. The BTR and BTW control files must be different for the next block-transfer to occur. The equal instruction is used at power-up. At power-up the BTR and BTW control files both equal zero. At power-up the BTW enables and block-transfers begin.
6.5 PLC-5 Family Processors
You can use the following ladder logic program with PLC-5 Family processors. This program assumes that your application requires a single BTR and BTW to pass data between the processor and the BASIC Module (i.e. 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 PLC-5 block-transfer program is an alternating read/write program (i.e. at the completion of the BTW the BTR enables. At the completion of the BTR the BTW enables). The processor checks data validity before accepting read data and sets one enable bit at a time. Figure 6.6 is a generic sample block-transfer program for a PLC-5 family processor. Figure 6.7 is an actual sample program.
6–7
Page 140
Chapter 6
Programming
+ +
6.5 Figure 6.6 PLC-5 Family Processors Sample PLC-5 Family Ladder Logic (continued) | | | BIW BTR + + | 1 +-++|/]---|/| + BIW Sea + | EN EN |Control Block xxx | | | [Data File yyy | | 1 | | | | [Continuous no | | | + + | | { | BIw BTR + + | 20 t+--[/]---17/] + BTR to---------- + | EN EN [Control Block zzz | | j |Data File aaa | | | | H | [Continuous no | | | + I | |
15047
6-8