The text of a manual · part 10 of 17
1771-DB Basic Module User Manual, pages 91 to 100
Pages 91 to 100 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 91
Chapter 5 Operating Functions
5.7.3 Set Block-Transfer-Write Length – CALL 4
This routine sets the number of words (1–64) to transfer between the BASIC Module and the host processor. The processor program block-transfer length must match the set value. Only one argument is input (the number of words to BTW) and none returned. If not used, the default length is 5 words. Example: u10 PUSH 10: u20 CALL 4
5.7.4 Set Block-Transfer-Read Length – CALL 5
This routine sets the number of words (1–64) to transfer between the BASIC Module and the host processor. The processor program block-transfer length must match the set value. Only one argument is input (the number of words to BTR) and none returned. If not used, the default length is 5 words. Example: u10 PUSH 10 u20 CALL 5
5.7.5 Update Block-Transfer-Write Buffer – CALL 6
This routine transfers the block-transfer-write (BTW) buffer of the auxiliary processor on the BASIC Module to the BASIC BTW buffer. This routine waits until a block-transfer occurs if one has not previously occurred.
5.7.6 Update Block-Transfer-Read Buffer – CALL 7
This routine transfers the block-transfer-read (BTR) buffer to the auxiliary processor on the BASIC Module for use in the next BTR request from the host processor. This routine waits until a block-transfer occurs.
5.7.7 Disable Interrupts – CALL 8
Important: You must use an Interrupt Control CALL 8 before a PROG command to disable interrupts. This routine disables system interrupts. It is mandatory for PROM programming. The wall clock cannot be accessed and the peripheral port is disabled by this call. Some call routines enable interrupts automatically upon completion.
5–54
Page 92
Chapter 5 Operating Functions
5.7.8 Enable Interrupts – CALL 9
Important: You must use an Interrupt Control CALL 9 after a PROG command to re-enable interrupts. This routine enables system interrupts. It is mandatory after programming a PROM. The wall clock is accessible and the peripheral port is enabled.
5.7.9 Input Call Conversion Routines
All of the input call conversion routines require the same sequence of commands. These are: PUSH – the word position of the processor block-transfer-file to be converted (1–64) CALL – the appropriate input conversion POP – the input argument into a variable The data format of the output arguments from each of the input conversion routines is described in more detail in Chapter 7.
5.7.9.1 3-Digit Signed, Fixed Decimal BCD to Internal Floating Point "XXX – CALL 10 The input argument is the number (1 to 64) of the word in the write-block-transfer buffer that is to be converted from 3-digit BCD to internal format. The output argument is the converted value in internal floating point format. The sign bit is bit number 16.
5.7.9.2 16-Bit Binary (4-digit hex) to Internal Floating Point – CALL 11 The input argument is the number (1 to 64) of the word in the write-data-transfer buffer to be converted from 16-bit binary to internal format. The output argument is the converted value in internal floating point format. There are no sign or error bits decoded.
5.7.9.3 4-Digit Signed Octal to Internal Floating Point "XXXX – CALL 12 The input argument is the number (1 to 64) of the word in the processor block-transfer buffer to be converted from 4-digit signed octal to internal format. This 12-bit format has a maximum value of "7777 octal. The output argument is the converted value in internal floating point format. The sign bit is bit number 16.
5–55
Page 93
Chapter 5 Operating Functions
5.7.9 Input Call Conversion Routines (continued)
5.7.9.4 6-Digit, Signed, Fixed Decimal BCD to Internal Floating Point "XXXXXX – CALL 13 The input argument is the number (1–64) of the first word (6-digit BCD is sent to the BASIC module in two processor words) of the write-block-transfer buffer to be converted from 6-digit, signed, fixed decimal BCD to internal format. The maximum values allowed are "999999. The output argument is the converted value in internal floating point format. The sign bit is bit number 16.
5.7.9.5 4-Digit BCD to Internal Floating Point XXXX – CALL 17 The input argument is the number (1–64) of the word in the write-block-transfer buffer to be converted from 4-digit BCD to internal format. The maximum value allowed is 0–9999. The output argument is the converted value in internal floating point format. Sample input conversions: u20 PUSH 3 :REM CONVERT 3rd WORD OF PLC DATA u30 CALL 10 :REM DO 3 DIGIT BCD TO F.P. CONVERSION u40 POP W :REM GET CONVERTED VALUE – STORE IN VARIABLE W u20 PUSH 9 :REM CONVERT STARTING WITH 9th WORD OF PLC DATA u30 CALL 13 :REM DO 6 DIGIT BCD TO F.P. CONVERSION u40 POP L(9) :REM GET CONVERTED VALUE – STORE IN ARRAY L (9)
5.7.10 Output Call Conversion Routines
All of the output call conversion routines require the same sequence of commands. These are: PUSH – the value to be converted PUSH – the word position of the processor block-transfer-file to be converted (1–64) CALL – the appropriate output conversion The data format of the converted value of each of the output conversion routines is described in more detail in Chapter 7. Use these output call conversion routines to load the BTR buffer before executing a CALL 7 or CALL 2.
5–56
Page 94
Chapter 5 Operating Functions
5.7.10 Output Call Conversion Routines (continued)
5.7.10.1 Internal Floating Point to 3-Digit, Signed, Fixed Decimal BCD "XXX – CALL 20 This routine has two input arguments and no output arguments. The first argument is the variable with a value in the range of –999 to +999 that is converted to a signed 3-digit binary coded decimal format used by the processor. The second input argument is the number of the word to receive the value in the read-block-transfer buffer. The sign bit is bit number 16. Example:
u20 PUSH W :REM DATA TO BE CONVERTED u30 PUSH 6 :REM WORD LOCATION TO GET DATA u40 CALL 20
5.7.10.2 Internal Floating Point to 16-Bit Unsigned Binary (4 digit hex) – CALL 21 This routine takes a value between 0 and 65535 and converts it to its binary representative and stores this in the read-block-transfer buffer in one word. Two arguments are PUSHed and none POPed. The first value PUSHed is the data or variable. This is followed by the number of the word to receive the value in the read-block-transfer buffer. Example: u50 PUSH T :REM THE VALUE TO CONVERTED TO 16 BINARY u60 PUSH 3 :REM WORD 3 IN THE BTR BUFFER GETS THE VALUE T u70 CALL 21 :REM DO THE CONVERSION
5.7.10.3 Internal Floating Point to 4-Digit, Signed Octal "XXXX–Call 22 This routine converts a value from internal format to a four digit signed octal value. Two arguments ar PUSHed and non POPed. The first value PUSHed is the data ("77778) or variable. This is followed by the number of the word to receive the value in the read-block-transfer buffer. The sign bit is bit number 16. Example: u50 PUSH H :REM THE VALUE TO CONVERTED TO 4-DIGIT SIGNED OCTAL u60 PUSH 3 :REM WORD 3 IN THE BTR BUFFER GETS THE VALUE H u70 CALL 22 :REM DO THE CONVERSION
5–57
Page 95
Chapter 5 Operating Functions
5.7.10 Output Call Conversion Routines (continued)
5.7.10.4 Internal Floating Point to 6-Digit, Signed, Fixed Decimal BCD "XXXXXX – CALL 23 This routine converts an internal 6-digit, signed, integer to a 2 word format and places the converted value in the read-block-transfer buffer. Two arguments are PUSHed and none POPed. The first value PUSHed is the data or variable. This is followed by the number of the word to receive the value in the read-block-transfer buffer. The sign bit is bit number 16. Example:
u20 PUSH 654321. OR u30 PUSH 3 u40 CALL 23 u20 PUSH B(I) u30 PUSH 3 u40 CALL 23
5.7.10.5 Internal Floating Point to 3.3-digit, Signed, Fixed Decimal BCD "XXX.XXX – CALL 26 This routine converts a variable in internal format to a signed, 6-digit, fixed decimal point number which is stored in 2 words in the block-transfer-read buffer. Two arguments are PUSHed and none POPed. The first value PUSHed is the data ("999.999) or variable. This is followed by the number of the first word to receive the value in the block-transfer-read buffer. The sign bit number is 16. Example: u50 PUSH S u60 PUSH 3 u70 CALL 26
:REM THE VALUE TO BE CONVERTED TO 3.3-DIGIT FIXED POINT :REM WORD 3 IN THE BTR BUFFER GETS THE VALUES :REM DO THE CONVERSION
5.7.10.6 Internal Floating Point to 4-digit BCD XXXX – CALL 27 This routine converts a value in internal floating point format to a 4-digit, unsigned BCD value and places it in the read-block-transfer buffer. Two arguments are PUSHed and none POPed. The first value PUSHed is the data (0–9999) or variable. This is followed by the number of the word to receive the value in the read-block-transfer buffer. Example: u20 PUSH B u30 PUSH 7 u40 CALL 27
5–58
REM THE VALUE TO BE CONVERTED TO 4-DIGIT BCD :REM WORD 7 IN THE BTR BUFFER GETS THE VALUE B :REM DO THE CONVERSION
Page 96
Chapter 5 Operating Functions
5.8 Peripheral Port Support
The peripheral port is used for: 1. exchanging data with an external device with user written protocol. 2. listing programs with the LIST# or LIST @ statement. 3. loading/saving programs using the 1771–SA/SB data recorders. For these functions to operate properly and to allow flexibility for talking to many different devices we provide parameter setup routines. To make best use of the port, a 256 character buffer is provided on both input and output. This means that the module may receive up to 256 characters without error from a device before the module must service the data. The module can store an entire response to a command in the input buffer. This is useful when the data arrives in a high speed burst that is too fast for the BASIC program to handle character by character. The 256 character output buffer allows the module to assemble an entire message leaving your user program free to perform other operations while the message is sent character by character by the device driver.
5.8.1 Peripheral Port Support – Parameter Set – CALL 30
This routine sets up the parameters for the peripheral port. The parameters set are the number of bits/word, parity enable or disable, even or odd parity, number of stop bits, software handshaking and hardware handshaking. Default values are: 1 stop bit no parity 8 bits/character DCD off XON/XOFF disabled 1200 baud (jumper selected) 1 start bit (fixed)
5–59
Page 97
Chapter 5 Operating Functions
5.8.1 Peripheral Port Support – Parameter Set – CALL 30 (continued)
The five values PUSHed on the stack before executing the CALL are in the following order: Parameter
Selections
Number of bits/word
5,6,7,8
Parity Enable
0=None,2=Even 1=Odd
Number of Stop Bits
1=1 Stop Bit, 2=2 Stop Bits, 3=1.5 Stop Bits
Software Handshaking
0=None, 1=XON–XOF
Hardware Handshaking
0=Disable DCD 1=enable DCD
Example:
100 PUSH 8 : REM 8 BITS/WORD 120 PUSH 0 : REM NO PARITY 140 PUSH 1 : REM 1 STOP BIT 160 PUSH 0 : REM NO SOFTWARE HANDSHAKING 180 PUSH 0 : REM DISABLE DCD 200 CALL 30 : REM SET UP PERIPHERAL PORT or Example:
100 PUSH 8,0,1,0,0:CALL 30
Important: Hardware and software handshaking is disabled and both I/O buffers are cleared on power-up.
5.8.2 Peripheral Port Support – Display Peripheral Port Parameters –CALL 31
This routine displays the current peripheral port configuration on the terminal. No argument is PUSHed or POPed. Enter CALL 31 [return] from the command mode. Example: CALL 31 [RETURN] DCD OFF 1 STOP BIT NO PARITY 8 BITS/CHAR Important: XON/XOFF status is shown only if enabled.
5–60
Page 98
Chapter 5 Operating Functions
5.8.3 Save Program to Data Recorder – CALL 32
Important: Maximum baud rate is 2400 bps for all data recorder CALL routines. The Peripheral Port is set up in these routines and does not need setting in BASIC. This routine saves the current RAM program on a 1770–SA/SB recorder. The program in RAM is not modified. The message ERROR - IN ROM displays if ROM is selected instead of RAM. To use this routine: insert the cassette/cartridge into the recorder and rewind. enter CALL 32. The terminal responds with “POSITION TAPE AND PRESS WRITE/RECORD ON TAPE”. Press RECORD. The module begins sending data to the recorder. An asterisk is displayed on the terminal as each program line is sent to the recorder. During this time the “DATA IN” LED on the data recorder and the XMIT LED on the front of the module illuminate. When the last line of program is sent to the recorder, a final asterisk is displayed on the terminal indicating that the save operation is complete. Finally, tape motion ceases and the BASIC prompt (u) is displayed. Press STOP if you are using a 1770–SA Recorder. Important: If there is no program in RAM, the module displays the message ERROR–NO BASIC PROGRAM EXISTS.
5.8.4 Verify Program with Data Recorder – CALL 33
Important: Maximum baud rate is 2400 bps for all data recorder CALL routines. The Peripheral Port is set up in these routines and does not need setting in BASIC. See section 4.2.2.2 for required cable connections. This routine is used to verify the current RAM program with a previously stored program on the data recorder. To use this routine: insert the cassette cartridge into the recorder and rewind. enter CALL 33. The terminal responds with “POSITION TAPE AND PRESS READ FROM TAPE”.
5–61
Page 99
Chapter 5 Operating Functions
5.8.4 Verify Program with Data Recorder – CALL 33 (continued)
Press PLAY. Tape movement begins and the recorder searches for the beginning of the next program. As each line of the program verifies, an asterisk displays. During this time the “DATA OUT” LED on the recorder and the “RECV” LED on the module illuminate. When the last line of program is verified a final asterisk is displayed on the terminal followed by the “VERIFICATION COMPLETE” message and the BASIC (u) prompt. If any differences between programs are encountered, the routine displays an “ERROR–VERIFICATION FAILURE” message and the BASIC (u) prompt is immediately displayed.
5.8.5 Load Program from Data Recorder – CALL 34
Important: Maximum baud rate is 2400 bps for all data recorder CALL routines. The UART is set up in these routines and does not need setting in BASIC. See section 4.2.2.2 for required cable connections. This routine loads a program stored on a 1770–SA/SB recorder into user RAM, destroying the previous contents of RAM. To use this routine: enter CALL 34. The terminal responds with “POSITION TAPE AND PRESS READ FROM TAPE”. Press PLAY. Tape movement begins and the routine searches for the beginning of the next program. When the program is found an asterisk is printed for each line read from the recorder. During this time the “DATA OUT” LED of the recorder and the “RECV” LED on the front of the module illuminate. When the recorder sends the last line of program, a final asterisk appears on the terminal indicating that the load operation is complete. Tape motion ceases and the BASIC prompt (u) appears. If you are using a 1770–SA Recorder, press STOP. Important: This routine loads the first program encountered and does not distinguish between labelled programs. See section 5.8.10 below titled, “Load Labeled Program from Data Recorder (1770–SB only) CALL 39″ for an explanation of labelled programs.
5–62
Page 100
Chapter 5 Operating Functions
5.8.6 Get Numeric Input Character from Peripheral Port – CALL 35
This routine gets the current character in the 255 character, peripheral port input buffer. It returns the decimal representation of the characters received as its output argument. The peripheral port receives data transmitted by your device and stores it in this buffer. If there is no character, the output argument is a 0 (null). If there is a character, the output argument is the ASCII representation of that character. There is no input argument for this routine. Example: u10 CALL 35 u20 POP X u30 IF X =0 THEN GOTO 10 u40 PRINT CHR(X) Important: A 0 (null) is a valid character in some communications protocols. You should use CALL 36 to determine the actual number of characters in the buffer. Important: Purge the buffer before storing data to ensure data validity.
5–63