Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 5 of 17

1771-DB Basic Module User Manual, pages 41 to 50

Pages 41 to 50 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 41

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.9 Expressions

An expression is a logical mathematical expression that involves operators (both unary and dyadic), constants and variables. Expressions are simple or complex, (e.g. 12*EXP(A)/100, H(1) + 55, or (SIN(A)*SIN(A)+COS(A)* COS(A)/2). A “stand alone” variable [var] or constant [const] is also considered an expression. We refer to expressions as: [expr].

5.2.10 Relational Expressions

Relational expressions involve the operators EQUAL (=), NOT EQUAL (tu), GREATER THAN OR EQUAL TO (u=), and LESS THAN OR EQUAL TO (t=). You use them in control statements to test a condition (i.e. IF A t100 THEN...). Relational expressions always require two operands. We refer to relational expressions as: [rel expr].

5.2.11 System Control Values

The system control values include the following: LEN (returns the length of your program). MTOP (the last memory location assigned to BASIC). See the following Section 5.6.2 more information.

5–4 titled, “System Control Values” for

Page 42

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.13 Control Stack

The control stack (C-stack) stores all information associated with loop control (i.e. DO-WHILE, DO-UNTIL, FOR-NEXT, BASIC subroutines and “PUSHed” or “POPed” values). The control stack is 157 bytes long. DO-WHILE and DO-UNTIL loops use 3 bytes of control stack. FOR-NEXT loops use 17 bytes. The control stack contains enough space for up to 9 nestings of control loops.

5–5

Page 43

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. You can terminate program execution at any time by typing a Control C on the console device. Variations: Some BASIC interpreters allow a line number to follow the RUN command (i.e. RUN 100). The BASIC Module does not permit this variation on the RUN command. Execution begins with the first line number. To obtain a function similar to the RUN[ln num] command, use the GOTO[ln num] statement in the direct mode. See statement GOTO. Example: u10 FOR I=1 TO 3 u20 PRINT I u30 NEXT I u40 END uRUN 1 2 3 READY u

5–6

Page 44

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. However, you cannot CONTinue if the program is modified during the STOP or after an error. Example: u10 FOR I=1 TO 10000 u20 PRINT I u30 PRINT I u40 END uRUN 1 2 3 4 5– (TYPE CONTROL C ON CONSOLE) STOP – IN LINE 20 READY uPRINT I 6 uI=10 uCONT 10 11 12

5.3.3 Command: LIST

Action taken: The LIST command prints the program to the console device. Spaces are inserted after the line number, and before and after statements. This helps in the debugging of BASIC Module programs. You can terminate the “listing” of a program at anytime by typing a Control C on the console device. You can interrupt and continue the listing using Control S and Control Q.

5–7

Page 45

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 (–).

numbers with a dash

Example: READY uLIST u10 PRINT “LOOP PROGRAM” u20 FOR I=1 TO 3 u30 PRINT I u40 NEXT I u50 END READY uLIST 30 u30 PRINT I u40 NEXT I u50 END READY uLIST 20–40 u20 FOR I=1 TO 3 u30 PRINT I u40 NEXT I

5.3.4 Command: LIST# or LIST

5–8

Action taken: The LIST# or LIST@ command lists the program to the device attached to the peripheral port (LIST device). All comments that apply to the LIST command apply to the LIST# or LIST@ commands. We include these commands to permit you to make “hard copy printouts” of a program. A configuration plug sets the baud rate and must match your list device (see section 3.2.4 titled, “Configuration Plugs”). Also, you must configure the peripheral port parameters to match your particular list device (see section 5.8.1 titled, “Peripheral Port Support – Parameter Set – CALL 30”).

Page 46

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.6 Command: NULL [integer]

Action taken: The NULL[integer] command determines how many NULL characters (00H) the BASIC Module outputs after a carriage return. After initialization NULL 0. Most printers contain a RAM buffer that eliminates the need to output NULL characters after a carriage return.

5.3.7 Command: Control C

Action taken: This command stops execution of the current program and returns the BASIC Module to the COMMAND mode. In some cases you can continue execution using a CONTinue. See the explanation for CONTinue for more information.

5.3.7.1 Command: Disabling Control C Action taken: This command disables the Control C break function. You can do this by setting bit 48 (30H) to 1. Bit 48 is located in internal memory location 38 (26H). Set bit 48 by executing the following statement in a BASIC Module program or from the command mode: DBY(38)

DBY(38).OR.01H

When bit 48 is set to 1, the Control C break function for both LIST and RUN operations is disabled. Cycling power returns Control C to normal operation if it is disabled from the command mode. To re-enable the Control C function, execute the following statement in a BASIC Module program or from the command mode. DBY(38)

DBY(38).AND.0FEH

CALL routines do not check for this feature. If you enter a Control C while using a CALL routine, the program stops if Control C is enabled or disabled.

5–9

Page 47

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. When received at any other time, program execution continues until a PRINT is encountered. At this time program execution is suspended. 4. XON (Control Q) is required to resume program operation.

5.3.9 Command: Control Q

Action taken: This command restarts a LIST command or PRINT output that is interrupted by a Control S.

5.3.10 Overview of EPROM File Commands

Your BASIC Module can execute and SAVE up to 255 programs in an EPROM. The module generates all of the timing signals needed to program most EPROM devices. The programs are stored in sequence in the EPROM for retrieval and execution. This sequential storing of programs is called the EPROM FILE. The following commands allow you to generate and manipulate the EPROM FILE.

5.3.11 Commands: RAM and ROM [integer]

Action taken: These two commands tell the the BASIC Module interpreter whether to select the current program out of RAM or EPROM. The current program is displayed during a LIST command and executed when RUN is typed.

5–10

Page 48

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. Use the following formula to calculate the available user RAM space: LEN system control program length value which contains current

+# bytes allocated for strings instruction)

(first

RAM value in the STRING

+6 * each array size + 1 (asterisk = multiply) +8 * each variable used (including each array name) +1024 – number of bytes reserved for BASIC V Available user RAM= MTOP–V

5.3.11.2 ROM When you enter ROM [integer], the BASIC Module selects the current program out of EPROM memory. If no integer is typed after the ROM command (i.e. ROM) the module defaults to ROM 1. Since the programs are stored in sequence in EPROM, the integer following the ROM command selects which program the user wants to run or list. If you attempt to select a program that does not exist (e.g. you type in ROM 8 and only 6 programs are stored in the EPROM) the message ERROR: PROM MODE is displayed. The module does not transfer the program from EPROM to RAM when the ROM mode is selected. If you attempt to alter a program in the ROM mode, by typing in a line number, the message ERROR: PROM MODE displays. The XFER command allows you to transfer a program from EPROM to RAM for editing purposes. You get no error message if you attempt to edit a line of ROM program. Important: When you transfer programs from EPROM to RAM you lose the previous RAM contents. Since the ROM command does NOT transfer a program to RAM, it is possible to have different programs in ROM and RAM simultaneously. You can move back and forth between the two modes when in command mode. If you are in run mode you can change back and forth using CALLS 70, 71 and 72. You can also use all of the RAM memory for variable storage if the program is stored in EPROM. The system control value – MTOP always refers to RAM. The system control value, LEN, refers to the currently selected program in RAM or ROM.

5–11

Page 49

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.13 Command: PROG

Important: Before you attempt to program a PROM, read the PROG, PROG1 and PROG2 sections of this chapter. Some PROG options exclude the use of others. Action taken: The PROG command programs the resident EPROM with the current program. The current selected program may reside in either RAM or EPROM. See Section 3.4, titled “Installing the User Prom”, for additional information concerning EPROM’s. Important: Be sure you have selected the program you want to save before using the PROG command. Your module does not automatically copy the RAM program to ROM. You must also disable interrupts prior to the PROG, PROG1 or PROG2 commands using CALL 8 and enable interrupts after the PROM is burned using CALL 9. If an error occurs during EPROM programming, the message ERROR PROGRAMMING is displayed. When this error occurs: previously stored programs may or may not be accessible. you cannot store additional programs on this PROM. After you type PROG(cr), the BASIC Module displays the number in the EPROM FILE the program occupies. Programming can take up to 12 minutes to complete depending on the length of the program (51 seconds per K bytes of program).

5–12

Page 50

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. In some cases you can alter the previously stored programs. Be sure to use CALL 81 to determine memory space prior to burning. See section 5.3.13.1 below.

5.3.13.1 User PROM Check and

Description – CALL 81

Use CALL 81 in command mode before burning a program into PROM memory. This CALL: determines the number of PROM programs. determines the number of bytes left in PROM. determines the number of bytes in the RAM program. prints a message telling if enough space is available in PROM for the RAM program. checks for a valid PROM if it contains no program.

prints a good or bad PROM message. A bad PROM message with an address of 00xx indicates an incomplete program. No PUSHes or POPs are needed.

5–13