BASIC Language (Catalog Numbers 1746-BAS and 1746-BAS-T) Reference Manual
Important User Information Because of the variety of uses for the products described in this publication, those responsible for the application and use of this control equipment must satisfy themselves that all necessary steps have been taken to assure that each application and use meets all performance and safety requirements, including any applicable laws, regulations, codes and standards.
Table of Contents Preface Who Should Use This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Purpose of this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Use this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Terms and Abbreviations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Conventions Used in this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . Rockwell Automation Support .
Table of Contents ii NULL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PROG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PROG1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PROG2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RAM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Table of Contents iii NEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9 ON-GOTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11 Chapter 8 Execution Control and Interrupt Support Functions CALL 16 – Enable DF1 Packet Interrupt . . . . . . . . . . . . . . . . . . . . . . 8-2 CALL 17 – Disable DF1 Packet Interrupt. . . . . . . . . . . . . . . . . . . . . . 8-3 CALL 20 – Enable Processor Interrupt . . . . . .
Table of Contents iv Chapter 11 Status Functions CALL 36 – Get Number of Characters in PRT2 Buffers . . . . . . . . . 11-2 CALL 51 – Check CPU Output Image Buffer . . . . . . . . . . . . . . . . . 11-3 CALL 55 – Check CPU Input Image Buffer. . . . . . . . . . . . . . . . . . . 11-4 CALL 58 – Check M0 File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5 CALL 59 – Check M1 File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Table of Contents v Chapter 13 Input Functions CALL 22 – Transfer Data from Port 1 or 2 to the CPU Files . . . . . . 13-2 CALL 27 – Read Remote DH485 SLC Data File . . . . . . . . . . . . . . . 13-8 CALL 29 – Read/Write to a PLC/SLC from the Module Internal String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-13 CALL 35 – Get Numeric Input Character from PRT2 . . . . . . . . . . 13-15 CALL 53 – Transfer CPU Output Image to BASIC Input Buffer . .
Table of Contents vi Appendix A Decimal/Hexadecimal/Octal/ ASCII Conversion Table Mathematical Conversion Overview . . . . . . . . . . . . . . . . . . . . . . . . . . A-1 Appendix B BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic List Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Preface Read this preface to familiarize yourself with the rest of the manual. This preface covers the following topics: • who should use this manual • the purpose of this manual • how to use this manual • terms and abbreviations • conventions used in this manual • Rockwell Automation support Who Should Use This Manual Use this manual if you are responsible for designing, installing, programming, or troubleshooting control systems that use Allen-Bradley small logic controllers.
P-2 Purpose of this Manual Chapter This manual is a reference guide for programming the BASIC or BASIC-T module. This manual is intended for reference purposes only. Title Contents Preface Describes the purpose, background, and scope of this manual. Also lists related publications. 1 Language Elements Describes BASIC program lines, line numbers, statements, commands, operators, and line length. 2 Data Types Describes and illustrates data types, variable names and types.
P-3 Related Documentation The following documents contain additional information regarding Rockwell Automation products. To obtain a copy, contact your local Rockwell Automation office or distributor. For Read this document A BASIC and BASIC-T manual that provides SLC 500™ BASIC and BASIC-T Modules information on installing and using the 1746-BAS User Manual and 1746-BAS-T modules.
P-4 Terms and Abbreviations The following terms and abbreviations are specific to this product. For a complete listing of Allen-Bradley terminology, refer to the Allen-Bradley Industrial Automation Glossary, publication number ICCG-7.1.
P-5 Rockwell Automation Support Allen-Bradley offers support services worldwide, with over 75 Sales/Support Offices, 512 authorized Distributors and 260 authorized Systems Integrators located throughout the United States alone, plus Rockwell Automation representatives in every major country in the world.
P-6 Publication 1746-RM001A-US-P
Chapter 1 Language Elements This chapter introduces you to the elements of a BASIC program. These elements include BASIC: • line numbers • statements, commands, and operators • line length Character Set BASIC programs are composed of a group of BASIC program lines. Each BASIC program line is composed of a group of ASCII characters. Refer to Appendix A for a complete listing of ASCII character codes.
1-2 Language Elements Typically, the line numbers of a program start out looking like the first column and end up looking something like the second column below: #1 10 20 30 40 50 60 70 80 . . . #2 5 7 10 15 20 30 35 40 . . . IMPORTANT Reuse of an existing line number causes all of the information referenced by the original line number to be lost. Be careful when entering numbers in the Command mode, as you may accidentally erase some program lines.
Chapter 2 Data Types This chapter provides you a method of defining or displaying data within the BASIC programming language through the use of: • data types • variables Data Types Data types are broken down into three sections: argument stack, string and numeric elementary data types, and backplane conversion data. Argument Stack The argument stack (A-stack) stores all constants that the BASIC or BASIC-T module is currently using.
2-2 Data Types When allocating memory for a string, you must account for the overhead bytes used by BASIC to manipulate strings. BASIC uses one overhead byte per string being declared plus one additional overhead byte. Example 1 String 106,20 Allocates space for five 20 byte strings (100 bytes) and includes five overhead bytes (1 per string) and one additional overhead byte. In the module you can define strings with the LET statement, the INPUT statement, and with the ASC operator.
Data Types 2-3 Numeric Data Types There are two different numeric data types: • integer numbers • floating-point numbers You can enter and display numbers in four formats: integer, decimal, hexadecimal, and exponential. Example 129, 34.98, 0A6EH, 1.23456E+3 The BASIC or BASIC-T module interprets all numbers as floating-point numbers except when performing logical operations.
2-4 Data Types Backplane Conversion Data The module communicates with the local processor through the SLC 500 I/O backplane. All data communicated to and from the SLC 500 is in SLC 500 format.
Data Types 2-5 Variable Names Variables may represent either numeric values or strings. Variable names can only be eight characters long. The module compares the first, last, and number of characters in a variable name with the first, last, and number of characters in other variable names to determine if it is a unique variable name. The characters allowed in a variable name are letters, numbers, and the decimal point. Special type declaration characters are also allowed.
2-6 Data Types Publication 1746-RM001A-US-P
Chapter 3 Expressions and Operators This chapter describes and illustrates how you manipulate and/or evaluate expressions and statements within the BASIC program or the command line. Table 3.1 lists the corresponding mnemonics. Table 3.1 Chapter Reference Guide If you need (to) Use this mnemonic Page Absolute value ABS( ) 3-9 Return the integer value of the ASCII character. ASC( ) 3-12 Return the arctangent of the argument. ATN( ) 3-8 Retrieve data from the specified memory address.
3-2 Expressions and Operators Table 3.1 Chapter Reference Guide Expressions and Operators If you need (to) Use this mnemonic Page Logical Exclusive OR .XOR. 3-6 Direct communications to port PRT1. @ 3-15 Direct communications to port PRT2. # 3-15 An expression is a logical mathematical expression that involves operators, constants, and variables.
Expressions and Operators Hierarchy of Operators 3-3 The hierarchy of operators is the order that the operations in an expression are performed. You can write complex expressions using only a small number of parentheses. To illustrate the hierarchy of operators, examine the following equation: 4+3*2 = ? In this equation, multiplication has precedence over addition. Therefore, multiply (3*2) and then add 4.
3-4 Expressions and Operators Divide ( / ) Use the Division operator to divide the first expression by the second expression. Example Result >PRINT 100/5 20 Exponentiation ( **) Use the Exponentiation operator to raise the first expression to the power of the second expression. The maximum power to which you can raise a number is 255. Example Result >PRINT 2**3 8 Multiply ( * ) Use the Multiplication operator to multiply the first expression by the second expression.
Expressions and Operators 3-5 Overflow and Division by Zero During the evaluation of an expression if an overflow, underflow, or division by zero error occurs, the module generates error messages and reverts to Command mode. Refer to the ONERR operation in chapter 8 for more information on how to trap these errors. The largest result allowed from any calculation is 0.99999999 E+127. If this number is exceeded, the module generates the ERROR: ARITH. OVERFLOW message and returns to Command mode.
3-6 Expressions and Operators Logical Operators The module contains a complete set of logical operators that are divided into two groups: dual-operand operators and single-operand operators. The general form of all dual-operand instructions is: (expr) OP (expr), where OP is one of the following logical operators. These operators perform BIT-WISE logical operations on numbers between 0 (0000H) and 65535 (0FFFFH) inclusive.
Expressions and Operators Relational Operators 3-7 Relational expressions involve the operators =, < >, >, >=, <, and <=. In the module, relational operations are typically used to test a condition. The module relational operators return a result of 65535 (0FFFFH) if the relational expression is true, and a result of 0 if the relation expression is false. The result returns to the argument stack. Because of this, it is possible to display the result of a relational expression.
3-8 Expressions and Operators Trigonometric Operators The module contains a complete set of trigonometric operators. These operators are single-operand operators. SIN([expr]) Use the SIN operator to return the sine of the argument. The argument is expressed in radians. Calculations are carried out to 7 significant digits. The argument must be between +200000. Example Result >PRINT SIN(PI/4) .7071067 >PRINT SIN(0) 0 COS([expr]) Use the COS operator to return the cosine of the argument.
Expressions and Operators 3-9 Comments on Trigonometric Functions The SIN, COS, and TAN operators use a Taylor series to calculate the function. These operators first reduce the argument to a value between 0 and PI/2. This reduction is accomplished by the following equation: reduced argument=(user arg/PI – INT(user arg/PI) *PI The reduced argument, from the above equation, is between 0 and PI. The reduced argument is then tested to see if is greater than PI/2.
3-10 Expressions and Operators INT([expr]) Use the INT operator to return the integer portion of the expression. Example Result >PRINT INT(3.7) 3 >PRINT INT(100.876) 100 PI PI is a stored constant. In the module PI is stored as 3.1415926. SGN([expr]) Use the SGN operator to return a value of +1 if the argument is greater than zero, zero if the argument is equal to zero, and –1 if the argument is less than zero.
Expressions and Operators 3-11 RND Use the RND operator to return 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. IMPORTANT Unlike most BASIC languages, the RND operator in the module does not require an argument or a dummy argument.
3-12 Expressions and Operators String Operators Two operators in the module can manipulate STRINGS. These operators are ASC( ) and CHR( ). ASC([expr]) Use the ASC operator to return the integer value of the ASCII character placed in the parentheses. >1 REM EXAMPLE PROGRAM >10 PRINT ASC(a) >20 PRINT ASC(A) READY >RUN 65 65 READY > The decimal representation for the ASCII character A is 65. The decimal representation for the ASCII character a is 97.
Expressions and Operators 3-13 When you use the ASC operator as shown above, the $([expr]) denotes what string is accessed. The expression after the comma selects an individual character in the string. In the above example, the first character in the string is selected. The decimal representation for the ASCII character T is 84. String character position 0 is invalid.
3-14 Expressions and Operators CHR([expr]) Use the CHR operator to convert a numeric expression to an ASCII character. Example Result >PRINT CHR(65) A Like the ASC operator, the CHR operator also selects individual characters in a defined ASCII string.
Expressions and Operators Special Function Operators 3-15 The module contains a complete set of special function operators. These operators manipulate the I/O hardware and memory addresses of the module. # and @ Use the # and @ operators to direct communications. Communication takes place through port PRT1 when the @ operator is programmed, and through port PRT2 when the # operator is programmed.
3-16 Expressions and Operators MTOP Use the MTOP operator to retrieve the last valid memory address in RAM that is available to the module. After reset, the 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 beyond the value assigned to MTOP. If this value has not been changed by CALL 77, then the last valid BASIC address is 5FFFH (24575). Example Result >PRINT MTOP 24575 PH0.
Expressions and Operators 3-17 XBY([expr]) Use the XBY operator to retrieve or assign data to or from the external data memory of the module. The argument for the XBY operator must be a valid integer between 0 and 65535 (0FFFFH). The value assigned to the XBY operator must between 0 and 255 inclusive. If it is not, a bad argument error occurs. IMPORTANT Improper use of this operator may cause a malfunction of the module.
3-18 Expressions and Operators You can change the fraction portion of TIME by manipulating the contents of internal memory location 71 (47H). You can do this by using a DBY(71) statement. Each count in internal memory location 71 (47H) represents 5 milliseconds of TIME. Continuing with the example: >DBY(71) = 0 (fraction of TIME = 0) >PRINT TIME 0 >DBY(71) = 3 (fraction of TIME = 3*5ms = 15 ms) >PRINT TIME 1.5 E–2 Only the integer portion of TIME changes when a value is assigned.
Chapter 4 BASIC Commands This chapter describes and illustrates words and expressions that cause a function to occur within the BASIC program or the command line. Table 4.1 lists the corresponding mnemonics. Table 4.1 Chapter Reference Guide 1 If you need (to) Use this mnemonic Page Set the program break point. BRKPNT 4-2 Re-enable the [CTRL-C] break function. CALL 18 4-5 Disable the [CTRL-C] break function. CALL 19 4-6 Continue after a Stop or [CTRL-C].
4-2 BASIC Commands BRKPNT Purpose Use the BRKPNT command to set a program break point at the line number specified by this command. Program execution stops just before the line number specified by the BRKPNT command. If the line number is zero, the break point is disabled. After the break point is reached, you can examine variables by using assignment statements. Continue from the break point by using the CONT command. Once the break point is reached, it is disabled.
BASIC Commands 4-3 STOP - IN LINE 160 READY >PRINT D,SU,AV .86042573 0 0 >D = .5 >PRINT D,SU,AV .5 0 0 >CONT THE AVERAGE VALUE IS .48060383 READY > CONT Purpose Use the CONT command to resume execution of a program stopped by a [CTRL-C], BRKPNT command, or a STOP statement. If you stop a program by pressing [CTRL-C] on the console device or by execution of a STOP statement, you can resume execution of the program by typing CONT. If you press [CTRL-C] while [CTRL-C] is enabled, it stops the program.
4-4 BASIC Commands Example >NEW >1 >10 >20 >30 >40 REM EXAMPLE PROGRAM FOR I = 1 TO 10000 PRINT I NEXT I END READY >RUN 1 2 3 4 5 6 7 8 9 10 [CTRL-C] pressed STOP - IN LINE 15 READY >CONT 20 21 22 Control-C Purpose Use the [CTRL-C] command to stop execution of the current program and return the module to the Command mode. In some cases you can continue execution of the program using a CONTinue. See the explanation for CONTinue for more information.
BASIC Commands >20 PRINT I >30 NEXT I >40 END >RUN 1 2 3 4 5 [CTRL-C] 4-5 pressed STOP – IN LINE 20 READY >PRINT I 27 >I =10 >CONT 10 11 12 Notice that after [CTRL-C] is pressed and I is printed the value of I is 27. The value of I is incremented several times before [CTRL-C] is detected. CALL 18 – Re-enable the Purpose Control-C Break Re-enable the [CTRL-C] break function by executing CALL 18 in a module Function program or from the Command mode.
4-6 BASIC Commands Syntax CALL 18 Example >1 REM EXAMPLE PROGRAM >10 CALL 19 . >90 CALL 18 CALL 19 – Disable the Control-C Break Function Purpose Disable the [CTRL-C] break function by executing CALL 19 in a module program or from the Command mode. When CALL 19 is executed, the [CTRL-C] break function for both LIST and RUN operations is disabled. Cycling power returns the [CTRL-C] function to normal operation if it is disabled from the Command mode . IMPORTANT [CTRL-C] is enabled by default.
BASIC Commands Control-S 4-7 Purpose Use the [CTRL-S] command to interrupt the scrolling of a BASIC program during the execution of a LIST command. [CTRL-S] stops output from the transmitting port if you are running a program. In this case XOFF ([CTRL-S]) operates as follows: • XOFF only operates on PRINT statements. • When received during a PRINT, data output is suspended immediately but program execution continues.
4-8 BASIC Commands Control-Q Purpose Use the [CTRL-Q] command to restart a LIST command or PRINT output that is interrupted by [CTRL-S]. Syntax [CTRL–Q] Example > LIST 1 REM EXAMPLE PROGRAM 10 A = 1 20 DO [CTRL–S] . . . [CTRL–Q] 30 A = A+1 40 PRINT A 50 WHILE A < 20 READY > In this example, the output is suspended when [CTRL–S] is pressed. The output is continued after [CTRL–Q] is pressed. EDIT Purpose Use the EDIT command to access the BASIC line editor.
BASIC Commands 4-9 Table 4.2 BASIC Editor Operations Operation Function Key Strokes Move Use the Move operation to provide right/left cursor control. [Space bar] – moves the cursor one space to the right. [Backspace] – moves the cursor one space to the left. Replace Use the Replace operation to replace the character at the current cursor position. Press the key that corresponds to the character that replaces the character at the current cursor position.
4-10 BASIC Commands Example >ERASE >ROM 13 ERASED The last program stored in EEPROM (ROM 13 in this example) is erased. IDLE Purpose Use the IDLE command to force the module to enter wait until Interrupt mode. Program execution halts until an ONTIME condition is met. The ONTIME interrupt must be enabled before executing the IDLE command or else the module enters a wait forever mode. [CTRL-C] exits the IDLE command if [CTRL-C] is enabled.
BASIC Commands LIST 4-11 Purpose Use the LIST command to print the program to the console device. Spaces are inserted after the line number, and before and after statements. This helps in the debugging of module programs. You can terminate the listing of a program at any time by pressing [CTRL-C] on the console device. You can interrupt and continue the listing using [CTRL-S] and [CTRL-Q]. IMPORTANT [CTRL–C] terminates the listing if [CTRL–C] checking is enabled.
4-12 BASIC Commands LIST@ Purpose Use the LIST@ command to print the program to the device attached to port PRT1. All comments that apply to the LIST command apply to the LIST@ command. You must configure PRT1 port parameters to match your particular list device. The PRT1 parameters (baud rate, parity, stop bits, and so on) can be set using the MODE command.
BASIC Commands 4-13 Table 4.
4-14 BASIC Commands Example >1 REM EXAMPLE PROGRAM >10 MODE(DH485,19200,0,1,2,,R) . . . >25 MODE(PRT1,1200,N,8,,,) IMPORTANT The E storage type option cannot be used if MODE is used as a statement. NEW Purpose Use the NEW command to delete the program currently stored in RAM. In addition, all variables are set equal to ZERO; all strings and all BASIC evoked interrupts are cleared. The free running clock, string allocation, and internal stack pointer values are not affected.
BASIC Commands PROG 4-15 IMPORTANT Before you attempt to program EEPROM, read the PROG, PROG1 and PROG2 sections of this chapter. Purpose Use the PROG command to program the resident EEPROM with the current program in RAM. The module cannot program UVPROMs. 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 EEPROM.
4-16 BASIC Commands IMPORTANT If you exceed the available EEPROM space, you cannot continue programming until it is erased. Use the ERASE command to erase the last program stored in EEPROM. Be sure to use CALL 81 or CALL 82 to determine memory space prior to programming your EEPROM. Refer to chapter 5 for information regarding CALLs 81 and 82. PROG1 IMPORTANT Before you attempt to program an EEPROM, read the PROG, PROG1 and PROG2 sections of this chapter.
BASIC Commands PROG2 4-17 IMPORTANT Before you attempt to program an EEPROM, read the PROG, PROG1 and PROG2 sections of this chapter. Note, the PROG2 command does not transfer the RAM program to EEPROM. The PROG2 command enables the first program in EEPROM to be loaded at each powerup.
4-18 BASIC Commands Figure 4.
BASIC Commands RAM 4-19 Purpose Use the RAM command to tell the module interpreter to select the current program out of RAM. The current program is displayed during a LIST command and executed when RUN is typed. IMPORTANT RAM space is limited to 24K bytes.
4-20 BASIC Commands Syntax REM Example >10 REM THIS IS A COMMENT LINE >20 NEW : REM THIS IS ALSO A COMMENT LINE REN Purpose Use the REN command to renumber program lines. Syntax REN[new number],[old number],[increment] Examples ROM Example Result REN Renumbers the entire program. The first new line number is 10. Line numbers increment by 10. REN 20 Renumbers the entire program. The first new line number is 10. Line numbers increment by 20. REN 300,50 Renumbers the entire program.
BASIC Commands 4-21 When you enter ROM [integer], the module selects that program out of EEPROM memory and makes it the current program. If no integer is typed after the ROM command (example: ROM) the module defaults to ROM 1. Since the programs are stored in sequence in EEPROM, the integer following the ROM command selects the program the user wants to run or list.
4-22 BASIC Commands When you enter RROM [integer], the module selects that program out of EEPROM memory, makes it the current program, and starts program execution. If no integer is typed after the RROM command (example: RROM) the module defaults to RROM 1. Since the programs are stored in sequence in EEPROM, the integer following the RROM command selects the program the user wants to run or list.
BASIC Commands 4-23 Variations Some BASIC interpreters allow a line number to follow the RUN command (example: RUN 100). The 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 in chapter 7.
4-24 BASIC Commands Example >1 >10 >20 >30 >40 >50 >60 REM EXAMPLE PROGRAM FOR I = 1 TO 5 PRINT I NEXT I PRINT “PASSED FOR – NEXT LOOP” PRINT “THIS IS THE END” END READY >SNGLSTP 20 SINGLE STEP ENABLED READY >RUN STOP – LINE 20 READY >CONT 1 STOP – LINE 30 READY >CONT STOP – LINE 20 READY >CONT 2 STOP – LINE 30 READY >CONT STOP – LINE 20 READY >CONT 3 STOP – LINE 30 READY >SNGLSTP 0 SINGLE STEP DISABLED READY >CONT 4 5 PASSED FOR – NEXT LOOP THIS IS THE END Publication 1746-RM001A-US-P
BASIC Commands 4-25 READY > VER Purpose Use the VER command to print the module sign-on message that displays the current version of the firmware. Syntax VER Example >VER SLC 500 module–Catalog Number 1746-BAS Firmware release: x.
4-26 BASIC Commands XFER Purpose Use the XFER command to transfer the current selected program in ROM to RAM and select RAM mode. 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.
Chapter 5 Command Line CALLs This chapter describes and illustrates CALLs that cause a function to occur within the BASIC or BASIC-T module. These CALLs cannot be executed within the BASIC program but are entered at the command line. Table 5.1 lists the corresponding mnemonics. Table 5.
5-2 Command Line CALLs CALL 74 – Battery-Backed RAM Enable Purpose Use CALL 74 to enable the battery-backed RAM. When this CALL is executed, the message Battery Backup Enabled is printed on the host terminal. Battery-backed RAM is enabled on module powerup and remains enabled until you execute a CALL 73 or until the battery fails. Syntax CALL 74 Example >CALL 74 Battery Backup Enabled CALL 77 – Protected Variable Storage IMPORTANT Change CALL 77 from Command mode only to ensure proper operation.
Command Line CALLs 5-3 Example: (For saving 2 variables) >PRINT MTOP 24575 >PRINT MTOP-12 24563 >PUSH 24563:REM NEW MTOP ADDRESS >CALL 77 >1 >10 >20 >30 >40 >50 >60 >70 >80 >90 >100 >110 >120 REM EXAMPLE PROGRAM K = 678*PI L = 520 PUSH K ST@ 24575 : REM STORE K IN PROTECTED AREA PUSH L ST@ 24569 : REM STORE L IN PROTECTED AREA REM TO RETRIEVE PROTECTED VARIABLES LD@ 24575 : REM REMOVE K FROM PROTECTED AREA POP K LD@ 24569 : REM REMOVE L FROM PROTECTED AREA POP L REM USE LD@ AFTER POWER LOSS AND BATTERY B
5-4 Command Line CALLs Example >CALL 81 Number of Available Available Length of BASIC bytes bytes BASIC programs in (E)EPROM.......... to end of user (E)EPROM....... to beginning of assembly pgm.. program in RAM................ 3 7944 3848 76 Program will fit in (E)EPROM. READY > CALL 82 – Check User Memory Module Map Purpose Use CALL 82 to check the user memory module and display a map of where all the BASIC programs are stored.
Command Line CALLs 5-5 Syntax PUSH [starting address] PUSH [ending address] CALL 101 Example >PUSH 8000 : PUSH 804FH : CALL 101 :108000003107021327CC3313276607005FFF473081 :108010005509000A8B41E034290D1000149C3130C1 :108020002C32302C33302C34300D0A001EA049EA9B :1080300030A6330D0900289B41E049290D06003286 :1080400097490D0A003CA04AEA4FA6330D090046A5 :00000001F > CALL 103 – Print PRT1 Output Buffer and Pointer Purpose Use CALL 103 to print the complete output buffer with address, front pointer, and number o
5-6 Command Line CALLs Example >CALL 103 PRT1 Output Queue 6D00H 6D10H 6D20H 6D30H 6D40H 6D50H 6D60H 6D70H 6D80H 6D90H 6DA0H 6DB0H 6DC0H 6DD0H 6DE0H 6DF0H 3AH 41H 33H 48H 48H 48H 36H 48H 36H 48H 48H 48H 48H 48H 48H 48H 31H 30H 30H 20H 20H 20H 44H 20H 44H 20H 20H 20H 20H 20H 20H 20H 30H 30H 33H 32H 32H 32H 33H 32H 37H 33H 33H 33H 33H 33H 33H 32H 38H 33H 30H 30H 30H 30H 30H 30H 30H 30H 34H 38H 38H 30H 34H 30H 30H 43H 48H 48H 48H 48H 48H 48H 48H 48H 48H 48H 48H 48H 48H 48H 34H 41H 20H 20H 20H 20H 20H 2
Command Line CALLs 5-7 Example >CALL 104 PRT1 Input Queue 6C00H 6C10H 6C20H 6C30H 6C40H 6C50H 6C60H 6C70H 6C80H 6C90H 6CA0H 6CB0H 6CC0H 6CD0H 6CE0H 6CF0H 33H 7FH 7FH 0DH 58H 36H 4EH 20H 4CH 20H 20H 52H 50H 30H 50H 4CH 0DH 7FH 7FH 0DH 41H 2DH 54H 54H 20H 57H 41H 45H 41H 30H 55H 4CH 43H 52H 7FH 0DH 4DH 37H 20H 48H 52H 49H 4EH 4DH 47H 48H 53H 20H 41H 45H 7FH 45H 50H 0DH 7FH 45H 45H 4CH 20H 20H 45H 3AH 48H 31H 4CH 4DH 7FH 58H 4CH 43H 7FH 52H 53H 4CH 45H 45H 20H 50H 20H 30H 4CH 20H 7FH 41H 45H 41H 7FH 45
5-8 Command Line CALLs CALL 110 – Print PRT2 Output Buffer Pointer Purpose Use CALL 110 to print the complete output buffer with addresses, front pointer and the number of characters in the buffer to the console device. No PUSHes or POPs are needed. Use this information as a troubleshooting aid. It does not affect the contents of the buffer.
Command Line CALLs 5-9 Example >CALL 111 PRT2 Input Queue 6E00H 6E10H 6E20H 6E30H 6E40H 6E50H 6E60H 6E70H 6E80H 6E90H 6EA0H 6EB0H 6EC0H 6ED0H 6EE0H 6EF0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00
5-10 Command Line CALLs Publication 1746-RM001A-US-P
Chapter 6 Assignment Functions This chapter describes and illustrates commands that assign storage, reset data storage, and values to variables within the BASIC program or from the command line. Table 6.1 lists the corresponding mnemonics. Table 6.1 Chapter Reference Guide CLEAR If you need (to) Use this mnemonic Page Clear variables, interrupts & strings. CLEAR 6-1 Clear interrupts. CLEARI 6-3 Clear all stacks. CLEARS 6-3 Data read by Read statement.
6-2 Assignment Functions Example >CLEAR >LIST 1 REM EXAMPLE PROGRAM 10 DIM A(4) 20 DATA 10,20,30,40 30 FOR I=0 TO 3 40 READ A(I) 50 NEXT I 60 FOR J=O TO 3 70 PRINT A(J) 80 NEXT J READY >PRINT A(1),I,J 0 0 0 >RUN 10 20 30 40 READY >PRINT A(1),I,J 20 4 4 >CLEAR >PRINT A(1),I,J 0 0 0 Publication 1746-RM001A-US-P
Assignment Functions CLEARI 6-3 Purpose Use the CLEARI statement to clear all of the BASIC evoked interrupts. The ONTIME interrupt is disabled after the CLEARI statement is executed. CLEARI does not affect the free running clock enabled by the CLOCK1 statement. CLOCK0 is the only module statement that can disable the free running clock. You can use this statement to selectively DISABLE ONTIME interrupts during specific sections of your BASIC program.
6-4 Assignment Functions DATA Purpose Use the DATA statement to specify the expressions that you can retrieve with a READ statement. If multiple expressions per line are used, you must separate them with a comma. Every time a READ statement is encountered the next consecutive expression in the DATA statement is evaluated and assigned to the variable in the READ statement. You can place DATA statements anywhere within a program. They are not executed and do not cause an error.
Assignment Functions 6-5 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 that causes the module to enter the Command mode. If an array variable is used that was not dimensioned by a DIM statement, BASIC assigns a default value of 10 to the array size. All arrays are set equal to zero when the RUN command, NEW command or the CLEAR statement is executed.
6-6 Assignment Functions Examples >1 REM EXAMPLE PROGRAM >10 LET A = 10*SIN(C)/100 >1 REM EXAMPLE PROGRAM >10 LET A = A +1 NOTE 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 (example: LET A = 2 is the same as A = 2). When LET is omitted the LET statement is called an IMPLIED LET. We use the word LET to refer to both the LET statement and the IMPLIED LET statement.
Assignment Functions RESTORE 6-7 Purpose Use the RESTORE statement to reset the internal read pointer to the beginning of the data so that it may be read again.
6-8 Assignment Functions Publication 1746-RM001A-US-P
Chapter 7 Control Functions This chapter describes and illustrates commands executed within the BASIC program or from the command line to control the internal clock or the flow of the BASIC program. Table 7.1 lists the corresponding mnemonics. Table 7.1 Chapter Reference Guide If you need (to) CLOCK1 Use this mnemonic Page Disable the real time clock. CLOCK0 7-2 Enable the real time clock. CLOCK1 7-1 Set up a conditional do-loop. DO-UNTIL 7-4 Set up a conditional do-loop.
7-2 Control Functions Example >NEW >1 >10 >15 >20 >30 >40 >50 >60 >100 >110 >120 REM EXAMPLE PROGRAM TIME = 0 DBY(71) = 0 CLOCK1 ONTIME 2,100 DO WHILE TIME < 10 END PRINT “TIMER INTERRUPT AT - ”,TIME,“ SECONDS” ONTIME TIME+2,100 RETI READY >RUN TIMER TIMER TIMER TIMER TIMER CLOCK0 INTERRUPT INTERRUPT INTERRUPT INTERRUPT INTERRUPT AT AT AT AT AT - 2.01 SECONDS 4.015 SECONDS 6.01 SECONDS 8.01 SECONDS 10.
Control Functions DO-WHILE 7-3 Purpose Use the DO-WHILE statement to set up loop control within a module program. The operation of this statement is similar to the DO-UNTIL [rel expr]. 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 statements. The control stack (C-stack) stores all information associated with loop control (example: DO-WHILE, DO-UNTIL, FOR-NEXT and BASIC subroutines).
7-4 Control Functions >1 >10 >20 >30 >40 >45 >50 >60 >70 >80 >90 REM EXAMPLE PROGRAM A=0 : C=0 DO A=A+1 DO C=C+1 PRINT A,C,A*C WHILE C<>3 C=0 WHILE A<4 END READY >RUN 1 1 1 2 2 2 3 3 3 1 2 3 1 2 3 1 2 3 1 2 3 2 4 6 3 6 9 READY > DO-UNTIL Purpose Use the DO-UNTIL statement to set up loop control within a module program. All statements between the DO and the UNTIL[rel expr] are executed until the relational expression following the UNTIL statement is TRUE. You can nest DO-UNTIL loops.
Control Functions 7-5 Examples END Simple DO-UNTIL Nested DO-UNTIL >1 REM EXAMPLE PROGRAM >10 A=0 >20 DO >30 A=A+1 >40 PRINT A >50 UNTIL A=4 >60 PRINT “DONE” >70 END >RUN >1 >10 >20 >30 >40 >50 >60 >70 >80 >90 RUN REM EXAMPLE PROGRAM DO A=A+1 DO C=C+1 PRINT A,C,A*C UNTIL C=3 C=0 UNTIL A=3 END Purpose Use the END statement to terminate program execution. CONT does not operate if the END statement is used to terminate execution. An ERROR : CAN’T CONTINUE prints to the console.
7-6 Control Functions FOR-TO-(STEP)-NEXT Purpose Use the FOR- TO-(STEP)-NEXT statement to set up and control program loops. The control stack (C-stack) stores all information associated with loop control (example: DO-WHILE, DO-UNTIL, FOR-NEXT and BASIC subroutines). The control stack is 157 bytes long. DO-WHILE and DO-UNTIL loops and GOSUB commands use 3 bytes of the control stack. FOR-NEXT loops use 17 bytes.
Control Functions 7-7 In the first example, since E-0, C-10, D-2, and the PRINT statement at line 20 executes 6 times, the values of A that are printed are 0, 2, 4, 6, 8 and 10. A represents the name of the index or loop counter. The value of E 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. If the STEP statement and the value D are omitted, the increment value defaults to 1, therefore; STEP is an optional statement.
7-8 Control Functions If line 100 exists, this statement causes execution of the program to resume at line 100. If line number 100 does not exist, the message ERROR: INVALID LINE NUMBER is printed to the console device and the module enters the Command mode. Unlike the RUN command, the GOTO statement, if executed in the Command mode, does not clear the variable storage space or interrupts.
Control Functions 7-9 Example 2 You may execute multiple statements following the THEN or ELSE if you use a colon to separate them. >30 IF A<>10 THEN PRINT A : GOTO 150 ELSE 10 >30 IF A<>10 PRINT A : GOTO 150 ELSE 10 In these examples, if A does not equal 10, then both PRINT A and GOTO 150 are executed. If A equals 10, then control passes to 10. Example 3 You may omit the ELSE statement. If you omit the ELSE statement control passes to the next statement.
7-10 Control Functions Example >1 REM EXAMPLE PROGRAM >5 E=0 : C=10 : D=2 >10 FOR A=E TO C STEP D >20 PRINT A >30 NEXT A >40 END >RUN 0 2 4 6 8 10 READY > >NEW >1 >10 >20 >30 >40 REM EXAMPLE PROGRAM FOR I = 0 TO 8 STEP 2 PRINT I NEXT I END >RUN 0 2 4 6 8 Publication 1746-RM001A-US-P
Control Functions ON-GOTO 7-11 Purpose Use the ON-GOTO statement to transfer control to the line(s) specified by the GOTO statement when the value of the expression following the ON statement is encountered in the BASIC program. Syntax ON [expr] GOTO [ln num] Example >1 REM EXAMPLE PROGRAM >10 ON Q GOTO 100,200,300 Control is transferred to line 100 if Q is equal to 0 and then to line 200 if Q is equal to 1. If Q is equal to 2, control is transferred to line number 300, and so on.
7-12 Control Functions Publication 1746-RM001A-US-P
Chapter 8 Execution Control and Interrupt Support Functions This chapter describes and illustrates commands that control data flow and program transfer between ROM and RAM within the BASIC program or from the command line. Table 8.1 lists the corresponding mnemonics. Table 8.1 Chapter Reference Guide 1 If you need (to) Use this mnemonic Page Enable the interrupt capability when a DF1 packet is received. CALL 16 8-2 Disable the DF1 packet interrupt capability.
8-2 Execution Control and Interrupt Support Functions CALL 16 – Enable DF1 Packet Interrupt Purpose Use CALL 16 to enable the DF1 packet interrupt capability. One argument is PUSHed and no arguments are POPped. The input argument is the BASIC line number of the beginning of the interrupt routine that the program should jump to, when a valid DF1 packet is received in the port PRT2 buffer. You should process the packet within the interrupt routine.
Execution Control and Interrupt Support Functions CALL 17 – Disable DF1 Packet Interrupt 8-3 Purpose Use CALL 17 to disable the DF1 packet interrupt capability enabled with CALL 16. This routine has no input or output arguments. Syntax CALL 17 Example >1 REM EXAMPLE PROGRAM >10 REM DISABLE DF1 PACKET INTERRUPT ENABLED WITH CALL 16 >20 CALL 17 CALL 20 – Enable Processor Interrupt Purpose Use CALL 20 to allow the processor to interrupt the module. One argument is PUSHed and no arguments are POPped.
8-4 Execution Control and Interrupt Support Functions Example >1 >10 >20 REM EXAMPLE PROGRAM REM ENABLE PROCESSOR INTERRUPTS PUSH 1000 : REM LINE NUMBER OF START OF PROCESSOR INTERRUPT ROUTINE >30 CALL 20 >1000 (BEGINNING OF THE PROCESSOR INTERRUPT ROUTINE) : >1050 RETI CALL 21 – Disable Processor Interrupt Purpose Use CALL 21 to disable the processor interrupt capability enabled with CALL 20. This routine has no input or output arguments.
Execution Control and Interrupt Support Functions 8-5 The POP shows the status of the SLC processor: • 0 - SLC processor acknowledges the interrupt but may not have executed the interrupt routine yet • 1 - SLC processor aborted the interrupt • 2 - SLC processor is not in Run mode • 3 - SLC 500 fixed and SLC 5/01 processor cannot support interrupts Syntax CALL 26 POP[ SLC processor status] Example >1 >10 THE >20 >30 CALL 38 – Expanded ONERR Restart REM EXAMPLE PROGRAM REM ENABLE MODULE INTERRUPT TO TH
8-6 Execution Control and Interrupt Support Functions If you perform an XBY in the error routine, this is a list of the status codes you might receive. Table 8.
Execution Control and Interrupt Support Functions 8-7 Syntax PUSH [0 or 1] CALL 38 Example >1 REM EXAMPLE PROGRAM >10 REM ENABLE EXPANDED ONERR FUNCTION >20 ONERR 160 >30 PUSH 1 >40 CALL 38 >50 CALL 53: REM GET DATA FROM OUTPUT IMAGE >60 PUSH 201: REM ADDRESS OF SECOND WORD IN BUFFER >70 CALL 14: REM GET DATA FROM INPUT BUFFER >80 POP X: REM VALUE FROM INPUT BUFFER >90 A=(X*2.499733)-8191.
8-8 Execution Control and Interrupt Support Functions CALL 70 – ROM to RAM Program Transfer Purpose Use CALL 70 to shift program execution from a running ROM program to the beginning of the RAM program. No arguments are PUSHed or POPped. IMPORTANT The first line of the RAM program is not executed. We recommend that you make it a remark.
Execution Control and Interrupt Support Functions CALL 71 – ROM/RAM to ROM Program Transfer 8-9 Purpose Use CALL 71 to transfer from a running ROM or RAM program to the beginning of any available ROM program. One argument is PUSHed (which ROM program). None are POPped. An invalid program error displays and you enter the Command mode if the ROM number does not exist. IMPORTANT The first line of the ROM program is not executed. We recommend that you make it a remark.
8-10 Execution Control and Interrupt Support Functions Syntax CALL 72 Example Program in ROM 1 >1 >10 >20 >30 >40 >50 >60 REM EXAMPLE PROGRAM REM SAMPLE PROG FOR CALL 72 PRINT “NOW EXECUTING ROM 1” PUSH 3 CALL 71 : REM EXECUTE ROM 3 THEN RETURN PRINT “EXECUTING ROM 1 AGAIN” END Program in ROM 3 >1 >10 >20 >30 REM EXAMPLE PROGRAM PRINT “NOW EXECUTING ROM 3” CALL 72 END With ROM 1 selected: >RUN NOW EXECUTING ROM 1 NOW EXECUTING ROM 3 EXECUTING ROM 1 AGAIN READY > Publication 1746-RM001A-US-P
Execution Control and Interrupt Support Functions GOSUB 8-11 Purpose Use the GOSUB statement to cause the module to transfer control of the program to the line number [ln num] following the GOSUB statement. In addition, the GOSUB statement saves the location of the statement following GOSUB on the control stack so that you can perform a RETURN statement to return control to the statement following the most recently executed GOSUB statement. You may nest the GOSUB statement up to 9 times.
8-12 Execution Control and Interrupt Support Functions >20 >30 >40 >100 >105 >110 >120 >200 >210 220 GOSUB 100 NEXT I END REM USER SUBROUTINE HERE PRINT I, GOSUB 200 RETURN REM START OF NESTED SUBROUTINE PRINT I*I RETURN READY >RUN 1 2 3 1 4 9 READY > ONERR Purpose Use the ONERR statement to handle arithmetic errors, if they occur, during program execution. Only arithmetic overflow, arithmetic underflow, divide by zero, and bad argument errors are trapped by the ONERR statement.
Execution Control and Interrupt Support Functions 8-13 Example >1 >10 >20 >30 >40 >50 >500 >510 REM EXAMPLE PROGRAM ONERR 500 FOR I = 5 TO 0 STEP -1 PRINT 1/I NEXT I END PRINT “ERROR CODE WAS ”,XBY(257) END READY >RUN .2 .25 .33333333 .5 1 ERROR CODE WAS 10 READY > A GOTO statement can replace the END statement in this example to provide a method of user programmed error recovery.
8-14 Execution Control and Interrupt Support Functions ON-GOSUB Purpose Use the ON-GOSUB statement to transfer control to the line(s) specified by the GOSUB statement when the value of the expression following the ON statement is encountered in the BASIC program. Syntax: ON [expr] GOSUB [ln num], [ln num],...[ln num] Example >1 REM EXAMPLE PROGRAM >10 ON Q GOSUB 100,200,300 If Q is equal to 0, control is transferred to line number 100. If Q is equal to 1, control is transferred to line number 200.
Execution Control and Interrupt Support Functions 8-15 Example >1 >10 >15 >20 >30 >40 >50 >60 >70 >100 >110 >120 REM EXAMPLE PROGRAM TIME = 0 DBY(71) = 0 CLOCK1 ONTIME 2,100 DO WHILE TIME < 10 CLOCK0 END PRINT “TIMER INTERRUPT AT - ”,TIME, “ SECONDS” ONTIME TIME+2,100 RETI READY >RUN TIMER TIMER TIMER TIMER TIMER INTERRUPT INTERRUPT INTERRUPT INTERRUPT INTERRUPT AT AT AT AT AT - 2.01 SECONDS 4.005 SECONDS 6.015 SECONDS 8.01 SECONDS 10.01 SECONDS In the example above, the time printed out is .
8-16 Execution Control and Interrupt Support Functions You can push more than one expression onto the argument stack using a single PUSH statement with multiple expressions ([expr], [expr],.[expr]). Each expression must be followed by a comma. The last value PUSHed onto the argument stack is the last expression [expr] encountered in the push statement. IMPORTANT The argument stack can hold up to 33 floating-point numbers before overflowing. Syntax PUSH [expr], [expr],.
Execution Control and Interrupt Support Functions POP 8-17 Purpose Use the POP statement to remove values from the module argument stack. The value at the top of the argument stack is assigned to the variable following the POP statement and the argument stack is POPped (example: incremented by 6). You can place values in the stack using the PUSH statement. IMPORTANT If a POP statement executes and no number is in the argument stack, an A-Stack error occurs and the module enters Command mode.
8-18 Execution Control and Interrupt Support Functions RETI Purpose Use the RETI statement to exit from an interrupt (ONTIME, CALL 16, or CALL 20) that is processed in a 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.
Execution Control and Interrupt Support Functions 8-19 Examples Simple Subroutine >1 >10 >20 >30 >40 >100 >110 REM EXAMPLE PROGRAM FOR I = 1 TO 5 GOSUB 100 NEXT I END PRINT I RETURN READY >RUN 1 2 3 4 5 READY > Nested Subroutine >1 >10 >20 >30 >40 >100 >110 >120 >200 >210 >220 >300 >310 REM EXAMPLE PROGRAM FOR I = 1 TO 5 GOSUB 100 NEXT I END PRINT I, GOSUB 200 RETURN PRINT I*I, GOSUB 300 RETURN PRINT I*I*I RETURN READY >RUN 1 2 3 4 5 1 1 4 8 9 27 16 64 25 125 READY > Publication 1746-RM001A-US-P
8-20 Execution Control and Interrupt Support Functions STOP Purpose Use the STOP statement to break program execution at specific points in a program. After a program is STOPped you can display or modify variables. You can resume program execution with a CONTinue command. The purpose of the STOP statement is to allow for easy program debugging.
Chapter 9 Math and Backplane Conversion Functions This chapter describes and illustrates commands that convert numbers between integer and BASIC floating-point. This chapter also describes and illustrates commands that transfer data from the BASIC or BASIC-T module output buffer to the processor input image or transfers data from the output image to the module input buffer. These commands can be used within the BASIC program or from the command line. Table 9.1 lists the corresponding mnemonics. Table 9.
9-2 Math and Backplane Conversion Functions CALL 15 – 16-Bit Unsigned Integer to BASIC Floating-Point Purpose Use CALL 15 to convert an SLC 500 controller 16-bit unsigned integer number to a module floating-point number. The input argument is the address number (0 to 207) of the word in the module input buffer to be converted. The output argument is the converted value.
Math and Backplane Conversion Functions 9-3 Syntax PUSH [value to be converted] PUSH [word number of module output buffer] CALL 24 Example >1 >10 >40 >50 >60 REM EXAMPLE PROGRAM W = 17 PUSH W : REM THE VALUE TO BE CONVERTED PUSH 0 : REM 1ST WORD OF BASIC OUTPUT BUFFER CALL 24 : REM DO THE F.P. TO 16-BIT SIGNED CONVERSION READY > CALL 25 – BASIC Floating-Point to 16-Bit Binary Purpose Use CALL 25 to convert a module floating-point value between 0 and 65535 to its 16-bit binary representation.
9-4 Math and Backplane Conversion Functions Example >1 >40 >50 >60 > REM EXAMPLE PROGRAM PUSH 9E+1 : REM THE VALUE TO BE CONVERTED PUSH 0 : REM 1ST WORD OF BASIC OUTPUT BUFFER CALL 25 : REM DO F.P. TO 16-BIT BINARY CONVERSION READY > CALL 88: BASIC Floating-Point to SLC Floating-Point Purpose This CALL may only be used with a SLC™ 5/03, 5/04 or 5/05 processor. These are the only SLC processors that support the floating-point data type.
Math and Backplane Conversion Functions 9-5 Syntax This routine has two input arguments and no output arguments. The first input argument is the floating-point value you want to convert. The second input argument is the first word in the module’s output buffer. The output buffer addresses are 100-163 for the M1 file and 200-207 for the Input Image.
9-6 Math and Backplane Conversion Functions SLC floating-point numbers are stored in two 16-bit words. IMPORTANT Due to the fact that the SLC floating-point number is a 7-digit floating-point number, and the module is an 8-digit floating-point number, some round-off error may be introduced during number conversions. Syntax This routine has one input and one output argument. The input argument is the address of the module’s input buffer containing the value to be converted.
Chapter 10 Clock/Calendar Functions This chapter describes and illustrates commands that set and display the real time clock/calendar within the BASIC program or from the command line. Table 10.1 lists the corresponding mnemonics. Table 10.1 Chapter Reference Guide If you need (to) CALL 40 – Set Clock/ Calendar Time Use this mnemonic Page Set the clock/calendar time (hour, minute, second). CALL 40 10-1 Set the clock/calendar date (day, month, year).
10-2 Clock/Calendar Functions Example Program the wall clock for 1:35 P.M. (programmed as 13:35; only a 24-hour clock is available) >1 >10 >20 >30 >40 REM EXAMPLE PROGRAM H = 13 : M = 35 : S = 00 REM HOURS = 13, MINUTES = 35, SECONDS = 00 PUSH H,M,S CALL 40 READY >RUN READY > CALL 41 – Set Clock/ Calendar Date Purpose Use CALL 41 to set the following clock/calendar functions: • D - day • M - month • Y - year Three values are PUSHed and none are POPped.
Clock/Calendar Functions 10-3 Example Program the clock/calendar for the 16th day of June 1991. >1 >5 >10 >20 >30 >40 >60 >70 >80 >90 >100 >120 >130 >140 REM EXAMPLE PROGRAM STRING 100,20 H=13 : M=35 : S=00 REM HOURS = 13, MINUTES = 35, SECONDS = 00 PUSH H,M,S CALL 40 D=16 : MO=6 : Y=91 PUSH D,MO,Y CALL 41 PUSH 3 CALL 42 PUSH 0 CALL 43 PRINT $(0) READY >RUN 16-JUN-91 13:35:00 CALL 42 – Set Day of Week Purpose Use CALL 42 to set the day of the week. Sunday is day 1. Saturday is day 7.
10-4 Clock/Calendar Functions CALL 43 – Retrieve Date/ Purpose Time String Use CALL 43 to return 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.
Clock/Calendar Functions 10-5 Example >1 >10 >20 >30 >40 >50 REM EXAMPLE PROGRAM REM DATE RETRIEVE - NUMERIC EXAMPLE CALL 44 : REM INVOKE THE UTILITY ROUTINE POP D,M,Y : REM GET THE DATA FROM THE ARGUMENT STACK PRINT “CURRENT DATE IS ”,Y,M,D END READY >RUN CURRENT DATE IS 91 6 19 READY > CALL 45 – Retrieve Time Purpose String Use CALL 45 to return the current time in a string (HH:MM:SS). PUSH the number of the string to receive the time. You must allocate a minimum of 8 characters for the string.
10-6 Clock/Calendar Functions CALL 46 – Retrieve Time Purpose Numeric Use CALL 46 to return the time of day in numeric form. Retrieve the time of day in numeric form by executing CALL 46 and POPping the three variables off of the argument stack on return. There are no input arguments. The time is POPped in hour, minute, and second order.
Clock/Calendar Functions 10-7 >20 PUSH 0 :CALL 47 >30 PRINT “TODAY IS ”,$(0) READY >RUN TODAY IS FRI READY > CALL 48 – Retrieve Day of Week Numeric Purpose Use CALL 48 to return the current day of week on the argument stack as a number (example: Sunday=1, Saturday=7). This number can be POPped into a variable. Syntax CALL 48 POP [day of week] Example >1 >10 >20 >30 >40 >50 REM EXAMPLE PROGRAM REM DAY OF WEEK RETRIEVE - NUMERIC EXAMPLE CALL 48 : REM INVOKE UTILITY TO GET D.O.W.
10-8 Clock/Calendar Functions Syntax PUSH [string number] CALL 52 Example >1 >10 >20 >30 >40 REM EXAMPLE PROGRAM STRING 100,20 PUSH 1 : CALL 52 : REM PUT DATE IN STRING 1 PRINT $(1) END READY >RUN 16-JUN-91 READY > Publication 1746-RM001A-US-P
Chapter 11 Status Functions This chapter describes and illustrates commands that monitor the status of the BASIC or BASIC-T module. This chapter also describes and illustrates commands that allow the setup of the DF1 driver within the BASIC program or from the command line. Table 11.1 lists the corresponding mnemonics. Table 11.1 Chapter Reference Guide 1 If you need to Use this mnemonic Page Get the number of characters in PRT2 buffers. CALL 36 11-2 Check the CPU output image buffer.
11-2 Status Functions CALL 36 – Get Number of Purpose Characters in PRT2 Use CALL 36 to retrieve the number of characters in the chosen buffer of port Buffers PRT2. You must PUSH the buffer that you want examined: PUSH 1 for the input buffer PUSH 0 for the output buffer One POP is required to get the number of characters.
Status Functions CALL 51 – Check CPU Output Image Buffer 11-3 Purpose Use CALL 51 to determine if the SLC 500 controller output image buffer located in the module has been updated since the last time it was checked. (In this case, update means that the data was written to these buffers from the CPU, even if the data is the same value.) This routine has no input arguments and one output argument.
11-4 Status Functions CALL 55 – Check CPU Input Image Buffer Purpose Use CALL 55 to determine if the SLC 500 controller input image buffer located in the module has been read by the Logic Processor since the last time it was checked. This routine has no input arguments and one output argument.
Status Functions 11-5 CALL 58 – Check M0 File Purpose Use CALL 58 to determine if the Module File M0 located in the module has been updated since the last time it was checked. (In this case, update means that the data was written to these buffers from the CPU, even if the data is the same value.) This routine has no input argument and one output argument.
11-6 Status Functions CALL 59 – Check M1 File Purpose Use CALL 59 to determine if the Module File M1 located in the module has been read by the Logic Processor since the last time it was checked. This routine has no input arguments and one output argument.
Status Functions 11-7 CALL 75 – Check SLC 500 Purpose Controller CPU Status Use CALL 75 to check the mode (Run/Program/Test) of the SLC processor. No PUSHes are required. One POP is required.
11-8 Status Functions CALL 80 – Check Battery Purpose Condition Use CALL 80 to check the module battery condition. If a 0 is POPped after a CALL 80, the battery is okay. If a 1 is POPped a low battery condition exists.
Status Functions 11-9 >110 POP X : REM GET THE STATUS >120 IF(X<>1) THEN GOTO 100 : REM WAIT ON THE DATA READY > CALL 87 – Check DH485 Interface File Remote Read Status Purpose Use CALL 87 to determine if the DH485 Common Interface File located in the module has been read by a device on the DH485 Serial Communications Link since the last time it was checked. This routine has no input arguments and one output argument.
11-10 Status Functions CALL 95 – Get Number of Purpose Characters in PRT1 Use CALL 95 to retrieve the number of characters in the chosen buffer of port Buffers PRT1. You must PUSH which buffer you want examined: • PUSH 1 for the input buffer • PUSH 0 for the output buffer One POP is required to get the number of characters.
Status Functions CALL 97 – Enable Port PRT2 DTR Signal 11-11 Purpose Use CALL 97 to enable the Data Terminal Ready (DTR) signal from port PRT2. The DTR signal on PTR2 is enabled by default on powerup. This CALL re-enables the DTR signal if it has been disabled by CALL 98. Syntax CALL 97 Example >10 REM EXAMPLE PROGRAM >20 CALL 97 : REM ENABLE DTR SIGNAL READY > CALL 98 – Disable Port PRT2 DTR Signal Purpose Use CALL 98 to disable the Data Terminal Ready (DTR) signal from port PRT2.
11-12 Status Functions CALL 108 – Enable DF1 Driver Communications Purpose Use CALL 108 to enable DF1 driver communications via port PRT2. IMPORTANT DF1 can only be enabled if jumper JW4 on the module is in the correct position. Refer to the SLC 500™ BASIC and BASIC-T Modules User Manual (publication number 1746-UM004A-US-P) for additional information. This routine has six input arguments and no output arguments.
Status Functions 11-13 IMPORTANT Other port parameters, such as baud rate, number of stop bits, and parity are selected using the MODE command before DF1 is enabled. The modem handshaking selection made here overrides the handshaking parameter of the MODE command until DF1 is disabled. Table 11.
11-14 Status Functions Half-Duplex No Handshaking Modem Control Half-duplex no handshaking modem control, selected by operational codes 0 through 3, has the following characteristics: • The RTS output line is activated during transmission, but no RTS On Delay or RTS Off Delay is performed. • The DTR output line is not manipulated by the DF1 driver.
Status Functions 11-15 Half-Duplex With Continuous Carrier Modem Control Half-duplex with continuous carrier modem control, selected by operational codes 8 through 11, has the following characteristics: IMPORTANT For proper operation, the Data Carrier Detect (DCD) line from the modem must be connected to the DSR input of port PRT2. • The RTS output line is activated only during transmissions.
11-16 Status Functions Full-Duplex With No Handshaking Full-duplex with no handshaking, selected by operation codes 16 through 23, has the following characteristics: • The RTS output line is activated when the DF1 Driver is enabled and remains so until the DF1 Driver is disabled. • The DTR output line is not manipulated by the DF1 Driver. It is recommended that the user activate DTR in his/her BASIC program while the DF1 communications is taking place.
Status Functions 11-17 The second input argument specifies the Poll Time-out period when in half-duplex mode or the ACKnowledge Time-out period when in full-duplex mode. Poll Timeout specifies in 5 ms increments how long to wait before being polled by the DF1 master, before a transmission request is ignored. PUSHing 0 indicates no Poll Time-out period. ACKnowledge Timeout specifies in 5 ms increments how long to wait for an ACK/NAK before transmitting an ENQuiry.
11-18 Status Functions Syntax PUSH [operational code] PUSH [Poll timeout or ACKnowledge timeout] PUSH [message retries or ENQuiry retries] PUSH [RTS On delay or NAK received retries] PUSH [RTS Off delay or NULL value] PUSH [module DF1 address] CALL 108 Example >1 >10 >20 >30 >40 >50 >60 >70 >80 CALL 113 – Disable DF1 Driver Communications REM EXAMPLE PROGRAM PUSH 5 : REM HDMWOCC, ENABLE DPD, BCC ERROR CHECKING PUSH 200 : REM WAIT 1 SECOND TO BE POLLED BY MASTER PUSH 2 : REM PERFORM 2 RETRIES PUSH 4 : R
Status Functions 11-19 that corresponds to the module input and output buffers, as shown in the table below: Table 11.
11-20 Status Functions Syntax CALL 121 POP [program ID number] Example >1 >10 >20 >30 Publication 1746-RM001A-US-P REM EXAMPLE PROGRAM CALL 121 POP X : REM GET SLC PROCESSOR PROGRAM ID END
Chapter 12 Output Functions This chapter describes and illustrates commands that allow the transfer of data from the BASIC or BASIC-T module to external ports PRT1, PRT2, and DH485 within the BASIC program or from the command line. Table 12.1 lists the corresponding mnemonics. Table 12.1 Chapter Reference Guide 1 If you need (to) Use this mnemonic Page Transfer data from the SLC I/O or M files to PRT1 or PRT2. CALL 23 12-2 Transfer data from the SLC processor to a remote DH485 data file.
12-2 Output Functions Table 12.1 Chapter Reference Guide If you need (to) Use this mnemonic Page Print numeric values in decimal notation. PRINT USING(#.#) 12-36 Restore the default print mode. PRINT USING(0) 12-37 Store variable. ST@ 12-38 CALL 23 – Transfer Data Purpose from the CPU Files to Use CALL 23 to transfer data from the CPU output data file or the CPU M0 file Port 1 or 2 directly to the module serial port and/or to a string within the module.
Output Functions 12-3 2. The ladder logic program of the SLC processor must set the output file word 0, bit 6 or bit 7 to inform the module that valid data is available. Bit 6 indicates that data is available for port 1 and bit 7 indicates that data is available for port 2. PORT PRT1 Output File Word 0, Bit 6 or Bit 7 PORT PRT2 SLC Processor SLC Backplane BASIC or BASIC-T Module 3. The module automatically transfers the data to the destination serial port (PRT1 or PRT2) from the SLC processor.
12-4 Output Functions Transfers continue in this manner until the CALL for the port is re-executed with different input parameters. If this occurs, the previous CALL 23 for the port is automatically disabled and the new CALL 23 takes effect. Multiple CALL 23s for the same port are not executed in parallel. However, port 1 and port 2 can be activated simultaneously by issuing separate CALL 23s for these ports. This CALL has five input arguments and one output argument.
Output Functions 12-5 The fifth input argument is the byte swap selection. It has the following values: • 0 - Data bytes transferred from the CPU are not swapped when passed to the module port or string. The data transfer order is low byte first, then high byte per word. The low byte of the first word in the source buffer contains the byte count. • 1 - Data bytes transferred from the CPU are swapped when passed to the module port or string.
12-6 Output Functions Example >1 >10 >20 >30 >40 >50 >60 >70 >80 >90 REM EXAMPLE PROGRAM REM ENABLE CALL 23 INTERRUPTS PUSH 2 : REM SEND DATA TO PRT1 PUSH 1 : REM GET DATA FROM M0 FILE PUSH 0 : REM WORD OFFSET INTO M0 FILE PUSH 0 : REM STRING NUMBER/NOT USED HERE PUSH 1 : REM ENABLE BYTE SWAPPING CALL 23 POP S : REM STATUS OF CALL SETUP IF (S<>0) THEN PRINT “UNSUCCESSFUL CALL 23 SETUP” Below is a sample ladder logic program for CALL 23. The module is located in slot 1 of the SLC chassis.
Output Functions 12-7 If an internal string is chosen, the first character (transaction number) is incremented on successful completion of the write to inform the module that data was sent. The value of the transaction number wraps around from 255 to 0. Execute CALL 28 once to set up the data transfer parameters. Input and output image bits (word 0, bit 11) for the slot containing the module, are used to initiate and notify completion of the transfer. The operation is described below: 1.
12-8 Output Functions Input File Word 0, Bit 11 SLC Processor SLC Backplane BASIC or BASIC-T Module 6. The SLC retrieves the status and resets output file word 0, bit 11. The data buffer can be reused by the SLC. Reset Output File Word 0, Bit 11 SLC Processor SLC Backplane BASIC or BASIC-T Module 7. The module resets the input file word 0, bit 11 on the same end of scan cycle in which the output file word 0, bit 11 was reset.
Output Functions 12-9 If the file type is not one of these listed below, the status equals 2 and the write message does not take place. Enter the file type code as shown: Table 12.
12-10 Output Functions offset should not be 0 since this word is reserved for the data transfer handshaking bits. The offset for the internal string is always 1. The string character (transaction number) at location 0 is incremented upon every data transfer. The tenth input argument is the string number. If the eighth input argument does not select internal string usage, the value of this input argument is ignored but must still be PUSHed. The output argument is the validation of the CALL parameters.
Output Functions 12-11 Syntax PUSH [type of WRITE command] PUSH [remote node address] PUSH [remote file number] PUSH [remote file type] PUSH [remote starting word offset] PUSH [number of words to be transferred] PUSH [message time-out value] PUSH [selection of source file] PUSH [word offset within source file] PUSH [string number] CALL 28 POP [CALL 28 status] Example >1 >10 REM EXAMPLE PROGRAM REM ENABLE INTERRUPTS FOR READ COMMANDS TO A REMOTE DH485 NODE >20 PUSH 2 : REM SLC TYPED WRITE >30 PUSH 1 : RE
12-12 Output Functions Input P.B. to initiate CALL 28. I:2 O:1 0000 0 11 COP Copy File Source Dest Length B3:0 OSR 0 #N7:0 #M0:1.0 20 CALL 28 Request Bit O:1 L 11 Buffer Status Byte if Non-zero I:1 0001 11 NEQ Not Equal Source A Handshake Bit from Module Source B I:1.1 0 0 MOV Move Source Dest I:1.1 0 N7:20 0 Command Failed Indication O:3 L 0 O:3 U 1 Command Success Indication EQU Equal Source A Source B O:3 L I:1.
Output Functions 12-13 CALL 29 – Read/Write to Purpose a PLC/SLC from the Use CALL 29, in conjunction with CALLs 122 or 123, to communicate between Module Internal String remote PLCs and the module internal string without local SLC processor interaction. You can also use CALL 29, in conjunction with CALLs 27 or 28, to communicate between remote SLCs and the module internal string without local SLC processor interaction. CALLs 27, 28, 122, or 123 must be executed within the BASIC program before CALL 29.
12-14 Output Functions Example CALL 122 must be enabled with internal string only prior to executing CALL 29 in this example. Upon execution of CALL 29, an attempt is made to transfer one element from integer file 10, starting at element 0 of the PLC-5® at node 3, to the internal string $(1) of the module.
Output Functions CALL 37 – Clear PRT2 Input/Output Buffers 12-15 Purpose Use CALL 37 to clear the peripheral port input and/or output buffers. Use the following PUSHes to clear the corresponding buffer: • PUSH 0 to clear the output buffer. • PUSH 1 to clear the input buffer. • PUSH 2 to clear both buffers.
12-16 Output Functions Bit 13 of word 200 is the battery status bit. It can have one of the following values: • 0 - Battery is good • 1 - Battery is low Word integrity is guaranteed during this transfer. File integrity is not. Handshaking bits can be used in your application program to provide file integrity.
Output Functions 12-17 Syntax PUSH [number of words to be transferred] CALL 57 POP [processor mode] Example >1 >50 >60 >70 >80 REM EXAMPLE PROGRAM PUSH 64 : REM TRANSFER LENGTH IS 64 WORDS CALL 57 : REM TRANSFER BASIC OUTPUT BUFFER TO M1 POP X : REM LOGIC PROCESSOR STATUS IS IN X PRINT X READY >RUN 0 READY > CALL 85 – Transfer BASIC Output Buffer to DH485 Common Interface File Purpose Use CALL 85 to transfer up to 40 words to the DH485 Common Interface File.
12-18 Output Functions Example >1 >40 >50 >60 REM EXAMPLE PROGRAM PUSH 31 : REM OFFSET ADDRESS = 31 PUSH 3 : REM WORD LENGTH = 3 CALL 85 : REM TRANSFER DATA TO DH485 COMMON INTERFACE FILE >70 POP R >80 IF R<>0 PRINT “TRANSFER ERROR CODE = ”,R : REM PRINT ERROR READY >RUN READY > CALL 91 – Write BASIC Purpose Output Buffer to Remote Use CALL 91 to write up to 40 words starting at word 0 of the module output DH485 Data File buffer to the remote DH485 data file at the designated node address, file number,
Output Functions 12-19 IMPORTANT The offset will be twice of what is expected. For example, if an offset of 3 was PUSHed, the data will be written to the remote DH485 data file beginning at element 6. The fifth input argument is the number of elements to be transferred. If the number is not within the range specified below, then the output argument equals 13, and the transfer does not take place. Table 12.
12-20 Output Functions Table 12.6 Output Argument Decimal Output Hexadecimal Output Description 0 00 Successful Completion. 2 02 Target node cannot accept the message at this time. 3 03 Target node cannot respond because message is too large. 4 04 Target node cannot respond because it does not understand the command parameters. 5 05 module is off-line (not on link). 6 06 Target node cannot respond because requested function is not available. 7 07 Target node does not respond.
Output Functions 12-21 Syntax PUSH [remote device node address] PUSH [remote device file number] PUSH [remote device file type] PUSH [starting element offset (x2) of remote device file] PUSH [number of elements to be transferred] PUSH [message time-out value] CALL 91 POP [status of message instruction] Example >1 >10 >20 >30 >40 >50 >60 >70 >80 >90 REM EXAMPLE PROGRAM PUSH 1 : REM REMOTE NODE ADDRESS = 1 PUSH 7 : REM REMOTE FILE 7 PUSH ASC(N) : REM FILE TYPE = INTEGER PUSH 0 : REM OFFSET = 0 PUSH 10: RE
12-22 Output Functions CALL 93 – Write Output Purpose Buffer to Remote DH485 Use CALL 93 to write up to 40 words starting at word 0 of the module output Common Interface File buffer to the remote DH485 Common Interface File at the designated node address, starting at the designated word offset. This routine has four input arguments and one output argument. The first input argument is the node address of the remote device (0 to 31).
Output Functions 12-23 Table 12.7 Output Argument Decimal Output Hexadecimal Output Description 0 00 Successful Completion. 2 02 Target node cannot accept the message at this time. 3 03 Target node cannot respond because message is too large. 4 04 Target node cannot respond because it does not understand the command parameters. 5 05 module is off-line (not on link). 6 06 Target node cannot respond because requested function is not available. 7 07 Target node does not respond.
12-24 Output Functions Example >1 >30 >40 >50 >60 >70 >80 >90 REM EXAMPLE PROGRAM PUSH 1 : REM REMOTE NODE ADDRESS = 1 PUSH 0 : REM OFFSET = 0 PUSH 10 : REM WORDLENGTH = 10 PUSH 5 : REM THE TIME-OUT VALUE = 0.
Output Functions 12-25 IMPORTANT If port PRT1 is configured for DH485 protocol, this CALL has no effect. Syntax PUSH [buffer selection] CALL 96 Example >1 REM EXAMPLE PROGRAM >10 PUSH 0 : CALL 96 : REM CLEAR PRT1 OUTPUT BUFFER READY > CALL 112 – User LED Control Purpose Use CALL 112 to activate or de-activate the user LEDs (LED1 and LED2). Two inputs arguments are required and no output arguments. The first input argument activates or de-activates LED1.
12-26 Output Functions Example >1 >100 >110 >120 REM EXAMPLE PROGRAM PUSH 1 : REM TURN ON LED1 PUSH 0 : REM TURN OFF LED2 CALL 112 : REM SET THE LEDS READY >RUN READY > CALL 114 – Transmit DF1 Purpose Packet Use CALL 114 to transmit the DF1 data packet. This routine has no input arguments and no output arguments. When CALL 114 is performed, the DF1 data is posted for the DF1 driver to transmit as a single message packet.
Output Functions 12-27 Example >1 REM EXAMPLE PROGRAM >10 CALL 114 >20 END CALL 115 – Check DF1 XMIT Status Purpose Use CALL 115 to check the DF1 transmit status. This routine has no input arguments and one output argument. The output argument returns a value that represents the DF1 transmit status.
12-28 Output Functions CALL 123 – Write to Remote DF1 PLC Data File Purpose Use CALL 123 to write up to 64 words of data from the CPU output image file, the CPU M0 file, and/or a string within the module to a remote DF1 node (PLC-2®, -3®, or -5). The following table lists specific notes when using CALL 123 with the PLC-3 and PLC-5. Table 12.8 PLC Application Notes PLC Notes -3 For timers and counters, the file number PUSHed (third parameter) is the structure number, limited to a maximum of 255 words.
Output Functions 12-29 3. The module places the status of the transaction in input file word 1, bits 0-7. Input File Word 1 Bits 0 through 7 SLC Processor SLC Backplane BASIC or BASIC-T Module 4. The module sets the input file word 0, bit 11 to inform the SLC processor that the data was transmitted, and that the status of the transfer is valid. Input File Word 0, Bit 11 SLC Processor SLC Backplane BASIC or BASIC-T Module 5. The SLC retrieves the status and resets output file word 0, bit 11.
12-30 Output Functions The second input argument is the decimal node address of the PLC remote device (0 through 254). If the number is not within this range, the status equals 2 and the write message does not occur. The third input argument is the file number to be written to on the PLC remote device (0 through 255). If the number is not within this range, the status equals 2 and the write message does not occur.
Output Functions 12-31 The seventh input argument is the message time-out value. This value (1 through 255) corresponds to the number of hundreds of milliseconds that are allowed to receive the write response (0.1 through 25.5 seconds). If the write response is not received within this time, the message aborts with the status equal to 55 in the input file word 1, bits 0-7. If the time-out value is not within the range (1 through 255), the POPped status equals 2 and the transfer does not take place.
12-32 Output Functions Table 12.11 Transaction Status Codes Code Indicates 0 Transfer OK. 1 Transmission failed. 2 Enquiry timeout. 3 With handshaking selected – either a loss of CTS signal while transmitting or a fatal transmitter failure occurred. 4 Transmission failure due to modem disconnection (DCD signal loss for more than 10 seconds) if modem handshaking with constant carrier is selected. 5 DF1 driver is not enabled. Without handshaking selected – a fatal transmitter failure occurred.
Output Functions 12-33 Table 12.11 Transaction Status Codes Code Indicates D3 Address reference exists to deleted area. D4 Command execution failure for unknown reason; PLC-3 histogram overflow. D5 Data conversion error. D6 The scanner is not able to communicate with a 1771 chassis adapter. D7 The adapter is not able to communicate with the module. D8 The 1771 module response was not valid. D9 Duplicated label. DA File is open - another station owns it.
12-34 Output Functions Example >1 >10 >20 >30 >40 >50 >60 >70 >80 >90 >100 >110 REM EXAMPLE PROGRAM REM ENABLE DF1 PLC REMOTE WRITE COMMAND PUSH 5 : REM PLC-5 FILE PUSH 0 : REM PLC-5 NODE ADDRESS PUSH 7 : REM PLC-5 FILE NUMBER PUSH ASC(N) : REM PLC-5 FILE TYPE PUSH 0 : REM STARTING WORD OFFSET FOR PLC-5 PUSH 20 : REM NUMBER OF WORDS TO TRANSFER PUSH 10 : REM COMMAND TIME-OUT VALUE (X100MS) PUSH 1 : REM USE M0 FILE PUSH 0 : REM OFFSET WITHIN M0 FILE PUSH 0 : REM STRING NUMBER - NOT APPLICABLE FOR THIS EXA
Output Functions PRINT 12-35 Purpose Use the PRINT statement to direct the module to output a value to the console device. You may print the value of expressions, strings, literal values, variables or text strings. You may combine the various forms in the print list by separating them with commas. If the list is terminated with a comma, the carriage return/line feed is suppressed. P. is a shorthand notation for PRINT. Values are printed next to one another with two intervening blanks.
12-36 Output Functions Use the PRINT CR expression to output a carriage return without a line feed. >1 REM EXAMPLE PROGRAM >10 PRINT “A”, CR, >20 PRINT “B” READY >RUN B READY > The A was printed and then overwritten by the B. Use the PRINT SPC( ) expression to output a specified number of spaces. >1 REM EXAMPLE PROGRAM >10 PRINT “A”, SPC(10), “B” READY >RUN A B Use the PRINT TAB( ) expression to output a specified number of tab characters.
Output Functions >1 >10 >20 >30 >40 12-37 REM EXAMPLE PROGRAM PRINT USING(###.##), PRINT 4.67890, 123.456 PRINT .0123, .234 PRINT 123.456, 2.1 READY >RUN 4.67 0.01 123.45 123.45 0.23 2.10 READY > Use the PRINT USING(0) expression to restore the default print mode if the mode was altered by the PRINT USING(Fx) expression, or by the PRINT USING(#.#) expression. PH0., PH1. Purpose Use the PH0. and PH1. statements to direct the module to output a hexadecimal value to the console device.
12-38 Output Functions Syntax PH0., PH1. Example >PH0.2*2 04H >PH1.2*2 0004H >PH0. 100 64H >PH0. 1000 3E8H >PH1. 1000 03E8H >PH1. 3E8 3.0 E+8 >PH0. PI 03H > ST@ Purpose Use the ST@ statement to store module floating point numbers to a specified address. The expression [expr] following the ST@ statement specifies the address where the number is stored in RAM. The ST@ statement takes the value on the top of the argument stack and stores it in RAM at the address location specified by [expr].
Output Functions 12-39 P. MTOP-10*6 24455 >PUSH 24455 : CALL 77 >P. MTOP 24455 >1 >5 >10 >20 >30 >40 >50 >60 >70 >80 >90 >100 >110 >120 REM EXAMPLE PROGRAM DIM A(10),B(10) REM *** ARRAY SAVE *** FOR I = 0 TO 9 A(I) = I+20 PUSH A(I) : REM PUT NUMBER ON STACK ST@ 5FFFH–I*6 NEXT I REM *** GET ARRAY *** FOR I = 0 TO 9 LD@ 5FFFH–I*6 POP B(I) : REM GET NUMBER FROM STACK PRINT B(I) NEXT I READY >RUN 20 21 22 23 24 25 26 27 28 29 READY >PUSH 5FFFH : CALL 77 >P.
12-40 Output Functions Publication 1746-RM001A-US-P
Chapter 13 Input Functions This chapter describes and illustrates commands that allow the BASIC or BASIC-T module to read input data from its external ports within the BASIC program or from the command line. Table 13.1 lists the corresponding mnemonics. Table 13.1 Chapter Reference Guide 1 If you need (to) Use this mnemonic Page Transfer data from PRT1 or PRT2 to the SLC I/O or M files. CALL 22 13-2 Transfer data from a remote DH485 data file to the SLC processor.
13-2 Input Functions CALL 22 – Transfer Data Purpose from Port 1 or 2 to the Use CALL 22 to transfer data from the module serial ports directly to the CPU CPU Files input data file, CPU M1 file and/or an internal string within the module. During data transfer, data is automatically transferred in 8-bit blocks from the input buffer of the selected port to the selected SLC processor buffer and/or BASIC internal string for storage.
Input Functions 13-3 2. The module places the byte count of the valid data into the lower byte of the first available word of the destination buffer. The upper byte of the first available word is not used. BYTE COUNT DATA SLC Processor Input Data file or M1 File SLC Backplane BASIC or BASIC-T Module 3. The module sets the input file word 0, bit 8 or bit 9 to inform the SLC processor that valid data is available.
13-4 Input Functions 6. The ladder logic program of the SLC resets output file word 0, bit 8 or bit 9. The module can begin loading the destination buffer with the next packet as data arrives from the port. PORT PRT1 Reset Output File Word 0, Bit 8 or Bit 9 SLC Processor PORT PRT1 SLC Backplane BASIC or BASIC-T Module Data transfers continue until the CALL for the port is re-executed with different input parameters.
Input Functions 13-5 The third input argument is the decimal value of the ASCII character delimiter. Any valid ASCII character can be chosen. If no delimiter is desired, enter a NULL value (0 decimal). The data will be transferred to the destination buffer when the delimiter is received from the selected port regardless of the number of characters received.
13-6 Input Functions The last CALL 22 or CALL 23 executed determines the byte swap option for all active CALL 22 commands previously executed. The output argument is the status of the CALL. It has the following values: • 0 - Successful setup • 1 - Disabled • 2 - Bad input parameter • 3 - PRT2 is chosen but it is already enabled for DF1 protocol. Transfer is not executed.
Input Functions 13-7 Example >1 >10 >20 >30 >40 REM EXAMPLE PROGRAM REM ENABLE CALL 22 INTERRUPTS PUSH 1 : REM PRT1 ACTIVE FOR CALL 22 PUSH 10 : REM RECEIVING 10 BYTES OF DATA MAXIMUM PUSH 13 : REM USED AS TERMINATION CHARACTER (13 DECIMAL) >50 PUSH 1 : REM SEND DATA TO M1 FILE >60 PUSH 0 : REM OFFSET INTO M1 FILE >70 PUSH 0 : REM STRING NUMBER - NOT USED >80 PUSH 1 : REM BYTE SWAPPING ENABLED >90 CALL 22 >100 POP S : REM STATUS OF CALL 22 SETUP >110 IF (S<>0) THEN PRINT “UNSUCCESSFUL CALL 22 SETUP”
13-8 Input Functions CALL 27 – Read Remote DH485 SLC Data File Purpose Use CALL 27 to read up to 64 words of data from a remote DH485 node data file to the local CPU input image file, the CPU M1 file, and/or a string within the module. If an internal string is chosen, the first character is incremented to inform the module that new data is in the string. The value of this character wraps around from 255 to 0. Execute CALL 27 once to set up the data transfer parameters.
Input Functions 13-9 4. The module places the status in the input file word 1, bits 0-7. Status Input File Word 1 Bits 7 through 10 SLC Processor SLC Backplane BASIC or BASIC-T Module 5. The module sets the input file word 0, bit 10 to inform the SLC processor that valid data is available. Input File Word 0, Bit 10 SLC Processor SLC Backplane BASIC or BASIC-T Module 6.
13-10 Input Functions The first input argument is the type of SLC READ command issued: • 0 - Disable the previously executed CALL 27 • 1 - Common Interface File Read • 2 - SLC Typed Read The second input argument is the node address of the SLC remote device (0 through 31). If the number is not within this range, the status equals 2 and the read message does not occur. The third input argument is the file number on the SLC remote device (0 through 255).
Input Functions 13-11 The seventh input argument is the message time-out value. This value (1 through 255) corresponds to the number of hundreds of milliseconds that are allowed to receive the read response (0.1 through 25.5 seconds). If the read response is not received within this time, the message aborts with the status equal to 55 in the input file word 1, bits 0 through 7. If the time-out value is not within the range (1 through 255), the POPped status equals 2 and the transfer does not take place.
13-12 Input Functions Whenever an attempt is made to read a remote packet, the status of the read is placed into input word 1, bits 0 through 7. These values have the same definition as the values POPped in CALL 92. The status becomes valid when the module sets the input file word 0, bit 10.
Input Functions T4:0 TON Timer On Delay Timer Time Base Preset Accum 0000 DN Initiate CALL 27 in the module every 10 seconds via timer T4:0. 13-13 EN T4:0 0.01 1000 0 DN CALL 27 Request Bit T4:0 O:1 0001 DN 10 I:1.0 Status OK EQU Equal Source A 0002 10 Source B Buffer Data if Status OK I:1.1 0 0 Bad Command Status NEQ Not Equal Source A Source B COP Copy File Source Dest Length I:1.1 0 0 O:1 L 10 #M1:1.0 #N10:20 21 Buffer Status Byte if Non-zero MOV Move Source Dest I:1.
13-14 Input Functions When CALL 29 is executed, the transfer is attempted. If the selected CALL (27, 28, 122, or 123) is not executed before CALL 29, a 1 is returned in the status POPped. When CALL 29 is executed successfully, the value in the first character of the string (transaction number) is incremented to designate that the transfer occurred. The range of this character is 0 through 255. After CALL 29 is executed, one word is POPped.
Input Functions CALL 35 – Get Numeric Input Character from PRT2 13-15 Purpose Use CALL 35 to retrieve the current character in the 256 character input buffer of port PRT2. It returns the decimal representation of the characters received as its output argument. Port PRT2 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 value of that character.
13-16 Input Functions Example 2 >1 >10 >20 >30 >40 >50 >55 >60 >70 >80 >90 >100 >120 >130 >140 >150 >155 >160 >170 >180 >185 >190 >200 >210 >215 >220 >230 >240 >250 >260 REM EXAMPLE PROGRAM REM PERIPHERAL PORT INPUT USING CALL 35 STRING 200,20 DIM D(254) CALL 35 : POP X IF X <>2 GOTO 40 REM WAIT FOR DEVICE TO SEND START OF TEXT REM DO I=I+1 CALL 35 : POP D(I): REM STORE DATA IN ARRAY UNTIL D(I)=3 : REM WAIT FOR DEVICE TO SEND END OF TEXT REM REM FORMAT AND PRINT DATA TYPES PRINT “RAW DATA=” FOR J=1 TO I
Input Functions CALL 53 – Transfer CPU Output Image to BASIC Input Buffer 13-17 Purpose Use CALL 53 to transfer words 0 to 7 of the CPU output image table to words 200 to 207 of the module input buffer. This routine has no input arguments and one output argument. The output argument is the status of the Logic Processor. It can have one of the following values: • 0 – Logic processor is in the Run mode • 1 – Logic processor is not in the Run mode Word integrity is guaranteed during this transfer.
13-18 Input Functions CALL 56 – Transfer CPU M0 File to BASIC Input Buffer Purpose Use CALL 56 to transfer up to 64 words starting at word 0 of the CPU M0 file to the module input buffer starting at word 100. This routine has one input argument and one output argument. The input argument is the number of words to be transferred (0 to 64). If the number is not within the range 0 to 64, no transfer occurs, and the output argument sets to 10.
Input Functions CALL 84 – Transfer DH485 Interface File to BASIC Input Buffer 13-19 Purpose Use CALL 84 to transfer up to 40 words starting at the designated offset of the DH485 Common Interface File to the module input buffer starting at the same designated offset from word 0. This routine has two input arguments and one output argument. The first input argument is the starting offset in the DH485 Common Interface File and the module input buffer (0 to 39).
13-20 Input Functions CALL 90 – Read Remote DH485 Data File to BASIC Input Buffer Purpose Use CALL 90 to read up to 40 words from the designated node address, file number, file type, and element offset of a remote DH485 data file to the module input buffer starting at word 0. This routine has six input arguments and one output argument. The first input argument is the node address of the remote device (0 to 31).
Input Functions 13-21 Table 13.6 Valid Length Range File Type Code Valid Length Range ASC(N) 1 to 40 ASC(S) 1 to 40 ASC(C) 1 to 13 ASC(T) 1 to 13 ASC(B) 1 to 40 ASC(R) 1 to 13 The sixth input argument is the message time-out value. This value is the number of hundreds of milliseconds that are allowed to receive the read response (1 to 50 0.1 to 5.0 seconds). If the read response is not received within this time, the message aborts with the output argument equal to 55.
13-22 Input Functions Table 13.7 Output Argument Decimal Output Hexadecimal Output Description 231 E7 Target node cannot respond because length requested is too large. 235 EB Target node cannot respond because target node denies access. 236 EC Target node cannot respond because requested function is currently unavailable. 241 F1 module detects illegal target file type. 250 FA Target node cannot respond because another node is file owner (has sole file access).
Input Functions CALL 92 – Read Remote DH485 Common Interface File to BASIC Input Buffer 13-23 Purpose Use CALL 92 to read up to 40 words from the remote DH485 Common Interface File of the designated node address, starting at the designated word offset to the module input buffer starting at word 0. This routine has four input arguments and one output argument. The first input argument is the node address of the remote device (0 to 31).
13-24 Input Functions Table 13.8 Output Argument Decimal Output Hexadecimal Output Description 0 00 Successful Completion. 2 02 Target node cannot accept the message at this time. 3 03 Target node cannot respond because message is too large. 4 04 Target node cannot respond because it does not understand the command parameters. 5 05 module is off-line (not on link). 6 06 Target node cannot respond because requested function is not available. 7 07 Target node does not respond.
Input Functions 13-25 Example >1 >30 >40 >50 >60 >70 >80 >90 REM EXAMPLE PROGRAM PUSH 1 : REM REMOTE NODE ADDRESS = 1 PUSH 0 : REM OFFSET = 0 PUSH 10 : REM WORD LENGTH = 10 PUSH 5 REM TIME-OUT VALUE = 0.5 SECONDS CALL 92 POP R : REM GET THE OUTPUT ARGUMENT IF (R<>0) THEN PRINT “READ ERROR CODE IS”,R : REM PRINT ERROR READY >RUN READ ERROR CODE IS 5 CALL 117 – Get DF1 Packet Length Purpose Use CALL 117 to get the length of the DF1 data packet.
13-26 Input Functions CALL 118 – PLC/SLC Unsolicited Writes Purpose Use CALL 118 to allow the module to receive data packets sent by PLC-2, PLC-3, or PLC-5 message instructions on the DF1 network. This CALL also sets up the module to receive data packets from an SLC node on the DH485 network. Both the DF1 port (PRT2) and the DH485 port cannot be active at the same time. Jumper JW4 on the module is used to select your port configuration.
Input Functions 13-27 3. The module places the byte count into the lower byte of the first available word of the destination buffer. BYTE COUNT DESTINATION BUFFER SLC Processor SLC Backplane BASIC or BASIC-T Module 4. The module sets the input file word 0, bit 12 to inform the SLC processor that valid data is available. Input File Word 0, Bit 12 SLC Processor SLC Backplane BASIC or BASIC-T Module 5.
13-28 Input Functions The SLC processor must not set, then reset, the output file word 0, bit 12 on the same ladder logic scan cycle. If this occurs, the module may miss the bit being set. This CALL is active until it is re-executed with different input parameters. If this occurs, the previous CALL 118 is automatically disabled and the new CALL 118 takes effect. Multiple CALL 118s are not executed in parallel. This CALL has five input arguments and one output argument.
Input Functions 13-29 If the DH485 port is used for data transfer, an offset of greater than 40 hex (64 decimal) words should not be used. Unsolicited write packets of greater than 64 causes a write to the DH485 program port buffer, leading to improper operation. The size of the data packet can be up to the maximum for the input file selected. If the CPU input image file is chosen as the destination, this offset must not be 0 or 1. Zero is a reserved word for the handshaking bits.
13-30 Input Functions Example >1 REM EXAMPLE PROGRAM >10 REM ENABLE PLC/SLC UNSOLICITED WRITE INTERRUPT >20 PUSH 1 : REM ENABLE THE CALL >30 PUSH 1 : REM DESTINATION SLC M1 FILE >40 PUSH 0 : REM WORD OFFSET INTO M1 FILE >50 PUSH 0 : REM STRING NUMBER - NOT USED >60 PUSH 20 : REM MAX ALLOWED WORD LENGTH OF DATA PACKET >70 CALL 118 >80 POP S >90 IF (S<>0) THEN PRINT “UNSUCCESSFUL CALL 118 SETUP” >100 GOTO 100 : REM CALL 118 stays active while BASIC program is running Below is a sample ladder logic program
Input Functions 13-31 If an internal string is chosen, the first character (transaction number) is incremented upon a successful read transaction to inform the module that new data is in the string. The value of the transaction number wraps around from 255 to 0. The DF1 port parameters must be set up with CALL 108. The DF1 port can operate with full-duplex or half-duplex slave protocol. Execute CALL 122 once to set up the data transfer parameters.
13-32 Input Functions 5. The module sets the input file word 0, bit 10 to inform the SLC processor that valid data and status are available. Input File Word 0, Bit 10 SLC Processor SLC Backplane BASIC or BASIC-T Module 6. The SLC retrieves the data and status from the buffer and resets output file word 0, bit 10 to inform the module that data was received. Reset Output File Word 0, Bit 10 SLC Processor SLC Backplane BASIC or BASIC-T Module 7.
Input Functions 13-33 The third input argument is the file number to be read on the PLC remote device (0 through 255). If the number is not within this range, the status equals 2 and the read message does not occur. The parameter is ignored if the common interface file is chosen in the first parameter, but must still be PUSHed. The fourth input argument is the file type to be read from the PLC remote device. Enter the file type code as shown below.
13-34 Input Functions The seventh input argument is the message time-out value. This value (1 through 255) corresponds to the number of hundreds of milliseconds that are allowed to receive the read response (0.1 through 25.5 seconds). If the read response is not received within this time, the message aborts with the status equal to 55 in the input file word 1, bits 0-7. If the time-out value is not within the range (1 through 255), the status POPped equals 2 and the transfer does not take place.
Input Functions 13-35 The output argument is the status of the CALL. It has the following values: • 0 – Successful • 1 – Disabled • 2 – Bad input parameter • 3 – DF1 not enabled • 4 – String too small • 5 – String is not dimensioned To disable this CALL, a zero must be PUSHed into the first input parameter. All other parameters are ignored but must still be PUSHed. Whenever an attempt is made to read a remote node, the status of the read is placed into the input word 1, bits 0-7.
13-36 Input Functions Table 13.12 Transaction Status Codes Publication 1746-RM001A-US-P Code Indicates C5 Illegal address format – symbol is 0 or greater than the maximum number of characters supported by this device. C6 Illegal address – address does not exist or does not point to something usable in this command. C7 Illegal size – file is wrong size; address is past end of file. C8 Cannot complete request. C9 Data or file is too large.
Input Functions 13-37 Syntax PUSH [type of PLC READ command] PUSH [remote PLC node address] PUSH [file number of remote PLC] PUSH [file type on remote PLC] PUSH [starting element offset on remote PLC] PUSH [number of elements to be transferred] PUSH [message time-out value] PUSH [selection of destination file] PUSH [word offset within destination file] PUSH [string number] CALL 122 POP [CALL 122 status] Example >1 REM EXAMPLE PROGRAM >10 REM ENABLE DF1 PLC REMOTE READ COMMAND >20 PUSH 5 : REM PLC-5 FILE
13-38 Input Functions T4:0 TON Timer On Delay Timer Time Base Preset Accum 0000 DN Initiate CALL 122 in the module every 10 seconds via timer T4:0. EN T4:0 0.01 1000 0 DN CALL 122 Request Bit T4:0 O:1 0001 DN 10 I:1 Buffer Data if Status OK EQU Equal Source A 0002 10 Source B COP Copy File Source Dest Length I:1.1 0 0 O:1 L 10 #M1:1.0 #N10:20 20 Buffer Status Byte if Non-zero NEQ Not Equal Source A Source B I:1.1 0 0 MOV Move Source Dest I:1.
Input Functions 13-39 Syntax GET Example >1 REM EXAMPLE PROGRAM >10 A = GET >20 IF (A<>0) THEN PRINT A : REM ZERO MEANS NO ENTRY >30 GOTO 10 >RUN 65 49 24 50 [A] [1] [^X] [2] STOP - IN LINE 30 READY > The GET operator is read only once before it is assigned a value of zero. This guarantees that the first character entered is always read, independent of where the GET operator is placed in the program. There is no buffering of characters on the program port.
13-40 Input Functions Example >1 >10 >20 >30 INPS REM EXAMPLE PROGRAM STRING 270,254 : REM ONE STRING OF < 254 BYTES INPL $(0) : REM READ LINE FROM PROGRAM PORT PRINT# $(0) : REM ECHO STRING TO PORT PRT2 Purpose Use the INPS statement to read an entire string of characters from the program port buffer. No characters are echoed. The INPS statement is preferred over INPUT or INPL for communications because all ASCII characters may be significant.
Input Functions 13-41 Syntax INPUT Examples >INPUT A,C >INPUT A,C 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. >1 REM EXAMPLE PROGRAM >10 INPUT A,C >20 PRINT A,C >RUN ?1 TRY AGAIN ?1,2 l 2 READY You can write the INPUT statement so that a descriptive prompt tells you what to enter.
13-42 Input Functions ENTER A NUMBER - 25 5 READY > You can also assign strings with an INPUT statement. Strings are always terminated with a carriage return (cr). If more than one string input is requested with a single INPUT statement, the module prompts you with a question mark. >1 REM EXAMPLE PROGRAM >10 STRING 100,20 >20 INPUT “NAME(CR),AGE - ”,$(1),A >30 PRINT “HELLO ”,$(1), “YOU ARE ”,A,“ YEARS OLD.” >40 END READY >RUN NAME(CR),AGE - PAM ?29 HELLO PAM YOU ARE 29 YEARS OLD.
Input Functions LD@ 13-43 IMPORTANT This instruction is not associated with any port designation. Purpose Use the LD@ statement to retrieve floating point numbers that were stored with a ST@ statement. The expression [expr] following the LD@ statement specifies the address where the number is stored after executing the LD@. The LD@ statement places the number on the ARGUMENT STACK at the address location specified by [expr].
13-44 Input Functions READY >RUN 20 21 22 23 24 25 26 27 28 29 READY >PUSH 5FFFH : CALL 77 >P.
Input Functions READ 13-45 Purpose Use the READ statement to retrieve the expressions that are specified in the DATA statement and assign the value of the expression to the variable in the READ statement. The READ statement is always followed by one or more variables. If more than one variable follows a READ statement, they are separated by a comma.
13-46 Input Functions Publication 1746-RM001A-US-P
Chapter 14 Setup Functions This chapter describes and illustrates commands used to set port parameters within the BASIC program or from the command line. Table 14.1 lists the corresponding mnemonics. Table 14.1 Chapter Reference Guide If you need (to) Use this mnemonic Page Set the PRT2 port parameters. CALL 30 14-1 Set the program port baud rate. CALL 78 14-2 Reset the print head pointer. CALL 99 14-3 Reset port PRT1 to the default settings.
14-2 Setup Functions Example >1 >10 >20 >30 >40 >50 REM EXAMPLE PROGRAM REM CALL 30 INPUT PARAMETERS: REM FIRST PUSH : 5, 6, 7, OR 8 (BITS/CHARACTER) REM SECOND PUSH : 0, 1, OR 2 (NO PARITY, ODD, OR EVEN) REM THIRD PUSH : 1, 2, OR 3 (1, 2, OR 1.
Setup Functions 14-3 Syntax PUSH [baud rate] CALL 78 Example >1 REM EXAMPLE PROGRAM >10 PUSH 4800 >20 CALL 78 CALL 99 – Reset Print Head Pointer Purpose Use CALL 99 to reset the internal print head character counter of your printer when printing out wide forms. This CALL prevents the automatic CR/LF at character 79. You must keep track of the characters in each line.
14-4 Setup Functions CALL 105 – Reset PRT1 to Purpose Default Settings Use CALL 105 to reset the port parameters of port PRT1 to their default settings. Table 14.3 lists the default parameters for port PRT1. Table 14.
Setup Functions MODE 14-5 Purpose Use the MODE command to set the port parameters of ports PRT1, PRT2, and DH485. IMPORTANT You must ensure that buffer space is available anytime that you are printing data out of the serial port using hardware handshaking or software handshaking (Xon/Xoff). Failure to do so causes the BASIC program to stop executing while awaiting buffer space. When space is available in the buffer, the module resumes execution from the point where it left off.
14-6 Setup Functions Table 14.6 DH485 Port Parameters Port Parameters Selections Default Settings Baud rate 300, 600, 1200, 2400, 4800, 9600, 19200 19200 baud arg1 (host node address) 0 to 31 0 arg2 (module node address) 1 to 31 1 arg3 (maximum node address ) 1 to 31 31 arg4 (not used) arg5 (storage type) Store information in user ROM and RAM (E). Store information in battery backed RAM (R). R IMPORTANT The E storage type option cannot be used if MODE is used as a statement.
Chapter 15 String Functions This chapter describes and illustrates commands used to manipulate string data structures within the BASIC program or from the command line. Table 15.1 lists the corresponding mnemonics. Table 15.1 Chapter Reference Guide If you need (to) Use this mnemonic Page String repeat CALL 60 15-1 String append (concatenation) CALL 61 15-2 Number to string conversion CALL 62 15-3 String to number conversion CALL 63 15-4 Find a string in a string.
15-2 String Functions Example >1 >10 >20 >30 >40 >50 >60 >70 >80 REM EXAMPLE PROGRAM REM STRING REPEAT EXAMPLE PROGRAM STRING 200,48 $(1) = “*” PUSH 40 : REM THE NUMBER OF TIMES TO REPEAT CHARACTER PUSH 1 : REM BASE STRING NUMBER CALL 60 PRINT $(1) END READY >RUN **************************************** READY > CALL 61 – String Append Purpose Use CALL 61 to append one string to the end of another string. This CALL expects two string arguments.
String Functions 15-3 Example >1 >10 >20 >30 >40 >50 >60 >70 >80 >90 >100 >110 >120 >130 REM EXAMPLE PROGRAM STRING 200,20 $(1) = “How are ” $(2) = “you?” PRINT “BEFORE ” PRINT “$(1) = ”,$(1) PRINT “$(2) = ”,$(2) PUSH 2 : REM STRING NUMBER TO BE APPENDED PUSH 1 : REM BASE STRING NUMBER CALL 61 : REM INVOKE STRING APPEND ROUTINE PRINT “AFTER:” PRINT “$(1) = ”,$(1) PRINT “$(2) = ”,$(2) END READY >RUN BEFORE: $(1) = How are $(2) = you? AFTER: $(1) = How are you? $(2) = you? READY > CALL 62 – Number to Str
15-4 String Functions Example >1 >10 >20 >30 >40 >50 >60 >70 REM EXAMPLE PROGRAM STRING 100,14 INPUT “ENTER A NUMBER TO CONVERT TO A STRING ”,N PUSH N : REM NUMBER TO CONVERT TO STRING PUSH 1 : REM CONVERT NUMBER TO STRING 1 CALL 62 : REM DO THE CONVERSION PRINT $(1) END READY >RUN ENTER A NUMBER TO CONVERT TO A STRING 2E3 2000 READY >RUN ENTER A NUMBER TO CONVERT TO A STRING 1.233 1.
String Functions 15-5 Example >1 >20 >30 >40 >50 >60 >70 >80 REM EXAMPLE PROGRAM INPUT “INPUT A STRING TO CONVERT ”,$(1) PUSH 1 : REM CONVERT STRING 1 CALL 63 POP V,N IF (V<>0) THEN PRINT $(1),“ ” N:GOTO 80 PRINT “INVALID OR NO VALUE FOUND” END READY >RUN INPUT A STRING TO CONVERT 123ABC 123ABC 123 READY >RUN INPUT A STRING TO CONVERT 1.2E-7 1.2E-7 1.2 E-7 READY >RUN INPUT A STRING TO CONVERT 1.3.
15-6 String Functions CALL 64 – Find a String in a String Purpose Use CALL 64 to find a string within a string. It locates the first occurrence (position) of this string. This CALL has two input arguments. The first is the string to be found, the second is the string searched for a match. One output argument is required. If the number is not zero then a match was located at the position indicated by the value of the output argument.
String Functions CALL 65 – Replace a String in a String 15-7 Purpose Use CALL 65 to replace a string within a string. Three arguments are expected. The first argument is the number of the string that replaces the string identified by the second argument string number. The third argument is the base string number. There are no output arguments.
15-8 String Functions CALL 66 – Insert a String Purpose in a String Use CALL 66 to insert 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 number of the base string. This routine has no output arguments.
String Functions CALL 67 – Delete a String in a String 15-9 Purpose Use CALL 67 to delete a string from within another string. The CALL expects two arguments. The first argument is the base string number. The second is the number of the string deleted from the base string. This routine has no output arguments. IMPORTANT This routine deletes only the first occurrence of the string.
15-10 String Functions CALL 68 – Find the Length of a String Purpose Use CALL 68 to determine 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($l)). The length of the string can be properly determined only if the string is terminated with a CR character.
String Functions STRING 15-11 Purpose Use the STRING statement to allocate memory for strings. Initially, no memory is allocated for strings. If you attempt to define a string with a statement such as LET $(1)=HELLO before memory is allocated for strings, an ERROR: MEMORY ALLOCATION message is generated. The first expression ([expr]) in the STRING statement is the total number of bytes you want to allocate for string storage.
15-12 String Functions Examples >1 >10 >20 >30 REM EXAMPLE PROGRAM STRING 100,30 $(0) = “-----MONTHLY REPORT-----” PRINT $(0) READY >RUN -----MONTHLY REPORT----READY > Publication 1746-RM001A-US-P
Appendix A Decimal/Hexadecimal/Octal/ASCII Conversion Table Mathematical Conversion Overview The table below lists the decimal, hexadecimal, octal, and ASCII conversions.
A-2 Decimal/Hexadecimal/Octal/ASCII Conversion Table Publication 1746-RM001A-US-P
B Appendix BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic List Overview Mnemonic The table below lists the various mnemonics found in this manual along with a description and location. Required PUSHes or POPs Description Active In Command Mode Only Page ABS( ) Absolute value 3-9 ASC( ) Return integer value of ASCII character. 3-12 ATN( ) Return arctangent of argument. 3-8 BRKPNT Set program break point.
B-2 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description CALL 24 PUSH [value to be converted] PUSH [word number of module output buffer] BASIC floating-point to 16-bit signed integer 9-2 CALL 25 PUSH [value to be converted] PUSH [word number of module output buffer] BASIC floating-point to 16-bit binary 9-3 CALL 26 POP[ SLC processor status] Generate an interrupt to the SLC processor.
BASIC Command, Statement, and CALL Quick Reference Guide Active In Command Mode Only B-3 Mnemonic Required PUSHes or POPs Description Page CALL 40 PUSH [hours] PUSH [minutes] PUSH [seconds] Set clock/calendar time (hour, minute, second). 10-1 CALL 41 PUSH [date] PUSH [month] PUSH [year] Set clock/calendar date (day, month, year). 10-2 CALL 42 PUSH [day of week] Set clock/calendar – day of week. 10-3 CALL 43 PUSH [string number] Retrieve date/time string.
B-4 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description CALL 64 PUSH [string number to be found] PUSH [base string number] POP [match position] Find a string in a string. 15-6 CALL 65 PUSH [new string number] PUSH [old string number to be replaced] PUSH [base string number] Replace a string in a string. 15-7 CALL 66 PUSH [insert position] PUSH [string number of inserted character] PUSH [base string number] Insert string in a string.
BASIC Command, Statement, and CALL Quick Reference Guide Active In Command Mode Only B-5 Mnemonic Required PUSHes or POPs Description Page CALL 90 PUSH [remote device node address] PUSH [remote device file number] PUSH [remote device file type] PUSH [starting element offset (x2) of remote device file] PUSH [number of elements to be transferred] PUSH [message time-out value] POP [status of message instruction] Read remote DH485 data file to BASIC input buffer.
B-6 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description CALL 108 PUSH [operational code] PUSH [poll timeout or ACKnowledge timeout] PUSH [message retries or ENQuiry retries] PUSH [RTS On delay or NAK received retries] PUSH [RTS Off delay or NULL value] PUSH [module DF1 address] Enable DF1 driver communications. CALL 109 None Print the argument stack. 5-7 CALL 110 None Print port PRT2 output buffer and pointer.
BASIC Command, Statement, and CALL Quick Reference Guide Active In Command Mode Only B-7 Mnemonic Required PUSHes or POPs Description CALL 123 PUSH [type of PLC WRITE command] PUSH [remote PLC node address] PUSH [file number of remote PLC] PUSH [file type on remote PLC] PUSH [starting word offset on remote PLC] PUSH [number of elements to be transferred] PUSH [message time-out value] PUSH [selection of source file] PUSH [word offset within source file] PUSH [string number] POP [CALL 123 status] Writ
B-8 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Command Mode Only Page GET Read console input device. 13-38 GET# Read console input device connected to PRT2. 13-38 GET@ Read console input device connected to PRT1. 13-38 GOSUB Execute subroutine. 8-11 GOTO Go to program line number. 7-7 IDLE Force module to enter “wait until interrupt mode”.
BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Command Mode Only B-9 Page ONERR Go to line number when an error is detected. 8-12 ON-GOSUB Conditional GOSUB 8-14 ON-GOTO Conditional GOTO 7-11 ONTIME Generate an interrupt when TIME is equal to or greater than ONTIME argument-line number. 8-14 PH0. Print hex value with zero suppression to console device. 12-37 PH0.# Print hex value with zero suppression to PRT2.
B-10 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Command Mode Only Page REM Specify a remark or comment line. 4-19 REN Renumber BASIC program. 4-20 RESTORE RESTORE read point. 6-7 RETI Return from interrupt. 8-18 RETURN RETURN from subroutine. 8-18 RND Random number 3-11 ROM Select ROM mode. * 4-20 RROM Select ROM mode and execute the selected program. * 4-21 RUN Execute a program.
Index Symbols # and @ quick reference guide B-10 special function operator 3-15 .AND. logical operator 3-6 quick reference guide B-10 .OR. logical operator 3-6 quick reference guide B-10 .XOR.
ii Index CALL 112 - User LED Control output function 12-25 quick reference guide B-6 CALL 113 - Disable DF1 Driver Communications quick reference guide B-6 status function 11-18 CALL 114 - Transmit DF1 Packet output function 12-26 quick reference guide B-6 CALL 115 - Check DF1 XMIT Status output function 12-27 quick reference guide B-6 CALL 117 - Get DF1 Packet Length input function 13-25 quick reference guide B-6 CALL 118 - PLC/SLC Unsolicited Writes input function 13-26 quick reference guide B-6 CALL 11
Index CALL 37 - Clear PRT2 Input/Output Buffers output function 12-15 quick reference guide B-2 CALL 38 - Expanded ONERR Restart execution control and interrupt support function 8-5 quick reference guide B-2 CALL 40 - Set Clock/Calendar Time clock/calendar function 10-1 quick reference guide B-3 CALL 41 - Set Clock/Calendar Date clock/calendar function 10-2 quick reference guide B-3 CALL 42 - Set Day of Week clock/calendar function 10-3 quick reference guide B-3 CALL 43 - Retrieve Date/Time String clock/ca
iv Index CALL 73 - Battery-Backed RAM Disable command line CALL 5-1 quick reference guide B-4 CALL 74 - Battery-Backed RAM Enable command line CALL 5-2 quick reference guide B-4 CALL 75 - Check SLC 500 Controller CPU Status quick reference guide B-4 status function 11-7 CALL 77 - Protected Variable Storage command line CALL 5-2 quick reference guide B-4 CALL 78 - Set Program Port Baud Rate quick reference guide B-4 setup function 14-2 CALL 80 - Check Battery Condition quick reference guide B-4 status func
Index CLEARS assignment function 6-3 quick reference guide B-7 clock/calendar function retrieve date numeric 10-4 retrieve date string 10-7 retrieve date/time string 10-4 retrieve day of week numeric 10-7 retrieve day of week string 10-6 retrieve time numeric 10-6 retrieve time string 10-5 set clock/calendar date 10-2 set clock/calendar time 10-1 set day of week 10-3 CLOCK0 control function 7-2 quick reference guide B-7 CLOCK1 control function 7-1 quick reference guide B-7 CONT BASIC command 4-3 quick refe
vi Index Disable Control-C 4-6 DF1 Driver Communications 11-18 DF1 Packet Interrupt 8-3 Port PRT2 DTR Signal 11-11 Processor Interrupt 8-4 Display Current PRT1 Port Setup 12-24 Current PRT2 Port Setup 12-14 Divide (/) arithmetic operator 3-4 quick reference guide B-10 DO-UNTIL control function 7-4 quick reference guide B-7 DO-WHILE control function 7-3 quick reference guide B-7 DTR signal disable 11-11 enable 11-11 functional operators ABS 3-9 expressions 3-2 F Find a String in a String 15-6 Find the Le
Index H hierarchy of operations 3-3 I IDLE BASIC command 4-10 quick reference guide B-8 IF-THEN-ELSE control function 7-8 quick reference guide B-8 INPL input function 13-39 quick reference guide B-8 INPL# input function 13-39 quick reference guide B-8 INPL@ input function 13-39 quick reference guide B-8 INPS input function 13-40 quick reference guide B-8 INPS# input function 13-40 quick reference guide B-8 INPS@ input function 13-40 quick reference guide B-8 INPUT input function 13-40 quick reference gui
viii Index MTOP quick reference guide B-8 special function operator 3-16 Multiply (*) arithmetic operator 3-4 quick reference guide B-10 N Negation (-) arithmetic operator 3-4 NEW BASIC command 4-14 quick reference guide B-8 NEXT control function 7-9 quick reference guide B-8 NOT functional operator 3-9 quick reference guide B-8 NULL BASIC command 4-14 quick reference guide B-8 Number to String Conversion 15-3 O ONERR execution control and interrupt support function 8-12 quick reference guide B-9 ON-GOS
Index PRINT@ output function 12-35 quick reference guide B-9 Processor Interrupt disable 8-4 enable 8-3 PROG BASIC command 4-15 quick reference guide B-9 PROG 1 BASIC command 4-16 quick reference guide B-9 PROG 2 BASIC command 4-17 quick reference guide B-9 Program ID Number 11-19 Protected Variable Storage 5-2 PRT1 clear input/output buffers 12-24 display current setup 12-24 get number of characters in buffers 11-10 print input buffer and pointer 5-6 print output buffer and pointer 5-5 reset to default se
x Index ROM/RAM to ROM Program Transfer 8-9 RROM BASIC command 4-21 quick reference guide B-10 RS-232 network 13-2 RS-422 network 13-2 RS-485 network 13-2 RUN BASIC command 4-22 quick reference guide B-10 S set clock/calendar date 10-2 Clock/Calendar Time 10-1 Day of Week 10-3 Program Port Baud Rate 14-2 PRT2 Port Parameters 14-1 SGN functional operator 3-10 quick reference guide B-10 SIN quick reference guide B-10 SLC 500 Controller CPU Status 11-7 SLC Processor Program ID Number 11-19 SNGLSTP BASIC com
Index U Unsolicited Writes 13-26 Upload User Memory Module Code to Host 5-4 User LED Control 12-25 User Memory Module Check and Description 5-3 W Write BASIC Output Buffer to Remote DH485 Data File 12-18 Write Output Buffer to Remote DH485 Common Interface File 12-22 Write to Remote DF1 PLC Data File 12-28 Write to Remote DH485 SLC Data File 12-6 V variables in general 2-4 name of 2-5 type of 2-5 VER BASIC command 4-25 quick reference guide B-10 xi X XBY quick reference guide B-10 special function ope
xii Index Publication 1746-RM001A-US-P
Back Cover Publication 1746-RM001A-US-P - April 2000 13 Supercedes Publication 1746-6.3 - November 1994 © 2000 Rockwell International Corporation. Printed in the U.S.A.