Rockwell Automation Allen-Bradley SLC 500 BASIC Reference Manual
Rockwell Automation Allen-Bradley SLC 500 BASIC Reference Manual

Rockwell Automation Allen-Bradley SLC 500 BASIC Reference Manual

Hide thumbs Also See for Allen-Bradley SLC 500 BASIC:
Table of Contents

Advertisement

Quick Links

BASIC Language
(Catalog Numbers 1746-BAS and
1746-BAS-T)
Reference Manual

Advertisement

Table of Contents
loading

Summary of Contents for Rockwell Automation Allen-Bradley SLC 500 BASIC

  • Page 1 BASIC Language (Catalog Numbers 1746-BAS and 1746-BAS-T) Reference Manual...
  • Page 2 • identify a hazard • avoid a hazard • recognize the consequences Identifies information that is critical for successful IMPORTANT application and understanding of the product. PLC-5 is a registered trademark; and MicroLogix, SLC 500, RSLogix, and RSLinx are trademarks of Rockwell Automation.
  • Page 3: Table Of Contents

    Conventions Used in this Manual ......P-4 Rockwell Automation Support ......P-5...
  • Page 4 Table of Contents NULL..........4-14 PROG .
  • Page 5 Table of Contents NEXT ..........7-9 ON-GOTO .
  • Page 6 Table of Contents 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 –...
  • Page 7 Table of Contents 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 –...
  • Page 8 Table of Contents Appendix A Decimal/Hexadecimal/Octal/ Mathematical Conversion Overview ......A-1 ASCII Conversion Table Appendix B BASIC Command, Statement, Mnemonic List Overview .
  • Page 9: Preface

    You should have a basic understanding of SLC 500™ products. You should understand programmable controllers and be able to interpret the ladder logic instructions required to control your application. If you do not, contact your local Rockwell Automation representative for information on available training courses before using this product. Publication 1746-RM001A-US-P...
  • Page 10: Purpose Of This Manual

    Purpose of this Manual This manual is a reference guide for programming the BASIC or BASIC-T module. This manual is intended for reference purposes only. Chapter Title Contents Preface Describes the purpose, background, and scope of this manual. Also lists related publications.
  • Page 11: How To Use This Manual

    Related Documentation The following documents contain additional information regarding Rockwell Automation products. To obtain a copy, contact your local Rockwell Automation office or distributor. Read this document Publication Number A BASIC and BASIC-T manual that provides SLC 500™ BASIC and BASIC-T Modules...
  • Page 12: Terms And Abbreviations

    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. • Module  SLC 500 BASIC and BASIC-T Modules (catalog numbers 1746-BAS and 1746-BAS-T) •...
  • Page 13: Rockwell Automation Support

    • warranty support • support service agreements Technical Product Assistance If you need to contact Rockwell Automation for technical assistance, please review the information in the appropriate chapter first. Then call your local Rockwell Automation representative. Your Questions or Comments on this Manual If you find a problem with this manual, please notify us of it on the enclosed Publication Problem Report.
  • Page 14 Publication 1746-RM001A-US-P...
  • Page 15: Language Elements

    Chapter 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.
  • Page 16 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: Reuse of an existing line number causes all of the information IMPORTANT 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.
  • Page 17: Data Types

    Chapter 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.
  • Page 18 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.
  • Page 19 Data Types 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.
  • Page 20: Variables

    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. The SLC 500 formats are: • 16-bit signed integer (–32768 to 32767) •...
  • Page 21 Data Types 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.
  • Page 22 Data Types Publication 1746-RM001A-US-P...
  • Page 23: Expressions And Operators

    Chapter 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( )
  • Page 24 Expressions and Operators Table 3.1 Chapter Reference Guide If you need (to) Use this mnemonic Page Logical Exclusive OR .XOR. Direct communications to port PRT1. 3-15 Direct communications to port PRT2. 3-15 Expressions and An expression is a logical mathematical expression that involves operators, constants, and variables.
  • Page 25: Hierarchy Of Operators

    Expressions and Operators Hierarchy of Operators 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.
  • Page 26 Expressions and Operators Divide ( / ) Use the Division operator to divide the first expression by the second expression. Example Result >PRINT 100/5 Exponentiation ( **) Use the Exponentiation operator to raise the first expression to the power of the second expression.
  • Page 27 Expressions and Operators 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.
  • Page 28: Logical Operators

    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: , where OP is one of the following logical operators. (expr) OP (expr) These operators perform BIT-WISE logical operations on numbers between 0 (0000H) and 65535 (0FFFFH) inclusive.
  • Page 29: Relational Operators

    Expressions and Operators Relational Operators 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.
  • Page 30: Trigonometric Operators

    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.
  • Page 31: Functional Operators

    Expressions and Operators 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 –...
  • Page 32 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) >PRINT INT(100.876) 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.
  • Page 33: Logarithmic Operators

    Expressions and Operators 3-11 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.
  • Page 34: String Operators

    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)
  • Page 35 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.
  • Page 36 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) Like the ASC operator, the CHR operator also selects individual characters in a defined ASCII string. >NEW >1 REM EXAMPLE PROGRAM >5 STRING 1000,40...
  • Page 37: Special Function Operators

    Expressions and Operators 3-15 Special Function The module contains a complete set of special function operators. These operators manipulate the I/O hardware and memory addresses of the module. Operators # 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.
  • Page 38 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.
  • Page 39 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.
  • Page 40 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.
  • Page 41: Basic Commands

    Chapter 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 If you need (to) Use this mnemonic Page Set the program break point.
  • Page 42: Brkpnt

    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.
  • Page 43: Cont

    BASIC Commands 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 , BRKPNT command, or a STOP statement.
  • Page 44: Control-C

    BASIC Commands Example >NEW >1 REM EXAMPLE PROGRAM >10 FOR I = 1 TO 10000 >20 PRINT I >30 NEXT I >40 END READY >RUN pressed 10 [CTRL-C] STOP - IN LINE 15 READY >CONT Control-C Purpose Use the command to stop execution of the current program and return [CTRL-C] the module to the Command mode.
  • Page 45: Call 18 - Re-Enable The Control-C Break Function

    BASIC Commands >20 PRINT I >30 NEXT I >40 END >RUN pressed [CTRL-C] STOP – IN LINE 20 READY >PRINT I >I =10 >CONT Notice that after is pressed and I is printed the value of I is 27. The [CTRL-C] value of I is incremented several times before is detected.
  • Page 46: Call 19 - Disable The Control-C Break Function

    BASIC Commands Syntax CALL 18 Example >1 REM EXAMPLE PROGRAM >10 CALL 19 >90 CALL 18 CALL 19 – Disable the Purpose Control-C Break Disable the break function by executing CALL 19 in a module program [CTRL-C] Function or from the Command mode. When CALL 19 is executed, the break function for both LIST and [CTRL-C]...
  • Page 47: Control-S

    BASIC Commands Control-S Purpose Use the command to interrupt the scrolling of a BASIC program during [CTRL-S] the execution of a LIST command. stops output from the transmitting [CTRL-S] port if you are running a program. In this case XOFF ( ) operates as [CTRL-S] follows:...
  • Page 48: Control-Q

    BASIC Commands Control-Q Purpose Use the command to restart a LIST command or PRINT output that is [CTRL-Q] interrupted by [CTRL-S] Syntax [CTRL–Q] Example > LIST REM EXAMPLE PROGRAM 10 A = 1 20 DO [CTRL–S] [CTRL–Q] 30 A = A+1 40 PRINT A 50 WHILE A <...
  • Page 49: Erase

    BASIC Commands Table 4.2 BASIC Editor Operations Operation Function Key Strokes Move Use the Move operation to provide – moves the cursor one [Space bar] right/left cursor control. space to the right. – moves the cursor one [Backspace] space to the left. Replace Use the Replace operation to replace Press the key that corresponds to the...
  • Page 50: Idle

    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.
  • Page 51: List

    BASIC Commands 4-11 LIST 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 on the console device.
  • Page 52: List

    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.
  • Page 53 BASIC Commands 4-13 Table 4.3 PRT1 and PRT2 Port Parameters Port Parameters Selections Default Settings baud rate 300, 600, 1200, 2400, 4800, 9600, 19200 1200 arg1 (parity) None (N), Even (E), Odd (O) arg2 (number of data bits) 7 or 8 arg3 (number of stop bits) 1 or 2 arg4 (handshaking)
  • Page 54: New

    4-14 BASIC Commands Example >1 REM EXAMPLE PROGRAM >10 MODE(DH485,19200,0,1,2,,R) >25 MODE(PRT1,1200,N,8,,,) The E storage type option cannot be used if MODE is used as a IMPORTANT statement. Purpose Use the NEW command to delete the program currently stored in RAM. In addition, all variables are set equal to ZERO;...
  • Page 55: Prog

    BASIC Commands 4-15 PROG Before you attempt to program EEPROM, read the PROG, IMPORTANT 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. Be sure you have selected the program you want to save before IMPORTANT using the PROG command.
  • Page 56: Prog1

    4-16 BASIC Commands If you exceed the available EEPROM space, you cannot continue IMPORTANT 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.
  • Page 57: Prog2

    BASIC Commands 4-17 PROG2 Before you attempt to program an EEPROM, read the PROG, IMPORTANT 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.
  • Page 58 4-18 BASIC Commands Figure 4.1 Operation of PROG1 or PROG2 Start Erase RAM battery backup program enabled? Erase MTOP and port information in battery-backed RAM Copy EEPROM MTOP and PROG1 or PROG2 port information to been executed? battery-backed RAM battery-backed Store default MTOP and RAM MTOP and port information in...
  • Page 59: Ram

    BASIC Commands 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 is typed. RAM space is limited to 24K bytes. Use the following formula to IMPORTANT calculate the available user RAM space Available user RAM = MTOP–H...
  • Page 60: Ren

    4-20 BASIC Commands Syntax Example >10 REM THIS IS A COMMENT LINE >20 NEW : REM THIS IS ALSO A COMMENT LINE Purpose Use the REN command to renumber program lines. Syntax REN[new number],[old number],[increment] Examples Example Result Renumbers the entire program. The first new line number is 10. Line numbers increment by 10.
  • Page 61: Rrom

    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: ) 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.
  • Page 62: Run

    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: ) the module RROM defaults to RROM 1.
  • Page 63: Snglstp

    BASIC Commands 4-23 Variations Some BASIC interpreters allow a line number to follow the RUN command (example: ). The module does not permit this variation on the RUN RUN 100 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.
  • Page 64 4-24 BASIC Commands Example >1 REM EXAMPLE PROGRAM >10 FOR I = 1 TO 5 >20 PRINT I >30 NEXT I >40 PRINT “PASSED FOR – NEXT LOOP” >50 PRINT “THIS IS THE END” >60 END READY >SNGLSTP 20 SINGLE STEP ENABLED READY >RUN STOP –...
  • Page 65: Ver

    BASIC Commands 4-25 READY > Purpose Use the VER command to print the module sign-on message that displays the current version of the firmware. Syntax Example >VER SLC 500 module–Catalog Number 1746-BAS Firmware release: x.xx Allen–Bradley Company, Copyright 19xx All rights reserved >...
  • Page 66: Xfer

    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. The XFER command clears existing RAM programs.
  • Page 67 Chapter 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.
  • Page 68: Call 77 - Protected Variable Storage

    Command Line CALLs CALL 74 – Purpose Battery-Backed RAM Use CALL 74 to enable the battery-backed RAM. When this CALL is executed, Enable the message is printed on the host terminal. Battery Backup Enabled Battery-backed RAM is enabled on module powerup and remains enabled until you execute a CALL 73 or until the battery fails.
  • Page 69: Call 81 - User Memory Module Check And Description

    Command Line CALLs Example: (For saving 2 variables) >PRINT MTOP 24575 >PRINT MTOP-12 24563 >PUSH 24563:REM NEW MTOP ADDRESS >CALL 77 >1 REM EXAMPLE PROGRAM >10 K = 678*PI >20 L = 520 >30 PUSH K >40 ST@ 24575 : REM STORE K IN PROTECTED AREA >50 PUSH L >60...
  • Page 70: Call 82 - Check User Memory Module Map

    Command Line CALLs Example >CALL 81 Number of BASIC programs in (E)EPROM..3 Available bytes to end of user (E)EPROM..7944 Available bytes to beginning of assembly pgm.. 3848 Length of BASIC program in RAM....76 Program will fit in (E)EPROM. READY >...
  • Page 71 Command Line CALLs 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 Purpose Output Buffer and Use CALL 103 to print the complete output buffer with address, front pointer, and Pointer number of characters in the buffer to the program port screen.
  • Page 72 Command Line CALLs Example >CALL 103 PRT1 Output Queue 6D00H 3AH 31H 30H 38H 30H 34H 30H 30H 30H 39H 37H 34H 39H 30H 44H 30H 6D10H 41H 30H 30H 33H 43H 41H 30H 34H 41H 45H 41H 34H 46H 41H 36H 33H 6D20H 33H 30H 33H 30H 48H 20H 33H 33H 48H 20H 33H 30H 48H 20H 34H 38H 6D30H 48H 20H 32H 30H 48H 20H 33H 33H 48H 20H 33H 33H 48H 20H 34H 38H 6D40H 48H 20H 32H 30H 48H 20H 33H 33H 48H 20H 33H 30H 48H 20H 34H 38H...
  • Page 73 Command Line CALLs Example >CALL 104 PRT1 Input Queue 6C00H 33H 0DH 43H 41H 4CH 4CH 20H 31H 30H 34H 7FH 7FH 7FH 7FH 7FH 7FH 6C10H 7FH 7FH 52H 45H 4DH 20H 45H 58H 41H 4DH 50H 4CH 45H 53H 7FH 7FH 6C20H 7FH 7FH 7FH 7FH 7FH 7FH 7FH 7FH 7FH 7FH 0DH 0DH 0DH 0DH 0DH 0DH 6C30H 0DH 0DH 0DH 45H 58H 41H 4DH 7FH 7FH 7FH 7FH 52H 45H 4DH 20H 45H 6C40H 58H 41H 4DH 50H 4CH 45H 53H 20H 4FH 4EH 20H 50H 41H 47H 45H 20H...
  • Page 74 Command Line CALLs CALL 110 – Print PRT2 Purpose Output Buffer Pointer 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.
  • Page 75 Command Line CALLs Example >CALL 111 PRT2 Input Queue 6E00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E10H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E20H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E30H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E40H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H...
  • Page 76 5-10 Command Line CALLs Publication 1746-RM001A-US-P...
  • Page 77: Chapter 6 Clear

    Chapter 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 If you need (to) Use this mnemonic Page Clear variables, interrupts &...
  • Page 78 Assignment Functions Example >CLEAR >LIST 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 >RUN READY >PRINT A(1),I,J >CLEAR...
  • Page 79: Cleari

    Assignment Functions CLEARI 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.
  • Page 80: Data

    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.
  • Page 81: Let

    Assignment Functions 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.
  • Page 82 Assignment Functions Examples >1 REM EXAMPLE PROGRAM >10 LET A = 10*SIN(C)/100 >1 REM EXAMPLE PROGRAM >10 LET A = A +1 The - sign used in the LET statement is not an equality operator. NOTE It is a replacement operator. The statement should be read A is replaced by A plus one.
  • Page 83: Restore

    Assignment Functions RESTORE Purpose Use the RESTORE statement to reset the internal read pointer to the beginning of the data so that it may be read again. Syntax RESTORE Example >1 REM EXAMPLE PROGRAM >10 FOR I = 1 TO 3 >20 READ A,C >30 PRINT A,C >40 NEXT I...
  • Page 84 Assignment Functions Publication 1746-RM001A-US-P...
  • Page 85: Clock1

    Chapter 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) Use this mnemonic Page...
  • Page 86: Clock0

    Control Functions Example >NEW >1 REM EXAMPLE PROGRAM >10 TIME = 0 >15 DBY(71) = 0 >20 CLOCK1 >30 ONTIME 2,100 >40 >50 WHILE TIME < 10 >60 >100 PRINT “TIMER INTERRUPT AT - ”,TIME,“ SECONDS” >110 ONTIME TIME+2,100 >120 RETI READY >RUN TIMER INTERRUPT AT - 2.01 SECONDS...
  • Page 87: Do-While

    Control Functions DO-WHILE 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.
  • Page 88: Do-Until

    Control Functions >1 REM EXAMPLE PROGRAM >10 A=0 : C=0 >20 DO >30 A=A+1 >40 DO >45 C=C+1 >50 PRINT A,C,A*C >60 WHILE C<>3 >70 C=0 >80 WHILE A<4 >90 END READY >RUN 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.
  • Page 89: End

    Control Functions Examples Simple DO-UNTIL Nested DO-UNTIL >1 REM EXAMPLE PROGRAM >1 REM EXAMPLE PROGRAM >10 A=0 >10 DO >20 DO >20 A=A+1 >30 A=A+1 >30 DO >40 PRINT A >40 C=C+1 >50 UNTIL A=4 >50 PRINT A,C,A*C >60 PRINT “DONE” >60 UNTIL C=3 >70 END >70 C=0...
  • Page 90: For-To-(Step)-Next

    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.
  • Page 91: Goto

    Control Functions 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.
  • Page 92: If-Then-Else

    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 is printed to the console device and the module enters the Command NUMBER mode.
  • Page 93: Next

    Control Functions 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.
  • Page 94 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 READY > >NEW >1 REM EXAMPLE PROGRAM >10 FOR I = 0 TO 8 STEP 2 >20 PRINT I >30 NEXT I >40 END...
  • Page 95: On-Goto

    Control Functions 7-11 ON-GOTO 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...
  • Page 96 7-12 Control Functions Publication 1746-RM001A-US-P...
  • Page 97 Chapter 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 If you need (to) Use this Page...
  • Page 98 Execution Control and Interrupt Support Functions CALL 16 – Enable DF1 Purpose Packet Interrupt 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.
  • Page 99: Call 20 - Enable Processor Interrupt

    Execution Control and Interrupt Support Functions CALL 17 – Disable DF1 Purpose Packet Interrupt 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...
  • Page 100: Call 21 - Disable Processor Interrupt

    Execution Control and Interrupt Support Functions Example >1 REM EXAMPLE PROGRAM >10 REM ENABLE PROCESSOR INTERRUPTS >20 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 –...
  • Page 101 Execution Control and Interrupt Support Functions 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 •...
  • Page 102 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.2 Status Codes Status Code Description module attempted to call an illegal call number port has been assigned an invalid parameter string has not been dimensioned defined string length is too small for operation...
  • Page 103 Execution Control and Interrupt Support Functions 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...
  • Page 104 Execution Control and Interrupt Support Functions CALL 70 – ROM to RAM Purpose Program Transfer 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. The first line of the RAM program is not executed.
  • Page 105: Call 71 - Rom/Ram To Rom Program Transfer

    Execution Control and Interrupt Support Functions CALL 71 – ROM/RAM to Purpose ROM Program Transfer 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).
  • Page 106 8-10 Execution Control and Interrupt Support Functions Syntax CALL 72 Example Program in ROM 1 >1 REM EXAMPLE PROGRAM >10 REM SAMPLE PROG FOR CALL 72 >20 PRINT “NOW EXECUTING ROM 1” >30 PUSH 3 >40 CALL 71 : REM EXECUTE ROM 3 THEN RETURN >50 PRINT “EXECUTING ROM 1 AGAIN”...
  • Page 107: Gosub

    Execution Control and Interrupt Support Functions 8-11 GOSUB 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.
  • Page 108: Onerr

    8-12 Execution Control and Interrupt Support Functions >20 GOSUB 100 >30 NEXT I >40 >100 REM USER SUBROUTINE HERE >105 PRINT I, >110 GOSUB 200 >120 RETURN >200 REM START OF NESTED SUBROUTINE >210 PRINT I*I 220 RETURN READY >RUN READY >...
  • Page 109 Execution Control and Interrupt Support Functions 8-13 Example >1 REM EXAMPLE PROGRAM >10 ONERR 500 >20 FOR I = 5 TO 0 STEP -1 >30 PRINT 1/I >40 NEXT I >50 >500 PRINT “ERROR CODE WAS ”,XBY(257) >510 END READY >RUN .33333333 ERROR CODE WAS 10...
  • Page 110: On-Gosub

    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...
  • Page 111: Push

    Execution Control and Interrupt Support Functions 8-15 Example >1 REM EXAMPLE PROGRAM >10 TIME = 0 >15 DBY(71) = 0 >20 CLOCK1 >30 ONTIME 2,100 >40 >50 WHILE TIME < 10 >60 CLOCK0 >70 >100 PRINT “TIMER INTERRUPT AT - ”,TIME, “ SECONDS” >110 ONTIME TIME+2,100 >120 RETI READY...
  • Page 112 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.
  • Page 113: Pop

    Execution Control and Interrupt Support Functions 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.
  • Page 114: Reti

    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.
  • Page 115 Execution Control and Interrupt Support Functions 8-19 Examples Simple Subroutine >1 REM EXAMPLE PROGRAM >10 FOR I = 1 TO 5 >20 GOSUB 100 >30 NEXT I >40 >100 PRINT I >110 RETURN READY >RUN READY > Nested Subroutine >1 REM EXAMPLE PROGRAM >10 FOR I = 1 TO 5...
  • Page 116: Stop

    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.
  • Page 117 Chapter 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.
  • Page 118: Call 15 - 16-Bit Unsigned Integer To Basic Floating-Point

    Math and Backplane Conversion Functions CALL 15 – 16-Bit Purpose Unsigned Integer to Use CALL 15 to convert an SLC 500 controller 16-bit unsigned integer number to BASIC Floating-Point 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.
  • Page 119 Math and Backplane Conversion Functions Syntax PUSH [value to be converted] PUSH [word number of module output buffer] CALL 24 Example >1 REM EXAMPLE PROGRAM >10 W = 17 >40 PUSH W : REM THE VALUE TO BE CONVERTED >50 PUSH 0 : REM 1ST WORD OF BASIC OUTPUT BUFFER >60 CALL 24 : REM DO THE F.P.
  • Page 120 Math and Backplane Conversion Functions Example >1 REM EXAMPLE PROGRAM >40 PUSH 9E+1 : REM THE VALUE TO BE CONVERTED >50 PUSH 0 : REM 1ST WORD OF BASIC OUTPUT BUFFER >60 CALL 25 : REM DO F.P. TO 16-BIT BINARY CONVERSION >...
  • Page 121 Math and Backplane Conversion Functions 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.
  • Page 122 Math and Backplane Conversion Functions SLC floating-point numbers are stored in two 16-bit words. Due to the fact that the SLC floating-point number is a 7-digit IMPORTANT floating-point number, and the module is an 8-digit floating-point number, some round-off error may be introduced during number conversions.
  • Page 123 Chapter 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) Use this mnemonic Page Set the clock/calendar time (hour, minute, second).
  • Page 124: Call 41 - Set Clock/Calendar Date

    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 REM EXAMPLE PROGRAM >10 H = 13 : M = 35 : S = 00 >20 REM HOURS = 13, MINUTES = 35, SECONDS = 00 >30 PUSH H,M,S >40 CALL 40 READY...
  • Page 125: Call 42 - Set Day Of Week

    Clock/Calendar Functions 10-3 Example Program the clock/calendar for the 16th day of June 1991. >1 REM EXAMPLE PROGRAM >5 STRING 100,20 >10 H=13 : M=35 : S=00 >20 REM HOURS = 13, MINUTES = 35, SECONDS = 00 >30 PUSH H,M,S >40 CALL 40 >60...
  • Page 126: Call 43 - Retrieve Date/Time String

    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.
  • Page 127: Call 45 - Retrieve Time String

    Clock/Calendar Functions 10-5 Example >1 REM EXAMPLE PROGRAM >10 REM DATE RETRIEVE - NUMERIC EXAMPLE >20 CALL 44 : REM INVOKE THE UTILITY ROUTINE >30 POP D,M,Y : REM GET THE DATA FROM THE ARGUMENT STACK >40 PRINT “CURRENT DATE IS ”,Y,M,D >50 END READY >RUN...
  • Page 128: Call 46 - Retrieve Time Numeric

    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.
  • Page 129: Call 48 - Retrieve Day Of Week Numeric

    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 Purpose of Week Numeric Use CALL 48 to return the current day of week on the argument stack as a number (example: ).
  • Page 130 10-8 Clock/Calendar Functions Syntax PUSH [string number] CALL 52 Example >1 REM EXAMPLE PROGRAM >10 STRING 100,20 >20 PUSH 1 : CALL 52 : REM PUT DATE IN STRING 1 >30 PRINT $(1) >40 END READY >RUN 16-JUN-91 READY > Publication 1746-RM001A-US-P...
  • Page 131 Chapter 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.
  • Page 132: Status Functions

    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.
  • Page 133 Status Functions 11-3 CALL 51 – Check CPU Purpose Output Image Buffer 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.
  • Page 134 11-4 Status Functions CALL 55 – Check CPU Purpose Input Image Buffer 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.
  • Page 135: Call 58 - Check M0 File

    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.
  • Page 136: Call 59 - Check M1 File

    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.
  • Page 137 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. In SLC 5/01 mode of operation, the POPped values are: •...
  • Page 138: Call 80 - Check Battery Condition

    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. Syntax CALL 80 POP [battery status]...
  • Page 139: Call 87 - Check Dh485 Interface File Remote Read Status

    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 Purpose Interface File Remote Use CALL 87 to determine if the DH485 Common Interface File located in the Read Status module has been read by a device on the DH485 Serial Communications Link since the last time it was checked.
  • Page 140: Call 95 - Get Number Of Characters In Prt1 Buffers

    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 •...
  • Page 141: Call 97 - Enable Port Prt2 Dtr Signal

    Status Functions 11-11 CALL 97 – Enable Port Purpose PRT2 DTR Signal 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.
  • Page 142 11-12 Status Functions CALL 108 – Enable DF1 Purpose Driver Communications Use CALL 108 to enable DF1 driver communications via port PRT2. DF1 can only be enabled if jumper JW4 on the module is in the IMPORTANT correct position. Refer to the SLC 500™ BASIC and BASIC-T Modules User Manual (publication number 1746-UM004A-US-P) for additional information.
  • Page 143 Status Functions 11-13 Other port parameters, such as baud rate, number of stop bits, IMPORTANT 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.
  • Page 144 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. •...
  • Page 145 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: For proper operation, the Data Carrier Detect (DCD) line from IMPORTANT the modem must be connected to the DSR input of port PRT2. •...
  • Page 146 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. •...
  • Page 147 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.
  • Page 148: Call 113 - Disable Df1 Driver Communications

    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 REM EXAMPLE PROGRAM...
  • Page 149: Call 121 - Get Slc Processor Program Id Number

    Status Functions 11-19 that corresponds to the module input and output buffers, as shown in the table below: Table 11.4 Information for Clearing Input and Output Buffer Decimal Equivalent Module Input and Output Buffer Areas SLC M0 File SLC M1 File SLC Output Image Table SLC Input Image Table Common Interface Input File...
  • Page 150 11-20 Status Functions Syntax CALL 121 POP [program ID number] Example >1 REM EXAMPLE PROGRAM >10 CALL 121 >20 POP X : REM GET SLC PROCESSOR PROGRAM ID >30 END Publication 1746-RM001A-US-P...
  • Page 151: Output Functions

    Chapter 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.
  • Page 152: Call 23 - Transfer Data From The Cpu Files To Port 1 Or 2

    12-2 Output Functions Table 12.1 Chapter Reference Guide If you need (to) Use this Page mnemonic Print numeric values in decimal notation. PRINT USING(#.#) 12-36 Restore the default print mode. PRINT USING(0) 12-37 Store variable. 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...
  • Page 153 Output Functions 12-3 2. 2. 2. 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 PORT PRT1 Output File Word 0, Bit 6...
  • Page 154 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.
  • Page 155 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.
  • Page 156 12-6 Output Functions Example >1 REM EXAMPLE PROGRAM >10 REM ENABLE CALL 23 INTERRUPTS >20 PUSH 2 : REM SEND DATA TO PRT1 >30 PUSH 1 : REM GET DATA FROM M0 FILE >40 PUSH 0 : REM WORD OFFSET INTO M0 FILE >50 PUSH 0 : REM STRING NUMBER/NOT USED HERE >60 PUSH 1 : REM ENABLE BYTE SWAPPING >70 CALL 23...
  • Page 157 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.
  • Page 158 12-8 Output Functions Input File Word 0, Bit 11 SLC Processor SLC Backplane BASIC or BASIC-T Module 6. 6. 6. 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...
  • Page 159 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.2 File Type File Type File Type Code Words/Element Integer File ASC(N)
  • Page 160 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.
  • Page 161 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...
  • Page 162 12-12 Output Functions Input P.B. to initiate CALL 28. B3:0 0000 Copy File Source #N7:0 Dest #M0:1.0 Length CALL 28 Request Bit Buffer Status Byte if Non-zero 0001 Not Equal Move Source A I:1.1 Source I:1.1 Handshake Bit from Module Source B Dest N7:20...
  • Page 163: Module Internal String

    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.
  • Page 164: Call 31 - Display Current Prt2 Port Setup

    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.
  • Page 165: Call 37 - Clear Prt2 Input/Output Buffers

    Output Functions 12-15 CALL 37 – Clear PRT2 Purpose Input/Output Buffers 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. •...
  • Page 166: Call 57 - Transfer Basic Output Buffer To Cpu M1 File

    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.
  • Page 167: Call 85 - Transfer Basic Output Buffer To Dh485

    Output Functions 12-17 Syntax PUSH [number of words to be transferred] CALL 57 POP [processor mode] Example >1 REM EXAMPLE PROGRAM >50 PUSH 64 : REM TRANSFER LENGTH IS 64 WORDS >60 CALL 57 : REM TRANSFER BASIC OUTPUT BUFFER TO M1 >70 POP X : REM LOGIC PROCESSOR STATUS IS IN X >80 PRINT X READY...
  • Page 168 12-18 Output Functions Example >1 REM EXAMPLE PROGRAM >40 PUSH 31 : REM OFFSET ADDRESS = 31 >50 PUSH 3 : REM WORD LENGTH = 3 >60 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...
  • Page 169 Output Functions 12-19 The offset will be twice of what is expected. For example, if an IMPORTANT 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.
  • Page 170 12-20 Output Functions Table 12.6 Output Argument Decimal Hexadecimal Description Output Output Successful Completion. Target node cannot accept the message at this time. Target node cannot respond because message is too large. Target node cannot respond because it does not understand the command parameters.
  • Page 171 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...
  • Page 172: Common Interface File

    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.
  • Page 173 Output Functions 12-23 Table 12.7 Output Argument Decimal Hexadecimal Description Output Output Successful Completion. Target node cannot accept the message at this time. Target node cannot respond because message is too large. Target node cannot respond because it does not understand the command parameters.
  • Page 174 12-24 Output Functions Example >1 REM EXAMPLE PROGRAM >30 PUSH 1 : REM REMOTE NODE ADDRESS = 1 >40 PUSH 0 : REM OFFSET = 0 >50 PUSH 10 : REM WORDLENGTH = 10 >60 PUSH 5 : REM THE TIME-OUT VALUE = 0.5 SECONDS >70 CALL 93 : REM WRITE DATA FROM BASIC OUTPUT BUFFER >80 POP R : REM GET THE OUTPUT ARGUMENT >90 IF R<>0 THEN PRINT READ ERROR CODE = ”,R...
  • Page 175 Output Functions 12-25 If port PRT1 is configured for DH485 protocol, this CALL has IMPORTANT no effect. Syntax PUSH [buffer selection] CALL 96 Example >1 REM EXAMPLE PROGRAM >10 PUSH 0 : CALL 96 : REM CLEAR PRT1 OUTPUT BUFFER READY >...
  • Page 176 12-26 Output Functions Example >1 REM EXAMPLE PROGRAM >100 PUSH 1 : REM TURN ON LED1 >110 PUSH 0 : REM TURN OFF LED2 >120 CALL 112 : REM SET THE LEDS READY >RUN READY > CALL 114 – Transmit DF1 Purpose Packet Use CALL 114 to transmit the DF1 data packet.
  • Page 177 Output Functions 12-27 Example >1 REM EXAMPLE PROGRAM >10 CALL 114 >20 END CALL 115 – Check DF1 Purpose XMIT Status 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.
  • Page 178 12-28 Output Functions CALL 123 – Write to Purpose Remote DF1 PLC Data Use CALL 123 to write up to 64 words of data from the CPU output image file, File the CPU M0 file, and/or a string within the module to a remote DF1 node ®...
  • Page 179 Output Functions 12-29 3. 3. 3. 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. 4. 4. 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.
  • Page 180: Common Interface File

    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).
  • Page 181 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.
  • Page 182 12-32 Output Functions Table 12.11 Transaction Status Codes Code Indicates Transfer OK. Transmission failed. Enquiry timeout. With handshaking selected – either a loss of CTS signal while transmitting or a fatal transmitter failure occurred. Without handshaking selected – a fatal transmitter failure occurred. Transmission failure due to modem disconnection (DCD signal loss for more than 10 seconds) if modem handshaking with constant carrier is selected.
  • Page 183 Output Functions 12-33 Table 12.11 Transaction Status Codes Code Indicates Address reference exists to deleted area. Command execution failure for unknown reason; PLC-3 histogram overflow. Data conversion error. The scanner is not able to communicate with a 1771 chassis adapter. The adapter is not able to communicate with the module.
  • Page 184 12-34 Output Functions Example >1 REM EXAMPLE PROGRAM >10 REM ENABLE DF1 PLC REMOTE WRITE COMMAND >20 PUSH 5 : REM PLC-5 FILE >30 PUSH 0 : REM PLC-5 NODE ADDRESS >40 PUSH 7 : REM PLC-5 FILE NUMBER >50 PUSH ASC(N) : REM PLC-5 FILE TYPE >60 PUSH 0 : REM STARTING WORD OFFSET FOR PLC-5...
  • Page 185: Print

    Output Functions 12-35 PRINT 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.
  • Page 186 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 READY > The A was printed and then overwritten by the B. Use the PRINT SPC( ) expression to output a specified number of spaces.
  • Page 187: Ph0., Ph1

    Output Functions 12-37 >1 REM EXAMPLE PROGRAM >10 PRINT USING(###.##), >20 PRINT 4.67890, 123.456 >30 PRINT .0123, .234 >40 PRINT 123.456, 2.1 READY >RUN 4.67 123.45 0.01 0.23 123.45 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.
  • Page 188 12-38 Output Functions Syntax PH0., PH1. Example >PH0.2*2 >PH1.2*2 0004H >PH0. 100 >PH0. 1000 3E8H >PH1. 1000 03E8H >PH1. 3E8 3.0 E+8 >PH0. PI > 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.
  • Page 189 Output Functions 12-39 P. MTOP-10*6 24455 >PUSH 24455 : CALL 77 >P. MTOP 24455 >1 REM EXAMPLE PROGRAM >5 DIM A(10),B(10) >10 REM *** ARRAY SAVE *** >20 FOR I = 0 TO 9 >30 A(I) = I+20 >40 PUSH A(I) : REM PUT NUMBER ON STACK >50 ST@ 5FFFH–I*6 >60...
  • Page 190 12-40 Output Functions Publication 1746-RM001A-US-P...
  • Page 191 Chapter 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 If you need (to) Use this Page...
  • Page 192: Input Functions

    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.
  • Page 193 Input Functions 13-3 2. 2. 2. 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...
  • Page 194 13-4 Input Functions 6. 6. 6. 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...
  • Page 195 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.
  • Page 196 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 •...
  • Page 197 Input Functions 13-7 Example >1 REM EXAMPLE PROGRAM >10 REM ENABLE CALL 22 INTERRUPTS >20 PUSH 1 : REM PRT1 ACTIVE FOR CALL 22 >30 PUSH 10 : REM RECEIVING 10 BYTES OF DATA MAXIMUM >40 PUSH 13 : REM <CR> USED AS TERMINATION CHARACTER (13 DECIMAL) >50 PUSH 1 : REM SEND DATA TO M1 FILE...
  • Page 198: Call 27 - Read Remote Dh485 Slc Data File

    13-8 Input Functions CALL 27 – Read Remote Purpose DH485 SLC Data File 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.
  • Page 199 Input Functions 13-9 4. 4. 4. 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. 5. 5. 5. The module sets the input file word 0, bit 10 to inform the SLC processor that valid data is available.
  • Page 200 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).
  • Page 201 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.
  • Page 202 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.
  • Page 203: Call 29 - Read/Write To A Plc/Slc From The Module Internal String

    Input Functions 13-13 T4:0 0000 Timer On Delay Timer T4:0 Initiate CALL 27 in the Time Base 0.01 Preset 1000 module every 10 seconds via Accum timer T4:0. CALL 27 Request Bit T4:0 0001 Status OK Buffer Data if Status OK I:1.0 0002 Equal...
  • Page 204 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.
  • Page 205 Input Functions 13-15 CALL 35 – Get Numeric Purpose Input Character from Use CALL 35 to retrieve the current character in the 256 character input buffer of PRT2 port PRT2. It returns the decimal representation of the characters received as its output argument.
  • Page 206 13-16 Input Functions Example 2 >1 REM EXAMPLE PROGRAM >10 REM PERIPHERAL PORT INPUT USING CALL 35 >20 STRING 200,20 >30 DIM D(254) >40 CALL 35 : POP X >50 IF X <>2 GOTO 40 >55 REM WAIT FOR DEVICE TO SEND START OF TEXT >60 >70 >80...
  • Page 207 Input Functions 13-17 CALL 53 – Transfer CPU Purpose Output Image to BASIC Use CALL 53 to transfer words 0 to 7 of the CPU output image table to words 200 Input Buffer to 207 of the module input buffer. This routine has no input arguments and one output argument.
  • Page 208 13-18 Input Functions CALL 56 – Transfer CPU Purpose M0 File to BASIC Input Use CALL 56 to transfer up to 64 words starting at word 0 of the CPU M0 file to Buffer the module input buffer starting at word 100. This routine has one input argument and one output argument.
  • Page 209 Input Functions 13-19 CALL 84 – Transfer Purpose DH485 Interface File to Use CALL 84 to transfer up to 40 words starting at the designated offset of the BASIC Input Buffer DH485 Common Interface File to the module input buffer starting at the same designated offset from word 0.
  • Page 210 13-20 Input Functions CALL 90 – Read Remote Purpose DH485 Data File to Use CALL 90 to read up to 40 words from the designated node address, file BASIC Input Buffer number, file type, and element offset of a remote DH485 data file to the module input buffer starting at word 0.
  • Page 211 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).
  • Page 212 13-22 Input Functions Table 13.7 Output Argument Decimal Hexadecimal Description Output Output Target node cannot respond because length requested is too large. Target node cannot respond because target node denies access. Target node cannot respond because requested function is currently unavailable. module detects illegal target file type.
  • Page 213: Call 92 - Read Remote Dh485 Common Interface File To Basic Input Buffer

    Input Functions 13-23 CALL 92 – Read Remote Purpose DH485 Common Use CALL 92 to read up to 40 words from the remote DH485 Common Interface Interface File to BASIC File of the designated node address, starting at the designated word offset to the Input Buffer module input buffer starting at word 0.
  • Page 214 13-24 Input Functions Table 13.8 Output Argument Decimal Hexadecimal Description Output Output Successful Completion. Target node cannot accept the message at this time. Target node cannot respond because message is too large. Target node cannot respond because it does not understand the command parameters.
  • Page 215 Input Functions 13-25 Example >1 REM EXAMPLE PROGRAM >30 PUSH 1 : REM REMOTE NODE ADDRESS = 1 >40 PUSH 0 : REM OFFSET = 0 >50 PUSH 10 : REM WORD LENGTH = 10 >60 PUSH 5 REM TIME-OUT VALUE = 0.5 SECONDS >70 CALL 92 >80 POP R : REM GET THE OUTPUT ARGUMENT >90 IF (R<>0) THEN PRINT “READ ERROR CODE IS”,R : REM PRINT...
  • Page 216: Call 118 - Plc/Slc Unsolicited Writes

    13-26 Input Functions CALL 118 – PLC/SLC Purpose Unsolicited Writes 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.
  • Page 217 Input Functions 13-27 3. 3. 3. 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. 4. 4. 4. The module sets the input file word 0, bit 12 to inform the SLC processor that valid data is available.
  • Page 218 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.
  • Page 219 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.
  • Page 220: Call 122 - Read Remote Df1 Plc Data File

    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...
  • Page 221 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.
  • Page 222 13-32 Input Functions 5. 5. 5. 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.
  • Page 223 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.
  • Page 224 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.
  • Page 225 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 •...
  • Page 226 13-36 Input Functions Table 13.12 Transaction Status Codes Code Indicates Illegal address format – symbol is 0 or greater than the maximum number of characters supported by this device. Illegal address – address does not exist or does not point to something usable in this command.
  • Page 227 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]...
  • Page 228: Get

    13-38 Input Functions T4:0 0000 Timer On Delay Timer T4:0 Time Base 0.01 Initiate CALL 122 in the module Preset 1000 every 10 seconds via timer T4:0. Accum CALL 122 Request Bit T4:0 0001 Buffer Data if Status OK 0002 Equal Copy File Source A...
  • Page 229: Inpl

    Input Functions 13-39 Syntax 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 [A] 49 [1] 24 [^X] 50 [2] STOP - IN LINE 30 READY >...
  • Page 230: Inps

    13-40 Input Functions Example >1 REM EXAMPLE PROGRAM >10 STRING 270,254 : REM ONE STRING OF < 254 BYTES >20 INPL $(0) : REM READ LINE FROM PROGRAM PORT >30 PRINT# $(0) : REM ECHO STRING TO PORT PRT2 INPS Purpose Use the INPS statement to read an entire string of characters from the program port buffer.
  • Page 231 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 on the console device.
  • Page 232 13-42 Input Functions ENTER A NUMBER - 25 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...
  • Page 233 Input Functions 13-43 This instruction is not associated with any port designation. IMPORTANT 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].
  • Page 234 13-44 Input Functions READY >RUN READY >PUSH 5FFFH : CALL 77 >P. MTOP 24575 Publication 1746-RM001A-US-P...
  • Page 235: Read

    Input Functions 13-45 READ 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.
  • Page 236 13-46 Input Functions Publication 1746-RM001A-US-P...
  • Page 237 Chapter 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.
  • Page 238: Setup Functions

    14-2 Setup Functions Example >1 REM EXAMPLE PROGRAM >10 REM CALL 30 INPUT PARAMETERS: >20 REM FIRST PUSH : 5, 6, 7, OR 8 (BITS/CHARACTER) >30 REM SECOND PUSH : 0, 1, OR 2 (NO PARITY, ODD, OR EVEN) >40 REM THIRD PUSH : 1, 2, OR 3 (1, 2, OR 1.5 STOP BITS) >50 REM FOURTH PUSH: 0 OR 1 (SOFTWARE HANDSHAKING...
  • Page 239: Call 99 - Reset Print Head Pointer

    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 Purpose Head Pointer Use CALL 99 to reset the internal print head character counter of your printer when printing out wide forms.
  • Page 240: Call 105 - Reset Prt1 To Default Settings

    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.3 PRT1 Port Parameter Default Settings PRT1 Port Parameters Default Setting Baud rate...
  • Page 241: Mode

    Setup Functions 14-5 MODE Purpose Use the MODE command to set the port parameters of ports PRT1, PRT2, and DH485. You must ensure that buffer space is available anytime that you IMPORTANT are printing data out of the serial port using hardware handshaking or software handshaking (Xon/Xoff).
  • Page 242 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 arg2 (module node address) 1 to 31 arg3 (maximum node address ) 1 to 31 arg4 (not used) arg5 (storage type) Store information in user ROM and RAM (E).
  • Page 243: String Functions

    Chapter 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...
  • Page 244: Call 61 - String Append

    15-2 String Functions Example >1 REM EXAMPLE PROGRAM >10 REM STRING REPEAT EXAMPLE PROGRAM >20 STRING 200,48 >30 $(1) = “*” >40 PUSH 40 : REM THE NUMBER OF TIMES TO REPEAT CHARACTER >50 PUSH 1 : REM BASE STRING NUMBER >60 CALL 60 >70 PRINT $(1) >80 END...
  • Page 245: Call 62 - Number To String Conversion

    String Functions 15-3 Example >1 REM EXAMPLE PROGRAM >10 STRING 200,20 >20 $(1) = “How are ” >30 $(2) = “you?” >40 PRINT “BEFORE ” >50 PRINT “$(1) = ”,$(1) >60 PRINT “$(2) = ”,$(2) >70 PUSH 2 : REM STRING NUMBER TO BE APPENDED >80 PUSH 1 : REM BASE STRING NUMBER >90...
  • Page 246: Call 63 - String To Number Conversion

    15-4 String Functions Example >1 REM EXAMPLE PROGRAM >10 STRING 100,14 >20 INPUT “ENTER A NUMBER TO CONVERT TO A STRING ”,N >30 PUSH N : REM NUMBER TO CONVERT TO STRING >40 PUSH 1 : REM CONVERT NUMBER TO STRING 1 >50 CALL 62 : REM DO THE CONVERSION >60 PRINT $(1) >70 END...
  • Page 247 String Functions 15-5 Example >1 REM EXAMPLE PROGRAM >20 INPUT “INPUT A STRING TO CONVERT ”,$(1) >30 PUSH 1 : REM CONVERT STRING 1 >40 CALL 63 >50 POP V,N >60 IF (V<>0) THEN PRINT $(1),“ ” N:GOTO 80 >70 PRINT “INVALID OR NO VALUE FOUND” >80 END READY >RUN...
  • Page 248: Call 64 - Find A String In A String

    15-6 String Functions CALL 64 – Find a String Purpose in a String 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.
  • Page 249: Call 65 - Replace A String In A String

    String Functions 15-7 CALL 65 – Replace a Purpose String in a String 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.
  • Page 250: Call 66 - Insert A String In A String

    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.
  • Page 251: Call 67 - Delete A String In A String

    String Functions 15-9 CALL 67 – Delete a Purpose String in a String 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.
  • Page 252: Call 68 - Find The Length Of A String

    15-10 String Functions CALL 68 – Find the Purpose Length of a String 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.
  • Page 253: String

    String Functions 15-11 STRING 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 message is generated.
  • Page 254 15-12 String Functions Examples >1 REM EXAMPLE PROGRAM >10 STRING 100,30 >20 $(0) = “-----MONTHLY REPORT-----” >30 PRINT $(0) READY >RUN -----MONTHLY REPORT----- READY > Publication 1746-RM001A-US-P...
  • Page 255 Appendix Decimal/Hexadecimal/Octal/ASCII Conversion Table Mathematical The table below lists the decimal, hexadecimal, octal, and ASCII conversions. Conversion Overview Column1 Column 2 Column 3 Column 4 ‘ “ & ‘ < > Publication 1746-RM001A-US-P...
  • Page 256 Decimal/Hexadecimal/Octal/ASCII Conversion Table Publication 1746-RM001A-US-P...
  • Page 257 Appendix BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic List The table below lists the various mnemonics found in this manual along with a description and location. Overview Mnemonic Required PUSHes or POPs Description Active In Page Command Mode Only ABS( ) Absolute value...
  • Page 258 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Page Command Mode Only CALL 24 PUSH [value to be converted] BASIC floating-point to 16-bit signed integer PUSH [word number of module output buffer] CALL 25 PUSH [value to be converted] BASIC floating-point to 16-bit binary...
  • Page 259 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Page Command Mode Only CALL 40 PUSH [hours] Set clock/calendar time (hour, minute, second). 10-1 PUSH [minutes] PUSH [seconds] CALL 41 PUSH [date] Set clock/calendar date (day, month, year). 10-2 PUSH [month] PUSH [year]...
  • Page 260 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Page Command Mode Only CALL 64 PUSH [string number to be found] Find a string in a string. 15-6 PUSH [base string number] POP [match position] CALL 65 PUSH [new string number] Replace a string in a string.
  • Page 261 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Page Command Mode Only CALL 90 PUSH [remote device node address] Read remote DH485 data file to BASIC input 13-20 PUSH [remote device file number] buffer.
  • Page 262 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Page Command Mode Only CALL 108 PUSH [operational code] Enable DF1 driver communications. 11-12 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]...
  • Page 263 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Page Command Mode Only CALL 123 PUSH [type of PLC WRITE command] Write to a PLC data file. 12-28 PUSH [remote PLC node address] PUSH [file number of remote PLC] PUSH [file type on remote PLC] PUSH [starting word offset on remote PLC]...
  • Page 264 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Page Command Mode Only 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.
  • Page 265 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Page Command Mode Only 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 8-14 greater than ONTIME argument-line number.
  • Page 266 B-10 BASIC Command, Statement, and CALL Quick Reference Guide Mnemonic Required PUSHes or POPs Description Active In Page Command Mode Only Specify a remark or comment line. 4-19 Renumber BASIC program. 4-20 RESTORE RESTORE read point. RETI Return from interrupt. 8-18 RETURN RETURN from subroutine.
  • Page 267 Index Symbols # and @ backplane conversion data quick reference guide BASIC Floating-Point to 16-Bit Binary B-10 special function operator BASIC Floating-Point to 16-Bit Signed Integer 3-15 .AND. BASIC Module Interrupt logical operator BASIC program quick reference guide line B-10 .OR.
  • Page 268 Index CALL 112 - User LED Control CALL 19 - Disable Control-C output function BASIC command 12-25 quick reference guide quick reference guide CALL 113 - Disable DF1 Driver Communications CALL 20 - Enable Processor Interrupt quick reference guide execution control and interrupt support function status function quick reference guide 11-18...
  • Page 269 Index CALL 37 - Clear PRT2 Input/Output Buffers CALL 56 - Transfer CPU M0 File to BASIC Input Buffer output function input function 12-15 13-18 quick reference guide quick reference guide CALL 38 - Expanded ONERR Restart CALL 57 - Transfer BASIC Output Buffer to CPU M1 File execution control and interrupt support function output function 12-16...
  • Page 270 Index CALL 73 - Battery-Backed RAM Disable CALL 91 - Write BASIC Output Buffer to Remote DH485 Data command line CALL File quick reference guide output function 12-18 CALL 74 - Battery-Backed RAM Enable quick reference guide command line CALL CALL 92 - Read Remote DH485 Common Interface File to quick reference guide BASIC Input Buffer...
  • Page 271 11-12 quick reference guide DF1 Packet Interrupt CONT disable BASIC command enable quick reference guide DF1 Packet Length contacting Rockwell Automation for assistance input function 13-25 contents of manual DF1 XMIT Status control stack output function 12-27 Control-C quick reference guide...
  • Page 272 Index Disable functional operators Control-C DF1 Driver Communications expressions 11-18 DF1 Packet Interrupt Port PRT2 DTR Signal 11-11 Processor Interrupt Find a String in a String 15-6 Display Find the Length of a String 15-10 Current PRT1 Port Setup 12-24 floating-point numbers Current PRT2 Port Setup 12-14...
  • Page 273 Index hierarchy of operations input function 13-43 quick reference guide LED, user control IDLE output function 12-25 BASIC command 4-10 quick reference guide quick reference guide IF-THEN-ELSE special function operator 3-15 control function quick reference guide assignment function INPL quick reference guide input function 13-39 LIST...
  • Page 274 viii Index MTOP quick reference guide PH0.@ special function operator 3-16 quick reference guide Multiply (*) PH1. arithmetic operator quick reference guide quick reference guide B-10 PH1.# quick reference guide PH1.@ quick reference guide Negation (-) PHO. arithmetic operator quick reference guide PHO.,PH1.
  • Page 275 8-18 quick reference guide B-10 functional operator 3-11 quick reference guide B-10 BASIC command 4-19 Rockwell Automation quick reference guide contacting for assistance RAM/ROM Return READ BASIC command 4-20 input function 13-45 quick reference guide...
  • Page 276 3-16 12-26 TIME trigonometric operators 3-17 3-17 functional operator 3-10 quick reference guide B-10 troubleshooting output function contacting Rockwell Automation 12-38 quick reference guide B-10 STOP execution control and interrupt support function 8-20 quick reference guide B-10 Publication 1746-RM001A-US-P...
  • Page 277 Index Unsolicited Writes Write BASIC Output Buffer to Remote DH485 Data File 13-26 12-18 Upload User Memory Module Code to Host Write Output Buffer to Remote DH485 Common Interface File User LED Control 12-25 12-22 User Memory Module Check and Description Write to Remote DF1 PLC Data File 12-28 Write to Remote DH485 SLC Data File...
  • Page 278 Index Publication 1746-RM001A-US-P...
  • Page 280 Back Cover Publication 1746-RM001A-US-P - April 2000 Supercedes Publication 1746-6.3 - November 1994 © 2000 Rockwell International Corporation. Printed in the U.S.A.

This manual is also suitable for:

Allen-bradley slc 500 basic-t1746-bas1746-bas-t

Table of Contents