Home
1771-6.5.34, 1771–DB Basic Module, User Manual
Contents
1. 5 4 14 Statements ON expr GOTO In num In num In num ON expr GOSUB In num In num ln num 5 4 15 Statements IF THEN 5410 Statement INPUT uua d opua dp 5 4 17 Statement LD 5 418 Statement LET ER RE RA 5 4 19 Statement ONERR In 5 4 20 Statement ONTIME expr ln 5 4 21 Statement PRINT or P 5 4 22 Special Print Formatting Statements 5 4 22 1 PRINT TAB lexpr 5122 2 5 4 22 2 52 55552 5 55 wees 5 4 22 4 PRINT USING special characters 501225 PRINT USING FX 5 4 22 6 5 555 227 PRINT USING 0 5 4 22 8 Reset Print Head Pointer CALL99 5 4 23 Statement PRINTHorP 5 4 24 Statements PHO PH1 1 5 4 25 Statement PUSH expr iv Table of Contents 5 4 26 Statement POP var 54 21 Statement REM det 5 4 28 Statement RET 5 4 19 Statement ST
2. 47 5 9 9 Retrieve Day of Week Numeric CALL 48 5 9 10 Date Retrieve String CALL 52 5 10 Description of String Operators 5 10 1 The ASC 5 10 2 The CHR 5 10 2 1 Clearing the Screen on an Allen Bradley Industrial Terminal 5 10 2 2 Cursor Positioning on an Industrial Terminal 5 10 3 String Support 5 10 3 1 String Repeat CALL 60 Table of Contents 5 10 3 2 String Append Concatenation CALL 61 5 10 3 3 Number to String Conversion CALL 62 5 10 3 4 String to Number Conversion CALL 63 5 10 3 5 Find a String ina String CALL 64 5 10 3 6 Replace a String a String CALL 65 5 10 3 7 Insert String in a String CALL 66 5 10 3 8 Delete String from a String CALL 67 5 10 3 9 Determine Length ofa String CALL 68 5 11 Memory Support Calls 5 11 1 ROM to RAM Program Transfer CALL 70 5 11 2 ROM RAM to ROM Program Transfer CALL 71 5 11 3 RAM ROM Return CALL 72 5 11 4 Battery backed RAM Disable CALL 73 5 11 5 Battery backed RAM Enable CALL 74 5 11 6 Protected
3. 54 30 5tatemenE STOP ri dos E exo ead 5 4 31 Statement STRING act 5 5 Description of Arithmetic and Logical O perators 5 5 1 Dual Operand dyadic Operators 5 5 1 1 Comments on logical operators AND OR and XOR 5 5 2 Unary rcr erarus trinii See or RR ad 5 5 2 1 General Purpose Operators 5522 Log FUNCIONS 12x credi wee worn 5 5 2 3 FH FUNCHONS saisisit 5 5 2 4 Comments on Trig Functions 5 5 3 Understanding Precedence of Operators 5 5 4 How Relational Expressions 5 6 Special Operators 5 6 1 Special Function Operators ETE 5 6 2 System Control 5 MAN 55 arene ate 5022 LEN gia og Stn da EC e edi d 5 7 Data Transfer Support Routines 5 7 1 Update Block Transfer Read Buffer timed CALL 2 5 7 2 Update Block Transfer Write Buffer timed CALL 3 5 7 3 Set Block Transfer Write Length CALL4 5 7 4 Set Block Transfer Read Length CALL5 5 7 5 Update Block Transfer Write Buffer CALL6 5 7 6 Update Block Transfer Read Buffer CALL7 5 7 7 Disable Interrupts CALL 8
4. Table of Contents vii Data 7 1 Chapter Objectives 1 2 Qutp t Data TYPES acs unnan ees 7 2 1 16 bit Binary 4 Hex Digits 7 2 2 3 digit Signed Fixed Decimal BCD 7 2 3 4 digit Unsigned Fixed Decimal BCD 1 23 3 010916 Signed Octa esa caa e rho nt 7 2 5 6 digit Signed Fixed 7 2 6 3 3 digit Signed Fixed Decimal BCD L3 Input Data 5 Editing A 8 2 Chapter Objectives 8 2 Entering the EditMode 8 3 Editing Commands Features 83 2 REPAGE E OE E EP LO PIERDE XS 9 3 3 SEI o oda did b duce io ORA 8 34 Delete a eR Ry ERG ARR 5 3 5 RalyDB is orsa xia s ARR 8 3 6 AREE 6 3 7 RENUMDE 8 4 Editing a Simple Procedure Error Messages and Anomalies 9 1 Chapter Objectives 9 2 Error Messages from BASIC 9 3 Error Messages from CALL Routines 9 3 1 Data Conversion CALL ErrorMessages 9 3 2 Peripheral P
5. wB001 0030 RUNG NUMBER RM1 XOR XOR AXORB R AXORB R l WB001 0030 wB001 0020 0000000010000100 0000000000000000 B WB001 0030 wB001 0020 1 0000000010000100 0000000000000000 WB001 0030 R wB001 0020 0000000010000100 0000000000000000 RUNG NUMBER RM2 BTW CNTL BLOCK XFER WRITE LE RACK 002 o2 GROUP 1 MODULE 1 HIGH DN DATA FB002 0150 05 LENGTH 10 CNTL FB001 0030 03 RUNG NUMBER RM3 BTR CNTL BLOCK XFER READ RACK 002 12 GROUP 1 MODULE 1 HIGH DN DATA FB002 0220 15 LENGTH 2 cnTL CNTL FB001 0020 ER 13 6 4 1 Rung Description for Sample PLC 3 Family Ladder Logic Single Data Set 6 5 PLC 5 Family Processors Chapter 6 Programming Rung 1 Rung one is true only at power up It uses status word 3 bit 3 the AC power loss bit of the PLC 3 to zero the control file of both the BTR and BTW Rungs 2 and 3 During normal program execution the BTW and BTR instructions are alternately executed The done bits of each instruction enable the next block transfer instruction The BTR and BTW con
6. 2 7182818 THE X 10 FOR TO STEP 5 22 SET UP FOR NEXT LOOP FOR A 1TO 5 er ls 50 READ CONSOLE es GOSUB 5 23 EXECUTE SUBROUTINE GOSUB 1000 GOTO 5 24 GOTO PROGRAM LINE NUMBER GOTO 5000 F THEN ELSE 5 25 CONDITIONAL TEST F A lt C THEN A 0 NPUT 5 26 INPUT A STRING OR VARIABLE NPUT A NT 6 45 INTEGER NT 3 2 LD 5 28 LOAD VARIABLE LD 14335 LEN 5 52 READ THE NUMBER OF BYTES OF MEMORY IN THE PRINT LEN CURRENT SELECTED PROGRAM LET 5 29 ASSIGN A VARIABLE OR STRING A VALUE LET IS LET 10 OPTIONAL LIST 5 7 LIST PROGRAM TO THE CONSOLE DEVICE LIST LIST 10 50 LIST 5 8 LIST PROGRAM TO SERIAL PRINTER LIST LIST 50 106 5 46 NATURAL LOG LOG 10 TOP 5 52 READ THE LAST VALID MEMORY ADDRESS PRINT MTOP EW 5 9 ERASE THE PROGRAM STORED IN RAM EW NEXT 5 22 TEST FOR NEXT LOOP CONDITION NEXT A NOT 5 45 ONE S COMPLEMENT NOT 0 ULL 5 9 SET NULL COUNT AFTER CARRIAGE RETURN LINE FEED NULL NULL 4 ONERR 5 30 Pn OR GOTO LINE NUMBER ONERR 1000 ON GOTO 5 25 DITIONAL GOTO ON A GOTO 5 20 be GOSUB H 25 ND OU GENERATE AN INTERRUPT WHEN TIME IS EQUALTO OR ONTIME 10 1000 REATER THAN ONTIME ARGUMENT LINE NUMBER IS AFTER COMMA Appendix A Quick Reference Guide Mnemonic PHO PH1 PHO PH1 PI POP PRINT READ REM RET bearer RND ROM RUN SGN SIN SQR STQ STOP STRING TAN TIME UNTIL WHILE XFER Description PRINT HEX MODE WITH ZERO SUPPRESSION PRINT HE
7. 9 3 5 Battery 10 Using the Serial Ports 1 1 4 1 Chapter Objectives we detur 1 1 4 2 Using BASIC Module Program and Peripheral Communication Ports Lii 4 2 1 Pin Descriptions 2 3 Program oui ad Pacem d Rete 3e 3 1 5 4 3 Program Port continued 1 6 4 3 1 Using the XOFF XON Commands forthe Program Port l 7 4 3 2 Connecting a T3 T4 Industrial Terminal to the Program Port 4 3 3 Connecting a T30 Industrial Terminal Cat No 1784 T30 to the Programi OIL es Rica Table of Contents 4 3 4 Connecting a T50 Industrial Terminal Cat No 1784 T50 to the Program Port 4 3 4 1 Configuring the Software 23 5 WAITING td eh denver Whe 4 4 4 4 1 Using the XON XOFF Commands for the Peripheral Port 4 4 2 Connecting A T30 Industrial Terminal 1784 130 to the Peripheral Port 44 2 1 Hardware Configuration 4 4 3 Connecting a 1770 SA SB Recorder to the Peripheral Port 4 4 4 Connecting a 1770 HC Printer to the Peripheral Port 4 4 5 Connecting RS 422 4 5 Cable Ass
8. Figure 7 4 Truncated 4 Digit Octal Integer 17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 5 De E N implied i 1 decimal point Octal Value not used underflow bit 1 value is fractional and between 1 1 ie 999 to 999 sign bit 1 negative 0 positive overflow bit 1 value gt 4095 15034 7 3 Chapter 7 Data Types 7 2 5 This value requires two words of the processor data table The first word Aigi i contains overflow underflow and sign data and the three most significant 6 digit Signed g g Fixed Decimal BCD digits of the 6 digit BCD integer The second word contains the lower three digits of the value figure 7 5 The value ranges from 999999 to 99999 If an overflow or underflow condition exists the appropriate bit is set and a value of 000000 is reported Fractional portions of any number used with this routine are truncated Figure 7 5 Truncated 6 Digit BCD Integer 17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 00 Word 1 Upper Half BCD Value not used underflow bit 1 value is fractional and between 1 and 1 ie 999 to 999 sign 1 negative 0 positive overflow bit 1 value gt 999999 17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 00 Word 2 D1 implied Decimal Point Lower Half BCD Value 15035 7 4 Chapter 7 Data Types 7 2 6 This value requires t
9. 5 7 8 Enable Interrupts CALL 9 5 7 9 Input Call Conversion 5 7 9 1 3 Digit Signed Fixed Decimal BCD to Internal Floating Point CALL 10 5 7 9 2 16 Bit Binary 4 digit hex to Internal Floating Poll 5 7 9 3 4 Digit Signed Octal to Internal Floating PONE XXXX PECES 5 7 9 4 6 Digit Signed Fixed Decimal BCD to Internal Floating Point XXXXXX CALL 13 5 7 9 5 4 Digit BCD to Internal Floating Point XXXX CALL 17 5 7 10 Output Call Conversion Routines 5 7 10 1 Internal Floating Point to 3 Digit Signed Fixed Decimal BCD CALL 20 xis caus Rare ER Y ia Table of Contents 5 7 10 2 Internal Floating Point to 16 Bit Unsigned Binary 4 digithex CALL21 5 7 10 3 Internal Floating Point to 4 Digit Signed 22_ 5 7 10 4 Internal Floating Point to 6 Digit Signed Fixed Decimal BCD CALL23 5 7 10 5 Internal Floating Point to 3 3 digit Signed Fixed Decimal BCD AXX XXX 26 Een RR Ru 5 7 10 6 Internal Floating Point to 4 digit BCD XXXX CALL 27 5 8 Peripheral Port Support 5 8 1 Peripheral Port Support Parameter Set CALL30 5 8 2 Peripheral Port Supp
10. 10 END gt 100 PRINT TIMER INTERRUPT AT TIME SECONDS gt 110 ONTIME TIME 2 100 RETI gt RUN TIMER INTERRUPT AT 2 045 SECONDS TIMER INTERRUPT AT 4 045 SECONDS TIMER INTERRUPT AT 6 045 SECONDS TIMER INTERRUPT AT 8 045 SECONDS TIMER INTERRUPT AT 10 045 SECONDS READY The terminal used in this example runs at 4800 baud This baud rate allows about 45 milliseconds to print the message TIMER INTERRUPT AT The resulting printed time is 45 milliseconds greater than the planned time Chapter 5 Operating Functions 5 4 20 If you do not want this delay you should assign a variable to the special Statement ONTIME function operator TIME at the beginning of the interrupt routine expr In num continued Example gt 10 TIME 0 CLOCK1 ONTIME 2 100 DO gt 20 WHILE TIME lt 10 END gt 100 A TIME gt 110 PRINT TIMER INTERRUPT A SECONDS gt 120 A 2 100 RETI gt RUN TIMER INTERRUPT 2 SECONDS TIMER INTERRUPT 4 SECONDS TIMER INTERRUPT 6 SECONDS TIMER INTERRUPT 8 SECONDS TIMER INTERRUPT 10 SECONDS READY Important You must exit the ONTIME interrupt routine with a RET I statement Failure to do this locks out all future interrupts The ONTIME statement eliminates the need for you to test the value of the TIME operator periodically throughout the BASIC program 5 4 21 COMMAND and or RUN
11. Communication between a programmable controller and the T30 Industrial Terminal using the BASIC Module requires two data transfers We use block transfer read and write instructions for bi directional data transfer between the programmable controller data table and the BASIC Module We use an RS 423 RS 232 communication link for bi directional data transfer between the BASIC Module and the industrial terminal Refer to the Plant Floor Terminal Application Data publication number 1784 4 1 for more information 4 9 Chapter 4 Using the Serial Ports 4 4 2 Connecting A T30 Industrial Terminal 1784 T30 to the Peripheral Port continued 4 4 2 1 Hardware Configuration You must configure the BASIC Module peripheral port and the T30 Industrial Terminal serial port in the same way for proper communications to occur We configure the peripheral port on the BASIC Module as follows full default setting 1 Handshaking disabled Configure the T30 Industrial Terminal serial port the same way Refer to the following figure 4 8 for T30 Serial Port BASIC Module Peripheral Port connections Figure 4 8 T30 Serial Port BASIC Module Peripheral Port Connections T30 Industrial Terminal BASIC Module Serial Port Program Port Shield sssr Kl Minimum connections 15039 Important Jumper the T30 Industrial Terminal and BASIC Module pins 4 and 5 if you do not use them 4 4 3 Connecting a 1770 SA SB Recorder to the Peri
12. Important When X you transfer programs from X EPROM to RAM you lose X the previous X RAM contents Since the ROM command does NOT transfer a program to RAM it X is possible to have different X programs in X ROM and RAM simultaneously You can X move back X and forth between the two modes when in command mode If you are in run mode you can change X back X and forth using CALLS 70 71 and 72 You can also use all of the RAM memory for variable storage if the program is stored in EPROM The X system control value MTOP always refers X to RAM The system control value LEN refers X to the currently X selected program in RAM or X ROM Chapter 5 Operating Functions 5 3 12 Command XFER 5 3 13 Command PROG Action X taken The XFER transfer command transfers the current selected X program in X EPROM to X RAM and x then selects the RAM mode If X you type X XFER while X the BASIC Module X is in the RAM mode the X program stored in RAM is X transferred back into RAM and the RAM mode X is X selected After the XFER command executes you can edit X the program in the same way you edit any RAM program Important The XFER command X clears existing RAM programs Important Before X you attempt to program a X PROM read the PROG PROGI x and x PROG2 sections of this chapter Some PROG options exclude X the use of others Action X taken The PROG command X programs the resident EPROM with the current X program X T
13. gt 10 STRING 100 10 gt 20 FOR 1 1 5 gt 30 ASC 0 65 gt 40 NEXT I gt 45 ASC 0 6 0DH gt 50 PRINT 0 or gt 10 STRING 100 10 gt 15 0 gt 20 FOR 1 5 730 ASC 00 65 gt 40 gt 50 PRINT 00 The following three programs allow you to determine how much string space to allocate when you know two of three variables associated with the strings number of characters in the longest string number of string variables amount of memory to allocate for strings Chapter 5 Operating Functions 5 10 3 Example program 1 String Support Calls continued gt LIST 10 REM STRING ALLOCATION COMPUTATION KNOWING 20 REM 1 CHARACTERS IN LONGEST STRING 2 OF STRING VARIABLES 30 PRINT PRINT 40 INPUT HOW MANY CHARACTERS IN YOUR LONGEST STRING C 50 INPUT HOW MANY STRING VARIABLES WILL YOU NEED V 60 PRINT 70 N C 1 V 1 REM COMPUTE THE OF BYTES OF MEMORY NEEDED 80 PRINT PRINT 90 PRINT YOU NEED TO ALLOCATE N BYTES OF MEMORY FOR V VARIABLES 100 PRINT CONTAINING C CHARACTERS EACH 110 PRINT PRINT 120 PRINT STRING N C 130 END gt RUN HOW MANY CHARACTERS IN YOUR LONGEST STRING 721 HOW MANY VARIABLES WILL YOU NEED 715 YOU NEED TO ALLOCATE 331 BYTES OF MEMORY FOR 15 VARIABLES CONTAINING 2 CHARACTERS EACH STRING 331 21 READY Chapter 5 Operating Functions 5 10 3 Example progr
14. Statement PRINT or P Type INPUT OUTPUT The PRINT statement directs the BASIC Module to output 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 Examples gt PRINT 10 10 3 3 gt PRINT MCS 51 gt PRINT 5 1E3 100 9 MCS 51 5 1000 Important Values are printed next to one another with two intervening blanks A PRINT statement with no arguments sends a carriage return line feed sequence to the console device 5 4 22 Special Print Formatting Statements Chapter 5 Operating Functions The following sections list and describe the special print formatting statements 5 4 22 1 PRINT TAB expr Use the TAB expr function in the PRINT statement to cause data to print out in exact locations on the output device TAB expr tells the BASIC Module which position to begin printing the next value in the print list If the printhead or cursor is on or beyond the specified TAB position the module ignores the TAB function Example gt PRINT 5 10 4 X Y 5 4 22 2 PRINT SPC expr Use the SPC expr function in the PRINT statement to cause the BASIC Module to output the number of spaces in the SPC argument Exam
15. value of 10 to the array size All arrays are set equal X to zero X when the RUN command NEW command or the CLEAR statement is executed The number of bytes allocated X for an array is 6 times X the array size X plus 1 The array 100 requires 606 bytes of storage Memory X size usually limits the size of a dimensioned X array Variations More than one variable X can be dimensioned X by a single DIM statement Example gt 10 DIM A 25 B 15 A1 20 Example Default error on attempt to re dimension X array gt 10 A 5 10 BASIC ASSIGNS DEFAULT OF 10 TO ARRAY SIZE HERE 720 DIM A 5 ARRAY CANNOT BE RE DIMENSIONED gt RUN ERROR ARRAY SIZE IN LINE x 20 20 DIM X A 5 X 5 4 8 Mode x RUN Statements DO UNTIL Type X CONTROL rel expr The DO UNTIL X rel expr instruction provides a means of loop control X within a module X program X statements between X the DO and X the UNTIL rel expr X are executed until the relational X expression following the UNTIL statement is TRUE You may nest DO UNTIL loops Chapter 5 Operating Functions 5 4 8 Statements DO UNTIL rel expr continued Examples SIMPLE DO UNTIL gt 10 0 gt 20 DO gt 30 1 gt 40 PRINT A gt 50 UNTIL A 4 gt 60 PRINT DONE gt 70 END gt RUN WN DONE READY NESTED DO UNTIL gt 10 gt 20 1 gt 30 gt 40 1 gt 50 PRINT A B A
16. wy Allen Bradley 1771 DB Basic Module User Manual Table of Contents Using This 1 1 Chapter Objectives 1 2 Whatthis manual contains 13 AUBSI S os orsa itin d Macer Vici RM 14 Definitions of 5 1 5 1 1 6 Conventions Introducing the BASIC Module 2 1 Chapter Objectives 2 2 General Features 2 3 Hardware 2 4 Software Features Installing the BASIC Module 3 2 Installing BASIC module 3 2 1 Power Requirements 3 2 2 Module Location the 1 0 Chassis 3459 Module 32 oues teat dew 3 2 4 Configuration Plugs 3 2 5 Module Installation 3 2 6 Initial Start up Procedure 3 3 Medus LEDS RESO RR 6 3 4 Installing the User Prom 3 4 1 Electrostatic Discharge 9 3 5 BOB
17. 20 INPUT NAME CR X AGE 1 A gt 30 PRINT HELLO 1 x YOU ARE A YEARS x OLD gt 40 END gt RUN AGE x FRED 15 HELLO FRED x YOU x ARE 15 x YEARS OLD READY gt 5 4 17 Mode COMMAND AND OR x RUN Statement LD expr This statement along with CALL 77 allows you to save retrieve variables X to from a protected X area of memory This protected X area is not zeroed on power up X or when the RUN command is issued The LD statement takes X the variable stored at address X expr and moves it X to the top of the argument stack X For more information on protecting variables X see section 5 11 6 Protected Variable Storage x CALL 77 5 4 18 Statement LET Chapter 5 Operating Functions Mode COMMAND AND OR X RUN Type X ASSIGNMENT Use the X LET statement X to assign a variable to the value of an expression X The general X form of X LET is LET var expr Examples LET A 10 SIN B 100 X or 1 Note that the sign X used in the LET statement X is not an equality operator It is a replacement operator The statement X should X be read is X replaced by A plus one The word LET is always optional X i e LET A 2 is the same as X 22 When LET is X omitted x the LET statement is called an IMPLIED LET We use X the word LET to refer X to both the LET statement X and the x IMPLIED LET statement Also use the LET statement to
18. B gt 60 UNTIL 3 gt 70 B 0 gt 80 UNTIL 3 gt 90 END gt 111 122 133 212 224 236 313 326 339 READY gt 5 4 9 Statements WHILE rel expr continued Mode RUN Type CONTROL Chapter 5 Operating Functions The DO WHILE rel expr instruction provides a means of loop control within a module program The operation of this statement is similar to the DO X UNTIL rel expr except that all X statements between the DO and the x WHILE rel expr are executed as long as the relational X expression following the WHILE statement X is true You can nest X DO WHILE and DO x UNTIL statements Examples SIMPLE DO WHILE gt 10 gt 20 1 gt 30 PRINT A gt 40 WHILE At4 gt 50 PRINT DONE gt 60 END gt RUN gt DONE READY NESTED DO WHILE DO UNTIL gt 10 gt 20 PRINT A A 1 gt 25 gt 30 1 gt 40 A B A B gt 50 WHILE B lt gt 3 gt 60 B 0 gt 70 UNTIL 3 gt 80 END gt RUN 111 122 133 212 224 236 313 326 339 READY gt Chapter 5 Operating Functions 5 4 10 Statement END 5 4 11 Statements FOR TO STEP NEXT Mode RUN Type CONTROL The END statement X terminates program execution X The continue comm and CONT does X not operate X if the END statement X is used to terminate execution A CAN T CONTINUE ERROR prints to the console The las
19. CALL 63 This routine converts the first decimal number found in the specified string to a number on the argument stack Valid numbers and associated characters 0 1 2 3 4 5 6 7 8 9 comma is not a valid number character and terminates the conversion Two bytes are POPed after the CALL validity of the value actual value If the string does not contain a legal value a zero is returned A valid value is between 1 and 255 PUSH the number of the string to convert Two POPs are required First POP the validity value then POP the value If a string contains a number followed by an E followed by a letter or non numeric character it is assumed that no number was found since the letter is not a valid exponent UAB701EA returns a zero in the first argument popped indicating that no valid number was in the string Example gt 10 STRING 100 14 gt 20 INPUT ENTER A STRING TO 1 730 PUSH 1 REM CONVERT STRING 1 740 CALL 63 REM DO THE CONVERSION 250 POP VN gt 60 IF V lt gt 0 THEN PRINT 1 N GO TO 80 gt 70 PRINT INVALID OR NO VALUE FOUND 80 END Chapter 5 Operating Functions 5 10 3 5 10 3 5 String Support Calls Find a String in a String CALL 64 continued This routine finds a string within a string It locates the first occurrence position of this string This call expects two input arguments The first is the string to be found t
20. EN l File ccc ppp 2 11 donee DN 1 source 2 destination 15043 6 3 1 1 Rung Description Rungs 1 and 2 The first two rungs of the sample program toggle the requests for block transfer writes BTW and block transfer reads BTR The interlocks shown do not allow a BTR and BTW instruction to enable at the same time 3 When a BTR successfully completes its done bit sets enabling the file to file move instruction The file to file move instruction FFM moves the BTR data file File CCC DDD into a storage data file EEE FFF This prevents the programmable controller from using invalid data if a block transfer communication fault occurs 6 3 Chapter 6 Programming 6 3 1 Figure 6 2 PLC 2 Processor Program Sample BASIC Module Program continued gt 5 DIM A 10 gt 10 REM SET BTW LENGTH TO 10 WORDS gt 20 PUSH 10 CALL 4 gt 30 SET BTR LENGTH 2 WORDS gt 40 PUSH 2 CALL 5 gt 50 REM READ THE BTW BUFFER gt 60 CALL 6 gt 70 REM CONVERT DATA FROM 3 DIGIT SIGNED BCD TO DB FORMAT gt 80 FOR I 1 TO 10 DO gt 90 PUSH CALL 10 POP gt 100 NEXT I gt 110 REM DO A CALCULATION gt 120 T A 1 A 2 A 3 A 4 A 5 A 6 A 7 A 8 A 9 A 10 V T 10 gt 130 REM CONVERT DATA FROM DB FORMAT TO 3 DIGIT SIGNED BCD gt 140 PUSH T PUSH 1 CALL 20 gt 150 PUSH V PUSH 2 CALL 20 gt 160 REM WRITE TO THE BTR BUFFER gt 170 CALL7 gt 180 RE
21. LIST 32 10 20 H 10 9 7 Chapter 9 Error Messages and Anomalies 9 4 Anomalies continued 2 When using the variable I before an ELSE statement put a space between the I and the ELSE statement If you do not the program assumes that the IE portion of IELSE is the special function operator IE This error may or may not yield a BAD SYNTAX IN LINE XXX error message depending on the particular program in which it is used Examples Wrong gt 20 IF I gt 10 THEN PRINT IELSE 100 gt LIST 20 IF I gt 10 THEN PRINT I ELSE 100 Right gt 20 IF gt 10 THEN PRINT I ELSE 100 gt LIST 20 IF I gt 10 THEN PRINT I ELSE 100 3 Do not place a space character inside the ASC operator A statement like PRINT ASCO yields a BAD SYNTAX ERROR You can put spaces in strings however allowing the following statement to work properly LET 1 gt HELLO HOW ARE YOU ASCO yields an error because the module eliminates all spaces when a line is processed ASC is stored as ASC and the module interprets this as an error 4 Do not use the following one letter variables B F R Unpredictable operation could result 5 Do not use the following two letter variables CR DO IE IF IP ON PI SP TO UI and UO 6 When using an INPUT statement to enter data you must be sure to enter valid data If you enter invalid data you see the prompt TRY AGAIN This disrupts the screen layout 7 SQR M M2 gives a ba
22. PHO and 1 function the same as PHO and PHI respectively except that the output is directed to the list device instead of the console device The baud rate and peripheral port parameters must match your deyice See Chapter 3 Section 3 2 4 titled Configuration Plugs and Chapted 5 Section 5 8 1 titled Peripheral Port Support Parameter Set CALL 30 Examples gt 2 2 gt 1 2 2 gt 99 gt 100 04H 0004H 153 64H gt 1000 gt PH1 1000 gt 3E8H gt PHO PI 3E8H 03E8H 1000 03H Chapter 5 Operating Functions 5 4 25 Statement PUSH expr SWAPPING VARIABLES gt 10 A 10 gt 20 20 gt 30 PRINT A B gt 40 PUSH A B gt 50 POP A B gt 60 PRINT A B gt 70 END gt RUN 10 20 20 10 READY gt CALL ROUTINE gt 10 PUSH 3 gt 20 CALL 10 gt 30 POP W Mode COMMAND AND OR RUN Type ASSIGNMENT The arithmetic expression or expressions following the PUSH statement are evaluated and then placed in sequence on the BASIC Module s ARGUMENT STACK This statement in conjunction with the POP statement provides a simple means of passing parameters to assembly language routines In addition the PUSH and POP statements are used to pass parameters to BASIC subroutines and to SWAP variables The last value PUSHed onto the ARGUMENT STACK is the first value POPed off the ARGUMENT STACK Variations You can push more than one expression onto the ARGUMENT
23. RUN SGN 5 SIN 3 14 SQR 100 STQ 14335 STOP STRING 50 10 TAN 0 PRINT TIME TIME 0 UNTIL A 10 WHILE XFER 1 1 10 2 2 4 4 2 8 4 10 AND 5 2 0R 1 3 XOR 2 25 2 lt Decimal Hexadecimal Octal ASCII Conversion Table Column 4 HEX Column 3 Column 2 HEX Column 1 HEX ASC DEC OCT ASC DEC 100 101 OCT DEC ASC NUL SOH OCT 000 001 DEC 041 t MO XO oO A NH cO Cc 9 Aa O oO O O oO oO dO oO o r rr rr rm rm orm or orm orm orm orm opm or cO c Cc M st wu r CO Q O c N M t THO c O M 8 OO OO O c c c c c c c c CO coc lt Aa Llu O ro St mom WO CO O lt O co CX TF NNT HN Hn HH Nn MH Hw xt i XO CO c co i0 CO cC c ceo XO r cO x wm cS See 96 1 st i oO r V t ai XO COO C g
24. UNDERFLOW ERROR CODE 40 BAD ARGUMENT You can examine this location X by using an XB Y 257 statement Example PRINT XBY 257 Or E XBY 257 5 4 20 Statement ONTIME expr In num Chapter 5 Operating Functions Mode RUN Type CONTROL Your BASIC Module can process a line in milliseconds while the timer counters on the microprocessor operate in microseconds You must use the ONTIME expr In num statement because of this incompatibility between the timer counters on the microprocessor and the BASIC Module The ONTIME statement generates an interrupt every time the special function operator TIME is equal to or greater than the expression following the ON TIME statement Only the integer portion of TIME is compared to the integer portion of the expression This comparison is performed at the end CR or of each line of BASIC The interrupt forces a GOSUB to the line number In num following the expression expr in the ONTIME statement Important The ONTIME statement does not interrupt an input command or a CALL routine Since the ONTIME statement uses the special function operator TIME you must execute the CLOCK1 statement for ONTIME to operate If CLOCKI is not executed the special function operator TIME does not increment You can generate periodic interrupts by executing the ONTIME statement again in the interrupt routine Example gt 10 TIME 0 ONTIME 2 100 DO 720 WHILE TIME
25. Use terminating resistors only at the ends of the link if using multiple RS 422 devices and at both ends if using point to point connections Chapter 4 Using the Serial Ports 4 5 You must supply cables for connecting devices to the program and Cable Assembly Parts peripheral ports You can construct the cables with the parts listed in Table 4 1 Table 4 1 Cable assembly parts for connection to the program and peripheral ports Manufacturer s Part Number 25 pin female connector Cannon type DB 255 or equivalent 25 pin male connector Cannon type DB 25P or equivalent Plastic Hood Amp type 205718 1 2 twisted pair 22 gauge Cat No 1778 CR Belden 8723 or equivalent Do not use for individually shielded cable cable RS 422 connections 5 1 Chapter Objectives 5 2 Definition of Terms 5 2 1 Commands 5 2 2 Statements Chapter 5 Operating Functions After reading this chapter you should be familiar with the BASIC instruction set and be ready to begin BASIC programming X This chapter is a reference section X to help you with module programming You should X already X be familiar with BASIC programming The following sections define the following terms commands statements format X statements X data format X integers constants operators variables expressions relational expressions X system control X values argument stack and control stack The BASIC module operates X in two modes the X c
26. continued gt 10 REM PERIPHERAL PORT INPUT USING CALL 35 gt 20 STRING 200 20 730 DIM D 254 gt 40 CALL 35 POP X gt 50 IF X lt 2GOTO 40 gt 55 REM WAIT FOR DEVICE TO SEND START OF TEXT gt 60 REM gt 70 DO gt 80 I I 1 gt 90 CALL 35 POP D I REM STORE DATA IN ARRAY gt 100 UNTIL 1 3 REM WAIT FOR DEVICE TO SEND END OF TEXT gt 120 REM gt 130 REM FORMAT AND PRINT DATA TYPES gt 140 PRINT RAW DATA gt 150 FOR J 1 TOI PRINT D J NEXT J gt 155 REM PRINT RAW DECIMAL DATA gt 160 PRINT PRINT PRINT gt 170 PRINT ASCII DATA gt 180 FOR J 1 TOI PRINT CHR D J NEXT J gt 185 REM PRINT ASCII DATA gt 190 PRINT PRINT PRINT gt 200 PRINT 1 gt 210 FOR J 1 TOI ASC 1 D 2D J NEXT J gt 215 REM STORE DATA IN STRING gt 220 PRINT 1 gt 230 PRINT PRINT PRINT gt 240 I 0 gt 250 REM gt 260 GOTO 40 READY gt RUN RAW DATA 65 66 67 68 69 70 71 49 50 51 52 53 54 55 56 57 3 ASCII DATA ABCDEFG 123456789 5 1 ABCDEFG 123456789 READY Chapter 5 Operating Functions 5 8 7 Use this routine to retrieve the number of characters in the chosen buffer as Get the Number of its output argument You must PUSH which buffer is to be examined Characters in the Peripheral a PUSH 1 for the input buffer Port Buffers CALL 36 a PUSH for the output buffer One POP is required to get the number of characters Example gt 10
27. operators and single operand unary operators The general form of all dual operand instructions is expr OP expr where OP is one of the following operators Addition Operator Example PRINT 3 2 5 a Division Operator Example PRINT 100 5 20 Exponentiation Operator The Exponentiation Operator raises the first expression to the power of the second expression The maximum power to which you raise a number is 255 Example PRINT 2 3 8 Multiplication Operator Example PRINT 3 3 9 Subtraction Operator Example PRINT 9 6 3 a AND Logical AND Operator Example PRINT 3 AND 2 2 a OR Logical OR Operator Example PRINT 1 OR 4 3 XOR Logical EXCLUSIVE OR operator Example PRINT 7 XOR 6 1 5 43 Chapter 5 Operating Functions 5 5 1 5 5 1 1 Comments on logical operators AND OR and XOR Dual Operand dyadic These operators perform a BIT WISE logical function on valid Operators continued INTEGERS This means both arguments for these operators are between 0 and 65535 OFFFFH inclusive If they are not the BASIC Module generates a BAD ARGUMENT ERROR non integer values are truncated not rounded Use the following chart for bit manipulations on 16 bit values Hex Decimal To set bit 0 VARIABLE WITH 0001H 1 1 0002H 2 2 0004H 4 3 0008H 8 4 0010H 16 5 0020H 32 6 0040H 64 7 0080H 128 10 0100H 256 11 0200H 512 12 0400H 1024 13 0800H
28. overflows X back to a count of zero The interrupts associated X with the statement X cause the module programs to run at about 99 6 of normal speed x That means that the interrupt handling for x the REAL TIME CLOCK feature uses about 4 of X the total CPU time CLOCKO The CLOCKO zero X statement X disables X or turns X off the real time clock feature After CLOCKO is executed X the special function operator TIME no longer X increments CLOCKO is x the only X module statement that can disable the real time clock CLEAR and x CLEARI do NOT disable the real time clock only X its associated ONTIME interrupt Important CLOCK1 and CLOCKO are independent of the X wall clock Chapter 5 Operating Functions 5 4 6 Statements DATA READ RESTORE Mode RUN Type Assignment DATA DATA specifies expressions that you can retrieve using a READ statement If multiple expressions per line are used you MUST separate them with a comma Example gt 10 10 5 ASC B 35 627 Important You cannot X use the CHR operator DATA statement READ READ retrieves the expressions X that are specified in the DATA statement and assigns X the value of the expression to the variable in the READ statement X The READ statement is X always followed X by one or more variables If more than one variable X follows X a READ statement they are separated by a comma RESTORE RESTORE rese
29. stack with a single PUSH statement The expressions are followed by a comma PUSH expr expr expr The last value PUSHed onto the ARGUMENT STACK is the last expression expr encountered in the PUSH STATEMENT Examples gt 40 REM PUSH VALUE ON STACK CALL gt 50 REM CONVERSION POP RESULT IN W gt 60 END 5 4 26 Statement POP var Chapter 5 Operating Functions Mode COMMAND AND OR RUN TYPE ASSIGNMENT The value on top of the ARGUMENT STACK is assigned to the variable following the POP statement and the ARGUMENT STACK is POPed i e incremented by 6 You can place values on the stack using either the PUSH statement or assembly language CALLS Important If a POP statement executes and no number is on the ARGUMENT STACK an A STACK ERROR occurs Variations You can pop more than one variable off the ARGUMENT stack with a single POP statement The variables are followed by a comma i e POP var var var Examples See PUSH statement above section 5 4 25 You can use the PUSH and POP statements to minimize GLOBAL variable problems These are caused by the main program and all subroutines used by the main program using the same variable names i e GLOBAL VARIABLES If you cannot use the same variables in a subroutine as in the main program you can re assign a number of variables i e A Q before a GOSUB statement is executed If you reserve some variable names just for subr
30. 110 PRINT CONTAINING C CHARACTERS EACH 120 PRINT PRINT 130 PRINT STRING N 5 C 140 END gt RUN ENTER OF BYTES OF MEMORY YOU CAN ALLOCATE FOR STRINGS 500 HOW MANY STRING VARIABLES WILL YOU NEED 15 YOU NEED TO ALLOCATE 496 BYTES OF MEMORY FOR 15 VARIABLES CONTAINING 32 CHARACTERS EACH STRING 496 32 READY Chapter 5 Operating Functions 5 10 3 5 10 3 1 String Support Calls String Repeat CALL 60 continued This routine allows you to repeat a character and place it in a string You can use the String Repeat when designing output formats First PUSH the number of times to repeat the character then PUSH the number of the string containing the character to be repeated No arguments are POPed You cannot repeat more characters than the string s maximum length gt 10 REM STRING REPEAT EXAMPLE PROGRAM gt 20 STRING 1000 50 gt 30 1 gt 40 PUSH 40 THE NUMBER OF TIMES TO REPEAT CHARACTER gt 50 PUSH 1 REM WHICH STRING CONTAINS CHARACTER gt 60 CALL 60 gt 70 PRINT 1 gt 80 END gt RUN READY Chapter 5 Operating Functions 5 10 3 5 10 3 2 String Support Calls String Append Concatenation CALL 61 continued This routine allows you to append one string to the end of another string The CALL expects two string arguments The first is the string number of the string to be appended and the second is the string number of the base string If the resulting
31. 20 FOR I 1 TO 16 PRINT CHR 1 D NEXT I gt 30 PRINT FOR I 16 TO 1 STEP 1 gt 40 PRINT CHR I D NEXT I gt RUN The BASIC Module eludoM CISAB ehT In the above example the expressions contained within the parenthesis following the CHR operator have the same meaning as the expressions in the 5 operator Unlike the ASC operator you CANNOT assign the CHR operator value A statement such as CHR 1 1 H is INVALID and generates a BAD SYNTAX ERROR Use the ASC operator to change a value in a string or use the string support call routine replace string in a string See Section 5 10 3 below titled String Support Calls for more information Important Use CHR function only in a print statement 5 10 2 1 Clearing the Screen on an Allen Bradley Industrial Terminal Refer to Appendix B at the rear of this manual In Column 1 under DEC you find that 12 equals ASCII FF form feed Type PRINT CHR 12 to clear the industrial terminal screen with a form feed 5 10 2 The CHR Operator continued 5 10 3 String Support Calls Chapter 5 Operating Functions 5 10 2 2 Cursor Positioning on an Industrial Terminal Allen Bradley Industrial Terminal Refer to the Industrial Terminal User s Manual publication number 1770 6 5 3 Table 6 3 You can control cursor positioning by typing CTRL P COLUMN ROW A The ASCII equivalent of CTRL P is DLE Using Appendix B t
32. 71 72 73 74 75 76 The numbers printed in the previous example represent the ASCII characters A through L Chapter 5 Operating Functions 5 10 1 You can also use the ASC operator to change individual characters in a The ASC Operator defined string continued Example gt 5 STRING 1000 40 gt 10 1 ABCDEFGHIJKL gt 20 PRINT 1 gt 30 ASC 1 1 275 REM DECIMAL EQUIVALENT OF K gt 40 PRINT 1 gt 50 ASC 1 2 ASC 1 3 gt 60 PRINT 1 gt RUN ABCDEFGHIJKL KBCDEFGHIJKL KCCDEFGHIJKL In general the ASC operator lets you manipulate individual characters in a string A simple program can determine if two strings are identical Example gt 5 STRING 1000 40 gt 10 1 REM SECRET IS THE PASSWORD gt 20 INPUT WHAT S THE PASSWORD 2 gt 30 FOR I 1 TO 6 gt 40 IF ASC 1 D ASC 2 D THEN NEXT I ELSE 70 gt 50 PRINT YOU GUESSED IT gt 60 END gt 70 PRINT WRONG TRY AGAIN GOTO 20 gt RUN WHAT S THE PASSWORD SECURE WRONG TRY AGAIN WHAT S THE PASSWORD SECRET YOU GUESSED IT Chapter 5 Operating Functions 5 10 2 The CHR Operator The CHRO operator converts a numeric expression to an ASCII character Example gt PRINT CHR 65 A Like the operator CHR operator also selects individual characters in a defined ASCII string Example gt 5 STRING 1000 40 gt 10 1 The BASIC Module gt
33. A gt B AND A gt C THEN By chaining together relational expressions with logical operators you can test particular conditions with one statement Important When using logical operators to link together relational expressions you must be sure operations are performed in the proper sequence 5 49 Chapter 5 Operating Functions 5 6 Special operators include special function operators and system control Special Operators values 5 6 1 Special function operators directly manipulate the I O hardware and the Special Function Operators memory addresses on the processor 5 6 1 1 GET Use the GET operator in the RUN mode It returns a result of zero in the command mode The GET operator reads the console input device If a character is available from the console device the value of the character is assigned to GET After GET is read in the program it is assigned the value of zero until another character is sent from the console device The following example prints the decimal representation of any character sent from the console Example gt 10 A GET gt 20 IF A lt gt 0 THEN PRINT REM ZERO MEANS NO ENTRY gt 30 GOTO 10 gt RUN 65 TYPE A ON CONSOLE 49 1 ON CONSOLE 24 CONTROL X ON CONSOLE 50 TYPE 2 ON CONSOLE 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
34. GOSUB GOTO ON ERR ON TIME and ON GOTO statements If the target line number does not exist or if there is insufficient memory to complete the task no lines are changed and the message RENUMBER ERROR appears on the console screen Important Because the renumber command uses the same RAM for renumbering as it does for variable and program storage available RAM may be insufficient in large programs We recommend that you renumber your program periodically during development Do not wait until it is completed 8 3 Chapter 8 Editing A Procedure 8 4 The following example shows you how to edit a simple procedure Editing a Simple Example Procedure LIST 10 REM 20 FOR 1 1 0 6 30 PRINT 40 NEXT READY gt Type EDIT 20 then RETURN EDIT 20 20 for 1TO 6 Press the space bar 18 times to move the cursor to 6 MOVE right feature Type 9 to change 6 to 9 REPLACE feature Press space bar once type STEP press space bar once type 2 Press CTRL A to exit the insert Press CTRL Q to exit the editor with the changes accepted READY Type LIST then RETURN gt LIST 10 REM 20 FOR 1to 9 STEP 2 30 PRINT 40 NEXT READY gt 8 4 Chapter 9 Error Messages and Anomalies 9 1 After reading this chapter you should be familiar with the module s error Chapter Objectives messages and anomalies 9 2 When BASIC is in the RUN mode the format of the ERROR messages is Error Messages from as
35. Internal Floating Point to 3 3 digit Signed Fixed Decimal BCD CALL 26 This routine converts a variable in internal format to a signed 6 digit fixed decimal point number which is stored in 2 words in the block transfer read buffer Two arguments are PUSHed and none POPed The first value PUSHed is the data 999 999 or variable This is followed by the number of the first word to receive the value in the block transfer read buffer The sign bit number is 16 Example gt 50 5 REM THE VALUE BE CONVERTED 3 3 DIGIT FIXED POINT gt 60 PUSH 3 WORD 3 IN THE BTR BUFFER GETS THE VALUES gt 70 CALL 26 DO THE CONVERSION Example 5 7 10 6 Internal Floating Point to 4 digit BCD XXXX CALL 27 This routine converts a value in internal floating point format to a 4 digit unsigned BCD value and places it in the read block transfer buffer Two arguments are PUSHed and none POPed The first value PUSHed is the data 0 9999 or variable This is followed by the number of the word to receive the value in the read block transfer buffer gt 20 PUSH B REM THE VALUE TO BE CONVERTED TO 4 DIGIT BCD gt 30 PUSH 7 REM WORD 7 IN THE BTR BUFFER GETS THE VALUE B gt 40 27 REM DO THE CONVERSION 5 8 Peripheral Port Support 5 8 1 Peripheral Port Support Parameter Set CALL 30 Chapter 5 Operating Functions The peripheral port is used for 1 exchanging data with an extern
36. POP L gt 100 REM USE LD AFTER POWER LOSS AND BATTERY BACK UP IS USED Chapter 5 Operating Functions 5 11 6 Example Protected Variable For using protected variable storage area Storage CALL 77 i A Scalar Variabl continued calar Variables Push all variables in one line gt PRINT MTOP 14335 gt PRINT MTOP 24 14311 gt PUSH 14311 REM NEW MTOP ADDRESS CALL 77 90 M1 14335 REM BEGIN STORING HERE 100 PUSH A D Use the ST and LD commands in a DO loop 2200 DO 2210 ST MI 2220 1 1 6 REM EACH VARIABLE 6 BYTES 7230 UNTIL MIZMTOP REM YOU DEFINED THE NEW MTOP W CALL 77 7290 M1 14335 2300 DO 2310 LD MI 2320 MI 1 6 7330 UNTIL MTOP gt 360 POP A B C D gt 370 PRINT A B C D Chapter 5 Operating Functions 5 11 6 Protected Variable Storage CALL 77 continued 5 12 Miscellaneous Calls 5 12 1 Program Port Baud Rate CALL 78 B Arrays Use an array to set up the data gt PRINT MTOP 14335 gt PRINT MTOP 24 14311 gt PUSH 14311 REM NEW MTOP ADDRESS CALL 77 100 DIM A 4 110 DATA 10 20 30 40 120 FOR I 1 4 READ A D NEXT I Use ST and LD commands in a DO loop gt 190 M1 14335 gt 200 DO gt 210 PUSH A D ST 22012I 1 MI MI 6 7230 UNTIL I 4 gt 290 M1 14335 gt 300 DO gt 310LD MI POP 1 gt 320 PRINT 1 gt 3301 1 1 1 1 6 gt 340 UNTIL I 10 The following sections lis
37. PRINT I gt 40 NEXT I gt 50 END READY gt LIST 20 40 gt 20 FOR I 1 gt 30 PRINT I gt 40 NEXT I Action X taken The LIST x or LIST command lists the program to the device attached to the peripheral port LIST device x All comments that X apply to the LIST command apply to the LIST or x LISTO commands We X include these commands to X permit you to make hard copy X printouts of a X program X A configuration X plug sets the baud rate and must match your list X device see section 3 2 4 titled Configuration Plugs X Also you must configure X the peripheral X port parameters to X match your X particular X list device see section 5 8 1 titled Peripheral Port X Support x Parameter Set CALL 30 5 3 5 Command NEW 5 3 6 Command NULL integer 5 3 7 Command Control C Chapter 5 Operating Functions Action taken When you enter the x BASIC Module deletes the program that X is currently stored in RAM memory In addition all variables are set equal to ZERO all strings and all BASIC evoked interrupts X are cleared The REAL TIME CLOCK x string allocation and the internal stack pointer values are not affected In general NEW cr is used to erase a program and all x variables Action taken The NULL integer command determines X how many NULL characters x 00H the BASIC Module outputs after a carriage return After initialization NULL 0 Most printer
38. PUSH 0 REM examines the output buffer gt 20 CALL 36 730 POP X REM get the number of characters gt 40 PRINT Number of characters in the Output Buffer 15 X gt 50 END 5 8 8 This routine clears either the peripheral ports input or output buffer Clear the Peripheral Ports PUSH O to clear the output buffer Input or Output Buffer CALL 37 a PUSH 1 to clear the input buffer PUSH 2 to clear both buffers Example gt 10 PUSH REM clears the output buffer gt 20 CALL 37 gt 30 END 5 8 9 Important Maximum baud rate is 2400 bps for all data recorder CALL Save Labeled Program to routines The Peripheral Port is set up in these routines and does not need Data Recorder 1770 SB only setting in BASIC See section 4 4 3 for required cable connections Tape CALL 38 verification failures result if you use a cable with different pin connections This routine is identical to the CALL 32 routine except the program is assigned an ID number 0 255 before storing it on tape This allows you to search for a specific program on a tape that contains many different programs To do this PUSH the ID number enter CALL 38 From this point on operation is identical to the CALL 32 routine See section 5 8 3 above titled Save Program to Data Recorder Call 32 for an explanation Chapter 5 Operating Functions 5 8 9 Save Labeled Program to Data Recorder 1770 SB only CALL 38 continued 5 8 10 Load
39. Variable Storage CALL 77 5 12 Miscellaneous 5 12 1 Program Port Baud Rate CALL 78 5 12 2 Blink the Active LED by Default CALL 79 5 12 3 Check Battery Condition CALL 80 5 12 4 User PROM Check and Description CALL 81 5 12 5 Reset Print Head Pointer CALL 99 5 12 6 Printthe Argument Stack CALL 109 5 12 7 Printthe Peripheral Port Output Buffer and Polls CALI Usu ed ud usd es AP Per xx 5 12 8 Printthe Peripheral Port Input Buffer and Pointer CALL 111 5 12 9 Resetthe Peripheral Port to Default Settings CALL 119 x Ra Programming 452232 nde wake kae ord o ac 1 ChapterO Dectes 13 S ewed espe ES ERA DRE 6 2 Block Transfer with the BASIC Module 6 2 1 Block Transfer Write and Block Transfer Read Buffers 6 3 Block Transfer with PLC 2 Family Processors 6 3 1 PLC 2 Processor Program 6 3 1 1 Rung Description 6 4 PLC 3 Family 550 5_ 6 4 1 Rung Description for Sample PLC 3 Family Ladder Eogic Single Data S ti 24d exte be RR te o 6 5 PLC 5 Family Processors 6 5 1 Rung Description for Sample PLC 5 Family Ladder Logic 6 6 Block Transfer Programming
40. a 50 foot maximum cable length for connections from either the program or peripheral ports Refer to the specifications section in Chaptel 2 For cable length recommendations Chapter 4 Using the Serial Ports 4 2 Using the BASIC Module Program and Peripheral CAUTION Be sure you properly ground the system before Communication Ports turning on power A difference in ground potential between the continued BASIC Module serial connectors and your program terminal or other serial device can cause damage to the equipment or loss of module programs 4 2 1 Use the following pins for connections made to the program or peripheral Pin Descriptions ports Refer to figure 4 2 for pin descriptions Not all signals are available on both ports Signal states are mark logical 1 voltage space logical 0 voltage Connect this pin to chassis ground for shielding purposes TXD is an RS 423A compatible serial output port RXD is an RS 423A compatible serial input data port RTS is an RS 423 compatible hardware handshaking output line This line changes to a mark 1 state when the BASIC Module has data in the output queue and is requesting permission to transmit to the data communications equipment CTS is an RS 423A compatible hardware handshaking input line This line must be in a mark 1 state for the BASIC Module to transmit on the peripheral port If no corresponding signal exists on the data communications equipment conn
41. are PUSH the value to be converted PUSH the word position of the processor block transfer file to be converted 1 64 CALL the appropriate output conversion The data format of the converted value of each of the output conversion routines is described in more detail in Chapter 7 Use these output call conversion routines to load the BTR buffer before executing a CALL 7 or CALL 2 5 7 10 Output Call Conversion Routines continued Chapter 5 Operating Functions 5 7 10 1 Internal Floating Point to 3 Digit Signed Fixed Decimal BCD XXX CALL 20 This routine has two input arguments and no output arguments The first argument is the variable with a value in the range of 999 to 999 that is converted to a signed 3 digit binary coded decimal format used by the processor The second input argument is the number of the word to receive the value in the read block transfer buffer The sign bit is bit number 16 Example gt 20 PUSH W DATA TO BE CONVERTED gt 30 6 REM WORD LOCATION TO GET DATA gt 40 CALL 20 5 7 10 2 Internal Floating Point to 16 Bit Unsigned Binary 4 digit hex CALL 21 This routine takes a value between 0 and 65535 and converts it to its binary representative and stores this in the read block transfer buffer in one word Two arguments are PUSHed and none POPed The first value PUSHed is the data or variable This is followed by the number of the word to receive the value
42. assign the string X variables LET 1 THIS x IS A STRING or LET 2 1 Before X you can assign strings you must execute the STRING expr expr statement or else a MEMORY ALLOCATION ERROR occurs See the following X section X 5 4 31 titled STRING Chapter 5 Operating Functions 5 4 19 Statement ONERR In num Mode RUN Type CONTROL The ONERR In num X statement lets you handle X arithmetic errors if they occur during program execution X Only ARITH OVERFLOW ARITH UNDERFLOW x DIVIDE BY ZERO and BAD ARGUMENT errors X are trapped x by the ONE RR X statement X other errors are not trapped If an arithmetic error X occurs after the ONE RR statement X is executed X the module interpreter passes control to the line number following the ONERR In num statement You handle the error condition in a manner suitable to the particular X application The ONERR command X does not trap X bad data X entered during an input instruction X This yields a TRY AGAIN x message X or EXTRA IGNORED X message X See Chapter explanation of errors With the x ONERR In num statement X you have the option of determining what X type of error X occurred Do this X by examining external X memory location 257 101H X after the error X condition X is trapped The error codes are ERROR CODE z10 X DIVIDE BY ZERO ERROR CODE 20 ARITH OVERFLOW ERROR x CODE x 230 ARITH
43. current program from X RAM MEMORY Important RAM X space X is limited to 13 bytes Use the following formula X to calculate the available X user RAM space LEN system X control X value which contains X current RAM program length bytes allocated X for strings X first X value in the STRING instruction 6 each array X size X 1 X asterisk X multiply 8 each variable X used including X each array name 1024 number of x bytes reserved x for BASIC V Available X user X RAM MTOP V 5 3 11 2 ROM When you enter ROM integer X the BASIC Module X selects the current program out X of EPROM memory If X no integer X is typed after the ROM command i e X ROM the module defaults X to ROM 1 X Since the programs are X stored X in sequence X in EPROM the integer X following the ROM command X selects X which program the user wants to X run or list If you attempt X to select a program that does not exist X e g you type in ROM 8 and only X 6 programs are stored X in the EPROM the message ERROR PROM MODE is X displayed The module X does not transfer X the program from EPROM to RAM when the ROM mode X is X selected X If you attempt to alter a program in the ROM mode by typing in a line X number the message ERROR PROM MODE displays x The XFER command allows X you to transfer a program from X EPROM to RAM for X editing X purposes X You get no error message if X you attempt to edit a line of ROM program
44. default length is 5 words Example gt 10 PUSH 10 gt 20 CALL 4 This routine sets the number of words 1 64 to transfer between the BASIC Module and the host processor The processor program block transfer length must match the set value Only one argument is input the number of words to BTR and none returned If not used the default length is 5 words Example gt 10 PUSH 10 gt 20 CALL 5 This routine transfers the block transfer write BTW buffer of the auxiliary processor on the BASIC Module to the BASIC BTW buffer This routine waits until a block transfer occurs if one has not previously occurred This routine transfers the block transfer read BTR buffer to the auxiliary processor on the BASIC Module for use in the next BTR request from the host processor This routine waits until a block transfer occurs Important You must use an Interrupt Control CALL 8 before a PROG command to disable interrupts This routine disables system interrupts It is mandatory for PROM programming The wall clock cannot be accessed and the peripheral port is disabled by this call Some call routines enable interrupts automatically upon completion 5 7 8 Enable Interrupts CALL 9 5 7 9 Input Call Conversion Routines Chapter 5 Operating Functions Important You must use an Interrupt Control CALL 9 after a PROG command to re enable interrupts This routine enables system interrupts It is mandatory after programmin
45. from the programmable controller and system power supplies before installing modules to avoid injury to personnel and damage to equipment Read this installation section completely before beginning Re check all option selections and connections before you begin programming Before installing your module in the I O chassis you must 1 calculate the power requirements of all the modules in each chassis Refer to Section 3 2 1 below 2 determine the location of the module in the I O chassis Refer to Section 3 2 2 below 3 key the backplane connectors in the I O chassis Refer to Section 3 2 3 below 4 setthe module configuration plugs Refer to Section 3 2 4 below Chapter 3 Installing the BASIC Module 3 2 1 Power Requirements 3 2 2 Module Location in the I O Chassis 3 2 3 Module Keying 3 2 Your module receives its power through the 1771 I O chassis backplane from the chassis power supply It does not require any other external power supply to function When planning your system you must consider the power usage of all modules in the I O chassis to prevent overloading the chassis backplane and or power supply Each BASIC module requires 1 5 A at 5V DC Add this to the requirements of all other modules in the I O chassis CAUTION Do not insert or remove modules from the I O chassis while system power is on Failure to observe this rule may result in damage to module circuitry You can place your
46. in the BASIC Module is IE 127 For example 1E 80 1E 80 causes an UNDERFLOW error ARRAY SIZE An ARRAY SIZE error occurs if an array is dimensioned by a DIM statement and you attempt to access a variable that is outside of the dimensioned bounds Example gt DIM A 10 7 Print A 11 ERROR ARRAY SIZE READY BAD ARGUMENT A BAD ARGUMENT error occurs when the argument of an operator is not within the limits of the operator For example SQR 12 generates a BAD ARGUMENT error because the value of the SOR argument is limited to positive numbers BAD SYNTAX A BAD SYNTAX error occurs when either an invalid BASIC Module command statement or operator is entered and BASIC cannot process the entry Check to make sure that all entries are correct C STACK A C STACK CONTROL STACK error occurs if the control stack pointer is forced out of bounds you attempt to use more control stack than is available in the module you execute a RETURN before a GOSUB a WHILE or UNTIL before a DO or a NEXT before a FOR you jump out of loop structures such as DO WHILE CAN T CONTINUE A CAN T CONTINUE error appears if you edit the program after halting execution and then enter the CONT command you enter CTRL C while in a call routine You can halt program execution by either entering CTRL C or by executing a STOP statement Normally program execution continues after entering the CONT c
47. in the read block transfer buffer Example gt 50 PUSH REM THE VALUE TO CONVERTED TO 16 BINARY gt 60 WORD 3 IN THE BTR BUFFER GETS THE VALUE gt 70 CALL 21 REM DO THE CONVERSION 5 7 10 3 Internal Floating Point to 4 Digit Signed Octal XXXX Call 22 This routine converts a value from internal format to a four digit signed octal value Two arguments ar PUSHed and non POPed The first value PUSHed is the data 77778 or variable This is followed by the number of the word to receive the value in the read block transfer buffer The sign bit is bit number 16 Example gt 50 PUSH REM THE VALUE TO CONVERTED TO 4 DIGIT SIGNED OCTAL gt 60 WORD 3 IN THE BTR BUFFER GETS THE VALUE gt 70 CALL 22 REM DO THE CONVERSION Chapter 5 Operating Functions 5 7 10 Output Call Conversion Routines continued gt 20 PUSH 654321 OR gt 30 PUSH 3 gt 40 CALL 23 5 7 10 4 Internal Floating Point to 6 Digit Signed Fixed Decimal BCD XXXXXX CALL 23 This routine converts an internal 6 digit signed integer to a 2 word format and places the converted value in the read block transfer buffer Two arguments are PUSHed and none POPed The first value PUSHed is the data or variable This is followed by the number of the word to receive the value in the read block transfer buffer The sign bit is bit number 16 Example gt 20 PUSH 1 gt 30 PUSH 3 gt 40 CALL 23 5 7 10 5
48. must use a terminal driver package to configure the industrial terminal serial port and communications protocol to match the BASIC Module These packages include the ability to upload to and download from the hard or floppy disk drives in the industrial terminal To upload and download you must 1 configure the software 2 construct a cable with the pin connections shown in figurd4 5 under Wiring 3 use the upload and download commands of the driver package 4 3 4 Connecting T50 Industrial Terminal Cat No 1784 T50 to the Program Port continued Chapter 4 Using the Serial Ports 4 3 4 1 Configuring the Software Configure the driver package for compatibility with the BASIC Module by setting baud rate 9600 baud recommended parity none data bits 8 start bits 1 stop bits 1 To download to the BASIC Module you must use a line wait function The industrial terminal waits for the gt BASIC Module prompt before sending the next line to the module You must enter a line delay of 1 5 seconds for terminal drivers that do not have the wait for character function so that you do not lose subsequent lines Most drivers allow storage of the complete set of parameters in a file for later recall The industrial terminal stores the BASIC Module program in a text file on the hard or floppy disc depending on where you store the terminal driver package We recommend
49. on the 1770 HC Printer switch selectable Refer to your printer manual You can find more information on printing reports and listing programs in Chapter 5 of this manual The BASIC Module can communicate with various RS 422 devices RS 422 signals for both sending and receiving data are located on the module s peripheral port Figure 4 9 hows point to point signal connections The RS 422 port floats i e no voltages are applied to the output when it is not sending characters This allows you to connect two transmitting devices on the same line Also you can connect more than one device in a multi drop configuration figuee 4 10 4 11 Chapter 4 Using the Serial Ports 4 4 5 Connecting RS 422 Devices Figure 4 9 continued Point to Point RS 422 Connections Up to Circuit Pin 4000 RXD BASIC Module Note Connect 1000 termination resistor across RXD if not internal to device 15045 Figure 4 10 Multi drop configuration with master and multiple slaves Slaves Master TXD RXD TXD RXD TXD RXD TXD 15041 Important When you use the peripheral port as a 422 port you must connect pin 4 to pin 5 on the port When using an RS 422 interface you must install termination resistors at each end of the line The module has a jumper selectable termination resistor Refer to figure 3 2 Use a cable with 2 twisted pairs and a nominal impedance of 100 ohms Important
50. selected instead of RAM To use this routine a insert the cassette cartridge into the recorder and rewind enter CALL 32 The terminal responds with POSITION TAPE AND PRESS WRITE RECORD ON TAPE Press RECORD The module begins sending data to the recorder An asterisk is displayed on the terminal as each program line is sent to the recorder During this time the DATA IN LED on the data recorder and the XMIT LED on the front of the module illuminate When the last line of program is sent to the recorder a final asterisk is displayed on the terminal indicating that the save operation is complete Finally tape motion ceases and the BASIC prompt gt gt is displayed Press STOP if you are using 1770 5 Recorder Important If there is no program in RAM the module displays the message ERROR NO BASIC PROGRAM EXISTS Important Maximum baud rate is 2400 bps for all data recorder CALL routines The Peripheral Port is set up in these routines and does not need setting in BASIC See section 4 2 2 2 for required cable connections This routine is used to verify the current RAM program with a previously stored program on the data recorder To use this routine insert the cassette cartridge into the recorder and rewind enter CALL 33 The terminal responds with POSITION AND PRESS READ FROM TAPE Chapter 5 Operating Functions 5 8 4 Verify Program with Data Recorder CALL 33 continue
51. string is longer than the maximum string length the append characters are lost There are no output arguments This is a string concatenation assignment Example 1 1 2 gt 10 STRING 200 20 gt 20 1 How are gt 30 2 you gt 40 PRINT 750 PRINT 1 1 2 2 gt 60 PUSH 2 REM STRING NUMBER OF STRING TO BE APPENDED gt 70 PUSH 1 REM BASE STRING NUMBER gt 80 CALL 61 REM INVOKE STRING CONCATENATION ROUTINE gt 90 PRINT AFTER gt 100 PRINT 51 8 1 2 2 gt 110 END gt RUN BEFORE 1 How are 2 you AFTER 1 How are you 2zyou READY 5 10 3 3 Number to String Conversion CALL 62 This routine converts a number or numeric variable into a string You must allocate a minimum of 14 characters for the string If the exponent of the value to be converted is anticipated to be 100 or greater you must allocate 15 characters Error checking traps string allocation of less than 14 characters only PUSH the value to be converted PUSH the number of the string to receive the value Example gt 10 STRING 100 14 gt 20 INPUT ENTER A NUMBER TO CONVERT TO A STRING N gt 30 PUSH gt 40 PUSH 1 REM CONVERT NUMBER TO STRING 1 gt 50 CALL 62 REM DO THE CONVERSION gt 60 PRINT 1 gt 70 END Chapter 5 Operating Functions 5 10 3 String Support Calls continued 5 10 3 4 String to Number Conversion
52. table with a block transfer read BTR instruction You transfer data 1 to 64 16 bit words to your module from the processor s data table with a block transfer write BTW instruction Important The module s read and write instruction enable bits must not set at the same time Your program must toggle requests for the read and write instructions as shown in the sample programs The BASIC Module processor maintains a block transfer write BTW buffer containing the values of the last BTW sent by the host processor You initialize this buffer using a CALL 4 You transfer data to the BASIC Module s buffer using CALL 6 or CALL 3 This buffer freezes and does not change when CALL 6 or CALL 3 completes This double buffering and freezing ensures that the data does not change during processing by the BASIC Module The BTW buffer remains unchanged and is accessed repeatedly by any of the data access routines provided An additional CALL 6 or CALL 3 changes the BTW buffer contents Chapter 6 Programming 6 2 1 Block Transfer Write and Block Transfer Read Buffers continued 6 3 Block Transfer with PLC 2 Family Processors 6 3 1 PLC 2 Processor Program 6 2 The BASIC Module also maintains a block transfer read BTR buffer that is the value of the next block read by the host processor The BASIC program initializes this buffer using CALL 5 and transfers the data to the BASIC Module processor for subsequent transfer to the host pro
53. these programs allows a direct interface with programmable controller ladder programs Your module uses the following devices and features terminal for programming editing system commands displaying data and interactive program dialog serial port for report generation output upload download to 1770 SA SB Recorder PLC 2 PLC 3 and PLC 5 data table reads and writes using block transfer We provide routines to use both the real time clock and the wall clock calendar The wall clock time base is seconds 2 3 Chapter 2 Introducing the BASIC Module 2 4 You can start program execution Software Features by entering commands at the interactive terminal continued at power up initialization You can store and execute programs in RAM or EPROM You can store one user program in RAM and up to 255 depending on program size independent user programs simultaneously in EPROM memory The programs run single task mode only You can generate the following data types with the BASIC Module 16 bit binary 4 hex digits a 3 digit signed fixed decimal BCD a 4 digit unsigned fixed decimal BCD 4 digit signed octal 6 digit signed fixed decimal BCD 3 3 digit signed fixed decimal BCD Refer to Chapted 7 Data Types for more information 2 5 Specifications ledlatioats integer decimal Walbelodk aceuracyecimal Formats integer decimal Tresaplagimahanggerparnenselated from esat
54. variables and or constants Operators X require X either one or two operands Typical two operand or dyadic operators include ADD x SUBTRACT MULTIPLY x and DIVIDE X We call X operators that require X only one operand unary operators Some typical x unary operators are SIN COS and ABS A variable can be aletter e g A X I a letter followed by a one dimensioned X expression e g J 4 GA A 6 I10 SIN X aletter followed by a number followed by a one dimensioned expression X e g X A1 8 P7 10 SIN X W8 A B aletter followed by a number or letter X e g AA XX X Al G8 except X for the following X combinations X CR DO IE IF IP ON PI SP TO UI and UO We refer to variables that include X a one dimensioned expression expr as dimensioned or arrayed variables We refer X to variables X that contain a letter X or a letter and a number as scalar variables Any variables entered in lower case are changed X to X upper case We refer X to variables as var The BASIC module X allocates variables X in a static manner This means that X the first time a variable X is used BASIC allocates a portion of memory 8 bytes X specifically X for that variable This memory cannot be de allocated X on a variable to variable basis This means that X if you execute X a statement e g X Q 3 you cannot X tell BASIC x that the variable no longer exists to free up the 8 by
55. where the GET operator is placed in the program There is no buffering of characters on the program port 5 6 1 2 TIME Use the TIME operator to retrieve and or assign a value to the real time clock resident in the BASIC Module After reset time is equal to 0 The CLOCK statement enables the real time clock When the real time clock is enabled the special function operator TIME increments once every 5 milliseconds The units of time are in seconds Chapter 5 Operating Functions 5 6 1 When TIME is assigned a value with a LET statement i e TIME gt 100 Special Function Operators only the integer portion of TIME is changed continued Example gt 1 enable REAL TIME CLOCK gt CLOCKO disable REAL TIME CLOCK gt PRINT TIME display TIME 3 315 gt TIME 0 set TIME 0 gt PRINT TIME display TIME 315 only the integer is changed You can change the fraction portion of TIME by manipulating the contents of internal memory location 71 47H You can do this by using a DBY 71 statement Note that each count in internal memory location 71 47H represents 5 milliseconds of TIME Continuing with the example gt DBY 71 0 fraction of TIME 0 gt PRINT TIME 0 gt DBY 71 23 fraction of TIME 3 15 ms gt PRINT TIME 1 5 E 2 Only the integer portion of TIME changes when a value is assigned This allows you to generate accurate time intervals For example if you want to create an ac
56. wiring connections The peripheral port can connect to printers figure 4 6 asynchronous modems and to SA SB recorders for program storage and retrieval figure 4 Figure 4 6 Cable Connection to 1771 HC Printer Peripheral Port Name Printer Port J2 Name Chassis Shield Ground TXD Output RD RXD Input TD Signal Common Common B Jumper pin 4 to pin 5 13312 44 Peripheral Port continued 4 4 1 Using the XON XOFF Commands for the Peripheral Port 4 4 2 Connecting A T30 Industrial Terminal 1784 T30 to the Peripheral Port Chapter 4 Using the Serial Ports Figure 4 7 Cable Connection to SA SB Recorder Peripheral Port Name 1770 SA SB Port Name Male Male Chassis Shield Shield TXD Output TD RXD Input RD RTS Output RTS CTS Input CTS DSR Input DSR Signal Common Ground DCD Input DCD DTR Output DTR Pins 9 through 19 and 21 through 25 must be unconnected 13313 Output Data The BASIC Module stops sending characters within 2 character times after receiving an XOFF Transmission resumes when XON is received Input Data The BASIC Module sends XOFF when the input buffer reaches 224 characters The module sends XON when the buffer contains less than 127 characters The BASIC Module requires CTS pin 5 to be true before data can be output If hardware handshaking is not used with your device then RTS pin 4 may be connected to CTS to satisfy this requirement Jumper pin 4 to pin 5
57. 0 allocates enough memory for 9 string variables ranging from 0 to 8 and all of the 100 allocated bytes are used Note that 0 is a valid string in the BASIC Module Refer to the following Section 5 10 titled Description of String Operators for further discussion of strings and example programs for string memory allocation Important After memory is allocated for string storage commands e g NEW and statements e g CLEAR cannot de allocate this memory Cycling power also cannot de allocate this memory unless battery backup is disabled You can de allocate memory by executing a STRING 0 0 statement STRING 0 0 allocates no memory to string variables Important The BASIC Module executes the equivalent of a CLEAR statement every time the STRING expr expr statement executes This is necessary because string variables and numeric variables occupy the same external memory space After the STRING statement executes all variables are wiped out Because of this you should perform string memory allocation early in a program during the first statement if possible If you re allocate string memory you destroy all defined variables 5 5 Description of Arithmetic and Logical Operators and Expressions 5 5 1 Dual Operand dyadic Operators Chapter 5 Operating Functions The BASIC Module contains a complete set of arithmetic and logical operators We divide the operators into two groups dual operand dyadic
58. 2 seconds the routine returns to BASIC without transferring data This routine has no input arguments and one output argument the status of the transfer A non zero returned means that no transfer occurred and the CALL timed out A zero returned means a successful transfer Example gt 10 CALL 2 gt 20 POP X gt 30 IF X lt gt 0 PRINT TRANSFER UNSUCCESSFUL This routine transfers the block transfer write BTW buffer of the auxiliary processor on the BASIC Module to the BASIC BTW buffer If no data transfer occurs within 2 seconds the routine returns to BASIC with no new data This routine has no input arguments and one output argument the status of the transfer A non zero returned means that no transfer occurred and the CALL timed out A zero returned means a successful transfer Example gt 10 CALL 3 gt 20 POP X gt 30 IF X lt gt 0 PRINT TRANSFER UNSUCCESSFUL Chapter 5 Operating Functions 5 7 3 Set Block Transfer Write Length CALL 4 5 7 4 Set Block Transfer Read Length CALL 5 5 7 5 Update Block Transfer Write Buffer CALL 6 5 7 6 Update Block Transfer Read Buffer CALL 7 5 7 7 Disable Interrupts CALL 8 This routine sets the number of words 1 64 to transfer between the BASIC Module and the host processor The processor program block transfer length must match the set value Only one argument is input the number of words to BTW and none returned If not used the
59. 2048 14 1000H 4096 15 2000H 8192 16 4000H 16384 17 8000H 32768 Example 10 OR 0100H REM SET BIT 10 To clear bit 0 AND VARIABLE WITH OFFFEH 65534 1 OFFFDH 65533 2 OFFFBH 65531 3 OFFF7H 65527 4 OFFEFH 65519 5 OFFDFH 65503 6 OFFBFH 65471 7 OFF7FH 65407 10 OFEFFH 65279 11 OFDFFH 65023 12 OFBFFH 64511 13 OF7FFH 63487 14 OEFFFH 61439 15 ODFFFH 57343 16 OBFFFH 49151 17 TFFFH 32767 Example 10 AZ A AND OF 7FFH REM CLR BIT 13 To clear all bits XOR VARIABLE WITH ITSELF Example 10 2 A XOR A REM CLR A 5 44 5 5 2 Unary Operators Chapter 5 Operating Functions We divide the unary operators into three groups general purpose log functions and trig functions 5 5 2 1 General Purpose Operators Following are the general purpose operators 5 5 2 1 1 ABS expr Returns the absolute value of the expression Examples gt PRINT ABS 5 gt PRINT 5 5 5 5 5 5 2 1 2 NOT expr Returns a 16 bit one s complement of the expression The expression must be a valid integer i e between 0 and 65535 inclusive Non integers are truncated not rounded Examples gt PRINT NOT 65000 gt PRINT NOT 0 535 65535 5 5 2 1 3 INT expr Returns the integer portion of the expression Examples gt PRINT INT 3 7 gt PRINT INT 100 876 3 100 5 5 2 1 4 SGN expr Returns a value of 1 if the argument is greater than zero zero if the argument is equal to zero and 1 if t
60. 6 4 for the sample ladder logic and Figurd 6 2 for the corresponding BASIC program You can use the BASIC program with any processor Values shown in the program are for demonstration purposes only Figurd 6 5 is an actual sample program Figure 6 4 Sample PLC 3 Family Ladder Logic Single Data Set PLC 3 AC 1 XOR A BTW cnt1 A BTR 1 Loss B BTW cntl B BTR cnti Bit R BTW cntl RsBTR enti e BTR 2 BIW DN LE EQU Data DN A BTW cntl Length B BTR cntl entl BIW 3 t DN LE c M C dj Data 1 DN Length nti Chapter 6 Programming 6 4 PLC 3 Family Processors continued Figure 6 5 Sample PLC 3 Family Ladder Diagram 50003 1 03 1 H i 1 t t 1 A B A WB001 0030 0000000010000100 WB001 0020 0000000000000000
61. CONTinue command The purpose of the STOP statement is to allow for easy program debugging More details of the STOP CONT sequence are covered in Section 5 3 2 titled Command CONT Example gt 10 FOR I 1 100 gt 20 PRINT I gt 30 STOP gt 40 NEXT I gt RUN 1 STOP IN LINE 40 READY gt CONT 2 Chapter 5 Operating Functions 5 4 30 Statement STOP continued 5 4 31 Statement STRING 5 42 Note that the line number printed out after execution of the STOP statement is the line number following the STOP statement not the line number that contains the STOP statement Mode COMMAND and or RUN Type CONTROL The STRING expr expr statement allocates 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 a MEMORY ALLOCATION ERROR is generated The first expression in the STRING expr expr statement is the total number of bytes you want to allocate for string storage The second expression gives the maximum number of bytes in each string These two numbers determine the total number of defined string variables The BASIC Module requires one additional byte for each string plus one additional byte overall The additional character for each string is allocated for the carriage return character that terminates the string This means that the statement STRING 100 1
62. F STRING CHARACTERS ALLOCATED This error occurs if you attempt to execute a CALL 43 45 or 52 anda string length of 18 8 or 9 respectively is not allocated during string allocation INVALID DATE TIME PUSHED This error occurs when you enter an invalid value for the date and or time when using CALL 40 and 41 NUMBER BYTES STRING EXCEED 254 This error occurs when using CALL 43 45 or 52 and the STRING X X command allocates more characters per string than is allowed Example 10 STRING 1000 300 INVALID NUMBER PUSHED This error occurs when you push an invalid string value or day of week value using CALL 42 43 and 52 9 3 4 String Support CALL Error Messages Chapter 9 Error Messages and Anomalies STRING NOT ALLOCATED This error occurs if you attempt to access a string that is outside the allocated string memory when using CALLs 60 61 64 65 66 67 or 68 Example gt 10 STRING 100 9 10 STRINGS ALLOCATED 0 9 gt 20 PUSH 5 12 REM REPEAT CHAR 5 TIMES IN 12 gt 30 CALL 60 gt RUN ERROR STRING NOT ALLOCATED Error occurs because STRING 12 is outside the area reserved for strings BYTES STRING EXCEED 254 This error occurs if the STRING X X command allocates more characters per string than is allowed using CALL 62 Example gt 10 STRING 1000 300 INSUFFICIENT NUMBER OF STRING CHARACTERS This error occurs if you do not use the required minimum string lengths when u
63. I 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 it is greater than PI 2 If it is then it is subtracted from PI to yield the final value If it is not then the reduced argument is the final value 5 47 Chapter 5 Operating Functions 5 5 2 Unary Operators continued 5 5 3 Understanding Precedence of Operators 5 48 Although this method of angle reduction provides a simple and economical means of generating the appropriate arguments for a Taylor series there is an accuracy problem associated with this technique The accuracy problem is noticed when the user argument is large i e greater than 1000 This is because significant digits in the decimal fraction portion of reduced argument are lost in the user arg PI INT user arg PI expression As a general rule keep the arguments for the trigonometric functions as small as possible You can write complex expressions using only a small number of parenthesis To illustrate the precedence of operators examine the following equation 443 2 In this equation multiplication has precedence over addition Therefore multiply 3 2 and then add 4 4 3 2 10 When an expression is scanned from left to right an operation is not performed until an operator of lower or equal precedence is encountered In the example you cannot perform addition because multiplication has high
64. IC Module Data Conversion CALL routines After reading this chapter you should be able to interpret and manipulate the data values generated by your module Converted data is exchanged with programmable controllers using block transfers You can generate the following data types with the BASIC Module a 16 bit binary XXXX a 3 digit signed fixed decimal BCD XXX a 4 digit unsigned fixed decimal BCD XXXX a 4 digit signed octal XXXX a 6 digit signed fixed decimal BCD XXXXXX a 3 3 digit signed fixed decimal BCD XXX XXX This value requires one word of the processor data table The data is represented by 16 straight binary bits figure 7 1 The value ranges from 0 to 65 535 No sign overflow or underflow bits are affected or decoded If you use a value larger than 65 535 or a negative number you get a BAD ARGUMENT error Figure 7 1 16 Bit Binary Word 4 digit hex 17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 00 e Binary Value 15031 Chapter 7 Data Types 7 2 2 3 digit Signed Fixed Decimal BCD 7 2 3 4 digit Unsigned Fixed Decimal BCD 7 2 This value requires one word of the processor data table The data is represented by a 3 digit binary coded decimal integer figure 7 2 Overflow underflow and sign are also indicated An underflow or overflow condition sets the appropriate bit and a value of 000 is returned The value ranges from 999 to 999 Fractional portions
65. L 44 REM INVOKE THE UTILITY ROUTINE gt 30 POP D MI Y REM GET THE DATA FROM THE 30 STACK gt 40 PRINT CURRENT DATE IS Y M1 D gt 50 END gt RUN CURRENT DATE IS 84 12 25 READY CALL 45 returns 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 Example gt 10 STRING 100 20 gt 20 PUSH 1 CALL 45 REM put time in string 1 gt 30 PRINT 1 gt 40 END Chapter 5 Operating Functions 5 9 7 Time Retrieve Number Call 46 The time of day is available in numeric form by executing a CALL 46 and POPing the three variables off of the argument stack on return There are no input arguments The time is POPed in hour minute and second order Example gt 10 REM TIME IN VARIABLES EXAMPLE REM GET THE WALL CLOCK TIME gt 20 CALL 46 gt 30 POP H M S gt 40 PRINT CURRENT TIME IS H M S 50 END gt RUN CURRENT TIME IS 13 44 54 READY 5 9 8 Retrieve Day of Week String CALL 47 5 9 9 Retrieve Day of Week Numeric CALL 48 CALL 47 returns the current day of week as a three character string PUSH the number of the string to receive the day of week You must allocate a minimum of 3 characters string Strings returned are SUN MON TUE WED THUR FRI SAT Example gt 10 PUSH 0 CALL 47 gt 20 PRINT TODAY IS 0 CALL 48 returns the current day of week on the argument stack as a num
66. Labeled Program from Data Recorder 1770 SB only CALL 39 5 8 11 Print the Peripheral Port Output Buffer and Pointer CALL 110 This routine has one input argument and no output arguments If no ID number is pushed prior to CALL 38 an error occurs and the routine aborts without saving An unlabeled save CALL 32 has an ID of 0 Important Do not press rewind between programs saved If you press rewind only the last program is saved Important Maximum baud rate is 2400 bps for all data recorder CALL routines The Peripheral Port is set up in these routines and does not need setting in BASIC The Peripheral Port parameters restore when the call is complete See section 4 4 3 for required cable connections Tape verification failures result if you use a cable with different pin connections This routine is identical to the CALL 34 routine except that labeled programs are organized according to an ID number 0 255 assigned to the stored program using a CALL 38 To use this routine PUSH the ID number Enter CALL 39 From this point on operation is identical to the CALL 34 routine See Section 5 8 4 above titled Verify Program with Data Recorder CALL 33 for explanation This routine has one input argument and no output arguments If no ID number is pushed prior to CALL 38 an error occurs and the routine aborts without saving While searching for the correct program one asterisk prints for each program en
67. M CONTINUE TO BLOCK TRANSFER gt 190 GOTO 60 gt 200 END Figure 6 3 Sample PLC 2 Family Ladder Diagram LADDER DIAGRAM DUMP START 110 010 010 1 Ml 0f BLOCK XFER WRITE 16 17 DATA ADDR 0050 16 MODULE ADDR 101 BLOCK LENGTH 05 110 FILE 0200 0204 4 DN 16 110 010 010 2 1 1 1 BLOCK XFER READ 17 16 DATA ADDR 0051 17 MODULE ADDR 101 BLOCK LENGTH 02 110 FILE 0205 0206 DN 17 110 0052 3 FILE TO FILE MOVE EN 17 COUNTER ADDR 0052 17 POSITION 001 FILE LENGTH 002 0052 FILE 0205 0206 DN FILE 0207 0210 15 PER SCAN 002 END 01295 15044 6 4 6 4 PLC 3 Family Processors Chapter 6 Programming You can use the following ladder logic program with PLC 3 or PLC 3 10 processors This program assumes that your application requires a single BTR and BTW to pass data between the processor and the BASIC Module i e transfer of 64 words or less If the transferred data exceeds 64 words you must program multiple file to file moves to move different data sets to and from the block transfer files Refer to Figure
68. M PRINT THE NUMBER PRINT Important REMark statements add time to program execution Use them selectively or place them at the end of the program where they do not affect program execution speed Do not use REMark statements in frequently called loops or subroutines 5 4 28 Statement 5 4 19 Statement ST expr 5 4 30 Statement STOP Chapter 5 Operating Functions Mode RUN Type CONTROL Use the RETI statement to exit from the ONTIME interrupts that are handled by a BASIC Module program The RETI statement functions the same as the RETURN statement except that it also clears a software interrupt flag so interrupts can again be acknowledged If you fail to execute the statement in the interrupt procedure all future interrupts are ignored Mode COMMAND AND OR RUN This statement along with CALL 77 allows you to save retrieve variables to from a protected area of memory This protected area is not zeroed on power up or when the RUN command is issued The ST statement takes the argument on top of the argument stack and moves it to the address location specified by expr For more information on protecting variables see section 5 11 6 Protected Variable Storage CALL 77 Mode RUN Type CONTROL The STOP statement allows you 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
69. M STRING NUMBER OF THE STRING TO BE REPLACED PUSH 0 REM BASE STRING NUMBER CALL 65 REM INVOKE REPLACE STRING IN STRING ROUTINE PRINT AFTER 0 0 END BEFORE RED LINES AFTER 0 BLUE LINES READY Chapter 5 Operating Functions 5 10 3 5 10 3 7 String Support Calls Insert String in a String CALL 66 continued This routine inserts a string within another string The call expects three arguments The first argument is the position at which to begin the insert The second argument is the string number of the characters inserted into the base string The third argument is the string number of the base string This routine has no return arguments gt 10 REM SAMPLE ROUTINE TO INSERT A STRING IN A STRING gt 20 STRING 500 15 gt 30 0 1234590 gt 40 1 07890 gt 50 PRINT BEFORE 0 0 gt 60 PUSH 6 REM POSITION TO START THE INSERT gt 70 PUSH 1 REM STRING NUMBER OF THE STRING TO BE INSERTED gt 80 PUSH 0 REM BASE STRING NUMBER gt 90 CALL 66 REM INVOKE INSERT A STRING IN A STRING gt 91 REM REM ROUTINE gt 100 PRINT AFTER 0 0 gt 110 END gt RUN BEFORE 0 1234590 AFTER 0 1234567890 READY Chapter 5 Operating Functions 5 10 3 5 10 3 8 String Support Calls Delete String from a String CALL 67 i is routine deletes a string from within another string The call expects continued Th del gf h h g The call exp two arguments The first argument is the base
70. M size is exceeded the previously stored program may be partially altered Your module generates the following messages when an error occurs while trying to execute a CALL routine NEGATIVE VALUES NOT VALID This error occurs when you attempt to convert a negative number with CALL 21 or 27 CHECKSUM ERROR FROM RECORDER This error occurs when bad data is received from the tape while executing CALLS 33 34 or 39 You should check for correct cable connections and baud rate Also check your tape cartridge 9 3 Chapter 9 Error Messages and Anomalies 9 3 2 Peripheral Port Support CALL Error Messages continued 9 3 3 Wall Clock CALL Error Messages 9 4 IN ROM The IN ROM message displays if you attempt to load a ROM program to tape with CALL 32 or 38 You should transfer the ROM program to RAM and then load the program to tape INVALID INPUT DATA This error occurs when you enter an invalid value when using CALL 30 INVALID VALUE PUSHED This error occurs when you enter a value other then 0 1 or 2 when using CALL 37 LOAD SAVE ABORT This error occurs when you execute a CTRL C from any tape CALL 32 33 34 38 or 39 NO BASIC PROGRAM EXIST This error occurs when the BASIC Module is in RAM mode with no program in RAM and you attempt to execute a CALL 32 or 38 You should enter a program in RAM or XFER a ROM program to RAM prior to loading to tape with CALL 32 or 38 INSUFFICIENT NUMBER O
71. STEP 20 gt 30 PRINT I gt 40 NEXT I gt 50 END gt RUN 1 00 2 00 3 00 1 00 21 00 41 00 61 00 81 00 101 READY Important The USING Fx and the USING formats always align the decimal points when printing a number This makes displayed columns of numbers easy to read 5 4 227 PRINT USING 0 This argument lets the BASIC Module determine what format to use If the number is between 99999999 and 1 BASIC displays integers and fractions If it is out of this range BASIC uses the USING FO format Leading and trailing zeros are always suppressed After reset the module is placed in the USING O format Chapter 5 Operating Functions 5 4 22 Special Print Formatting Statements continued 5 4 23 Statement PRINT or 5 4 22 8 Reset Print Head Pointer CALL 99 You can use CALL 99 when printing out wide forms to reset the internal print read character counter and prevent the automatic CR LF at character 79 You must keep track of the characters in each line You can solve this problem in revision A or B modules using DBY 1 6H 0 Example gt 10 REM THIS PRINTS TIME BEYOND 80TH COLUMN gt 20 PRINT TAB 79 gt 30 CALL 99 40 PRINT TAB 41 TIME 250PRINTH M S gt 60 GOTO 20 gt 70 END Mode COMMAND and or RUN Type INPUT OUTPUT The PRINT PRINT or P statement functions the same as the PRINT or P statement except that the output is directed to the list
72. THIS IS A STRING gt 30 INPUT WHAT S YOUR 2 gt 40 PRINT 1 2 gt 50 END gt RUN WHAT S YOUR NAME FRED THIS IS A STRING FRED You can also assign strings to each other with a LET statement Example LET 2 1 Assigns the string value in 1 to the STRING 2 Chapter 5 Operating Functions 5 10 1 The ASC Operator Two operators in the BASIC Module can manipulate STRINGS These operators are ASC and CHR The ASC operator returns the integer value of the ASCII character placed in the parentheses Example gt PRINT ASC A 65 The decimal representation for the ASCII character A is 65 In addition you can evaluate individual characters in a pre defined ASCII string with the ASC operator Example gt 5 STRING 1000 40 gt 10 1 THIS IS A STRING gt 20 PRINT 1 gt 30 PRINT ASC 1 1 gt 40 END gt RUN THIS IS A STRING 84 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 is 84 String character position 0 is invalid Example gt 5 STRING 1000 40 gt 10 1 ABCDEFGHIJKL gt 20 FOR X 1 12 gt 30 PRINT ASC 1 X gt 40 NEXT X gt 50 END gt RUN 65 66 67 68 69 70
73. X MODE WITH NO ZERO SUPPRESSION PHO TO LINE PRINTER 1 LINE PRINTER PI 3 1415926 POP ARGUMENT STACK TO VARIABLES PRINT VARIABLES STRINGS OR LITERALS 15 SHORTHAND FOR PRINT PRINT TO SOFTWARE SERIAL PORT PRINT I CR PRINT A SPC 5 N N PRINT 5 x PRINT USING F3 1 2 PRINT USING 4 1 2 SAVE THE CURRENT PROGRAM IN EPROM SAVE BAUD RATE INFORMATION IN EPROM SAVE BAUD RATE INFORMATION IN EPROM AND EXECUTE PROGRAM AFTER RESET PUSH EXPRESSIONS ON ARGUMENT STACK EVOKE RAM MODE CURRENT PROGRAM IN READ WRITE MEMORY READ DATA IN DATA STATEMENT REMARK RESTORE READ POINTER RETURN FROM INTERRUPT RETURN FROM SUBROUTINE RANDOM NUMBER EVOKE ROM MODE EPROM PROGRAM DEFAULT TO ROM1 EXECUTE A PROGRAM SIGN RETURNS THE SINE OF ARGUMENT SQUARE ROOT STORE VARIABLE BREAK PROGRAM EXECUTION ALLOCATE MEMORY FOR STRINGS BYTES TO ALLOCATE BYTES STRING RETURNS THE TANGENT OF THE ARGUMENT RETRIEVE AND OR ASSIGN REAL TIME CLOCK VALUE TEST DO LOOP CONDITION TEST DO LOOP CONDITION TRANSFER A PROGRAM FROM ROM EPROM RAM ADDITION DIVISION EXPONENTIATION ULTIPLICATION SUBTRACTION LOGICAL AND LOGIC OR LOGICAL EXCLUSIVE OR Example PHO A 1 PH1 ZA PI POP A C D PRINTA PRINT A A B GaK 1 00 0 2 00E0 1 002 00 PROG PROGI PROG2 PUSH10 A RAM READA REM DONE RESTORE RET RETURN RND RO ROM3
74. X the same results gt 20 IF x INT A lt 10 THEN GOTO x 100 X ELSE GOTO 200 gt 20 IF x INT A X 10 THEN 100 ELSE 200 You can replace the THEN statement with any valid x BASIC Module statement as shown below gt 30 IF lt gt 10 THEN PRINT x A x ELSE 10 gt 30 IF A lt gt 10 PRINT x A x ELSE 10 You may execute multiple X statements following the THEN or ELSE if X you use a colon to separate them Example gt 30 IF x lt gt 10 THEN PRINT X A GOTO 150 X ELSE 10 gt 30 1 lt gt 10 PRINT X A GOTO 150 ELSE 10 In these examples X if X A does not equal 10 then both PRINT A and GOTO 150 X are executed X If A10 then control passes to 10 You may omit the ELSE statement If you omit the ELSE statement control passes to the next statement Example gt 20 IF x A10 THEN 40 gt 30 PRINT XA In this example if A equals 10 then control X passes to line number 40 If A does not equal 10 line X number 30 X is executed Mode RUN Type X INPUT OUTPUT The INPUT statement allows you to enter data from the console during program X execution You may assign data to one or more variables with a single X input statement X You must separate the variables X with a comma Example gt 5 4 16 Statement INPUT continued Chapter 5 Operating Functions Causes a question X mark X to print on the console device X This prompts X you to input X two numbers separ
75. a maximum of 64 words in and 64 words out per scan The module responds with the requested block length of data The module has an auxiliary processor dedicated to servicing of the block transfers to and from the host processor These support routines provide the communications link between the host processor and the BASIC processor The block transfer read BTR buffer resides at address 7800H and is 128 bytes long You can examine the values in the buffer using the XB Y command i e PRINT XBY 7800H The block transfer write BTW buffer resides at one of two starting addresses 7 or 7COOH Examine addresses 7DO AH and 7DOBH which point to the proper starting address 7DOAH contains the high byte of the address and 7DOBH contains the low byte of the address The BTW buffer is also 128 bytes long You can also examine these values in the buffer using the XBY command 5 7 Data Transfer Support Routines continued 5 7 1 Update Block Transfer Read Buffer timed CALL 2 5 7 2 Update Block Transfer Write Buffer timed CALL 3 Chapter 5 Operating Functions Example gt 10 REM PRINT CONTENTS OF BTW BUFFER gt 20 C XBY 7D0AH 100H XB Y 7D0BH gt 30 FOR I 0 TO 128 gt 40 PHO XBY C D gt 50 NEXT I gt 60 END This routine transfers the block transfer read BTR buffer to the auxiliary processor on the BASIC Module for use in the next BTR request from the host processor If no data transfer occurs within
76. acters You enter BASIC programs through a dumb ASCII terminal such as an industrial terminal in alphanumeric mode Refer to section 4 3 2 Connecting a T3 T4 Industrial Terminal to the Program Port Use the XOFF XON commands to disable outputs from the program port in the following way 1 Use XOFF only on PRINT statements 2 When XOFF is received during a PRINT data output and program execution are suspended immediately 3 When XOFF is received at any other time program execution continues until a PRINT is encountered When a PRINT is encountered program execution is suspended 4 Use XON to resume program execution The program port accepts uppercase or lowercase input however the input receiver changes all commands keywords or variables to upper case before storing in memory thus gt 10 print hello CR appears as 10 PRINT hello when listed 4 3 2 Connecting a T3 T4 Industrial Terminal to the Program Port Chapter 4 Using the Serial Ports You can use an Industrial Terminal System as the programming system for the BASIC Module Connect the module to CHANNEL C only You can construct cable for distances up to 50 feet Figure 4 3 shows cable connections to a T3 T4 Industrial Terminal from the program port Important You may continue to use CHANNEL B in existing installations Figure 4 3 Cable Connection to T3 T4 Terminal from the Program Port Programming Port Name T3 T4 Channel Name M
77. al device with user written protocol 2 listing programs with the LIST or LIST statement 3 loading saving programs using the 1771 SA SB data recorders For these functions to operate properly and to allow flexibility for talking to many different devices we provide parameter setup routines To make best use of the port a 256 character buffer is provided on both input and output This means that the module may receive up to 256 characters without error from a device before the module must service the data The module can store an entire response to a command in the input buffer This is useful when the data arrives in a high speed burst that is too fast for the BASIC program to handle character by character The 256 character output buffer allows the module to assemble an entire message leaving your user program free to perform other operations while the message is sent character by character by the device driver This routine sets up the parameters for the peripheral port The parameters set are the number of bits word parity enable or disable even or odd parity number of stop bits software handshaking and hardware handshaking Default values are stop bit no parity 6 bits character a DCD off XON XOFF disabled 1200 baud jumper selected start bit fixed Chapter 5 Operating Functions 5 8 1 Peripheral Port Support Parameter Set CALL 30 continued 5 8 2 Peripheral Port Sup
78. ale Male Chassis Shield Ground TXD Output TXD RXD Input RXD Signal Common Common NOTE Chassis shield should be connected only at the terminal end 13384 You can use a or T4 Industrial Terminal with the following keyboard revisions T3 Series A Revision H or later T3 Series B Revision H or later T3 Series C Revision or later Series A Revision or later Refer to the Industrial Terminal Systems User s Manual Cat No 1770 T1 T2 T3 publication number 1770 6 5 3 and PLC 3 Industrial Terminal User s Manual Cat No 1770 T4 publication number 1770 6 5 15 for additional information 4 5 Chapter 4 Using the Serial Ports 4 3 3 Connecting a T30 Industrial Terminal Cat No 1784 T30 to the Program Port 4 3 4 Connecting a T50 Industrial Terminal Cat No 1784 T50 to the Program Port 4 6 You can connect a T30 Industrial Terminal to the BASIC Module program port to act as a dumb terminal Refer to the following figure 4 4 for BASIC Module T30 connections Figure 4 4 Connecting a T30 Industrial Terminal to a BASIC Module T30 Industrial Terminal BASIC Module Serial Port Program Port Ei Minimum connections 15037 Important Jumper T30 Industrial Terminal pin 4 5 and 6 and BASIC Module pins 4 and 5 if you do not use them You can use your T50 Industrial Terminal as a BASIC Module programming device You
79. am 2 String Support Calls continued gt LIST 10 REM STRING ALLOCATION COMPUTATION KNOWING 20 REM 1 CHARACTERS IN LONGEST STRING 2 AMOUNT OF STRING MEMORY 30 PRINT PRINT 40 INPUT HOW MANY CHARACTERS IN YOUR LONGEST STRING C 50 INPUT OF BYTES OF MEMORY CAN YOU ALLOCATE FOR STRINGS N 60 PRINT 70 V INT N 1 C 1 REM COMPUTE THE OF POSSIBLE VARIABLES 80 N V C 1 1 REM COMPUTE HOW MUCH MEMORY IS ACTUALLY NEEDED 90 PRINT PRINT 100 PRINT YOU NEED TO ALLOCATE N BYTES OF MEMORY FOR V VARIABLES 110 PRINT CONTAINING C CHARACTERS EACH 120 PRINT PRINT 130 PRINT STRING N C 140 END gt RUN HOW MANY CHARACTERS IN YOUR LONGEST STRING 20 OF BYTES OF MEMORY CAN YOU ALLOCATE FOR STRINGS 500 YOU NEED TO ALLOCATE 485 BYTES OF MEMORY FOR 22 VARIABLES CONTAINING 21 CHARACTERS EACH STRING 485 21 READY gt Chapter 5 Operating Functions 5 10 3 Example program 3 String Support Calls continued 10 REM STRING ALLOCATION COMPUTATION KNOWING 20 REM 1 AMOUNT OF STRING MEMORY 2 OF STRING VARIABLES 30 PRINT PRINT 40 INPUT ENTER OF BYTES OF MEMORY YOU CAN ALLOCATE FOR STRINGS N 50 INPUT HOW MANY STRING VARIABLES WILL YOU NEED V 60 PRINT 70 C INT N 1 V 1 REM COMPUTE THE OF CHARACTERS STRING 80 N V C 1 1 REM COMPUTE THE OF BYTES OF MEMORY NEEDED 90 PRINT PRINT 100 PRINT YOU NEED TO ALLOCATE N BYTES OF MEMORY FOR V VARIABLES
80. ated X by a comma If you do not enter X enough data the module prints X TRY AGAIN on the console device Example gt 10INPUT A B gt 20 PRINT A B gt RUN 7 TRY AGAIN 71 2 1 2 READY You can X write the INPUT statement X so that X a descriptive prompt tells you what to X enter The message to be printed X is placed in quotes after the INPUT statement X If a comma appears X before the first variable on the input list X the question mark prompt X character is not displayed Examples gt 10 INPUT ENTER A NUMBER gt 10 INPUT ENTER A gt 20 PRINT SQR A gt 20 PRINT SQR A gt 30 END gt 30 END gt RUN gt RUN ENTER A NUMBER ENTER A 100 7100 10 10 You can X also assign strings with an INPUT statement Strings always terminated with a carriage X return cr If more than one string input is requested with a single INPUT statement the module prompts you X with X a question mark Chapter 5 Operating Functions 5 4 16 Examples Statement INPUT continued gt 10 STRING 110 10 gt 10 STRING 110 10 gt 20 INPUT NAME 1 gt 20 INPUT NAMES 1 2 gt 30 PRINT HI 1 gt 30 PRINT 1 AND 2 gt 40 END gt 40 END gt RUN gt RUN NAME SUSAN NAMES BILL HI SUSAN ANN HI BILL AND ANN READY READY You can assign X strings and variables with a single X INPUT statement Example gt 10 STRING 100 10 gt
81. ber i e Sunday 1 Saturday 7 This can be POPed into a variable Example gt 10 REM DAY OF WEEK RETRIEVE NUMERIC EX gt 20 CALL 44 REM INVOKE UTILITY TO GET D O W gt 30 POP D 5 9 10 Date Retrieve String CALL 52 5 10 Description of String Operators Chapter 5 Operating Functions CALL 52 returns the current date in a string dd mmm yy PUSH the number of the string to receive the date You must allocate a minimum of 9 characters for the string Example gt 10 STRING 100 20 gt 20 PUSH 1 CALL 52 REM put date in string 1 gt 30 PRINT 1 gt 40 END gt RUN 30 JAN 87 A string is a character or group of characters stored in memory Usually the characters stored in a string make up a word or a sentence Strings allow you to deal with words instead of numbers This allows you to refer to individuals by name instead of by number The BASIC Module contains one dimensioned string variable expr The dimension of the string variable the expr value ranges from 0 to 254 This means that you can define and manipulate 255 different strings in the BASIC Module Initially no memory is allocated for strings Memory is allocated by the STRING expr expr STATEMENT See Section 5 4 31 for more information on this statement In the BASIC Module you can define strings with the LET statement the INPUT statement and with the ASC operator Example gt 10 STRING 100 20 gt 20 1
82. cessor when CALL 7 or CALL 2 executes You should complete the building of the read buffer before initiating its transfer The following sample programs use block transfer instructions The Mini PLC 2 cat 1772 LN3 and PLC 2 20 cat no 1772 LP1 LP2 processors use multiple GET instructions to perform block transfers Refer to the processor user s manual for an explanation of multiple GET block transfers This sample program figure 6 1 and 6 3 assumes that the application requires a single block transfer read BTR and a single block transfer write BTW to pass data between the processor and the BASIC Module i e transfer of 64 words or less If the transferred data exceeds 64 words you must program multiple file to file moves to move different data sets to and from the block transfer files Chapter 6 Programming 6 3 1 PLC 2 Processor Program continued PLC 2 PLC 3 and PLC 5 processor ladder logic programs shown in this chapter Figurd 6 3 is an actual sample program Figure 6 1 Sample PLC 2 Family Ladder Logic BTW BTR PEE 1 BIW tacat DN EN EN File DN BTR BIW 2 BTR DN EN EN File x DN BTR a eee 3 t DN
83. countered When the correct program is found one asterisk per line prints You must press the READ FROM TAPE button twice on the SB Recorder at the end of each program encountered to continue the search Press the READ FROM TAPE button when the DATA OUT light on the SB Recorder goes out This indicates the end of file If the BASIC Module starts loading from the middle of a file the DATA OUT light is on but no asterisk is printed on the console Follow the above procedure to continue the search An unlabeled save CALL 32 has an ID of 0 CALL 110 prints the complete buffer with addresses front pointer and the number of characters in the buffer to the console No PUSHes or POPs are needed Use this information as a troubleshooting aid It does not affect the contents of the buffer 5 8 12 Print the Peripheral Port Input Buffer and Pointer CALL 111 5 8 13 Reset the Peripheral Port to Default Settings CALL 119 5 9 Wall Clock Support Calls Chapter 5 Operating Functions CALL 111 prints the complete buffer with addresses front pointer and the number of characters in the buffer to the console No PUSHes or POPs are needed Use this information as a troubleshooting aid It does not affect the contents of the buffer CALL 119 resets the peripheral port to the following default settings 8 bits character stop bit No parity a DCD off XON XOFF off No PUSHes or POPs are needed The battery backe
84. curate 12 hour clock There are 43200 seconds in a 12 hour period so an ONTIME 43200 In num statement is used When the TIME interrupt occurs the statement TIME 0 is executed but the millisecond counter is not re assigned a value If interrupt latency exceeds 5 milliseconds the clock remains accurate Chapter 5 Operating Functions 5 6 2 System Control Values 5 7 Data Transfer Support Routines The system control values determine how memory is allocated by the BASIC Module 5 6 2 1 MTOP After reset the BASIC Module sizes the external memory and assigns the last valid memory address to the system control value MTOP The module does not use any external RAM memory beyond the value assigned to MTOP Examples gt PRINT MTOP Or MTOP 14335 37FFH 5 6 2 2 LEN The system control value LEN tells you how many bytes of memory the currently selected program occupies This is the length of the program and does not include the size of string memory variables and array memory usage You cannot assign LEN a value it can only be read A NULL program i e no program returns a LEN of 1 The 1 represents the end of program file character Important The BASIC Module does not require any dummy arguments for the system control values The BASIC Module communicates with the host processor using block transfer communications The host processor sends variable length blocks of data to the module You can transfer
85. d 5 8 5 Load Program from Data Recorder CALL 34 Press PLAY Tape movement begins and the recorder searches for the beginning of the next program As each line of the program verifies an asterisk displays During this time the DATA OUT LED on the recorder and the LED on the module illuminate When the last line of program is verified a final asterisk is displayed on the terminal followed by the VERIFICATION COMPLETE message and the BASIC gt prompt If any differences between programs are encountered the routine displays an ERROR VERIFICATION FAILURE message and the BASIC gt prompt is immediately displayed Important Maximum baud rate is 2400 bps for all data recorder CALL routines The UART is set up in these routines and does not need setting in BASIC See section 4 2 2 2 for required cable connections This routine loads a program stored on a 1770 S A SB recorder into user RAM destroying the previous contents of RAM To use this routine enter CALL 34 The terminal responds with POSITION AND PRESS READ FROM TAPE Press PLAY Tape movement begins and the routine searches for the beginning of the next program When the program is found an asterisk is printed for each line read from the recorder During this time the DATA OUT LED of the recorder and the LED on the front of the module illuminate When the recorder sends the last line of program a final as
86. d X in memory You can use format X statements within the print X statement The format statements X include TAB lexprl SPC expr USING special symbols and CR carriage return with no line feed You can represent the following range of numbers in X the BASIC module 1E 127 X to 99999999E 127 There are eight X significant X digits X Numbers are X internally rounded to X fit this precision You can X enter and display numbers in X four formats integer X decimal hexadecimal and exponential Example x 129 34 98 OA6EH 1 23456E 3 In the BASIC module X integers X are numbers that X range from to 65 535 or OFFFFH You X can X enter all integers in either decimal or hexadecimal X format You indicate X a hexadecimal number by placing the character X after the number e g 170H If the hexadecimal number begins X with A F then it must be preceded by a zero i e You must enter A567H as 567 When an X operator such as AND requires an integer the BASIC module truncates X the fraction X portion of the number so it fits the integer format We refer X to integers and line numbers as integer In num 5 2 6 Constants 5 2 7 Operators 5 2 8 Variables Chapter 5 Operating Functions A constant is a real X number that ranges from 1 E 127 to 9999999 9 127 A constant X can be an integer X We refer to constants as const An operator performs a predefined operation on
87. d argument if 8 ONTIME does not interrupt CALL routines INPUT statements or PRINT statements waiting for handshaking CTS DCD to become true ONTIME is a polling mechanism which is checked after each line of BASIC is completed End of line is either a CR or 9 8 9 4 Anomalies continued 10 11 12 13 14 15 Chapter 9 Error Messages and Anomalies If you use a VT100 terminal the BASIC Module can miss an XON character sent by your terminal when you enable software handshaking and use a 19 2K baud rate on the module s program port You must type CTRL Q to resume If you use a CTRL C to abort LIST or PRINT to a peripheral device the BASIC Module no longer transmits on the program port only at 9600 or 19 2 K baud You can correct the problem by deleting any line The line deleted need not actually exist in the program Illegal CALL numbers above 128 are not trapped and cause the micro to jump into code memory at the address specified This can cause the module to get lost The BASIC Module does not save the EPROM stored baud rate Example The module is powered up after a CALL 73 is issued and a valid baud rate is previously stored in EPROM using a PROGI If the module is powered down and then up it is powered up at 1200 baud The renumber routine does not renumber a program if there is insufficient RAM left or if a GOTO or GOSUB exists and the target line number do
88. d wall time clock provides year month day of month day of week hours minutes and seconds The clock operates in 24 hour military time format The support routines allow the setting of the clock and retrieval of clock values in numeric form The wall clock support routines use the argument stack to pass data between the BASIC program and the routines Data is passed in both directions and consists of the actual clock data The wall clock or time of day clock is separate from the real time clock also provided on the module The real time clock is accessed by CLOCK 1 CLOCKO and other statements and has a resolution of 5 milliseconds It should be used for all short time interval measurements because the greater resolution results in more accurate timing The two clocks are not synchronized and comparison of times is not recommended Also the real time clock is not battery backed Chapter 5 Operating Functions 5 9 1 Use this routine to set the following wall clock time functions Setting the Wall Clock Time H hours 0 to 23 Hour Minute Second CALL 40 s minutes 0 to 59 S seconds 0 59 Example Program the wall clock for 1 35 pm 13 35 on a 24 hour clock gt 10 H 13 M 35 5 00 HOURS 13 MINUTES 35 SECONDS 00 gt 20 PUSH H M S PUSH HOURS MINUTES SECONDS gt 30 CALL 40 CALL THE ROUTINE TO SET THE WALL CLOCK TIME 5 9 2 Use this routine to set the following wall c
89. device instead of the console device The baud rate and peripheral port parameters must match your device See Chapter 3 Section 3 2 4 titled Configuration Plugs and Chapter 5 Section 5 8 1 titled Peripheral Port Support Parameter Set CALL 30 comments that apply to the PRINT or P statement apply to the PRINT or P statement is a shorthand notation for PRINT 5 4 24 Statements PHO PH1 PH1 Chapter 5 Operating Functions Mode COMMAND and or RUN Type INPUT OUTPUT The PHO and PH1 statements function the same as the PRINT statement except that the values are printed out in a hexadecimal format The PHO statement suppresses two leading zeros if the number printed is less than 255 OFFH The PH1 statement always prints out four hexadecimal digits The character H is always printed after the number when PHO or PH1 is used to direct an output The values printed are always truncated integers If the number printed is not within the range of valid integer i e between 0 and 65535 OFFFFH inclusive the BASIC Module defaults to the normal mode of print If this happens H prints out after the value Since integers are entered in either decimal or hexadecimal form the statements PRINT PHO and PH1 are used to perform decimal to hexadecimal and hexadecimal to decimal conversion All comments that apply to the PRINT statement apply to the PHO and PHI statements
90. e BASIC Module Action Taken X After you type RUN all variables X are set equal to zero X all BASIC X evoked X interrupts X are cleared and program execution begins with the first line number of the selected program The RUN command and the x GOTO statement are the only way you can place the BASIC Module X interpreter X into the RUN mode X from the COMMAND mode You can terminate program execution X at any time by typing a Control C on X the X console device Variations X Some BASIC interpreters allow a line number to follow the RUN command X i e X RUN 100 The BASIC x 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 In num command x use the GOTO In X num statement X in the direct mode See statement GOTO Example gt 10 FOR I 1 TO 3 gt 20 PRINT I gt 30 NEXT xI gt 40 END gt RUN 5 3 2 5 3 3 Command LIST Chapter 5 Operating Functions Action X Taken If X you stop a program by X typing a Control C on the console X device or by execution X of a STOP statement X you can resume execution of the program by typing X CONT If X you enter X a Control C during the execution X of a CALL routine X you cannot X CONTinue Between X the stopping and the re starting of the program you X may display the values of variables X or change the X values of variables However you cannot CONTinue if X the pr
91. e aaa Cont inuous 15047 6 8 6 5 PLC 5 Family Processors continued 6 5 1 Rung Description for Sample PLC 5 Family Ladder Logic Chapter 6 Programming Figure 6 7 Sample PLC 5 Family Ladder Logic File 2 Rung 0 N1010 N1110 BTW 1 1 1 1 BLOCK TRNSFR WRITE 15 15 Rack 01 Group O DN Module 0 Control Block N1010 ER Data file N1015 Length 10 Cont inuous NI File 2 Rung 1 N1010 N1110 2 BLOCK TRNSFR READ EN 15 15 01 Group 0 DN Module 0 Control Block N1110 ER file N1115 Length 2 Continuous NI File 2 Rung 2 15048 Rungs 1 and 2 Rungs 1 and 2 execute the BTR and BTW instructions alternately When the BTR completes the BTW enables immediately following the BTR scan Important Do not select the continuous mode when using bidirectional block transfer Continuous mode does not allow use of the status bits in the block transfer instructions Important Set the block transfer write timeout bit control block word 0 bit 08 to minimize the impact of the block transfer instructions on the program scan time See the following Section 6 6 Block Transf
92. e two operands We refer to relational expressions X as rel expr The system control values include X the following LEN returns the length of your program MTOP the last memory location assigned to BASIC See the following X Section X 5 6 2 x titled System Control Values for more information 5 2 12 Argument Stack 5 2 13 Control Stack Chapter 5 Operating Functions The argument stack A stack stores all constants that the BASIC Module is currently using Operations such as add subtract X multiply and divide always operate X on the first two numbers on X the argument X stack X and return X the result to the stack x The argument X stack X is 203 bytes long Each floating point X number placed on the stack requires X 6 bytes of storage The argument stack can hold up to 33 floating X point numbers before X overflowing The control stack C stack X stores all information X associated with loop control i e DO WHILE DO UNTIL FOR NEXT BASIC subroutines and PUSHed or POPed values The control X stack is 157 bytes long DO WHILE and x DO UNTIL loops X use 3 bytes of control X stack FOR NEXT loops X use 17 bytes X The control X stack contains X enough space X for up to 9 nestings X of control X loops 5 5 Chapter 5 Operating Functions 5 3 Description of Commands 5 3 1 Command RUN 5 6 The X following X sections list and describe X the commands X you can use with th
93. ect CTS to RTS DSR is a general purpose RS 423A compatible input line The BASIC Module transmits or receives in the mark 1 or space 0 state Use this line for data recorder interface Use the signal common pins to reference all RS 423A R S 422 compatible signals If DCD is enabled using CALL 30 the BASIC Module does not transmit or receive characters until the DCD line is in the mark 1 state When disabled the module ignores the state of this line 11 12 13 15 NC No connection 17 19 21 22 23 24 14 25 422 TXD RS 422A compatible equivalent of the RS 423A TXD line Differential serial output lines 16 18 422 RXD Differential RS 422A compatible serial input lines 20 is RS 423A compatible hardware handshaking output line This line changes to a space 0 state when the BASIC Module input queue has accumulated more than 223 characters The DTR line changes to a mark 1 state when the input queue contains less than 127 characters 1 port pins 42 4 3 Program Port Chapter 4 Using the Serial Ports The program port is an RS 423A 232C compatible serial port that provides minimum signal line connection to terminals printers and other serial devices for operator program interaction command level input printer output etc Figure 4 2 shows the signals available on both the program port and the peripheral port described later Figure 4 2 Program Port and Peripheral Port Wiri
94. eed x the available PROM space X you cannot continue X programming until it is erased In some cases you can alter X the previously stored programs Be sure X to use CALL 81 X to determine memory space prior to burning See section 5 3 13 1 below 5 3 13 1 User PROM Check x and x Description CALL 81 Use CALL 81 X in command mode before burning a program into PROM memory This X CALL determines X the number of x PROM programs determines X the number of X bytes left x in PROM determines X the number of X bytes in the X RAM program prints X a message telling if enough space is available in X PROM for the RAM program checks X for X a valid PROM if X it contains X no X program prints X a good or X bad PROM message A bad PROM message with an address of 00 X indicates an incomplete program No x PUSHes POPs are X needed Chapter 5 Operating Functions 5 3 14 Command PROG1 5 3 15 Command PROG2 Action taken X You can use the PROGI x command to program the resident EPROM with X baud rate information When the module is powered up the module reads this information and X initializes X the program port with the stored baud rate The X sign on message is sent to the X console immediately after X the module X completes its reset sequence X If the baud rate on X the console device is changed you must program X a new EPROM to make X the module compatible with the new console If X you
95. embly Parts Operating Functions x wp nx 5 1 Chapter Objectives 5 2 Definition ofTerms 5 2 1 Commands 2 22 2 5 2 2 Statements tere 5 2 3 Format Statements 5 2 4 Data tia oa ie Mee eS ws 52O CONSTANS ove 5 27 Diet den anes 5550 Variables od SOR UR us 5 2 9 EXDIGSSIDIS 2545008 van bp UE PER QU S ER E d 5 2 10 Relational 55 0 5 5 2 11 System Control Values 2512 RUMEN TREE 5 2 13 Control Stack 2 5 3 Description 5 5 3 1 Command RUN ases vag ace ca ce ep rev 5 3 2 Command CONT oe der eR acer 5 3 3 Commande LIST oues acc teer Ex DOR ERA 5 3 4 Command 5 5 5 3 5 Command NEW 5 3 6 Command NULL integer 5 3 7 Command Control C 5 3 7 1 Command Disabling Control C 5 2 8 Command Control S 5 3 9 Command Control Q 5 3 10 Overvie
96. er Programming Tips for more information 6 9 Chapter 6 Programming 6 6 Block Transfer Programming Tips The block lengths PUSHed for CALLs 4 and 5 must equal the corresponding lengths on your BTW BTR instructions in the processor If a BTW appears first in your ladder logic put CALLs 3 or 6 first in your BASIC program If a BTR appears first in your ladder logic put CALLs 2 or 7 first in your BASIC program Set the PLC 5 block transfer write timeout bit block transfer control block word 0 bit 8 to eliminate excessive PLC 5 scan times When the timeout bit sets the processor attempts two DB block transfers before generating a block transfer error The error condition resets the enable bit and restarts the block transfer in our program example figure 6 7 If your application requires bidirectional block transfers you can use CALL 6 or 3 and CALL 7 or 2 as necessary if you use an equal number of each type you alternate their use e g CALL 6 CALL 7 CALL 6 CALL 7 You can put the calls anywhere in the program They can occur at any time interval If your application requires way block transfer all write block transfers or all read block transfers use only the associated CALLs 4 and 3 or 6 5 and 2 or 7 7 1 Chapter Objectives 7 2 Output Data Types 7 2 1 16 bit Binary 4 Hex Digits Chapter 7 Data Types This chapter describes the data types and formats used by the BAS
97. er precedence Use parentheses if you are in doubt about the order of precedence The precedence of operators from highest to lowest in the BASIC Module is 1 Operators that use parenthesis 2 Exponentiation 3 Negation 4 Multiplication and division 5 Addition and subtraction 6 Relational expressions lt gt gt gt lt lt 7 Logical and AND 8 Logical or 9 Logical XOR XOR 5 5 4 How Relational Expressions Work Chapter 5 Operating Functions Relational expressions involve the operators lt gt gt gt lt and lt These operators are typically used to test a condition In the BASIC Module relational operations are typically used to test a condition In the BASIC Module relational operators return a result of 665535 OFFFFH if the relational expression is true and a result of 0 if the relation expression is false The result is returned to the argument stack Because of this it is possible to display the result of a relational expression Examples PRINT 120 PRINT 10 PRINT A lt gt A PRINT A A 0 65535 0 65535 You can chain relational expressions together using the logical operators OR and XOR This makes it possible to test a complex condition with ONE statement Example gt 10 IF A gt B AND A gt C OR A gt D THEN Additionally you can use the NOT expr operator Example gt 10 IF NOT
98. es not Error reporting does not indicate the cause only that an error occurred We recommend renumbering the program in sections and not to renumber a program greater than 9 K When editing a line an excessive line length may cause the terminal to issue a CTRL S A CTRL Q causes termination of the edit You must retype the complete line The BASIC Module updates the wall clock for Daylight Savings Time This occurs on the last Sunday in April and October if the Day of Week is set properly CALL 42 9 9 Quick Reference Guide Description ABSOLUTE VALUE RETURNS INTEGER VALUE OF ASCII CHARACTER ABS 3 P ASC A RETURNS ARCTANGENT OF ARGUMENT CALL APPLICATION PROGRAM CALL 10 COUNTS VALUE CONVERTED ASCII CHARACTER P CHR 65 CLEARS VARIABLES INTERRUPTS amp STRINGS CLEAR CLEAR INTERRUPTS CLEARI DISABLE REAL TIME CLOCK CLOCKO ENABLE REAL TIME CLOCK CLOCK1 CONTINUE AFTER A STOP OR CONTROL C CONT CONTROL STOP EXECUTION amp RETURN TO COMMAND MODE CTRL CONTROLS 5 10 INTERRUPT A LIST COMMAND CTRLS ONTROL Q Bir RESTART A LIST AFTER CONTROL S 05 5 47 RETURNS THE COSINE OF ARGUMENT 5 0 DATA 5 18 BE READ BY READ STATEMENT DATA 7 5 19 ALLOCATE MEMORY FOR ARRAY VARIABLES DIM A 20 p bee SET UP LOOP FOR WHILE OR UNTIL D 5 22 TERMINATE PROGRAM EXECUTION END ber 46
99. eturn CALL 72 Chapter 5 Operating Functions The user is now executing ROM 4 if it exists If the ROM routine requested does not exist the result is PROGRAM NOT FOUND READY gt This routine allows you to return to the ROM or RAM routine that called this ROM or RAM routine Execution begins on the line following the line that CALLed the routine No arguments are PUSHed or POPed This routine works one layer deep You may go back to the last CALLing program s next line Important There must be a next line in the ROM or RAM routine otherwise unpredictable events could occur which may destroy the contents of RAM For this reason always be sure that at least one END statement exists following a Call 70 or 71 Example gt ROM 1 gt 10 REM SAMPLE PROG FOR CALL 72 gt 20 PRINT NOW EXECUTING ROM 1 gt 30 PUSH3 gt 40 CALL 71 REM EXECUTE ROM 3 THEN RETURN gt 50 PRINT EXECUTING ROM 1 AGAIN gt 60 END ROM 3 gt 10 REM THIS LINE WONT BE EXECUTED 220 PRINT NOW EXECUTING ROM 3 gt 30 CALL 72 240 END With ROM 1 selected gt RUN NOW EXECUTING ROM 1 NOW EXECUTING ROM 3 EXECUTING ROM 1 AGAIN READY gt Chapter 5 Operating Functions 5 11 4 Battery backed RAM Disable CALL 73 5 11 5 Battery backed RAM Enable CALL 74 5 11 6 Protected Variable Storage CALL 77 gt PRINT MTOP 14335 gt PRINT MTOP 12 14323 CALL 73 disables the battery backed RAM prin
100. f a BASIC program X during the execution of a LIST command X It also X stops output from the receiving X port if you are running a program X In this case XOFF Control S operates as follows 1 XOFF only operates on PRINT statements 2 When received during a PRINT X data X output X and program execution are suspended immediately 3 When received at any other time X program execution continues until a PRINT is X encountered X At this time program execution Xis suspended 4 XON Control X Q is required X to resume program operation Action X taken This command restarts a LIST command or PRINT output that X is interrupted by a Control S Your BASIC Module X can X execute and SAVE up to 255 programs X in an EPROM The X module X generates X all of the timing X signals needed to program most x EPROM devices The programs X are X stored in sequence in the EPROM for X retrieval and execution This sequential storing of programs is X called the EPROM FILE The following commands allow X you to generate X and manipulate X the x EPROM FILE Action X taken These two commands tell x the the BASIC Module interpreter whether to select the current program out of RAM or EPROM The X current program is X displayed during a LIST command and executed X when RUN is typed 5 3 11 Commands ROM integer continued Chapter 5 Operating Functions 5 3 11 1 RAM When you enter RAM cr the BASIC Module X selects X the
101. f digits varies depending upon the number The module always outputs at least 3 significant digits even if x is 1 or 2 The maximum value for x is 8 Example gt 10 USING F3 1 2 3 gt 20 PRINT USING F4 1 2 3 gt 30 PRINT USING F5 1 2 3 gt 40 FOR I 10 TO 40 STEP 10 gt 50 PRINT I gt 60 NEXT I gt RUN 100 0 2 00 0 3 00E0 1 000 2 000 0 3 000 0 1 0000E0 2 0000 0 3 0000 0 1 0000 1 2 0000 E 1 3 0000 E 1 4 0000 E 1 READY 5 4 22 Special Print Formatting Statements continued Chapter 5 Operating Functions 5 4 22 6 PRINT USING This forces the module to output all numbers using an integer and or fraction format The number of 4 5 before the decimal point represents the number of significant integer digits that are printed and the number of 5 after the decimal point represents the number of digits that are printed in the fraction Omit the decimal point to print integers only You may use the abbreviation U for USING USING H t USING HHH and USING HHBEHHE 4H are all valid in the BASIC Module The maximum number of characters is 8 If the module cannot output the value in the desired format usually because the value is too large a question mark is printed to the console device BASIC then outputs the number in the FREE FORMAT described below refer to section 5 4 22 7 Example gt 10 PRINT USING HE HP 1 2 3 gt 20 FOR I 1 TO 120
102. f the BASIC Module The BASIC Module figure 2 1 provides math functions report generation and BASIC language capabilities for any Allen Bradley processor that communicates with the 1771 I O system using block transfer It provides basic programming using the Intel BASIC 52 language math functions consistent with the BASIC 52 definition two independently configurable serial ports capable of connecting to various user devices user accessible real time clock with 5 ms resolution user accessible wall clock calendar with 1 second resolution program generation and editing using a dumb ASCII terminal or a T3 T4 Industrial Terminal in alphanumeric mode program storage and retrieval using the 1770 5 A SB Recorder block transfer communication capability from a PLC 2 PLC 3 or PLC 5 family processor on board program PROM burning Chapter 2 Introducing the BASIC Module 2 2 j Figure 2 1 General Features continued SASIC Module Front Edge 2 3 Your module is a one slot module with the following functions and Hardware Features features 13 K bytes of battery backed RAM for user programs 32K bytes of EPROM storage for user software routines One RS 423A 232C compatible serial communications port PROGRAM port which works with ASCII terminals providing operator program interaction command level input printer output etc The program port baud rate defaults to 1200 baud Initiall
103. f you break communications with the module check that the terminal is set at the proper baud rate 3 3 There are five LED s figure 3 3 on the front panel of the module which Module Status LED s indicate the status of the module Figure 3 3 Module Status Indicators Active green MTG green RWG green Fault red AGTIVE LOW red MTG BAT LOW LED Description ACTIVE green Indicates the module has passed power up diagnostics You can program using CALL 79 to remain on default remain on in RUN mode and blink every second when in COMMAND mode Refer to Chapte 5ffor an explanation of CALL 79 XMTG green ON when data is transmitting on the peripheral port Lights for either RS 422 or RS 423 RS 232C output RCVG green ON when data is transmitting on the peripheral port Lights for either RS 422 or RS 423 RS 232C input This LED does not indicate whether or not valid data was received FAULT red When LED is on indicates either a hardware problem or block transfer problem See below BAT LOW red Lights when the battery voltage drops below about 3 0V DC 3 6 3 3 Module Status LED s continued 3 4 Installing the User Prom Chapter 3 Installing the BASIC Module If the FLT LED lights after the module has been operating properly check the following troubleshooting chart con con is 5 con Problem odule s programming port d
104. follows BASIC ERROR XXX IN LINE YYY YYY BASIC STATEMENT x Where XXX is the ERROR TYPE and YYY is the line number of the program in which the error occurred A specific example is ERROR BAD SYNTAX IN LINE 10 10 PRINT 34 21 The X shows approximately where the ERROR occurred in the line number The specific location of the X may be off by one or two characters or expressions depending on the type of error and where the error occurred in the program If an ERROR occurs in the COMMAND MODE only the ERROR TYPE is printed out not the line number The ERROR TYPES are as follows A STACK An A STACK ARGUMENT STACK error occurs when the argument stack pointer is forced out of bounds An out of bounds condition occurs if you overflow the argument stack by PUSHing too many expressions onto the stack you attempt to POP data off the stack when no data is present ARITH OVERFLOW An ARITH OVERFLOW occurs when an arithmetic operation exceeds the upper limit of a module floating point number The largest floating point number in the BASIC Module is 99999999 127 For example 1E 70 1E 70 causes an ARITH OVERFLOW error Chapter 9 Error Messages and Anomalies 9 2 Error Messages from BASIC continued 9 2 ARITH UNDERFLOW An ARITH UNDERFLOW occurs when an arithmetic operation exceeds the lower limit of a module floating point number The smallest floating point number
105. g a PROM The wall clock is accessible and the peripheral port is enabled All of the input call conversion routines require the same sequence of commands These are PUSH the word position of the processor block transfer file to be converted 1 64 CALL the appropriate input conversion POP the input argument into a variable The data format of the output arguments from each of the input conversion routines is described in more detail in Chapte 5 7 9 1 3 Digit Signed Fixed Decimal BCD to Internal Floating Point XXX CALL 10 The input argument is the number 1 to 64 of the word in the write block transfer buffer that is to be converted from 3 digit BCD to internal format The output argument is the converted value in internal floating point format The sign bit is bit number 16 5 7 9 2 16 Bit Binary 4 digit hex to Internal Floating Point CALL 11 The input argument is the number 1 to 64 of the word in the write data transfer buffer to be converted from 16 bit binary to internal format The output argument is the converted value in internal floating point format There are no sign or error bits decoded 5 7 9 3 4 Digit Signed Octal to Internal Floating Point XXXX CALL 12 The input argument is the number 1 to 64 of the word in the processor block transfer buffer to be converted from 4 digit signed octal to internal format This 12 bit format has a maximum value of 7777 octal The output argument is the co
106. have X already used a PROG2 command you cannot X use the PROG 1 command Action taken x The PROG2 command functions the same as the command X except for the following Instead of signing on and entering the command X mode the module immediately X begins executing the first program stored in the resident EPROM if no program X is stored in RAM Otherwise it X executes the RAM program X You can use the PROG2 command to RUN a program on power up without X connecting to a console X Saving PROG2 information is the same as typing a ROM 1 RUN command sequence This feature X also allows you to write a special initialization X sequence in BASIC and X generate a custom sign on message for specific applications If X you have X already used a PROGI command X you cannot X use the PROG 2 command 5 3 15 Command PROG2 continued Chapter 5 Operating Functions Figure 5 1 Flow Chart of Power up Operation Power turn on Start Is RAM valid No Yes Use baud rate from RAM Is there a RAM program 9 Yes Execute RAM program Select 1200 baud rate Have you donea PROG 1 2 Use baud rate from ROM Have you donea PROG 2 Use baud rate from ROM Output sign on Execute message ROM 1 program Enter command mode 15042 Figure 5 1 shows BASIC Module operation from a power up condition using PROGI or PROG2 or batte
107. he DEC equivalent of ASCII DLE is 16 PRINT CHR 16 40 10 This prints TEST at column 40 row 10 on your Allen Bradley Industrial Terminal To enhance the BASIC Module we have added several string manipulation routines that make programming easier Strings in the BASIC Module are declared by the STRING statement You must execute the STRING statement before you can access or call any strings or string routines The STRING statement has two arguments or numbers that follow it They are the total amount of space to allocate to string storage and the maximum size in characters of each string Since you terminate strings using a carriage return character each string is given an extra byte of storage for its carriage return if it is the maximum length You can determine the number of strings allowed by taking the first number and dividing it by one plus the second number Note that you must use the strings consecutively starting with string 0 through the allowed number of strings strings are allocated the maximum number of characters regardless of the actual number used of these routines use or modify strings as part of their operation The mechanism for passing a string to the support routine is to PUSH its number or subscript onto the stack The support routine can then get the string number from the module s argument stack and locate it in string memory Many of these routines also require the leng
108. he argument is less than zero Examples gt PRINT SGN 52 gt PRINT SGN 0 gt PRINT SGN 8 1 0 1 5 5 2 1 5 SQR expr Returns the square root of the argument The argument may not be less than zero The result returned is accurate to within value of 5 on the least significant digit Examples gt PRINT SQR 9 gt PRINT SQR 45 gt PRINT SQR 100 3 6 7082035 10 5 45 Chapter 5 Operating Functions 5 5 2 Unary Operators continued 5 6 5 5 2 1 6 Returns a pseudo random number in the range between 0 and 1 inclusive The RND operator uses a 16 bit binary seed and generates 65536 pseudo random numbers before repeating the sequence The numbers generated are specifically between 0 65535 and 65535 65535 inclusive Unlike most BASICS the RND operator in the BASIC Module does not require an argument or a dummy argument If an argument is placed after the RND operator a BAD SYNTAX error occurs Examples gt PRINT Rnd 30278477 5 5 2 1 7 PI PI is a stored constant In the BASIC Module PI is stored as 3 1415926 5 5 2 2 Log Functions Following are the log functions 5 5 2 2 1 LOG expr Returns the natural logarithm of the argument The argument must be greater than 0 This calculation is carried out to 7 significant digits Examples gt PRINT LOG 12 gt PRINT LOG EXP 1 2 484906 1 5 5 2 2 2 This function raises the number 2 7182818 to the
109. he current selected program may reside X in either RAM or EPROM See Section 3 4 titled Installing X the User Prom for X additional information X concerning EPROM s Important Be sure X you have selected the program you want to save before using the PROG command Your X module does not automatically copy the RAM program to ROM You must also disable interrupts prior to the PROG PROGI x or PROG2 commands using X CALL 8 X and enable interrupts X after the PROM is X burned using X CALL 9 X If an error X occurs during EPROM programming the X message ERROR PROGRAMMING is X displayed When this X error occurs previously X stored programs may or X may not X be accessible you cannot X store X additional programs on this PROM After you type X PROG cr the BASIC Module displays X the number in the EPROM FILE the X program occupies Programming X can take up to 12 minutes X to complete depending X on the length X of the program 51 seconds per K bytes of program 5 3 13 Command PROG continued Chapter 5 Operating Functions Example gt LIST 10 FOR 1 1 TO 10 20 PRINT XI 30 NEXTI 40 END READY gt CALL 8 REM DISABLE INTERRUPTS gt PROG 12 gt READY CALL 9 REM ENABLE X INTERRUPTS gt ROM 12 READY gt LIST 10 FOR I 1 TO 10 20 PRINT XI 30 NEXT XI 40 END READY gt In this X example the program just placed in the EPROM is X the 12th program stored Important If you exc
110. he second is the string to be searched for a match One return argument is required If the number is not zero then a match was located at the position indicated by the value of the return argument This routine is similar to the BASIC INSTR findstr str Example L INSTR 1 2 gt 10 REM SAMPLE FIND STRING IN STRING ROUTINE gt 20 STRING 1000 20 gt 30 1 456 gt 40 2 12345678 gt 50 PUSH 1 REM STRING NUMBER OF STRING TO BE FOUND gt 60 PUSH 2 REM BASE STRING NUMBER gt 70 CALL 64 REM GET LOCATION OF FIRST CHARACTER gt 80 POPL gt 90 IF L 0 THEN PRINT NOT FOUND gt 100 IF L gt 0 THEN PRINT FOUND AT LOCATION L gt 110 END gt RUN FOUND AT LOCATION 4 READY Chapter 5 Operating Functions 5 10 3 5 10 3 6 String Support Calls Replace a String in a String CALL 65 continued This routine replaces a string within a string Three arguments are gt 10 gt 20 gt 30 gt 40 gt 50 gt 70 gt 80 gt 90 gt 100 gt 110 gt 120 RUN expected The first argument is the string number of the string which replaces the string identified by the second argument string number The third argument is the base string s string number There are no return arguments REM SAMPLE OF REPLACE STRING IN STRING STRING 1000 20 0 RED LINES 1 RED 2 gt 60 PRINT BEFORE 0 0 PUSH 2 REM STRING NUMBER OF THE STRING TO REPLACE WITH PUSH 1 RE
111. inwards slightly 3 Rotate the screwdriver and battery cover counterclockwise 1 4 turn 4 Release the pressure and remove the battery cover 5 Replace the battery with the positive terminal out 6 Replace the battery cover 3 9 Chapter 3 Installing the BASIC Module 3 5 The BAT LOW indicator should go out Battery continued You can monitor the battery low condition in revision A and revision B modules using a XBY 77B4H statement Bit 2 high indicates the battery low condition With revision C modules use CALL 80 to monitor battery status 4 1 Chapter Objectives 4 2 Using the BASIC Module Program and Peripheral Communication Ports Chapter 4 Using the Serial Ports This chapter describes how to use the program serial port and the peripheral serial port to connect terminals Data Cartridge Recorders Digital Cassette Recorders printers and other compatible devices The BASIC Module has a program serial port and a peripheral serial port capable of connecting to various user devices figure 4 1 You can configure each port independently Both ports are electrically isolated from each other and from the backplane up to 500 V with no external power needed Both ports operate from 300 baud to 19 2K baud and default to 1200 baud Figure 4 1 Program Peripheral Port Locations Fram TDM If you use an RS 423 RS 232 device or an Allen Bradley Industrial Terminal you can use up to
112. ition You must type a second to terminate the insert Important When you use insert all text to the right of the cursor disappears until you type the second CTRL A Total line length is 79 characters Invoke the delete command by typing CTRL D This command deletes the character at the cursor position Invoke the retype command by typing the RETURN key This feature retypes the line and initializes the cursor to the first character Invoke the exit command by typing CTRL Q or CTRL C CTRL Q exits the editor and replaces the old line with the edited line CTRL C exits the editor with no changes made to the line Invoke the renumber command by typing any of the following commands a REN begins at the start of the program and continues through the end of the program The new line numbers begin at 10 and increment by 10 REN NUM begins at the start of the program and continues through the end of the program The new line numbers begin at 10 and increment by NUM 8 3 7 Renumber continued Chapter 8 Editing A Procedure a REN NUMI NUM 2 begins at the start of the program and continues through the end of the program The new line numbers begin with NUMI and increment by NUM2 REN NUMI NUM2 NUM3 begins at NUM2 and continues through the end of the program The new line numbers begin with and increment by NUM3 Important The renumber command updates the destination of
113. l transfers X back to the statement X after X the FOR statement X Stepping backwards FOR X I 100 TO 1 STEP 1 is X permitted in the BASIC Module You may not X omit the index from the x NEXT statement in the module The NEXT statement X is always followed by the appropriate variable You may nest FOR NEXT loops up to 9 times Examples gt 10 FOR I 1 TO 4 gt 10 FOR I O TO 8 STEP 2 gt 20 PRINT I gt 20 PRINT I gt 30 NEXT I gt 30 NEXT I gt 40 END gt 40 END gt RUN gt RUN 1234 0 2 4 6 8 READY gt READY gt Mode RUN Type CONTROL GOSUB The GO SUB X num statement X causes the BASIC Module x to transfer X control of the program directly to the line number In num following the GOSUB statement X In addition X the GOSUB statement saves the location X of the statement following x GOSUB on the control stack so that you can perform a RETURN statement to return X control X to the statement X following X the most recently X executed GO SUB STATEMENT Chapter 5 Operating Functions 5 4 12 Statements GOSUB In num RETURN continued 5 4 13 Statement GOTO In num RETURN Use this statement X to return X control to the statement following X the most recently executed GO SUB STATEMENT Use one return for each GOSUB to X avoid overflowing X the C STACK This X means that x a subroutine X called by the GO SUB statement X can call another subroutine with another GOSUB statement Exa
114. ley a Rockwell Automation Business has been helping its customers improve productivity and quality for more than 90 years We design manufacture and support a broad Allen Bradley range of automation products worldwide They include logic processors power and motion control devices operator interfaces sensors and a variety of software Rockwell is one of the world s leading technology companies Worldwide representation ELA M Argentina e Australia Austria e Bahrain Belgium Brazil e Bulgaria e Canada e Chile China PRC Colombia e Costa Rica e Croatia e Cyprus e Czech Republic e Denmark Ecuador e Egypt e El Salvador e Finland e France e Germany e Greece e Guatemala e Honduras e Hong Kong Hungary e Iceland e India e Indonesia e Ireland e Israel e Italy e Jamaica e J ordan e Korea e Kuwait e Lebanon Malaysia e Mexico e Netherlands e New Zealand e Norway e Pakistan e Peru e Philippines e Poland Portugal e Puerto Rico e Qatar e Romania e Russia CIS e Saudi Arabia e Singapore e Slovakia e Slovenia e South Africa Republic e Spain e Sweden e Switzerland e Taiwan e Thailand e Turkey e United Arab Emirates e United Kingdom e United States e Uruguay e Venezuela e Yugoslavia Allen Bradley Headquarters 1201 South Second Street Milwaukee WI 53204 USA Tel 1 414 382 2000 Fax 1 414 382 4444 Publication 1771 6 5 34 J uly 1987 PN 955101 26 Copyright 1987 Allen Bradley Company Inc P
115. lock functions Setting the Wall Clock Date D day Day Month Year CALL 41 aan Y year Three values are PUSHed and POPed Example Program the wall clock for the 16th day of June 1985 gt 10 D 16 06 Y 85 DAY OF MONTH 16 MONTH 6 YEAR 85 gt 20 PUSH D M Y PUSH DAY OF MONTH MONTH YEAR gt 30 CALL 41 CALL THE ROUTINE TO SET THE WALL CLOCK DATE 5 9 3 CALL 42 sets the day of the week Sunday is day 1 Saturday is day 7 Set Wall Clock Day of Week Ex ample CALL 42 gt 3 CALL 42 REM DAY IS TUESDAY 5 9 4 Date Time Retrieve String CALL 43 5 9 5 Date Retrieve Numeric Day Month Year CALL 44 2 5 9 6 Time Retrieve String CALL 45 Chapter 5 Operating Functions CALL 43 returns the current date and time as a string PUSH the number of the string to receive the date time dd mmm yy HH MM SS You must allocate a minimum of 18 characters for the string This requires you to set the maximum length for all strings to at least 18 characters Example gt 10 STRING 100 20 gt 20 PUSH 1 CALL 43 REM put date time in string 1 gt 30 PRINT 1 gt 40 END CALL 44 returns the current date on the argument stack as three numbers There is no input argument to this routine and three variables are returned The date is POPed in day month and year order Example gt 10 REM DATE RETRIEVE NUMERIC EXAMPLE gt 20 CAL
116. module in any I O slot of the I O chassis except for the extreme left slot This slot is reserved for processors or adapter modules You can place your module in the same module group as a discrete high density module if you are using processors or adapters with single slot addressing capabilities Important Certain processors restrict the placement of block transfer output modules Refer to the user manual for your particular processor for more information Initially you can insert your module into any I O module slot in the I O chassis However once you designate a slot for a module you must not insert other modules into these slots We strongly recommend that you use the plastic keying bands shipped with each I O chassis to key I O slots to accept only one type of module Your module is slotted in two places on the rear edge of the board The position of the keying bands on the backplane connector must correspond to these slots to allow insertion of the module You may key any I O rack connector to receive the module assembly Snap the keying bands onto the upper backplane connectors between the numbers printed on the backplane figure 3 1 Between 8 and 10 Between 32 and 34 Chapter 3 Installing the BASIC Module 3 2 3 Module Keying Figure 3 1 continued Keying Diagram for Placement of Module Keying Bands You may change the position of these bands if subsequent system design and rewiring makes insertion of a differe
117. mples SIMPLE SUBROUTINE NESTED SUBROUTINES gt 10 FOR I 1 TO 5 gt 10 FOR I 1 gt 20 GOSUB 100 gt 20 GOSUB 100 gt 30 NEXT I gt 30 NEXT I gt 40 END gt 40 END gt 100 PRINT I gt 100 REM USER SUBROUTINE HERE gt 110 RETURN gt 105 PRINT I gt RUN gt 110 GOSUB 200 1 gt 200 PRINT LI I 2 gt 210 RETURN 3 gt RUN 4 5 1 1 24 READY 3 9 gt READY gt Mode COMMAND AND OR x RUN Type CONTROL The GOTO In num statement X causes BASIC to transfer control directly to the line number In X num following the GOTO statement Example gt 50 GOTO 100 If x line 100 exists X this statement causes X execution X of the program to resume at line 100 If line number 100 does not exist the message ERROR INVALID X LINE X NUMBER X is printed to the console device 5 4 13 Statement GOTO In num continued 5 4 14 Statements ON expr GOTO In num In num In num ON expr GOSUB In num In num In num 5 4 15 Statements IF THEN ELSE Chapter 5 Operating Functions Unlike the RUN command the GOTO statement if executed in the COMMAND mode does X not clear the variable storage space or interrupts However if x the GOTO statement is executed in the COMMAND mode after a line X is edited the module clears X the variable storage X space and all BASIC evoked interrupts This is necessary because X the variable storage and the BASIC program reside in the same RAM memory Because X of
118. n PROM for the RAM program checks PROM validity if no program is found prints a good or bad PROM message A bad PROM message with an address of 00 indicates an incomplete program cannot detect a defective PROM No PUSHes or POPs are needed Chapter 5 Operating Functions 5 12 5 Reset Print Head Pointer CALL 99 5 12 6 Print the Argument Stack CALL 109 5 12 7 Print the Peripheral Port Output Buffer and Pointer CALL 110 5 12 8 Print the Peripheral Port Input Buffer and Pointer CALL 111 You can use CALL 99 when printing out wide forms to reset the internal print head character counter and prevent the automatic CR LF at character 79 You must keep track of the characters in each line You can solve this problem in revision or B modules using DBY 1 6H 0 Example gt 10 THIS PRINTS TIME BEYOND 80TH COLUMN gt 20 PRINT TAB 79 gt 30 CALL 99 gt 40 PRINT TAB 41 TIME gt 50 PRINT H M S gt 60 END CALL 109 prints the top 9 values on the argument stack to the console No PUSHes or POPs are needed Use this information as a troubleshooting aid It does not affect the contents of or pointer to the stack CALL 110 prints the complete buffer with addresses front pointer and the number of characters in the buffer to the console No PUSHes or POPs are needed Use this information as a troubleshooting aid It does not affect the contents of the b
119. ng Connections Program Port Peripheral Port Chassis S hield TXD Output 31 31 RXD Input 4 41 RTS Output 5 CTS Input 6 61 DSR Input n 7 Signal Common 8 8 DCD Input 9 91 Signal Common 10 101 Signal Common 11 11 C 12 12 C 13 13 NC 14 141 RS 422 TXD 15 15 C 16 161 RS 422 RXD 17 17 NC 18 181 RS 422 RXD 19 19 20 20 DTR Output X 4 22 22 NC 23 23 24 24 C 25 251 RS 422 TXD Isignal is provided on this pin The baud rate is initially set at 1200 baud You can use CALL 78 to change the baud rate from 300 to 19 2K bps The program port has the following fixed format parity none start bits 1 a stop bits 1 data bits 8 receiver threshold 200 mV driver output loaded 3 6V 4 3 Chapter 4 Using the Serial Ports 4 3 Program Port continued 4 3 1 Using the XOFF XON Commands for the Program Port 44 Important The program port always resets the most significant bit of all its data inputs The range of each byte of data is 0 to 127 7 On output the module transmits all bits as specified when using the PRINT command except for the XOFF 13H character The range of each byte of data is 0 to 255 OFFy Important The program port automatically inserts a CR LF sequence after the 79th character column Use CALL 99 to reset the column counter to zero to allow PRINT page width s in excess of 79 char
120. nt type of module necessary Use needle nose pliers to insert or remove keying bands 3 2 4 There are three sets of user selectable configuration plugs on the BASIC Configuration Plugs Module figure 3 2 You can use these configuration plugs to select PROM size peripheral port baud rate bps 422 receiver termination 3 3 Chapter 3 Installing the BASIC Module 3 2 4 Configuration Plugs Figure 3 2 continued The Configuration Plugs Peripheral Port Baud Hate bps jn 192E User PROM Sine 9500 16 byte 4800 center right pins 2400 32K byte M heft canter pina 800 422 Recalver Type 10011 Terminated 422 receiver top center ping Unterminated pins E 391 factory All other configuration plugs factory set Do not reset these factory set configuration plugs 3 4 Chapter 3 Installing the BASIC Module 3 2 5 Now that you have determined the configuration power requirements Module Installation location keying and wiring for your module you are ready to install it in the I O chassis 1 Turn off power to the I O chassis 2 Insert your module in the I O rack Plastic tracks on the top and bottom of the slots guide the module into position Do not force the module into its backplane connector Apply firm even pressure on the module to seat it properly Note the rack module group and slot numbers and enter them in the module address secti
121. nverted value in internal floating point format The sign bit is bit number 16 Chapter 5 Operating Functions 5 7 9 Input Call Conversion Routines continued 5 7 9 4 6 Digit Signed Fixed Decimal BCD to Internal Floating Point XXXXXX CALL 13 The input argument is the number 1 64 of the first word 6 digit BCD is sent to the BASIC module in two processor words of the write block transfer buffer to be converted from 6 digit signed fixed decimal BCD to internal format The maximum values allowed are 999999 The output argument is the converted value in internal floating point format The sign bit is bit number 16 5 7 9 5 4 Digit BCD to Internal Floating Point XXXX CALL 17 The input argument is the number 1 64 of the word in the write block transfer buffer to be converted from 4 digit BCD to internal format The maximum value allowed 15 0 9999 The output argument is the converted value in internal floating point format Sample input conversions gt 20 PUSH 3 REM CONVERT 3rd WORD OF PLC DATA 730 CALL 10 REM DO 3 DIGIT BCD TO CONVERSION 740 POP W REM GET CONVERTED VALUE STORE IN VARIABLE W gt 20 PUSH 9 REM CONVERT STARTING WITH 9th WORD OF PLC DATA 730 CALL 13 REM DO 6 DIGIT BCD TO CONVERSION 740 POP L 9 REM GET CONVERTED VALUE STORE IN ARRAY L 9 5 7 10 Output Call Conversion Routines of the output call conversion routines require the same sequence of commands These
122. oes not respond odule s programming port tinues to function but FLT LED goes on and off odule s programming port tinues to function and FLT LED goes out when processor witched to program mode odule s programming port tinues to function and FLT LED remains on Probable Cause Recommended Action Hardware failure Send module for repair Problem with block transfers Verify ladder logic between processor and BASIC module Problem with block transfer Send module for repair circuitry on the BASIC Module The BASIC Module has a 32 K byte EPROM installed figure 3 4 We recommend that you keep JEDEC standard 8 K 16 K or 32 K byte EPROMSs which use 12 5 V DC programming voltage as spares You buy 32 byte EPROMs from Allen Bradley part numbers 940654 02 or 9406454 03 3 7 Chapter 3 Installing the BASIC Module Installing the User Prom continued Figure 3 4 User PROM and Battery Holder Locking Schw Usor Pin 1 Bathory Gover PLI p battery alignment To replace the EPROM 1 the small screw in the socket just above the chip figure 3 4 1 4 turn counterclockwise 2 Remove the old chip 3 Insert the new chip with pin one down and the center notch down as shown in the socket diagram 4 Turn the small screw in the socket above the chip 1 4 turn clockwise 5 Refer to the above section titled Configuration Plugs for the prope
123. of any number used with the routine are truncated Figure 7 2 Truncated 3 Digit BCD Integer 17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 00 OOTAN e D3 2 01 Implied decimal point BCD Value not used underflow bit 1 value is fractional and between 1 1 ie 999 to 999 sign bit 1 negative 0 positive overflow bit 1 value gt 999 15032 This value requires one word of the processor data table The data is represented by a 4 digit BCD integer figure 7 3 The value ranges from 0 9999 There is no indication of sign underflow or overflow However if a value of greater than 9999 is converted the value reported is 0000 Fractional portions of any number used with the routine are truncated 7 2 3 4 digit Unsigned Fixed Decimal BCD continued 7 2 4 4 digit Signed Octal Chapter 7 Data Types Figure 7 3 Truncated 4 Digit BCD Integer 17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 00 04 03 2 D1 Implied decimal point BCD Value 15033 This value requires one word of the processor data table The data is represented by a 4 digit octal integer figure 7 4 The value ranges from 7777 8 4095 Overflow underflow and sign are also indicated If an overflow or underflow condition exists the appropriate bit is set and the value of 0000 is reported Fractional portions of any number used in this routine are truncated
124. ogram is X modified X during the STOP or after X an error Example gt 10 FOR I 1 TO 10000 gt 20 PRINT XI gt 30 PRINT XI gt 40 END gt RUN Uo 4 5 TYPE CONTROL x C X ON CONSOLE STOP IN LINE 20 READY gt PRINT I 6 gt I 10 gt CONT 10 11 12 Action X taken The LIST command prints the program to the console device Spaces are inserted after the line number and before X and after statements X This helps in the debugging of BASIC Module programs You can X terminate the listing X of a program at anytime X by typing a Control C on the console device You can interrupt and continue X the listing using Control S and Control Q 5 7 Chapter 5 Operating Functions 5 3 3 Command LIST continued 5 3 4 Command LIST or LIST 5 8 Variations Two variations of the LIST command are possible with the BASIC Module They are 1 LIST In num cr 2 LIST num In num cr The first X variation X causes the program to print X from the designated line X number integer to the end of the program The second variation causes the program to print from the first line number integer X to the second line X number integer Important You must X separate X the two line X numbers with X a dash C Example READY gt LIST gt 10 PRINT LOOP PROGRAM gt 20 FOR I 1 TO 3 gt 30 PRINT I gt 40 NEXT I gt 50 END READY gt LIST 30 gt 30
125. ommand You must enter CTRL C during program execution or you must execute a STOP statement before the CONT command can work DIVIDE BY ZERO A DIVIDE BY ZERO error occurs if you attempt to divide by zero 12 0 9 2 Error Messages from BASIC continued 9 3 Error Messages from CALL Routines 9 3 1 Data Conversion CALL Error Messages 9 3 2 Peripheral Port Support CALL Error Messages Chapter 9 Error Messages and Anomalies EXTRA IGNORED Error occurs when an INPUT statement requiring numeric data receives numeric data followed by letters Letters are ignored Error also occurs from CALL 61 MEMORY ALLOCATION A MEMORY ALLOCATION error occurs when user memory RAM is full BASIC cannot determine memory bounds because the system control value MTOP is altered RAM contains an incomplete program file you attempt to access STRINGS that are outside the defined string limits NO DATA A NO DATA message occurs if a READ STATEMENT is executed and no DATA STATEMENT exists or all DATA was read and a RESTORE instruction was not executed The message ERROR NO DATA IN LINE XXX is printed to the console device PROGRAMMING If an error occurs while the BASIC Module is programming an EPROM a PROGRAMMING error occurs error during programming destroys the EPROM file structure You cannot save any more programs on that particular EPROM once a PROGRAMMING error occurs If the EPRO
126. ommand or direct mode X and the interpreter X or run mode You can only enter commands when the X processor is in the command or direct X mode This X document uses X the terms run mode and command mode X to refer X to the two different X operation X modes A BASIC program consists X of statements Every statement begins X with a line X number followed X by a statement body and terminated X with x a carriage X return cr or a colon in the case of multiple X statements per line X There are three types of statements assignments input output X and control Every line in a program must have X a statement line X number ranging between X 0 and 65535 X inclusive X BASIC uses X this to order the program statements in sequence You use a statement number only X once in a program BASIC automatically X orders X statements in ascending order A statement X may not contain more than X 79 characters BASIC ignores X blanks spaces and automatically inserts them during a LIST command Chapter 5 Operating Functions 5 2 2 Statements continued 5 2 3 Format Statements 5 2 4 Data Format 5 2 5 Integers 5 2 You may put more than X one statement on a line if separated by a colon X You can use only one statement number per X line You can enter lower case characters X in the COMMAND mode Any keywords commands variable and array names entered in lower case change to upper case when store
127. on of the block transfer instructions 3 the I O chassis latch over the module This secures the module in place 3 2 6 You must use the following procedure when powering up the module for Initial Start up Procedure the first time This procedure is a continuation of the installation procedure presented above 4 Connect the cable from your program terminal to the BASIC Module program port CAUTION Be sure you properly ground the system be fore turning on power difference in ground potential between the BASIC Module serial connectors and your program terminal or other serial device can cause damage to the equipment or loss of module programs 5 Turn on your program terminal Select 1200 baud If you are using an industrial terminal select the Alpha Numeric mode baud rate and press RETURN 6 Turn on power to the rack The following sequence takes place Fault FLT and ACTIVE LED s go on FLT and ACTIVE LED s go out until power up diagnostics is complete Ignore any other LED activity during power up ACTIVE LED goes on 3 5 Chapter 3 Installing the BASIC Module 3 2 6 When the ACTIVE LED comes on observe the sign on message displayed Initial Start up Procedure on the terminal followed by lt READY continued You are now ready to begin BASIC programming Refer to Chapter 6 for an example program to help you get your processor and BASIC Module communicating properly Important I
128. ort Display Peripheral Port Parameters CALL3I sei oues Ss owe bbade E Eq 5 8 3 Save Program to Data Recorder CALL 32 5 8 4 Verify Program with Data Recorder CALL 33 5 8 5 Load Program from Data Recorder CALL 34 5 8 6 Get Numeric Input Character from Peripheral Port CALL 35 5 8 7 Getthe Number of Characters in the Peripheral Port Buffers CALL 36 5 8 8 Clear the Peripheral Ports Input or Output Buffer CALL 37 5 8 9 Save Labeled Program to Data Recorder LTIO SB only 3B iius sr 5 8 10 Load Labeled Program from Data Recorder 1770 SB only S CALL 39 5a coa ebria Sawa iw nd caw 5 8 11 Printthe Peripheral Port Output Buffer and Pointer CALL TR 5 8 12 Print the Peripheral Port Input Buffer and Pointer CALL 111 5 8 13 Reset the Peripheral Port to Default Settings CALL 119 5 9 Wall Clock Support o4 du brem bee pedet 5 9 1 Setting the Wall Clock Time Hour Minute Second CALL 40 5 9 2 Setting the Wall Clock Date Day Month Year CALL 41 5 9 3 Set Wall Clock Day of Week CALL 42 5 9 4 Date Time Retrieve String CALL 43 5 9 5 Date Retrieve Numeric Day Month Year CALL 44 2 5 9 6 Time Retrieve String CALL45 5 9 7 Time Retrieve Number 46 5 9 8 Retrieve Day of Week String
129. ort Support CALL Error Messages 9 3 3 Wall Clock CALL Error Messages 9 3 4 String Support CALL ErrorMessages 9 3 5 Memory Support CALL Error 9 3 6 Miscellaneous CALL Error Messages 9 4 Anomalies Quick Reference Guide Decimal Hexadecimal Octal ASCII Conversion Table Basic Module Programming Hints BASIC Module Programming 5 1 1 Chapter Objectives 1 2 What this manual contains 1 3 Audience 1 4 Definitions of major terms Chapter 1 Using This Manual Read this chapter before you use the BASIC Module It tells you how to use this manual properly and efficiently This manual shows you how to install and operate your module It gives you information about hardware specifications installing the module a the BASIC instruction set programming the module This manual is not a BASIC tutorial document We assume that you are familiar with BASIC programming Before you read this manual or try to use the BASIC Module you should be familiar with the operation of the 1771 I O structure as it relates to your particular processor Refer to our Publication Index publication number 510499 for the appropriate Programming and Operations manual To make this manual easier for you to read and understand
130. outines S1 S2 and pass variables on the stack as shown in the previous example you can avoid any GLOBAL variable problems in the BASIC Module The PUSH and POP statements accept dimensioned variables A 4 and 51 12 as well as scalar variables This is useful when large amounts of data must be PUSHed or POPed when using CALL routines Example gt 40 FOR I 1 TO 64 gt 50 PUSH I gt 60 CALL 10 gt 70 POP A D gt 80 NEXT I Chapter 5 Operating Functions 5 4 27 Statement REM 5 40 Mode COMMAND and or RUN Type CONTROL Performs no operation REM is short for REMark REM allows you to add comments to a program to make it easier to understand If a REM statement appears on a line the entire line is used for the REM statement You cannot terminate a REM statement using a colon however you can place a REM statement after colon This allows you to place a comment on each line Example gt 10 REM INPUT ONE VARIABLE gt 20 INPUT A gt 30 REM INPUT ANOTHER VARIABLE gt 40 INPUT B gt 50 REM MULTIPLY THE TWO gt 60 Z A B gt 70 REM PRINT THE ANSWER gt 80 PRINT Z gt 90 END gt 10 INPUT A REM INPUT ONE VARIABLE gt 20 INPUT B REM INPUT ANOTHER VARIABLE gt 30 7 REM MULTIPLY THE TWO gt 40 PRINT 7 REM PRINT THE ANSWER gt 50 END The following example does NOT work because the entire line is interpreted as a REMark The PRINT statement is not executed Example gt 10 RE
131. pheral Port 4 4 4 Connecting 1770 Printer to the Peripheral Port 4 4 5 Connecting RS 422 Devices Chapter 4 Using the Serial Ports You can use a 1770 SB Data Cartridge Recorder or 1770 SA Digital Cassette Recorder to save and load BASIC programs to the BASIC Module Fig hows cable pin connections Use the connections shown in figure 4 6 otherwise improper operation could occur Note that the standard cable does not connect properly with the BASIC Module Refer to the user manuals for the 1770 SB publication number 1770 6 5 4 and 1770 SA publication number 1770 6 5 1 for more information on these recorders It is not necessary to set the peripheral port parameters except baud rate before CALLing the recorder interface routines This is done automatically by the software The parameters are returned to their original state when the routine is complete You can find more information on saving and loading programs in Chapter f this manual Important STR LINK II and Recorders do not function like SA SB recorders Do not use them with the BASIC Module You can connect a 1770 HC Printer to the peripheral port for program listing report generation etc Figurd 4 7 shows cable pin connections Refer to your printer product manual for more information We recommend enabling XON XOFF on the peripheral port see Chapter section titled Peripheral Port Support Parameter Set and selecting XON XOFF DEC protocol
132. ple gt PRINT A SPC 5 B Use the above statement to place an additional 5 spaces between the A and B in addition to the two that would normally print 5 4 22 3 PRINT Use CR in a PRINT statement to force a carriage return but no line feed You can use CR to create one line on a CRT device that is repeatedly updated Example gt 10 FOR I 1 TO 1000 gt 20 PRINT gt 30 NEXT I The above example causes the output to remain on one line only No line feed is ever sent to the console device Chapter 5 Operating Functions 5 4 22 Special Print Formatting Statements continued 5 4 22 4 PRINT USING special characters Use the USING function to tell the BASIC Module what format to use when displaying printed values The module stores the desired format after the USING statement is executed All outputs following a USING statement are in the format evoked by the last USING statement executed You do not need to execute the USING statement within every PRINT statement unless you want to change the format U is a shorthand notation for USING Important The USING statement applies to numbers following it until another USING statement is encountered 5 4 22 5 PRINT USING Fx This forces the BASIC Module to output all numbers using the floating point format The value of x determines how many significant digits are printed If x equals 0 the module does not output any trailing zeros so the number o
133. port Display Peripheral Port Parameters CALL 31 The five values PUSHed on the stack before executing the CALL are in the following order Number of bits word 5 6 7 8 Parity Enable 0 2 1 0 dd Number of Stop Bits 1 1 Stop Bit 2 2 Stop Bits 3 1 5 Stop Bits Software Handshaking 0 1 XON XOF Hardware Handshaking 0 Disable DCD 1 enable DCD 100 PUSH 8 REM 8 BITS WORD 120 PUSH 0 REM NO PARITY 140 PUSH 1 REM 1 STOP BIT 160 PUSH 0 REM NO SOFTWARE HANDSHAKING 180 PUSH 0 REM DISABLE DCD 200 CALL 30 REM SET UP PERIPHERAL PORT 100 PUSH 8 0 1 0 0 CALL 30 Important Hardware and software handshaking is disabled and both I O buffers are cleared on power up This routine displays the current peripheral port configuration on the terminal No argument is PUSHed or POPed Enter CALL 31 return from the command mode Example CALL 31 RETURN DCD OFF STOP BIT NO PARITY 8 BITS CHAR Important XON XOFF status is shown only if enabled 5 8 3 Save Program to Data Recorder CALL 32 5 8 4 Verify Program with Data Recorder CALL 33 Chapter 5 Operating Functions Important Maximum baud rate is 2400 bps for all data recorder CALL routines The Peripheral Port is set up in these routines and does not need setting in BASIC This routine saves the current RAM program 1770 S A SB recorder The program in RAM is not modified The message ERROR IN ROM displays if ROM is
134. power of the argument Examples gt PRINT EXP 1 gt PRINT EXP LOG 2 2 7182818 2 5 5 2 3 Trig Functions 5 5 2 3 1 SIN expr Returns 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 Examples gt PRINT SIN PI 4 gt PRINT SIN 0 7071067 0 5 5 2 Unary Operators continued Chapter 5 Operating Functions 5 5 2 3 2 COS expr Returns the cosine of the argument The argument is expressed in radians Calculations are carried out to 7 significant digits The argument must be between 200000 Examples gt PRINT COS PI 4 gt PRINT COS 0 7071067 1 5 5 2 3 3 TAN expr Returns the tangent of the argument The argument is expressed in radians The argument must be between 200000 Examples gt PRINT TAN PI 4 gt PRINT TAN 0 1 0 5 5 2 3 4 ATN expr Returns the arctangent of the argument The result is in radians Calculations are carried out to 7 significant digits The ATN operator returns a result between PI 2 3 1415926 2 and PI 2 Examples gt PRINT ATN PI gt PRINT ATN 1 1 2626272 78539804 5 5 2 4 Comments on Trig 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 P
135. program continues to run INVALID MTOP ADDRESS ENTERED This error occurs when you select an invalid RAM location for a new MTOP value when using CALL 77 PROGRAM NOT FOUND This error occurs if a program number higher than 255 is PUSHed when using CALL 71 or 72 or if the program is not found Chapter 9 Error Messages and Anomalies 9 3 6 INVALID BAUD RATE ENTERED This error occurs when a baud rate Miscellaneous CALL other than 300 600 1200 2400 4800 9600 or 19 2K bps is PUSHed Error Messages use CALL TS INCOMPLETE ROM PROGRAM FOUND This error occurs when CALL 81 detects an incomplete program in the EPROM You can burn no additional programs onto this PROM earlier programs are still accessible NO PROGRAM FOUND BUT THE PROM IS NOT BLANK x This error occurs if miscellaneous data is found on a blank PROM using CALL 81 You should clear the PROM before using it NEGATIVE VALUE NOT VALID x This error occurs if you attempt to convert a negative number using CALL 21 9 4 Anomalies are deviations from the normal Anomalies in the BASIC Anomalies Module can occur as the module compacts or tokenizes the BASIC program The known anomalies and cautions are as follows 1 When using the variable H after a line number put a space between the line number and the H If you do not the program assumes that the line number is a HEX number Examples Wrong Right gt 20 10 gt 20 10 gt LIST gt
136. r setting of the corresponding configuration plug 3 8 3 4 1 Electrostatic Discharge 3 5 Battery Chapter 3 Installing the BASIC Module Electrostatic discharge can damage integrated circuits or semiconductors in this module if you touch backplane connector pins It can also damage the module when you set configuration plugs and or switches inside the module Avoid electrostatic damage by observing the following precautions Touch a grounded object to rid yourself of charge before handling the module s Do not touch the backplane connector or connector pins If you configure or replace internal components do not touch other circuit components inside the module If available use a static safe work station When not in use keep the module in its static shield bag CAUTION Electrostatic discharge can degrade performance or damage the module Handle as stated above The 13 K bytes of user RAM and the clock calendar are battery backed Drain on the battery should be less than 0 5 mA DC during battery back up no power and less than 50 uA while the module is powered Battery life during no power conditions is about 2000 hours Battery shelf life is about 20 000 hours When the BAT LOW indicator comes on the battery should maintain the clock and program data for about three days We recommend immediate replacement To replace the battery figure 3 4 1 Place a screwdriver in the battery cover slot 2 Press
137. rinted in USA
138. ry backed RAM Chapter 5 Operating Functions 5 4 Description of Statements 5 4 1 Statement CALL integer 5 4 2 Statement CLEAR 5 4 3 Statement CLEARI clear interrupts The following sections list and describe the statements you can X use with the BASIC Module Mode X COMMAND AND OR RUN Type X CONTROL You X use the CALL integer statement to call specially X written BASIC Module application programs Specific X call numbers are X defined later in this chapter Mode X COMMAND AND OR RUN Type X CONTROL The X CLEAR statement X sets all variables equal to 0 and resets all BASIC evoked interrupts and stacks This means that after the CLEAR statement is executed an ONTIME statement X must be executed before the module acknowledges the X internal timer interrupts ERROR trapping using the ONE X RR statement also does not occur X until an ONERR integer X statement is executed The CLEAR statement X does not affect X the real time clock that is enabled by the x CLOCK1 statement X CLEAR also does not reset the memory that has been allocated X for strings X so it is not necessary X to enter X the STRING expr X expr statement X to re allocate X memory for strings after the CLEAR X statement X is executed In general X CLEAR is used X to erase X all variables Mode X COMMAND AND OR RUN Type X CONTROL The X CLEARI statement clears all of the BASIC evoked interrupts x The ONTIME interr
139. s X contain X a RAM buffer that eliminates the need to output NULL characters X after a carriage return Action taken This command stops X execution of the current program and returns the BASIC Module x to the COMMAND mode In some cases you can continue X execution using a CONTinue See X the explanation for CONTinue for more information 5 3 7 1 Command Disabling Control C Action taken This command disables X the Control C break X function You can do this X by setting bit 48 to 1 Bit 48 is located in internal memory location 38 26H Set bit 48 by executing the following statement in a BASIC Module program or from the X command mode DBY 38 x DBY 38 OR 01H When bit X 48 is set to 1 the Control C break function for both LIST and RUN operations X is disabled Cycling power returns Control C to normal operation X if it is disabled X from the command mode To re enable the Control x C function execute the following statement in a BASIC Module X program or X from the X command mode DBY 38 x DBY 38 AND 0FEH CALL routines X do not check for this feature If you enter a Control C while x using a CALL routine the program stops if Control C is enabled or disabled 5 9 Chapter 5 Operating Functions 5 3 8 Command Control 6 5 3 9 Command Control 5 3 10 Overview of EPROM File Commands 5 3 11 Commands RAM and ROM integer Action X taken This command interrupts x the scrolling X o
140. sing CALL 62 BAD PUSHED This error occurs if the string position pointer is zero invalid position using CALL 66 INSUFFICIENT STRING SIZE This error occurs if the resulting string cannot hold all required characters when using CALLs 61 or 66 Example gt 10 STRING 100 9 REM MAX OF 9 CHR S STRING gt 20 0 2 01234567 gt 30 1 890 If you attempt to insert or concatenate an error occurs because the resulting string requires 11 characters 9 5 Chapter 9 Error Messages and Anomalies 9 3 4 String Support CALL Error Messages continued 9 3 5 Memory Support CALL Error Messages 9 6 BAD POSITION This error occurs if you attempt to access a string position that is beyond the declared length of the string when using CALL 66 Example gt 10 STRING 100 9 gt 20 0 1234 gt 30 1 56 gt 40 PUSH 6 REM INVALID POSITION OF 0 gt 50 PUSH REM 1 60PUSHO0 REM 0 gt 70 CALL 66 REM INSERT 1 INTO 0 POS 6 BAD POSITION error results because position 6 is outside of the declared string EXTRA IGNORED This error occurs when the resulting string cannot hold all the characters when using CALL 61 Similar to insufficient string size error Extra characters are lost Input An input statement requiring numeric data received numeric data followed by letters The letters are ignored Example Input A Entering 1 23AB causes this error message The
141. string number The second is the string number of the string to be deleted from the base string This routine has no return arguments Important This routine deletes only the first occurrence of the string gt 10 REM ROUTINE TO DELETE A STRING IN A STRING gt 20 gt 30 gt 40 gt 50 gt 60 gt 70 gt 80 gt 90 gt 100 gt RUN STRING 200 14 1 123456789012 2 12 PRINT BEFORE 1 1 PUSH 1 REM BASE STRING NUMBER PUSH 2 REM STRING NUMBER OF THE STRING TO BE DELETED CALL 67 REM INVOKE STRING DELETE ROUTINE PRINT AFTER 1 1 END BEFORE 1 123456789012 AFTER 1 3456789012 READY Chapter 5 Operating Functions 5 10 3 5 10 3 9 String Support Calls Determine Length of a String CALL 68 continued This routine determines the length of a string One input argument is expected This is the string number on which the routine acts One output argument is required It is the actual number of non carriage return CR characters in this string This is similar to the BASIC command LEN str Example L LEN 1 gt 10 REM SAMPLE OF STRING LENGTH 220 STRING 100 10 gt 30 1 1234567 gt 40 PUSH 1 REM BASE STRING gt 50 CALL 68 REM INVOKE STRING LENGTH ROUTINE gt 60 POP L REM GET LENGTH OF BASE STRING gt 70 PRINT THE LENGTH OF 1 IS 71 gt 80 END gt RUN THE LENGTH OF 1234567 IS 7 READY 5 11 The following sections list and describe the memor
142. t t TH OO r cO C D A C C ce NM t NA CO c tr i oO r sr F F b HH 40 HH Hm lt lt x x occ u c t S gt Z o e e O gt go KF u c OOOO gt gt DH WM lt u gt ua vn A C Z HN O c ue 176 126 136 137 076 077 BASIC Module Programming Hints Appendix C Basic Module Programming Hints These programming hints can help you to properly program your module to increase module performance 2 99 Always define strings first Always dimension arrays after defining strings Define the most used variables first You can use 0 values until you assign real values When doing math save intermediate values rather than recalculate Place the most used subroutines near the beginning of the program Straight through code executes faster but uses more memory Put multiple statements on a line after the program has been debugged Comments use space and slow program execution After the program is debugged save a fully commented copy on tape or spare ERROM and remove comments 9 Rockwell Automation Allen Brad
143. t and describe the miscellaneous calls you can use with the BASIC Module CALL 78 allows you to change the program port baud rate from its default value 1200 baud to one of the following 300 600 1200 2400 4800 9600 or 19 2 K baud PUSH the desired baud rate and CALL 78 The program port remains at this baud rate unless CALL 73 is invoked or the battery is removed and power is cycled If this happens the baud rate defaults to 1200 baud Example gt 10 PUSH 4800 gt 20 CALL 78 5 12 2 Blink the Active LED by Default CALL 79 5 12 3 Check Battery Condition CALL 80 5 12 4 User PROM Check and Description CALL 81 Chapter 5 Operating Functions The Active LED is on constantly during program execution or command mode When you issue a CALL 79 the Active LED remains on while a program executes and blinks every second when the module is in the command mode Issue CALL 79 again to cancel the blinking LED CALL 80 checks the module s battery condition If a 0 is POPed after a CALL 80 battery is okay If a 1 is POPed a low battery condition exists Example gt 10 CALL 80 gt 20 POPC gt 30 IFC lt gt 0 THEN PRINT BATTERY LOW gt 40 END Use CALL 81 before burning a program into PROM memory This routine determines the number of PROM programs determines the number of bytes left in PROM determines the number of bytes in the RAM program prints a message telling if enough space is available i
144. t statement in a module program X automatically terminates program execution X if you do not use an end statement X You should always X use an END statement X to terminate a program Examples END STATEMENT TERMINATION gt 10 FOR 1 1 4 gt 20 GOSUB 100 gt 30 gt 40 END gt 100 PRINT xI gt 110 RETURN gt RUN gt READY Variations X None Mode RUN Type CONTROL Use the X FOR TO STEP NEXT statements X to set up and control loops Example gt 5 B 0 x C 10 D 2 gt 10 FOR A x B TO C STEP D gt 20 PRINT gt 30 NEXT A gt 40 END 5 4 11 Statements FOR TO STEP NEXT continued 5 4 12 Statements GOSUB In num RETURN Chapter 5 Operating Functions Since 0 C 10 and D 2 the PRINT statement X at line X 20 executes 6 times The values of printed are 0 2 4 6 8 and 10 A represents the name of the index or loop counter The value of is the starting value of the index The value X of is the limit X value of the index and the X value of D is the increment X to the index If the STEP statement and the value D are omitted X the increment value X defaults X to 1 therefore STEP is an optional statement x The NEXT statement X adds the value of D to the index X The index is then compared to the value of the limit X If the index is less than or equal to the limit contro
145. teimal andbexpoinemtittl 25 C hexadecimal and exponential the 1771 1 0 backplane 500 V Qa Torpg utput 3 6 minimudndule location The Peripheral Portis isolated from lana 50 ppm year 25 One 1771 1 0 chassis module slot the 1771 1 0 backplane 4500 V driver and receiver Backplane power supply load The Programming Portis isolated from 3 6 V minimum 15 the Peripheral Port 500 V Receiver sensitivity 200 mV minimum Environmental Conditions Communication Rates 66 Operational temperature 0 to 60 C 300 600 1200 2400 4800 9600 Precision 8 significant digits 8286 to 140 19 2 K bits Range 1 127 to 40 C to 85 C Communication rates distances 99999999E 127 40 F to 185 Relative humidity 5 to 95 non condensing Keying top backplane connector Rate bps RS 232 C Between 8 and 10 300 Between 32 and 34 600 1200 4800 9600 19 200 Communication Maximum Distance Allowed 2 4 Chapter 3 Installing the BASIC Module 3 1 This chapter describes how to install your BASIC module in a 1771 I O Chapter Objectives rack After reading this chapter you should be able to configure the module using the configuration plugs insert the module into a 1771 I O backplane understand module status indicators install additional EPROM s 3 2 Installing the BASIC module WARNING Disconnect and lockout all AC power
146. terisk appears on the terminal indicating that the load operation is complete Tape motion ceases and the BASIC prompt 7 appears If you are using 1770 S Recorder press STOP Important This routine loads the first program encountered and does not distinguish between labelled programs See section 5 8 10 below titled Load Labeled Program from Data Recorder 1770 SB only CALL 39 for an explanation of labelled programs 5 8 6 Get Numeric Input Character from Peripheral Port CALL 35 Chapter 5 Operating Functions This routine gets the current character in the 255 character peripheral port input buffer It returns the decimal representation of the characters received as its output argument The peripheral port receives data transmitted by your device and stores it in this buffer If there is no character the output argument is 0 null If there is a character the output argument is the ASCII representation of that character There is no input argument for this routine Example gt 10 CALL 35 gt 20 POP X gt 30 IF X 0 THEN GOTO 10 gt 40 PRINT CHR X Important A 0 null is a valid character in some communications protocols You should use CALL 36 to determine the actual number of characters in the buffer Important Purge the buffer before storing data to ensure data validity Chapter 5 Operating Functions 5 8 6 Get Numeric Input Example Character from Peripheral Port CALL 35
147. tes of memory that belong to Q You can X clear X the memory allocated X to variables by executing a CLEAR statement X The CLEAR statement frees all memory allocated X to variables 5 3 Chapter 5 Operating Functions 5 2 8 Variables continued 5 2 9 Expressions 5 2 10 Relational Expressions 5 2 11 System Control Values 5 4 Important The BASIC Module requires less time to find a scalar variable because there is no expression X to evaluate If you want to X run a program as X fast as possible X use dimensioned X variables only when necessary Use scalars X for intermediate variables and assign the final result to a dimensioned X variable Also put the most frequently used variables x first Variables defined first X require the least amount of time to locate An expression X is a logical X mathematical X expression that involves operators both unary and dyadic X constants and variables X Expressions are simple or complex e g 12 EXP AY100 H 1 X 55 or SIN A SIN A COS A COS A 2 X A stand alone x variable var or constant const is also considered an expression We refer X to expressions as expr Relational X expressions involve X the operators EQUAL X NOT EQUAL lt gt GREATER THAN X OR X EQUAL TO X gt and LESS THAN OR X EQUAL TO lt You use them in control statements to test a condition X i e IF A 100 THEN Relational X expressions always requir
148. th of a string as an input This number must normally be inclusively between zero and the second number used in the last STRING statement which specifies the maximum size of a string However in all cases if a string length argument of minus one 1 is given it is interpreted as the maximum allowable string length Chapter 5 Operating Functions 5 10 3 String Support Calls continued It is important to note that since the carriage return character is the string terminator you cannot use it within a string as one of its characters If the high bit is set in a carriage return character use 141 instead of 13 as the decimal value of the carriage return character the BASIC Module does not recognize it as the end of string character and passes it to the output device Most devices use a seven bit ASCII code ignore the top bit and treat the 141 as a normal carriage return Important undefined characters of a string i e characters following CR are nulls If data is input to a string using the ASC X I command you must be sure the string is CR terminated properly You can initialize the string or add a CR to terminate the string Example gt 10 STRING 100 10 gt 20 FOR I 1 TO 5 gt 30 ASC 0 D 65 gt 40 NEXT I gt 50 PRINT 0 gt RUN AAAAA The string is stored in memory without a CR terminator Be sure to insert a CR ODH into the last position of the string if using the above method Example
149. this editing a program can destroy variables Mode RUN Type X CONTROL The value X of the expression X following the ON statement X is the number in the line list that control is transferred to Example 7 10 ON GOTO 100 200 300 If Q is equal to 0 control X is transferred X to line number 100 X If Q is equal to 1 control is transferred to line number 200 If Q is equal to 2 GOTO line 300 etc All comments that apply to GOTO and x GOSUB apply X to the ON statement If Q is less than X ZERO a BAD ARGUMENT ERROR X is X generated X If Q is greater than the line number list X following X the GOTO or GOSUB statement a BAD SYNTAX X ERROR X is generated The ON statement X provides conditional branching X options within the constructs of a BASIC Module X program Mode RUN Type X CONTROL The IF statement sets up a conditional test The general form of the IF THEN X ELSE statement follows In num IF rel expr THEN valid X statement x ELSE valid statement Example gt 10 IF x A 100 THEN A 0 ELSE 1 Chapter 5 Operating Functions 5 4 15 Statements IF THEN ELSE continued 5 4 16 Statement INPUT Upon execution X of line 10 IF A is X equal to 100 THEN A is assigned a value of IF A does not equal 100 A is assigned a value of 1 If you want to X transfer X control to different line numbers using the IF statement you may omit X the GOTO statement X The following examples give
150. trol files must be different for the next block transfer to occur The equal instruction is used at power up At power up the BTR and BTW control files both equal zero At power up the BTW enables and block transfers begin You can use the following ladder logic program with PLC 5 Family processors This program assumes that your application requires a single BTR and BTW to pass data between the processor and the BASIC Module i e transfer of 64 words or less If the transferred data exceeds 64 words you must program multiple file to file moves to move different data sets to and from the block transfer files The PLC 5 block transfer program is an alternating read write program i e at the completion of the BTW the BTR enables At the completion of the BTR the BTW enables The processor checks data validity before accepting read data and sets one enable bit at a time Figurd 6 6 s a generic sample block transfer program for a PLC 5 family processor Figurd 6 7 s an actual sample program Chapter 6 Programming 6 5 Figure 6 6 PLC 5 Family Processors Sample PLC 5 Family Ladder Logic continued BTW 1 BIW EN EN Control Block Data File yyy Continuous no BTW BTR 2 BTR EN EN Control Block zzz Data Fil
151. ts the internal read pointer X to the beginning of the data so that it may be read again Example gt 10 FOR I 1 3 gt 20 READ A B gt 30 PRINT A B gt 40 NEXT I gt 50 RESTORE gt 60 READ A B gt 70 PRINT A B gt 80 DATA 10 20 x 10 2 20 2 SIN PD COS PI gt RUN 10 20 5 10 0 1 10 20 Every time X a READ statement X is encountered the next consecutive expression X in the DATA statement X is evaluated and assigned X to the variable in the READ statement X You can place DATA statements anywhere within a program X They are not executed X and do not cause an error DATA statements are considered to be chained X together and appear to be one large DATA statement If at anytime all the data is read and another READ statement is executed X the program terminates and the message ERROR NO X DATA X IN LINE XX X prints to the console device Chapter 5 Operating Functions 5 4 7 Mode x COMMAND x AND OR RUN Statement DIM Type X Assignment DIM reserves storage for matrices The storage X area is first assumed X to be zero X Matrices X in the BASIC Module X may have only X one dimension and the size X of the dimensioned X array may not X exceed 254 elements Once a variable is dimensioned in X a program it may not be re dimensioned X An attempt to re dimension X an array causes an ARRAY SIZE X ERROR If an arrayed X variable is used that is not dimensioned by the DIM statement BASIC assigns a default
152. ts Battery Backup Disabled when executed and allows a purging reset The next power loss destroys the contents of RAM When power is reapplied RAM is cleared and battery back up is reenabled automatically CALL 74 enables the battery backed RAM and prints Battery Backup Enabled when executed It is enabled on power up and remains enabled until you execute a CALL 73 or until the battery fails Important Change MTOP from command mode only to ensure proper operation CALL 77 reserves the top of RAM memory for protected variable storage Values are saved if BATTERY BACKUP is invoked You store values with the ST command and retrieve them with the LD command Each variable stored requires 6 bytes of storage space You must subtract 6 times the number of variables to be stored from MTOP reducing available RAM memory This value is PUSHed onto the stack as the new MTOP address All appropriate variable pointers are reconfigured Do this only in command mode Important Do not let the ST address write over the MTOP address This could alter the value of a variable or string Example For saving 2 variables gt PUSH 14323 REM NEW MTOP ADDRESS gt CALL 77 gt 10 678 gt 15 L 520 PUSH gt 30 ST 14335 REM STORE IN PROTECTED AREA gt 40 PUSH L gt 50 ST 14329 gt 55 REM TO RETRIEVE PROTECTED VARIABLES gt 60 LD 14335 REM REMOVE FROM PROTECTED AREA gt 70 POP K gt 80 LD 14329 gt 90
153. uffer CALL 111 prints the complete buffer with addresses front pointer and the number of characters in the buffer to the console No PUSHes or POPs are needed Use this information as a troubleshooting aid It does not affect the contents of the buffer Chapter 5 Operating Functions 5 12 9 CALL 119 resets the peripheral port to the following default settings Reset the Peripheral Port to Default Settings CALL 119 s isto No parity DCD off XON XOFF off No PUSHes or POPs are needed 6 1 Chapter Objectives 6 2 Block Transfer with the BASIC Module 6 2 1 Block Transfer Write and Block Transfer Read Buffers Chapter 6 Programming After reading this chapter you should be able to program your BASIC Module for use with a programmable controller use block transfer to communicate with a programmable controller This chapter shows the BASIC programming and ladder logic needed for use with your processor It also gives you sample programs Your BASIC Module communicates with any processor that has block transfer capability Your ladder logic program and BASIC program work together to enable proper communications between the module and processor The BASIC Module is a bi directional block transfer module Bi directional means that the module performs both read and write block transfer operations You transfer data 1 to 64 16 bit words from your module to the processor s data
154. under Output Data Types except for 3 3 digit BCD Refer to the above descriptions The BASIC Module converts the data looking at the sign bit when applicable Refer to the programming manual for your processor for the proper data formats 8 2 Chapter Objectives 8 2 Entering the Edit Mode 8 3 Editing Commands Features 8 3 1 Move 8 3 2 Replace Chapter 8 Editing A Procedure After reading this chapter you should be able to make corrections or modifications to your BASIC programs using the editing features presented To invoke the edit mode type EDIT and the line number of the RAM program line to edit For example gt EDIT 10 The following features are available in the edit mode right left cursor control replace a character insert a character delete a character s retype a line Use the following editing commands to make corrections or modifications to your BASIC program in RAM The move feature provides right left cursor control The space bar moves the cursor one space to the right The RUB OUT DELETE key moves the cursor one space to the left The replace feature allows you to replace the character at the cursor position Type the new character over the previous one Chapter 8 Editing A Procedure 8 3 3 Insert 8 3 4 Delete 8 3 5 Retype 8 3 6 Exits 8 3 7 Renumber 8 2 Invoke the insert command by typing CTRL A This command inserts text at the cursor pos
155. upt X disables after the CLEARI statement X executes CLEARI does not affect the real time clock x enabled X by the CLOCKI statement You can use this statement X to selectively x DISABLE ONTIME interrupts during specific X sections of your BASIC X program You must X execute the X ONTIME statement again before the specific interrupts enable Important When the CLEARI X statement is LISTED it appears X as CLEAR X I 5 4 4 Statement CLEARS 5 4 5 Statements CLOCK1 and CLOCKO Chapter 5 Operating Functions Mode x COMMAND RUN Type CONTROL The CLEARS statement resets X all of the module s X stacks The control X argument and internal X stacks all reset to their initialization values You can use this X command to reset the stack 1f an error X occurs in a subroutine Important When the CLEARS statement is LISTed it appears as CLEAR S Mode COMMAND AND OR RUN Type CONTROL CLOCK1 The CLOCKI statement enables the real time clock x feature X resident on the BASIC Module x The special X function operator TIME is incremented X once every X 5 milliseconds after the CLOCK1 statement is executed The CLOCK1 STATEMENT uses an internal TIMER to generate an interrupt once every 5 milliseconds Because of this the special X function operator TIME has a resolution X of 5 milliseconds The special X function operator X TIME counts X from 0 to 65535 995 seconds X After reaching X a count of 65535 995 seconds x TIME
156. w of EPROM File Commands 5 3 11 Commands RAM and ROM 555 comin dork Quiscisded naan vostra Levinas wees Table of Contents iii 5 9 12 Command APER 5 93 13 Command PR DI 2 223 544 Y eet ea mane 5 3 13 1 User PROM Check and Description CALL 81 5 3 IE Command PROGI uar dao uo Gor ax ink op dese 5 3 15 Command PROGZ vik suas san OR awe 5 4 Description of Statements 5 4 1 Statement CALL integer 5 52 Statement CLEAR 5 4 3 Statement CLEARI clear 5 4 4 Statement CLEARS 5 4 5 Statements CLOCK1 and CLOCKO E a Ec AQUAE CLOG DT 5 4 6 Statements DATA READ RESTORE DATA os Ki VIS EIN 5 47 Statement DIM 50 e ERR 5 4 8 Statements DO UNTIL rel expr 5 4 10 Statement END 5 4 11 Statements FOR STEP NEXT 5 4 12 Statements GOSUB In num RETURN GOSUB iius ois ced Bebo o bh he ik De oq Tes RETURN toten bte oai oda e Qao a OR aed 5 4 13 Statement
157. we avoid repeating product names where possible We refer to the BASIC Language Module Cat No 1771 DB as the BASIC Module Industrial Terminal System Cat No 1770 T3 T4 as the industrial terminal s Data Recorder Cat No 1770 S A SB as the 1770 SA SB Recorder RS 232 C compatible devices which communicate with the BASIC Module such as the Industrial Terminal SA SB Recorder computers robots barcode readers or data terminals as RS 423A RS 232C devices Chapter 1 Using This Manual 1 5 There are three different types of precautionary statements in this manual Important information Important CAUTION and WARNING Important used to point out specific areas of concern when operating your BASIC Module CAUTION used to make you aware of instances where damage to your equipment could occur WARNING used to make you aware of instances where personal injury could occur 1 6 In this manual we use certain notational conventions to indicate Conventions keystrokes and items displayed on a CRT or printer A keystroke is shown in parentheses ENTER 2 1 Chapter Objectives 2 2 General Features Chapter 2 Introducing the BASIC Module This chapter discusses the functions and features of the BASIC Module When you finish reading this chapter you should a understand and be able to identify the hardware components of the BASIC Module understand the basic features and functions o
158. wo words of the processor data table The first word q Aigi i contains the overflow underflow sign data and the three most significant 3 3 digit Signed g g Fixed Decimal BCD digits of the value The second word contains the lower three digits of the value figure 7 6 The value ranges from 999 999 to 999 999 If an overflow or underflow condition exists a value of 000 000 is reported and the appropriate bit is set Any digits more than 3 places to the right of the decimal point are truncated Figure 7 6 Truncated 3 3 Digit BCD 17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 00 1 A Decimal Point Integer Portion of Value not used underflow bit 1 value smaller than 001 ie 0002 UL sign negative O positive overflow 1 value lt 999 999 17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 AOH LL Not used Fractional Portion of Value 15036 7 5 Chapter 7 Data Types 7 3 Input Data Types 7 6 The BASIC Module interfaces with the PLC 2 PLC 3 and PLC 5 family processors You can send the following data types to the BASIC Module types to the BASIC Module 16 bit binary 4 Hex digits XXXX a 3 digit signed fixed decimal BCD XXX 4 digit unsigned fixed decimal BCD XXXX 4 digit signed octal XXXX a 6 digit signed fixed decimal BCD XXXXXX These data formats are the same as those described
159. y support calls you can Memory Support Calls use with the BASIC Module strings arrays and variables are shared Chapter 5 Operating Functions 5 11 1 This routine shifts program execution from a running ROM program to the ROM to RAM Program beginning of the RAM program No arguments are PUSHed or POPed Transfer CALL 70 Important The first line of the RAM program is not executed We recommend that you make it a remark Example ROM 5 gt 10 REM SAMPLE ROM PROG FOR CALL 70 gt 20 PRINT NOW EXECUTING ROM 5 gt 30 CALL 70 REM GO EXECUTE RAM gt 40 END RAM gt 10 REM SAMPLE RAM PROGRAM FOR CALL 70 gt 20 PRINT NOW EXECUTING RAM gt 30 END gt RUN NOW EXECUTING ROM 5 NOW EXECUTING RAM 5 11 2 This routine transfers from a running ROM or RAM program to the ROM RAM to ROM Program beginning of any available ROM program One argument is PUSHed Transfer CALL 71 which ROM program None are POPed An invalid program error ansfer C 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 Example gt 10 REM THIS ROUTINE WILL CALL AND EXECUTE A ROM ROUTINE gt 20 INPUT ENTER ROM ROUTINE TO EXECUTE N gt 30 PUSHN gt 40 CALL 71 gt 50 END gt RUN ENTER ROM ROUTINE TO EXECUTE 4 5 11 2 ROM RAM to ROM Program Transfer CALL 71 continued 5 11 3 RAM ROM R
160. y you must set your terminal for 1200 baud Use CALL 78 to change the program port baud rate The program port is fixed at no parity 1 start bit 1 stop bit and 8 data bits It also supports XON XOFF for interruption of LISTing or to suspend data output from the program port 2 2 Chapter 2 Introducing the BASIC Module 2 3 One RS 423A 232C RS 422 compatible serial communications port Hardware Features PERIPHERAL port supporting bi directional XON XOFF software continued handshaking and RTS CTS DTR DSR DCD hardware handshaking for interfacing to printers and commercial asynchronous modems You can change the peripheral port configuration using a CALL 30 Refer to Section 5 8 1 Default values are 1 start bit 1 stop bit 8 bits character no parity handshaking off and 1200 baud The baud rate is jumper selectable 300 to 19 2 K bps Refer to Section 3 2 4 titled Configuration Plugs Interface to the 1771 I O rack backplane to support block transfer Wall clock calendar with battery back up available for program access Battery replacement without removing the module from the I O rack All power derived from the backplane 1 5 A a Multiple BASIC modules can reside in the same I O rack and function independently of each other 2 4 Your module runs BASIC language programs in an interactive mode Software Features through the dumb terminal programming port interface or on power up The execution of
161. you store the driver package on the hard drive to increase execution speed Most driver packages have upload and download capability Refer to the driver documentation for these commands 4 3 4 2 Wiring Figure 4 5 Connecting a T50 Industrial Terminal to a BASIC Module T50 Industrial Terminal BASIC Module Serial Port Program Port 9 pin female 4 7 Chapter 4 Using the Serial Ports 4 4 Peripheral Port 48 The peripheral port is an asynchronous serial communication channel compatible with RS 423A 232C or RS 422 interfaces It uses bi directional XON XOFF software handshaking and RTS CTS DTR DSR DCD hardware handshaking for interfacing with printers terminals and commercial asynchronous modems Use a CALL routine to change peripheral port configuration Configure the baud rate 300 to 19 2K bps by setting a configuration plug Refer to figurd 32 configuration plug locations In addition the peripheral port has the following format requirements configurable parity odd even or none m fixed start bits 1 configurable stop bits 1 1 5 or 2 configurable data bits 5 6 7 or 8 receiver threshold 200 mV driver output loaded 3 6V Defaults are 1 start bit 1 stop bit 8 bits character no parity handshaking off and 1200 baud When you select 8 bits character you have full access to all 8 bits of each character on both input and output data bytes Refer to figure 4 2 for peripheral port
Download Pdf Manuals
Related Search
Related Contents
4 - Klint Wärme-Wasser IMPORTANT! - Appliances Connection compact ATS-909X - Thiecom コンビ ラブリーメリー取扱説明書 Brother PT-2430PC Printer User Manual Application Trace Logger Bioclave 12L manual tecnico 取扱説明書 GBW-105S MIO-CARE PRO - I-Tech Medical Division Copyright © All rights reserved.
Failed to retrieve file