Allen-Bradley 1771–DB Basic Module User Manual I–1
Table of Contents Using This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 1.2 1.3 1.4 1.5 1.6 1 1 1 1 2 2 Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What this manual contains . . . . . . . . . . . . . . . . . . . . . . . . . . Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Definitions of major terms . . . . . . . . . . . . . . . . . . . . . . . . . . . Important information . . . . . . . . . . . .
ii Table of Contents 4.3.4 Connecting a T50 Industrial Terminal (Cat. No. 1784-T50) to the Program Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3.4.1 Configuring the Software . . . . . . . . . . . . . . . . . . . . . . . . 4.3.4.2 Wiring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4 Peripheral Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.1 Using the XON/XOFF Commands for the Peripheral Port . . . 4.4.
Table of Contents 5.3.12 Command: XFER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.13 Command: PROG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.13.1 User PROM Check and Description – CALL 81 . . . . . . . 5.3.14 Command: PROG1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.15 Command: PROG2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4 Description of Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.
iv Table of Contents 5.4.26 Statement: POP[var] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.27 Statement: REM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.28 Statement: RETI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.19 Statement: ST@ [expr] . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.30 Statement: STOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.31 Statement: STRING . . . . . . . . . . . . . . . . . . . . . . .
Table of Contents 5.7.10.2 Internal Floating Point to 16-Bit Unsigned Binary (4 digit hex) – CALL 21 . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.7.10.3 Internal Floating Point to 4-Digit, Signed Octal ”XXXX–Call 22 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.7.10.4 Internal Floating Point to 6-Digit, Signed, Fixed Decimal BCD ”XXXXXX – CALL 23 . . . . . . . . . . . . . . . . . . . . . . . . . 5.7.10.5 Internal Floating Point to 3.3-digit, Signed, Fixed Decimal BCD ”XXX.
vi Table of Contents 5.10.3.2 String Append (Concatenation) – CALL 61 . . . . . . . . . . 5.10.3.3 Number to String Conversion – CALL 62 . . . . . . . . . . . 5.10.3.4 String to Number Conversion – CALL 63 . . . . . . . . . . . 5.10.3.5 Find a String in a String – CALL 64 . . . . . . . . . . . . . . . 5.10.3.6 Replace a String in a String – CALL 65 . . . . . . . . . . . . 5.10.3.7 Insert String in a String – CALL 66 . . . . . . . . . . . . . . . . 5.10.3.8 Delete String from a String – CALL 67 . . . . . .
Table of Contents vii Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7.1 Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Output Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.1 16-bit Binary (4 Hex Digits) . . . . . . . . . . . . . . . . . . . . . . . . 7.2.2 3-digit, Signed, Fixed Decimal BCD . . . . . . . . . . . . . . . . . . 7.2.3 4-digit, Unsigned, Fixed Decimal BCD . . . . . . . . . . . . . .
Chapter 1 Using This Manual 1.1 Chapter Objectives Read this chapter before you use the BASIC Module. It tells you how to use this manual properly and efficiently. 1.2 What this manual contains This manual shows you how to install and operate your module. It gives you information about: hardware specifications. installing the module. the BASIC instruction set. programming the module. This manual is not a BASIC tutorial document. We assume that you are familiar with BASIC programming. 1.
Chapter 1 Using This Manual 1.5 Important information There are three different types of precautionary statements in this manual: Important, CAUTION and WARNING. Important: used to point out specific areas of concern when operating your BASIC Module. CAUTION: used to make you aware of instances where damage to your equipment could occur. WARNING: used to make you aware of instances where personal injury could occur. 1.
Chapter 2 Introducing the BASIC Module 2.1 Chapter Objectives This chapter discusses the functions and features of the BASIC Module. When you finish reading this chapter, you should: understand and be able to identify the hardware components of the BASIC Module. understand the basic features and functions of the BASIC Module. 2.2 General Features The BASIC Module (figure 2.
Chapter 2 Introducing the BASIC Module 2.2 General Features (continued) Figure 2.1 BASIC Module Front Edge 2.3 Hardware Features Your module is a one-slot module with the following functions and features: 13 K bytes of battery backed RAM for user programs. 32 K bytes of EPROM storage for user software routines. One RS-423A/232C compatible serial communications port(PROGRAM port) which works with ASCII terminals providing operator program interaction, command level input printer output, etc.
Chapter 2 Introducing the BASIC Module 2.3 Hardware Features (continued) One RS-423A/232C/RS-422 compatible serial communications port (PERIPHERAL port), supporting bi-directional XON/XOFF software handshaking and RTS/CTS, DTR, DSR, DCD hardware handshaking for interfacing to printers and commercial asynchronous modems. You can change the peripheral port configuration using a CALL 30. (Refer to Section 5.8.1).
Chapter 2 Introducing the BASIC Module 2.4 Software Features (continued) You can start program execution: by entering commands at the interactive terminal. at power-up initialization. You can store and execute programs in RAM or EPROM. You can store one user-program in RAM and up to 255 (depending on program size) independent user-programs simultaneously in EPROM memory. The programs run single-task mode only.
Chapter 3 Installing the BASIC Module 3.1 Chapter Objectives This chapter describes how to install your BASIC module in a 1771 I/O rack. After reading this chapter you should be able to: configure the module using the configuration plugs. insert the module into a 1771 I/O backplane. understand module status indicators. install additional EPROM’s. 3.
Chapter 3 Installing the BASIC Module 3.2.1 Power Requirements Your module receives its power through the 1771 I/O chassis backplane from the chassis power supply. It does not require any other external power supply to function. When planning your system you must consider the power usage of all modules in the I/O chassis to prevent overloading the chassis backplane and/or power supply. Each BASIC module requires 1.5 A at +5V DC. Add this to the requirements of all other modules in the I/O chassis.
Chapter 3 Installing the BASIC Module 3.2.3 Module Keying (continued) Figure 3.1 Keying Diagram for Placement of Module Keying Bands You may change the position of these bands if subsequent system design and rewiring makes insertion of a different type of module necessary. Use needle-nose pliers to insert or remove keying bands. 3.2.4 Configuration Plugs There are three sets of user selectable configuration plugs on the BASIC Module (figure 3.2).
Chapter 3 Installing the BASIC Module 3.2.4 Configuration Plugs (continued) Figure 3.2 The Configuration Plugs All other configuration plugs are factory set. Do not reset these factory set configuration plugs.
Chapter 3 Installing the BASIC Module 3.2.5 Module Installation 3.2.6 Initial Start-up Procedure Now that you have determined the configuration, power requirements, location, keying and wiring for your module, you are ready to install it in the I/O chassis. 1. Turn off power to the I/O chassis. 2. Insert your module in the I/O rack. Plastic tracks on the top and bottom of the slots guide the module into position. Do not force the module into its backplane connector.
Chapter 3 Installing the BASIC Module 3.2.6 Initial Start-up Procedure (continued) When the ACTIVE LED comes on observe the sign-on message displayed on the terminal followed by tREADY. You are now ready to begin BASIC programming. Refer to Chapter 6 for an example program to help you get your processor and BASIC Module communicating properly. Important: If you break communications with the module check that the terminal is set at the proper baud rate. 3.
Chapter 3 Installing the BASIC Module 3.3 Module Status LED’s (continued) If the FLT LED lights after the module has been operating properly check the following troubleshooting chart.
Chapter 3 Installing the BASIC Module Installing the User Prom (continued) Figure 3.4 User PROM and Battery Holder To replace the EPROM: 3–8 1. Turn the small screw in the socket just above the chip (figure 3.4) 1/4 turn counterclockwise. 2. Remove the old chip. 3. Insert the new chip with pin one down and the center notch down as shown in the socket diagram. 4. Turn the small screw in the socket above the chip 1/4 turn clockwise. 5.
Chapter 3 Installing the BASIC Module 3.4.1 Electrostatic Discharge Electrostatic discharge can damage integrated circuits or semiconductors in this module if you touch backplane connector pins. It can also damage the module when you set configuration plugs and/or switches inside the module. Avoid electrostatic damage by observing the following precautions: Touch a grounded object to rid yourself of charge before handling the module. Do not touch the backplane connector or connector pins.
Chapter 3 Installing the BASIC Module 3.5 Battery (continued) The BAT LOW indicator should go out. You can monitor the battery low condition in revision A and revision B modules using a XBY(77B4H) statement. Bit 2 high indicates the battery low condition. With revision C modules use CALL 80 to monitor battery status.
Chapter 4 Using the Serial Ports 4.1 Chapter Objectives This chapter describes how to use the program serial port and the peripheral serial port to connect terminals, Data Cartridge Recorders, Digital Cassette Recorders, printers and other compatible devices. 4.2 Using the BASIC Module Program and Peripheral Communication Ports The BASIC Module has a program serial port and a peripheral serial port capable of connecting to various user devices (figure 4.1). You can configure each port independently.
Chapter 4 Using the Serial Ports 4.2 Using the BASIC Module Program and Peripheral Communication Ports (continued) 4.2.1 Pin Descriptions CAUTION: Be sure you properly ground the system before turning on power. A difference in ground potential between the BASIC Module serial connectors and your program terminal or other serial device can cause damage to the equipment or loss of module programs. Use the following pins for connections made to the program or peripheral ports. Refer to figure 4.
Chapter 4 Using the Serial Ports 4.3 Program Port The program port is an RS-423A/232C compatible serial port that provides minimum signal line connection to terminals, printers and other serial devices for operator-program interaction, command level input, printer output etc. Figure 4.2 shows the signals available on both the program port and the peripheral port described later. Figure 4.
Chapter 4 Using the Serial Ports 4.3 Program Port (continued) Important: The program port always resets the most significant bit of all its data inputs. The range of each byte of data is 0 to 127 (7FH). On output, the module transmits all bits as specified when using the PRINT CHR() command except for the XOFF (13H) character. The range of each byte of data is 0 to 255 (OFFH). Important: The program port automatically inserts a CR, LF sequence after the 79th character column.
Chapter 4 Using the Serial Ports 4.3.2 Connecting a T3/T4 Industrial Terminal to the Program Port You can use an Industrial Terminal System as the programming system for the BASIC Module. Connect the module to CHANNEL C only. You can construct cable for distances up to 50 feet. Figure 4.3 shows cable connections to a T3/T4 Industrial Terminal from the program port. Important: You may continue to use CHANNEL B in existing installations. Figure 4.
Chapter 4 Using the Serial Ports 4.3.3 Connecting a T30 Industrial Terminal (Cat. No. 1784-T30) to the Program Port You can connect a T30 Industrial Terminal to the BASIC Module program port to act as a dumb terminal. Refer to the following figure 4.4 for BASIC Module/T30 connections. Figure 4.4 Connecting a T30 Industrial Terminal to a BASIC Module Important: Jumper T30 Industrial Terminal pin 4,5 and 6; and BASIC Module pins 4 and 5 if you do not use them. 4.3.
Chapter 4 Using the Serial Ports 4.3.4 Connecting a T50 Industrial Terminal (Cat. No. 1784-T50) to the Program Port (continued) 4.3.4.1 Configuring the Software Configure the driver package for compatibility with the BASIC Module by setting: baud rate – 9600 baud recommended parity – none data bits – 8 start bits – 1 stop bits – 1 To download to the BASIC Module, you must use a line wait function. The industrial terminal waits for the “u” BASIC Module prompt before sending the next line to the module.
Chapter 4 Using the Serial Ports 4.4 Peripheral Port The peripheral port is an asynchronous serial communication channel compatible with RS-423A/232C or RS-422 interfaces. It uses bi-directional XON/XOFF software handshaking and RTS/CTS, DTR, DSR, DCD hardware handshaking for interfacing with printers, terminals and commercial asynchronous modems. Use a CALL routine to change peripheral port configuration. Configure the baud rate (300 to 19.2K bps) by setting a configuration plug. Refer to figure 3.
Chapter 4 Using the Serial Ports 4.4 Peripheral Port (continued) 4.4.1 Using the XON/XOFF Commands for the Peripheral Port Figure 4.7 Cable Connection to SA/SB Recorder Output Data – The BASIC Module stops sending characters within 2 character times after receiving an XOFF. Transmission resumes when XON is received. Input Data – The BASIC Module sends XOFF when the input buffer reaches 224 characters. The module sends XON when the buffer contains less than 127 characters.
Chapter 4 Using the Serial Ports 4.4.2 Connecting A T30 Industrial Terminal (1784-T30) to the Peripheral Port (continued) 4.4.2.1 Hardware Configuration You must configure the BASIC Module peripheral port and the T30 Industrial Terminal serial port in the same way for proper communications to occur.
Chapter 4 Using the Serial Ports 4.4.3 Connecting a 1770-SA/SB Recorder to the Peripheral Port You can use a 1770-SB Data Cartridge Recorder or 1770-SA Digital Cassette Recorder to save and load BASIC programs to the BASIC Module. Figure 4.6 shows cable pin connections. Use the connections shown in figure 4.6 otherwise improper operation could occur. Note that the standard cable does not connect properly with the BASIC Module. Refer to the user manuals for the 1770-SB (publication number 1770-6.5.
Chapter 4 Using the Serial Ports 4.4.5 Connecting RS-422 Devices (continued) Figure 4.9 Point-to-Point RS-422 Connections Figure 4.10 Multi-drop configuration with master and multiple slaves Important: When you use the peripheral port as a 422 port, you must connect pin 4 to pin 5 on the port. When using an RS-422 interface you must install termination resistors at each end of the line. The module has a jumper selectable termination resistor (Refer to figure 3.2).
Chapter 4 Using the Serial Ports 4.5 Cable Assembly Parts You must supply cables for connecting devices to the program and peripheral ports. You can construct the cables with the parts listed in Table 4–1.
Chapter 5 Operating Functions 5.1 Chapter Objectives After reading this chapter you should be familiar with the BASIC instruction set and be ready to begin BASIC programming. This chapter is a reference section to help you with module programming. You should already be familiar with BASIC programming. 5.
Chapter 5 Operating Functions 5.2.2 Statements (continued) You may put more than one statement on a line, if separated by a colon (:). You can use only one statement number per line. You can enter lower case characters in the COMMAND mode. Any keywords, commands, variable and array names entered in lower case change to upper case when stored in memory. 5.2.3 Format Statements You can use format statements within the print statement.
Chapter 5 Operating Functions 5.2.6 Constants A constant is a real number that ranges from +1E–127 to +.9999999 9E+127. A constant can be an integer. We refer to constants as: [const] 5.2.7 Operators An operator performs a predefined operation on variables and/or constants. Operators require either one or two operands. Typical two operand or dyadic operators include ADD (+), SUBTRACT (–), MULTIPLY (*) and DIVIDE(/). We call operators that require only one operand, unary operators.
Chapter 5 Operating Functions 5.2.8 Variables (continued) Important: The BASIC Module requires less time to find a scalar variable because there is no expression to evaluate. If you want to run a program as fast as possible, use dimensioned variables only when necessary. Use scalars for intermediate variables and assign the final result to a dimensioned variable. Also, put the most frequently used variables first. Variables defined first require the least amount of time to locate. 5.2.
Chapter 5 Operating Functions 5.2.12 Argument Stack The argument stack (A-stack) stores all constants that the BASIC Module is currently using. Operations such as add, subtract, multiply and divide always operate on the first two numbers on the argument stack and return the result to the stack. The argument stack is 203 bytes long. Each floating point number placed on the stack requires 6 bytes of storage. The argument stack can hold up to 33 floating point numbers before overflowing. 5.2.
Chapter 5 Operating Functions 5.3 Description of Commands The following sections list and describe the commands you can use with the BASIC Module. 5.3.1 Command: RUN Action Taken: After you type RUN, all variables are set equal to zero, all BASIC evoked interrupts are cleared and program execution begins with the first line number of the selected program. The RUN command and the GOTO statement are the only way you can place the BASIC Module interpreter into the RUN mode from the COMMAND mode.
Chapter 5 Operating Functions 5.3.2 Command: CONT Action Taken: If you stop a program by typing a Control C on the console device or by execution of a STOP statement, you can resume execution of the program by typing CONT. If you enter a Control C during the execution of a CALL routine you cannot CONTinue. Between the stopping and the re-starting of the program you may display the values of variables or change the values of variables.
Chapter 5 Operating Functions 5.3.3 Command: LIST (continued) Variations: Two variations of the LIST command are possible with the BASIC Module. They are: 1. LIST [ln num] (cr) and 2. LIST [ln num] – [ln num] (cr) The first variation causes the program to print from the designated line number (integer) to the end of the program. The second variation causes the program to print from the first line number (integer) to the second line number (integer). Important: You must separate the two line (–).
Chapter 5 Operating Functions 5.3.5 Command: NEW Action taken: When you enter NEW(cr), the BASIC Module deletes the program that is currently stored in RAM memory. In addition, all variables are set equal to ZERO, all strings and all BASIC evoked interrupts are cleared. The REAL TIME CLOCK, string allocation, and the internal stack pointer values are not affected. In general, NEW (cr) is used to erase a program and all variables. 5.3.
Chapter 5 Operating Functions 5.3.8 Command: Control S Action taken: This command interrupts the scrolling of a BASIC program during the execution of a LIST command. It also stops output from the receiving port if you are running a program. In this case XOFF (Control S) operates as follows: 1. XOFF only operates on PRINT statements. 2. When received during a PRINT, data output and program execution are suspended immediately. 3.
Chapter 5 Operating Functions 5.3.11 Commands: RAM and ROM [integer] (continued) 5.3.11.1 RAM When you enter RAM(cr), the BASIC Module selects the current program from RAM MEMORY. Important: RAM space is limited to 13 K bytes.
Chapter 5 Operating Functions 5.3.12 Command: XFER Action taken: The XFER (transfer) command transfers the current selected program in EPROM to RAM and then selects the RAM mode. If you type XFER while the BASIC Module is in the RAM mode, the program stored in RAM is transferred back into RAM and the RAM mode is selected. After the XFER command executes, you can edit the program in the same way you edit any RAM program. Important: The XFER command clears existing RAM programs. 5.3.
Chapter 5 Operating Functions 5.3.13 Command: PROG (continued) Example: uLIST 10 FOR I=1 TO 10 20 PRINT I 30 NEXT I 40 END READY uCALL 8 :REM DISABLE INTERRUPTS uPROG 12 uREADY CALL 9 :REM ENABLE INTERRUPTS uROM 12 READY uLIST 10 FOR I=1 TO 10 20 PRINT I 30 NEXT I 40 END READY u In this example, the program just placed in the EPROM is the 12th program stored. Important: If you exceed the available PROM space, you cannot continue programming until it is erased.
Chapter 5 Operating Functions 5.3.14 Command: PROG1 Action taken: You can use the PROG1 command to program the resident EPROM with baud rate information. When the module is “powered-up” the module reads this information and initializes the program port with the stored baud rate. The “sign-on” message is sent to the console immediately after the module completes its reset sequence.
Chapter 5 Operating Functions 5.3.15 Command: PROG2 (continued) Figure 5.1 Flow Chart of Power-up Operation Figure 5.1 shows BASIC Module operation from a power-up condition using PROG1 or PROG2; or battery backed RAM.
Chapter 5 Operating Functions 5.4 Description of Statements The following sections list and describe the statements you can use with the BASIC Module. 5.4.1 Statement: CALL [integer] Mode: COMMAND AND/ OR RUN Type: CONTROL You use the CALL [integer] statement to call specially written BASIC Module application programs. Specific call numbers are defined later in this chapter. 5.4.
Chapter 5 Operating Functions 5.4.4 Statement: CLEARS Mode: COMMAND/RUN Type: CONTROL The CLEARS statement resets all of the module’s stacks. The control, argument and internal stacks all reset to their initialization values. You can use this command to reset the stack if an error occurs in a subroutine. Important: When the CLEARS statement is LISTed it appears as CLEAR S. 5.4.
Chapter 5 Operating Functions 5.4.6 Statements: DATA – READ – RESTORE Mode: RUN Type: Assignment DATA DATA specifies expressions that you can retrieve using a READ statement. If multiple expressions per line are used, you MUST separate them with a comma. Example: u10 DATA 10,ASC(A), ASC(B), 35.627 Important: You cannot use the CHR() operator in a DATA statement.
Chapter 5 Operating Functions 5.4.7 Statement: DIM Mode: COMMAND AND/OR RUN Type: Assignment DIM reserves storage for matrices. The storage area is first assumed to be zero. Matrices in the BASIC Module may have only one dimension and the size of the dimensioned array may not exceed 254 elements. Once a variable is dimensioned in a program it may not be re-dimensioned. An attempt to re-dimension an array causes an ARRAY SIZE ERROR.
Chapter 5 Operating Functions 5.4.
Chapter 5 Operating Functions 5.4.9 Statements: DO – WHILE [rel expr] (continued) Mode: RUN Type: CONTROL The DO – WHILE [rel expr] instruction provides a means of “loop control” within a module program. The operation of this statement is similar to the DO – UNTIL [rel expr] except that all statements between the DO and the WHILE [rel expr] are executed as long as the relational expression following the WHILE statement is true. You can nest DO – WHILE and DO – UNTIL statements.
Chapter 5 Operating Functions 5.4.10 Statement: END Mode: RUN Type: CONTROL The END statement terminates program execution. The continue comm and, CONT does not operate if the END statement is used to terminate execution. A CAN’T CONTINUE ERROR prints to the console. The last statement in a module program automatically terminates program execution if you do not use an end statement. You should always use an END statement to terminate a program.
Chapter 5 Operating Functions 5.4.11 Statements: FOR – TO – (STEP) – NEXT (continued) Since B=0, C=10 and D=2, the PRINT statement at line 20 executes 6 times. The values of “A” printed are 0, 2, 4, 6, 8 and 10. “A” represents the name of the index or loop counter. The value of “B” is the starting value of the index. The value of “C” is the limit value of the index and the value of “D” is the increment to the index.
Chapter 5 Operating Functions 5.4.12 Statements: GOSUB [ln num] – RETURN (continued) RETURN Use this statement to “return” control to the statement following the most recently executed GO SUB STATEMENT. Use one return for each GOSUB to avoid overflowing the C-STACK. This means that a subroutine called by the GO SUB statement can call another subroutine with another GOSUB statement.
Chapter 5 Operating Functions 5.4.13 Statement: GOTO [ln num] (continued) Unlike the RUN command the GOTO statement, if executed in the COMMAND mode, does not clear the variable storage space or interrupts. However, if the GOTO statement is executed in the COMMAND mode after a line is edited the module clears the variable storage space and all BASIC evoked interrupts. This is necessary because the variable storage and the BASIC program reside in the same RAM memory.
Chapter 5 Operating Functions 5.4.15 Statements: IF – THEN – ELSE (continued) Upon execution of line 10 IF A is equal to 100, THEN A is assigned a value of 0. IF A does not equal 100, A is assigned a value of A+1. If you want to transfer control to different line numbers using the IF statement, you may omit the GOTO statement.
Chapter 5 Operating Functions 5.4.16 Statement: INPUT (continued) Causes a question mark (?) to print on the console device. This prompts you to input two numbers separated by a comma. If you do not enter enough data, the module prints TRY AGAIN on the console device. Example: u10 INPUT A,B u20 PRINT A,B uRUN ?1 TRY AGAIN ?1,2 1 2 READY You can write the INPUT statement so that a descriptive prompt tells you what to enter. The message to be printed is placed in quotes after the INPUT statement.
Chapter 5 Operating Functions 5.4.16 Statement: INPUT (continued) Examples: u10 STRING 110,10 u20 INPUT “NAME:”,$(1) u30 PRINT “HI”,$(1) u40 END uRUN u10 STRING 110,10 u20 INPUT “NAMES:”,$(1),$(2) u30 PRINT “HI”,$(1),“ AND “,$(2) u40 END uRUN NAME: SUSAN HI SUSAN NAMES: BILL ?ANN HI BILL AND ANN READY READY You can assign strings and variables with a single INPUT statement.
Chapter 5 Operating Functions 5.4.18 Statement: LET Mode: COMMAND AND/OR RUN Type: ASSIGNMENT Use the LET statement to assign a variable to the value of an expression. The general form of LET is: LET [var] = [expr] Examples: LET A =10*SIN(B)/100 or LET A = A+1 Note that the = sign used in the LET statement is not an equality operator. It is a “replacement” operator. The statement should be read A is replaced by A plus one. The word LET is always optional, (i.e. LET A =2 is the same as A =2).
Chapter 5 Operating Functions 5.4.19 Statement: ONERR [ln num) Mode: RUN Type: CONTROL The ONERR[ln num] statement lets you handle arithmetic errors, if they occur, during program execution. Only ARITH. OVERFLOW, ARITH. UNDERFLOW, DIVIDE BY ZERO and BAD ARGUMENT errors are “trapped” by the ONE RR statement. All other errors are not “trapped”. If an arithmetic error occurs after the ONE RR statement is executed, the module interpreter passes control to the line number following the ONERR[ln num] statement.
Chapter 5 Operating Functions 5.4.20 Statement: ONTIME [expr],[ln num] Mode: RUN Type: CONTROL Your BASIC Module can process a line in milliseconds while the timer/counters on the microprocessor operate in microseconds. You must use the ONTIME [expr], [In num] statement because of this incompatibility between the timer/counters on the microprocessor and the BASIC Module.
Chapter 5 Operating Functions 5.4.20 Statement: ONTIME [expr], [ln num] (continued) If you do not want this delay, you should assign a variable to the special function operator, TIME, at the beginning of the interrupt routine.
Chapter 5 Operating Functions 5.4.22 Special Print Formatting Statements The following sections list and describe the special print formatting statements. 5.4.22.1 PRINT TAB([expr]) Use the TAB([expr]) function in the PRINT statement to cause data to print out in exact locations on the output device. TAB([expr]) tells the BASIC Module which position to begin printing the next value in the print list.
Chapter 5 Operating Functions 5.4.22 Special Print Formatting Statements (continued) 5.4.22.4 PRINT USING (special characters) Use the USING function to tell the BASIC Module what format to use when displaying printed values. The module “stores” the desired format after the USING statement is executed. All outputs following a USING statement are in the format evoked by the last USING statement executed.
Chapter 5 Operating Functions 5.4.22 Special Print Formatting Statements (continued) 5.4.22.6 PRINT USING(#.#) This forces the module to output all numbers using an integer and/or fraction format. The number of “#”’s before the decimal point represents the number of significant integer digits that are printed and the number of “#”’s after the decimal point represents the number of digits that are printed in the fraction. Omit the decimal point to print integers only.
Chapter 5 Operating Functions 5.4.22 Special Print Formatting Statements (continued) 5.4.22.8 Reset Print Head Pointer – CALL 99 You can use CALL 99 when printing out wide forms to reset the internal print read/character counter and prevent the automatic CR/LF at character 79. You must keep track of the characters in each line.
Chapter 5 Operating Functions 5.4.24 Statements: PH0., PH1., PH0.#, PH1.# Mode: COMMAND and/or RUN Type: INPUT/OUTPUT The PH0. and PH1. statements function the same as the PRINT statement except that the values are printed out in a hexadecimal format. The PH0. statement suppresses two leading zeros if the number printed is less than 255 (0FFH). The PH1. statement always prints out four hexadecimal digits. The character “H” is always printed after the number when PH0. or PH1. is used to direct an output.
Chapter 5 Operating Functions 5.4.25 Statement: PUSH[expr] Mode: COMMAND AND/OR RUN Type: ASSIGNMENT The arithmetic expression, or expressions, following the PUSH statement are evaluated and then placed in sequence on the BASIC Module’s ARGUMENT STACK. This statement, in conjunction with the POP statement, provides a simple means of passing parameters to assembly language routines. In addition, the PUSH and POP statements are used to pass parameters to BASIC subroutines and to “SWAP” variables.
Chapter 5 Operating Functions 5.4.26 Statement: POP[var] Mode: COMMAND AND/OR RUN TYPE: ASSIGNMENT The value on top of the ARGUMENT STACK is assigned to the variable following the POP statement and the ARGUMENT STACK is “POPed” (i.e. incremented by 6). You can place values on the stack using either the PUSH statement or assembly language CALLS. Important: If a POP statement executes and no number is on the ARGUMENT STACK, an A-STACK ERROR occurs.
Chapter 5 Operating Functions 5.4.27 Statement: REM Mode: COMMAND and/or RUN Type: CONTROL – Performs no operation REM is short for REMark. REM allows you to add comments to a program to make it easier to understand. If a REM statement appears on a line the entire line is used for the REM statement. You cannot terminate a REM statement using a colon (:), however, you can place a REM statement after a colon. This allows you to place a comment on each line.
Chapter 5 Operating Functions 5.4.28 Statement: RETI Mode: RUN Type: CONTROL Use the RETI statement to exit from the ONTIME interrupts that are handled by a BASIC Module program. The RETI statement functions the same as the RETURN statement except that it also clears a software interrupt flag so interrupts can again be acknowledged. If you fail to execute the RETI statement in the interrupt procedure, all future interrupts are ignored. 5.4.19 Statement: ST@ [expr] Mode: COMMAND AND/OR RUN 5.4.
Chapter 5 Operating Functions 5.4.30 Statement: STOP (continued) Note that the line number printed out after execution of the STOP statement, is the line number following the STOP statement, not the line number that contains the STOP statement. 5.4.31 Statement: STRING Mode: COMMAND and/or RUN Type: CONTROL The STRING [expr], [expr] statement allocates memory for strings. Initially, no memory is allocated for strings.
Chapter 5 Operating Functions 5.5 Description of Arithmetic, and Logical Operators and Expressions The BASIC Module contains a complete set of arithmetic and logical operators. We divide the operators into two groups, dual operand (dyadic) operators and single operand (unary) operators. 5.5.1 Dual Operand (dyadic) Operators The general form of all dual operand instructions is: (expr) OP (expr), where OP is one of the following operators.
Chapter 5 Operating Functions 5.5.1 Dual Operand (dyadic) Operators (continued) 5.5.1.1 Comments on logical operators .AND.,.OR. and .XOR. These operators perform a BIT-WISE logical function on valid INTEGERS. This means both arguments for these operators are between 0 and 65535 (0FFFFH) inclusive. If they are not, the BASIC Module generates a BAD ARGUMENT ERROR. All non-integer values are truncated, not rounded. Use the following chart for bit manipulations on 16 bit values.
Chapter 5 Operating Functions 5.5.2 Unary Operators We divide the unary operators into three groups; general purpose, log functions and trig functions. 5.5.2.1 General Purpose Operators Following are the general purpose operators. 5.5.2.1.1 ABS([expr]) Returns the absolute value of the expression. Examples: uPRINT ABS(5) 5 uPRINT ABS(–5) 5 5.5.2.1.2 NOT([expr]) Returns a 16 bit one’s complement of the expression. The expression must be a valid integer (i.e. between 0 and 65535 (0FFFFH) inclusive).
Chapter 5 Operating Functions 5.5.2 Unary Operators (continued) 5.5.2.1.6 RND Returns a pseudo-random number in the range between 0 and 1 inclusive. The RND operator uses a 16-bit binary seed and generates 65536 pseudo-random numbers before repeating the sequence. The numbers generated are specifically between 0/65535 and 65535/65535 inclusive. Unlike most BASICS, the RND operator in the BASIC Module does not require an argument or a dummy argument.
Chapter 5 Operating Functions 5.5.2 Unary Operators (continued) 5.5.2.3.2 COS([expr]) Returns the cosine of the argument. The argument is expressed in radians. Calculations are carried out to 7 significant digits. The argument must be between " 200000. Examples: uPRINT COS(PI/4) .7071067 uPRINT COS(0) 1 5.5.2.3.3 TAN([expr]) Returns the tangent of the argument. The argument is expressed in radians. The argument must be between "200000. Examples: uPRINT TAN(PI/4) 1 uPRINT TAN(0) 0 5.5.2.3.
Chapter 5 Operating Functions 5.5.2 Unary Operators (continued) Although this method of angle reduction provides a simple and economical means of generating the appropriate arguments for a Taylor series, there is an accuracy problem associated with this technique. The accuracy problem is noticed when the user argument is large (i.e. greater than 1000). This is because significant digits, in the decimal (fraction) portion of reduced argument are lost in the (user arg/PI – INT(user arg/PI)) expression.
Chapter 5 Operating Functions 5.5.4 How Relational Expressions Work Relational expressions involve the operators =, tu, u, u=, t, and t=. These operators are typically used to “test” a condition. In the BASIC Module relational operations are typically used to “test” a condition. In the BASIC Module relational operators return a result of 665535 (OFFFFH) if the relational expression is true, and a result of 0, if the relation expression is false. The result is returned to the argument stack.
Chapter 5 Operating Functions 5.6 Special Operators Special operators include special function operators and system control values. 5.6.1 Special Function Operators Special function operators directly manipulate the I/O hardware and the memory addresses on the processor. 5.6.1.1 GET Use the GET operator in the RUN mode. It returns a result of zero in the command mode. The GET operator reads the console input device.
Chapter 5 Operating Functions 5.6.1 Special Function Operators (continued) When TIME is assigned a value with a LET statement (i.e. TIME u 100), only the integer portion of TIME is changed. Example: uCLOCK1 (enable REAL TIME CLOCK) uCLOCK0 (disable REAL TIME CLOCK) uPRINT TIME (display TIME) 3.315 uTIME = 0 (set TIME = 0) uPRINT TIME (display TIME) .315 (only the integer is changed) You can change the “fraction” portion of TIME by manipulating the contents of internal memory location 71 (47H).
Chapter 5 Operating Functions 5.6.2 System Control Values The system control values determine how memory is allocated by the BASIC Module. 5.6.2.1 MTOP After reset, the BASIC Module sizes the external memory and assigns the last valid memory address to the system control value, MTOP. The module does not use any external RAM memory beyond the value assigned to MTOP. Examples: uPRINT MTOP 14335 or PH0. MTOP 37FFH 5.6.2.
Chapter 5 Operating Functions 5.7 Data Transfer Support Routines (continued) Example: 5.7.1 Update Block-Transfer-Read Buffer (timed) – CALL 2 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. If no data transfer occurs within 2 seconds the routine returns to BASIC without transferring data. This routine has no input arguments and one output argument (the status of the transfer).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
Chapter 5 Operating Functions 5.8.
Chapter 5 Operating Functions 5.8.7 Get the Number of Characters in the Peripheral Port Buffers – CALL 36 Use this routine to retrieve the number of characters in the chosen buffer as its output argument. You must PUSH which buffer is to be examined. PUSH 1 for the input buffer. PUSH 0 for the output buffer. One POP is required to get the number of characters.
Chapter 5 Operating Functions 5.8.9 Save Labeled Program to Data Recorder (1770-SB only) – CALL 38 (continued) This routine has one input argument and no output arguments. If no ID number is pushed prior to CALL 38, an error occurs and the routine aborts without saving. An unlabeled save (CALL 32) has an ID of 0. Important: Do not press rewind between programs saved. If you press rewind only the last program is saved. 5.8.
Chapter 5 Operating Functions 5.8.12 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.8.13 Reset the Peripheral Port to Default Settings – CALL 119 CALL 119 resets the peripheral port to the following default settings: Use this information as a troubleshooting aid. It does not affect the contents of the buffer.
Chapter 5 Operating Functions 5.9.1 Setting the Wall Clock Time (Hour, Minute, Second) – CALL 40 Use this routine to set the following wall clock time functions: H = hours (0 to 23) M = minutes (0 to 59) S = seconds(0-59) Example: Program the wall clock for 1:35 pm (13:35 on a 24 hour clock). u10 H=13: M=35: S=00 u20 PUSH H,M,S u30 CALL 40 :REM HOURS=13; MINUTES=35; SECONDS=00 :REM PUSH HOURS, MINUTES, SECONDS :REM CALL THE ROUTINE TO SET THE WALL CLOCK TIME 5.9.
Chapter 5 Operating Functions 5.9.4 Date/Time Retrieve String – CALL 43 CALL 43 returns the current date and time as a string. PUSH the number of the string to receive the date/time (dd/mmm/yy HH:MM:SS). You must allocate a minimum of 18 characters for the string. This requires you to set the maximum length for all strings to at least 18 characters. Example: u10 STRING 100,20 u20 PUSH 1: CALL 43: REM put date/time in string 1 u30 PRINT $(1) u40 END 5.9.
Chapter 5 Operating Functions 5.9.7 Time Retrieve Number – Call 46 The time of day is available in numeric form by executing a CALL 46 and POPing the three variables off of the argument stack on return. There are no input arguments. The time is POPed in hour, minute and second order. Example: u10 REM TIME IN VARIABLES EXAMPLE : REM GET THE WALL CLOCK TIME u20 CALL 46 u30 POP H,M,S u40 PRINT “CURRENT TIME IS”, H,M,S 50 END uRUN CURRENT TIME IS 13 44 54 READY 5.9.
Chapter 5 Operating Functions 5.9.10 Date Retrieve String – CALL 52 CALL 52 returns the current date in a string (dd/mmm/yy). PUSH the number of the string to receive the date. You must allocate a minimum of 9 characters for the string. Example: u10 STRING 100,20 u20 PUSH 1: CALL 52: REM put date in string 1 u30 PRINT $(1) u40 END uRUN 30/JAN/87 5.10 Description of String Operators A string is a character or group of characters stored in memory.
Chapter 5 Operating Functions 5.10.1 The ASC Operator Two operators in the BASIC Module can manipulate STRINGS. These operators are ASC() and CHR(). The ASC() operator returns the integer value of the ASCII character placed in the parentheses. Example: uPRINT ASC(A) 65 The decimal representation for the ASCII character “A” is 65. In addition, you can evaluate individual characters in a pre-defined ASCII string with the ASC() operator.
Chapter 5 Operating Functions 5.10.1 The ASC Operator (continued) You can also use the ASC() operator to change individual characters in a defined string. Example: u5 STRING 1000,40 u10 $(1)=“ABCDEFGHIJKL” u20 PRINT $(1) u30 ASC($(1),1)=75 REM: DECIMAL EQUIVALENT OF K u40 PRINT $(1) u50 ASC($(1),2)=ASC($(1),3) u60 PRINT $(1) uRUN ABCDEFGHIJKL KBCDEFGHIJKL KCCDEFGHIJKL In general, the ASC() operator lets you manipulate individual characters in a string.
Chapter 5 Operating Functions 5.10.2 The CHR Operator The CHR() operator converts a numeric expression to an ASCII character. Example: uPRINT CHR(65) A Like the ASC() operator, the CHR() operator also selects individual characters in a defined ASCII string.
Chapter 5 Operating Functions 5.10.2 The CHR Operator (continued) 5.10.2.2 Cursor Positioning on an Industrial Terminal Allen-Bradley Industrial Terminal – Refer to the Industrial Terminal User’s Manual (publication number 1770-6.5.3), Table 6-3. You can control cursor positioning by typing: (CTRL)(P)(COLUMN#)(;)(ROW#)(A). The ASCII equivalent of (CTRL)(P) is DLE. Using Appendix B, the DEC equivalent of ASCII DLE is 16.
Chapter 5 Operating Functions 5.10.3 String Support Calls (continued) It is important to note that since the carriage return character is the string terminator, you cannot use it within a string as one of its characters. If the high bit is set in a carriage return character (use 141 instead of 13 as the decimal value of the carriage return character) the BASIC Module does not recognize it as the end of string character and passes it to the output device.
Chapter 5 Operating Functions 5.10.
Chapter 5 Operating Functions 5.10.
Chapter 5 Operating Functions 5.10.
Chapter 5 Operating Functions 5.10.3 String Support Calls (continued) 5.10.3.1 String Repeat – CALL 60 This routine allows you to repeat a character and place it in a string. You can use the String Repeat when designing output formats. First PUSH the number of times to repeat the character, then PUSH the number of the string containing the character to be repeated. No arguments are POPed. You cannot repeat more characters than the string’s maximum length.
Chapter 5 Operating Functions 5.10.3 String Support Calls (continued) 5.10.3.2 String Append (Concatenation) – CALL 61 This routine allows you to append one string to the end of another string. The CALL expects two string arguments. The first is the string number of the string to be appended and the second is the string number of the base string. If the resulting string is longer than the maximum string length, the append characters are lost. There are no output arguments.
Chapter 5 Operating Functions 5.10.3 String Support Calls (continued) 5.10.3.4 String to Number Conversion – CALL 63 This routine converts the first decimal number found in the specified string to a number on the argument stack. Valid numbers and associated characters are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ., E, +, -. The comma (,) is not a valid number character and terminates the conversion.
Chapter 5 Operating Functions 5.10.3 String Support Calls (continued) u10 u20 u30 u40 u50 u60 u70 u80 u90 u100 u110 5.10.3.5 Find a String in a String – CALL 64 This routine finds a string within a string. It locates the first occurrence (position) of this string. This call expects two input arguments . The first is the string to be found, the second is the string to be searched for a match. One return argument is required.
Chapter 5 Operating Functions 5.10.3 String Support Calls (continued) 5.10.3.6 Replace a String in a String – CALL 65 This routine replaces a string within a string. Three arguments are expected. The first argument is the string number of the string which replaces the string identified by the second argument string number. The third argument is the base string’s string number. There are no return arguments.
Chapter 5 Operating Functions 5.10.3 String Support Calls (continued) u10 u20 u30 u40 u50 u60 u70 u80 u90 u91 u100 u110 5.10.3.7 Insert String in a String – CALL 66 This routine inserts a string within another string. The call expects three arguments. The first argument is the position at which to begin the insert. The second argument is the string number of the characters inserted into the base string. The third argument is the string number of the base string. This routine has no return arguments.
Chapter 5 Operating Functions 5.10.3 String Support Calls (continued) 5.10.3.8 Delete String from a String – CALL 67 This routine deletes a string from within another string. The call expects two arguments. The first argument is the base string number. The second is the string number of the string to be deleted from the base string. This routine has no return arguments. Important: This routine deletes only the first occurrence of the string.
Chapter 5 Operating Functions 5.10.3 String Support Calls (continued) u10 u20 u30 u40 u50 u60 u70 u80 5.10.3.9 Determine Length of a String – CALL 68 This routine determines the length of a string. One input argument is expected. This is the string number on which the routine acts. One output argument is required. It is the actual number of non-carriage return (CR) characters in this string. This is similar to the BASIC command LEN(str$). (Example: L=LEN($1)).
Chapter 5 Operating Functions 5.11.1 ROM to RAM Program Transfer – CALL 70 This routine shifts program execution from a running ROM program to the beginning of the RAM program. No arguments are PUSHed or POPed. Important: The first line of the RAM program is not executed. We recommend that you make it a remark.
Chapter 5 Operating Functions 5.11.2 ROM/RAM to ROM Program Transfer – CALL 71 (continued) The user is now executing ROM 4 if it exists. If the ROM routine requested does not exist the result is: 5.11.3 RAM/ROM Return – CALL 72 This routine allows you to return to the ROM or RAM routine that called this ROM or RAM routine. Execution begins on the line following the line that CALLed the routine. No arguments are PUSHed or POPed. This routine works one layer deep.
Chapter 5 Operating Functions 5.11.4 Battery-backed RAM Disable – CALL 73 CALL 73 disables the battery-backed RAM, prints “Battery Backup Disabled” when executed and allows a purging reset. The next power loss destroys the contents of RAM. When power is reapplied, RAM is cleared and battery back-up is reenabled automatically. 5.11.5 Battery-backed RAM Enable – CALL 74 CALL 74 enables the battery-backed RAM and prints “Battery Backup Enabled” when executed.
Chapter 5 Operating Functions 5.11.6 Protected Variable Storage – CALL 77 (continued) Example: For using protected variable storage area. A.
Chapter 5 Operating Functions 5.11.6 Protected Variable Storage – CALL 77 (continued) B.
Chapter 5 Operating Functions 5.12.2 Blink the Active LED by Default – CALL 79 The Active LED is on constantly during program execution or command mode. When you issue a CALL 79 the Active LED remains on while a program executes and blinks every second when the module is in the command mode. Issue CALL 79 again to cancel the blinking LED. 5.12.3 Check Battery Condition – CALL 80 CALL 80 checks the module’s battery condition. If a 0 is POPed after a CALL 80, battery is okay.
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.
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.
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.
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.
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.
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.
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.
Chapter 6 Programming 6.4 PLC-3 Family Processors (continued) 6–6 Figure 6.
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.
Chapter 6 Programming 6.5 PLC-5 Family Processors (continued) 6–8 Figure 6.
Chapter 6 Programming 6.5 PLC-5 Family Processors (continued) Figure 6.7 Sample PLC-5 Family Ladder Logic 6.5.1 Rung Description for Sample PLC-5 Family Ladder Logic Rungs 1 and 2 – Rungs 1 and 2 execute the BTR and BTW instructions alternately. When the BTR completes the BTW enables immediately following the BTR scan. Important: Do not select the continuous mode when using bidirectional block-transfer. Continuous mode does not allow use of the status bits in the block-transfer instructions.
Chapter 6 Programming 6.6. Block-Transfer Programming Tips 1. The block lengths PUSHed for CALLs 4 and 5 must equal the corresponding lengths on your BTW/BTR instructions in the processor. 2. If a BTW appears first in your ladder logic, put CALLs 3 or 6 first in your BASIC program. If a BTR appears first in your ladder logic, put CALLs 2 or 7 first in your BASIC program. 3. Set the PLC-5 block-transfer-write timeout bit (block-transfer control block, word 0 bit 8) to eliminate excessive PLC-5 scan times.
Chapter 7 Data Types 7.1 Chapter Objectives This chapter describes the data types and formats used by the BASIC Module Data Conversion CALL routines. After reading this chapter you should be able to interpret and manipulate the data values generated by your module. 7.2 Output Data Types Converted data is exchanged with programmable controllers using block-transfers. You can generate the following data types with the BASIC Module: 16-bit binary (XXXX) 3-digit, signed, fixed decimal BCD (" XXX.
Chapter 7 Data Types 7.2.2 3-digit, Signed, Fixed Decimal BCD This value requires one word of the processor data table. The data is represented by a 3-digit binary coded decimal integer (figure 7.2). Overflow, underflow and sign are also indicated. An underflow or overflow condition sets the appropriate bit and a value of 000 is returned. The value ranges from -999 to +999. Fractional portions of any number used with the routine are truncated. Figure 7.2 Truncated 3-Digit BCD Integer 7.2.
Chapter 7 Data Types 7.2.3 4-digit, Unsigned, Fixed Decimal BCD (continued) 7.2.4 4-digit, Signed, Octal Figure 7.3 Truncated 4-Digit BCD Integer This value requires one word of the processor data table. The data is represented by a 4-digit octal integer (figure 7.4). The value ranges from "7777 8 ("4095). Overflow, underflow and sign are also indicated. If an overflow or underflow condition exists, the appropriate bit is set and the value of 0000 is reported.
Chapter 7 Data Types 7.2.5 6-digit, Signed, Fixed Decimal BCD This value requires two words of the processor data table. The first word contains overflow, underflow and sign data and the three most significant digits of the 6-digit BCD integer. The second word contains the lower three digits of the value (figure 7.5). The value ranges from -999999 to +99999. If an overflow or underflow condition exists, the appropriate bit is set and a value of 000000 is reported.
Chapter 7 Data Types 7.2.6 3.3-digit, Signed, Fixed Decimal BCD This value requires two words of the processor data table. The first word contains the overflow, underflow, sign data and the three most significant digits of the value. The second word contains the lower three digits of the value (figure 7.6). The value ranges from -999.999 to +999.999. If an overflow or underflow condition exists, a value of 000.000 is reported and the appropriate bit is set.
Chapter 7 Data Types 7.3 Input Data Types The BASIC Module interfaces with the PLC-2, PLC-3 and PLC-5 family processors. You can send the following data types to the BASIC Module types to the BASIC Module: 16-bit binary (4 Hex digits) (XXXX) 3-digit, signed, fixed decimal BCD (" XXX.) 4-digit, unsigned, fixed decimal BCD (XXXX.) 4-digit, signed, octal (" XXXX.) 6-digit, signed, fixed decimal BCD (" XXXXXX.) These data formats are the same as those described under ”Output Data Types” except for 3.
Chapter 8 Editing A Procedure 8.2 Chapter Objectives After reading this chapter you should be able to make corrections or modifications to your BASIC programs using the editing features presented. 8.2 Entering the Edit Mode To invoke the edit mode, type [EDIT] and the line number of the RAM program line to edit. For example: uEDIT 10. The following features are available in the edit mode. right/left cursor control replace a character insert a character delete a character retype a line 8.
Chapter 8 Editing A Procedure 8.3.3 Insert Invoke the insert command by typing [CTRL]A. This command inserts text at the cursor position. You must type a second [CTRL]A to terminate the insert. Important: When you use insert, all text to the right of the cursor disappears until you type the second [CTRL]A. Total line length is 79 characters. 8.3.4 Delete Invoke the delete command by typing [CTRL]D. This command deletes the character at the cursor position. 8.3.
Chapter 8 Editing A Procedure 8.3.7 Renumber (continued) REN[NUM1],[NUM2] — begins at the start of the program and continues through the end of the program. The new line numbers begin with NUM1 and increment by NUM2. REN[NUM1],[NUM2],[NUM3] — begins at NUM2 and continues through the end of the program. The new line numbers begin with NUM1 and increment by NUM3. Important: The renumber command updates the destination of GOSUB, GOTO, ON ERR, ON TIME and ON GOTO statements.
Chapter 8 Editing A Procedure 8.4 Editing a Simple Procedure The following example shows you how to edit a simple procedure. Example: When the screen shows You do this LIST 10 REM EM 20 FOR I = 1 TO 6 30 PRINT I 40 NEXT E TI READY u Type EDIT 20 then [RETURN] EDIT 20 20 fo for I = 1 TTO 6 Press the space bar 18 times to move the cursor to 6 (MOVE right feature).
Chapter 9 Error Messages and Anomalies 9.1 Chapter Objectives After reading this chapter you should be familiar with the module’s error messages and anomalies. 9.2 Error Messages from BASIC When BASIC is in the RUN mode the format of the ERROR messages is as follows: ERROR: XXX – IN LINE YYY YYY BASIC STATEMENT X Where XXX is the ERROR TYPE and YYY is the line number of the program in which the error occurred.
Chapter 9 Error Messages and Anomalies 9.2 Error Messages from BASIC (continued) ARITH. UNDERFLOW — An ARITH. UNDERFLOW occurs when an arithmetic operation exceeds the lower limit of a module floating point number. The smallest floating point number in the BASIC Module is +/–lE–127. For example, 1E–80/1E+80 causes an ARITH. UNDERFLOW error. ARRAY SIZE — An ARRAY SIZE error occurs if an array is dimensioned by a DIM statement and you attempt to access a variable that is outside of the dimensioned bounds.
Chapter 9 Error Messages and Anomalies 9.2 Error Messages from BASIC (continued) EXTRA IGNORED — Error occurs when an INPUT statement requiring numeric data, receives numeric data followed by letters. Letters are ignored. Error also occurs from CALL 61. MEMORY ALLOCATION — A MEMORY ALLOCATION error occurs when: user memory (RAM) is full. BASIC cannot determine memory bounds because the system control value MTOP is altered. RAM contains an incomplete program file.
Chapter 9 Error Messages and Anomalies 9.3.2 Peripheral Port Support CALL Error Messages (continued) IN ROM — The IN ROM message displays if you attempt to load a ROM program to tape with CALL 32 or 38. You should transfer the ROM program to RAM and then load the program to tape. INVALID INPUT DATA — This error occurs when you enter an invalid value when using CALL 30. INVALID VALUE PUSHED — This error occurs when you enter a value other then 0, 1 or 2 when using CALL 37.
Chapter 9 Error Messages and Anomalies 9.3.4 String Support CALL Error Messages STRING# NOT ALLOCATED — This error occurs if you attempt to access a string that is outside the allocated string memory when using CALLs 60, 61, 64, 65, 66, 67, or 68. Example: u10 STRING 100,9 u20 PUSH 5,12 REM 10 STRINGS ALLOCATED$ (0)–$(9) REM REPEAT CHAR 5 TIMES IN$(12) u30 CALL 60 uRUN ERROR — STRING # NOT ALLOCATED Error occurs because STRING 12 is outside the area reserved for strings.
Chapter 9 Error Messages and Anomalies 9.3.4 String Support CALL Error Messages (continued) BAD POSITION— This error occurs if you attempt to access a string position that is beyond the declared length of the string when using CALL 66. Example: u10 STRING 100,9 u20 $(0)=“1234” u30 $(1)=“56” u40 PUSH 6 REM INVALID POSITION OF $(0) u50 PUSH 1 REM $(1) u60 PUSH 0 REM $(0) u70 CALL 66 REM INSERT $(1) INTO $(0) @ POS 6 BAD POSITION error results because position 6 is outside of the declared string.
Chapter 9 Error Messages and Anomalies 9.3.6 Miscellaneous CALL Error Messages INVALID BAUD RATE ENTERED — This error occurs when a baud rate other than 300, 600, 1200, 2400, 4800, 9600 or 19.2K bps is PUSHed using CALL 78. INCOMPLETE ROM PROGRAM FOUND — This error occurs when CALL 81 detects an incomplete program in the EPROM. You can burn no additional programs onto this PROM. All earlier programs are still accessible.
Chapter 9 Error Messages and Anomalies 9.4 Anomalies (continued) 2. When using the variable I before an ELSE statement, put a space between the I and the ELSE statement. If you do not, the program assumes that the IE portion of IELSE is the special function operator IE. This error may or may not yield a BAD SYNTAX — IN LINE XXX error message, depending on the particular program in which it is used.
Chapter 9 Error Messages and Anomalies 9.4 Anomalies (continued) 9. If you use a VT100 terminal, the BASIC Module can miss an XON character sent by your terminal when you enable software handshaking and use a 19.2K baud rate on the module’s program port. You must type CTRL Q to resume. 10. If you use a CTRL C to abort LIST# or PRINT# to a peripheral device, the BASIC Module no longer transmits on the program port (only at 9600 or 19.2 K baud). You can correct the problem by deleting any line.
Appendix A Quick Reference Guide Mnemonic Page Description ABS( ) ASC( ) ATN( ) CALL CHR( ) CLEAR CLEARI CLOCK0 CLOCK1 CONT CONTROL C CONTROL S CONTROL Q COS( ) DATA DIM DO END EXP( ) FOR-TO (STEP) GET GOSUB GOTO IF-THEN-ELSE INPUT INT( ) LD@ LEN 5–45 5–72 5–47 5–16 5–74 5–16 5–16 5–17 5–17 5–7 5–9 5–10 5–10 5–47 5–18 5–19 5–19 5–22 5–46 5–22 5–50 5–23 5–24 5–25 5–26 6–45 5–28 5–52 LET 5–29 LIST 5–7 ABSOLUTE VALUE RETURNS INTEGER VALUE OF ASCII CHARACTER RETURNS ARCTANGENT OF ARGUMENT CALL APPLICA
Appendix A Quick Reference Guide PH0 PH1 PH0.# PH1.# PI POP PRINT Mnemonic 5–37 5–37 5–37 5–37 5–46 5–38 5–32 PRINT# PRINT CR PRINT SPC(5) PRINT TAB(#) PRINT USING (Fx) PRINT USING(#.
Appendix B Decimal/Hexadecimal/Octal/ASCII Conversion Table Column 1 DEC HEX OCT 00 00 000 01 01 02 Column 2 ASC Column 3 Column 4 DEC HEX OCT ASC DEC HEX OCT ASC DEC HEX OCT ASC NUL 32 20 040 SP 64 40 100 @ 96 60 140 \ 001 SOH 33 21 041 ! 65 41 101 A 97 61 141 a 02 002 STX 34 22 042 ″ 66 42 102 B 98 62 142 b 03 03 003 ETX 35 23 043 # 67 43 103 C 99 63 143 c 04 04 004 EOT 36 24 044 $ 68 44 104 D 100 64 144 d 0
2
Appendix C Basic Module Programming Hints BASIC Module Programming Hints These programming hints can help you to properly program your module to increase module performance. 1. Always define strings first. 2. Always dimension arrays after defining strings. 3. Define the most used variables first. You can use 0 values until you assign real values. 4. When doing math, save intermediate values rather than recalculate. 5. Place the most used subroutines near the beginning of the program. 6.
Allen-Bradley, a Rockwell Automation Business, has been helping its customers improve productivity and quality for more than 90 years. We design, manufacture and support a broad range of automation products worldwide. They include logic processors, power and motion control devices, operator interfaces, sensors and a variety of software. Rockwell is one of the world’s leading technology companies. Worldwide representation.