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

The text of a manual · part 11 of 17

1771-DB Basic Module User Manual, pages 101 to 110

Pages 101 to 110 of 167

The original document is the PDF (943 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Allen-Bradley 1771-DB

Page 101

Chapter 5 Operating Functions

5.8.6 Get Numeric Input Character from Peripheral Port – CALL 35 (continued)

Example:

u10 REM PERIPHERAL PORT INPUT USING CALL 35 u20 STRING 200,20 u30 DIM D(254) u40 CALL 35: POP X u50 IF X tu2 GOTO 40 u55 REM WAIT FOR DEVICE TO SEND START OF TEXT u60 REM u70 DO u80 I=I+1 u90 CALL 35: POP D(I) : REM STORE DATA IN ARRAY u100 UNTIL D(I)=3 : REM WAIT FOR DEVICE TO SEND END OF TEXT u120 REM u130 REM FORMAT AND PRINT DATA TYPES u140 PRINT “RAW DATA=” u150 FOR J=1 TO I : PRINT D(J), : NEXT J u155 REM PRINT RAW DECIMAL DATA u160 PRINT: PRINT: PRINT u170 PRINT “ASCII DATA=” u180 FOR J=1 TO I : PRINT CHR(D(J)), : NEXT J u185 REM PRINT ASCII DATA u190 PRINT: PRINT: PRINT u200 PRINT “$(1)=” u210 FOR J=1 TO I : ASC($(1),J)=D(J) : NEXT J u215 REM STORE DATA IN STRING u220 PRINT $(1) u230 PRINT: PRINT: PRINT u240 I=0 u250 REM u260 GOTO 40 READY uRUN RAW DATA= 65 66 67 68 69 70 71 49 50 51 52 53 54 55 56 57 3 ASCII DATA= ABCDEFG123456789 $(1)= ABCDEFG123456789 READY u

5–64

Page 102

Chapter 5 Operating Functions

5.8.7 Get the Number of Characters in the Peripheral Port Buffers – CALL 36

Use this routine to retrieve the number of characters in the chosen buffer as its output argument. You must PUSH which buffer is to be examined. PUSH 1 for the input buffer. PUSH 0 for the output buffer. One POP is required to get the number of characters. Example:

u10 PUSH 0: REM examines the output buffer u20 CALL 36 u30 POP X: REM get the number of characters u40 PRINT “Number of characters in the Output Buffer is”,X u50 END

5.8.8 Clear the Peripheral Ports Input or Output Buffer – CALL 37

This routine clears either the peripheral ports input or output buffer. PUSH 0 to clear the output buffer. PUSH 1 to clear the input buffer. PUSH 2 to clear both buffers. Example:

u10 PUSH 0: REM clears the output buffer u20 CALL 37 u30 END

5.8.9 Save Labeled Program to Data Recorder (1770-SB only) – CALL 38

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

5–65

Page 103

Chapter 5 Operating Functions

5.8.9 Save Labeled Program to Data Recorder (1770-SB only) – CALL 38 (continued)

This routine has one input argument and no output arguments. If no ID number is pushed prior to CALL 38, an error occurs and the routine aborts without saving. An unlabeled save (CALL 32) has an ID of 0. Important: Do not press rewind between programs saved. If you press rewind only the last program is saved.

5.8.10 Load Labeled Program from Data Recorder (1770-SB only) – CALL 39

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 encountered. 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.

5.8.11 Print the Peripheral Port Output Buffer and Pointer – CALL 110

5–66

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.

Page 104

Chapter 5 Operating Functions

5.8.12 Print the Peripheral Port Input Buffer and Pointer – CALL 111

CALL 111 prints the complete buffer with addresses, front pointer and the number of characters in the buffer to the console. No PUSHes or POPs are needed.

5.8.13 Reset the Peripheral Port to Default Settings – CALL 119

CALL 119 resets the peripheral port to the following default settings:

Use this information as a troubleshooting aid. It does not affect the contents of the buffer.

8 bits/character 1 stop bit No parity DCD off XON-XOFF off No PUSHes or POPs are needed.

5.9 Wall Clock Support Calls

The battery backed 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, CLOCK0, ONTIME 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.

5–67

Page 105

Chapter 5 Operating Functions

5.9.1 Setting the Wall Clock Time (Hour, Minute, Second) – CALL 40

Use this routine to set the following wall clock time functions: H = hours (0 to 23) M = minutes (0 to 59) S = seconds(0-59) Example: Program the wall clock for 1:35 pm (13:35 on a 24 hour clock).

u10 H=13: M=35: S=00 u20 PUSH H,M,S u30 CALL 40

:REM HOURS=13; MINUTES=35; SECONDS=00 :REM PUSH HOURS, MINUTES, SECONDS :REM CALL THE ROUTINE TO SET THE WALL CLOCK TIME

5.9.2 Setting the Wall Clock Date (Day, Month, Year) – CALL 41

Use this routine to set the following wall clock functions: D = day M = month Y = year Three values are PUSHed and none POPed. Example:

Program the wall clock for the 16th day of June, 1985 u10 D=16: M=06: Y=85 u20 PUSH D,M,Y u30 CALL 41

:REM DAY OF MONTH = 16, MONTH = 6, YEAR = 85 :REM PUSH DAY OF MONTH, MONTH, YEAR :REM CALL THE ROUTINE TO SET THE WALL CLOCK DATE

5.9.3 Set Wall Clock – Day of Week – CALL 42

5–68

CALL 42 sets the day of the week. Sunday is day 1. Saturday is day 7. Example: uPUSH 3 : CALL 42 REM DAY IS TUESDAY.

Page 106

Chapter 5 Operating Functions

5.9.4 Date/Time Retrieve String – CALL 43

CALL 43 returns the current date and time as a string. PUSH the number of the string to receive the date/time (dd/mmm/yy HH:MM:SS). You must allocate a minimum of 18 characters for the string. This requires you to set the maximum length for all strings to at least 18 characters. Example: u10 STRING 100,20 u20 PUSH 1: CALL 43: REM put date/time in string 1 u30 PRINT $(1) u40 END

5.9.5 Date Retrieve Numeric (Day, Month, Year) – CALL 44 (2)

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: u10 REM DATE RETRIEVE – NUMERIC EXAMPLE u20 CALL 44: REM INVOKE THE UTILITY ROUTINE u30 POP D,M1,Y : REM GET THE DATA FROM THE 30 STACK u40 PRINT “CURRENT DATE IS”, Y,M1,D u50 END uRUN CURRENT DATE IS 84 12 25 READY

5.9.6 Time Retrieve String – CALL 45

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: u10 STRING 100,20 u20 PUSH 1, CALL 45: REM put time in string 1 u30 PRINT $(1) u40 END

5–69

Page 107

Chapter 5 Operating Functions

5.9.7 Time Retrieve Number – Call 46

The time of day is available in numeric form by executing a CALL 46 and POPing the three variables off of the argument stack on return. There are no input arguments. The time is POPed in hour, minute and second order. Example:

u10 REM TIME IN VARIABLES EXAMPLE : REM GET THE WALL CLOCK TIME u20 CALL 46 u30 POP H,M,S u40 PRINT “CURRENT TIME IS”, H,M,S 50 END uRUN CURRENT TIME IS 13 44 54 READY

5.9.8 Retrieve Day of Week String – CALL 47

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: u10 PUSH 0: CALL 47 u20 PRINT “TODAY IS”,$(0)

5.9.9 Retrieve Day of Week Numeric – CALL 48

CALL 48 returns the current day of week on the argument stack as a number (i.e. Sunday = 1, Saturday = 7). This can be POPed into a variable. Example: u10 REM DAY OF WEEK RETRIEVE – NUMERIC EX u20 CALL 44: REM INVOKE UTILITY TO GET D.O.W. u30 POP D

5–70

Page 108

Chapter 5 Operating Functions

5.9.10 Date Retrieve String – CALL 52

CALL 52 returns the current date in a string (dd/mmm/yy). PUSH the number of the string to receive the date. You must allocate a minimum of 9 characters for the string. Example: u10 STRING 100,20 u20 PUSH 1: CALL 52: REM put date in string 1 u30 PRINT $(1) u40 END uRUN 30/JAN/87

5.10 Description of String Operators

A string is a character or group of characters stored in memory. 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: u10 STRING 100,20 u20 $(1)=“THIS IS A STRING,” u30 INPUT “WHAT’S YOUR NAME? – ”,$(2) u40 PRINT $(1),$(2) u50 END uRUN 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).

5–71

Page 109

Chapter 5 Operating Functions

5.10.1 The ASC Operator

Two operators in the BASIC Module can manipulate STRINGS. These operators are ASC() and CHR(). The ASC() operator returns the integer value of the ASCII character placed in the parentheses. Example: uPRINT ASC(A) 65 The decimal representation for the ASCII character “A” is 65. In addition, you can evaluate individual characters in a pre-defined ASCII string with the ASC() operator. Example: u5 STRING 1000,40 u10 $(1)=“THIS IS A STRING” u20 PRINT $(1) u30 PRINT ASC($(1),1) u40 END uRUN 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 “T” is 84. String character position 0 is invalid. Example: u5 STRING 1000,40 u10 $(1)=“ABCDEFGHIJKL” u20 FOR X=1 TO 12 u30 PRINT ASC($(1),X), u40 NEXT X u50 END uRUN 65 66 67 68 69 70 71 72 73 74 75 76 The numbers printed in the previous example represent the ASCII characters A through L.

5–72

Page 110

Chapter 5 Operating Functions

5.10.1 The ASC Operator (continued)

You can also use the ASC() operator to change individual characters in a defined string. Example: u5 STRING 1000,40 u10 $(1)=“ABCDEFGHIJKL” u20 PRINT $(1) u30 ASC($(1),1)=75 REM: DECIMAL EQUIVALENT OF K u40 PRINT $(1) u50 ASC($(1),2)=ASC($(1),3) u60 PRINT $(1) uRUN ABCDEFGHIJKL KBCDEFGHIJKL KCCDEFGHIJKL In general, the ASC() operator lets you manipulate individual characters in a string. A simple program can determine if two strings are identical. Example: u5 STRING 1000,40 u10 $(1)=“SECRET” : REM SECRET IS THE PASSWORD u20 INPUT “WHAT’S THE PASSWORD – ”,$(2) u30 FOR I=1 TO 6 u40 IF ASC($(1),I)=ASC($(2),I) THEN NEXT I ELSE 70 u50 PRINT “YOU GUESSED IT!” u60 END u70 PRINT “WRONG, TRY AGAIN” : GOTO 20 uRUN WHAT’S THE PASSWORD – SECURE WRONG, TRY AGAIN WHAT’S THE PASSWORD – SECRET YOU GUESSED IT

5–73