beautypg.com

Xl™ series – Xylem XL-BASIC Programming Guide User Manual

Page 20

background image

23-20 XL-BASIC Programming Guide

XL™ SERIES

variable for each basic program. The value of the variable is represented by the XX.XX above.
The above screen shows Basic Program number 1, and programs 2 to 5 look and act the same as
this one.

If there is a problem with a program it may be necessary to ‘step’ through the program line by
line. When the single step mode is enabled, com port 1 is turned on and waits for a program to
be executed. When the program is executed each line of the program is printed to the serial port
of the PC and then the program waits for the user to press the PC ENTER key to actually execute
the listed line of code. The stepping operation cannot be activated if scanning is on and is
automatically turned off when scanning is enabled. In most cases it is best to just use the PC
menu to test the XL-Basic programs since it must be connected anyway.

Example XL-BASIC Programs:

Example Program #1

Send Formatted Data To Remote Display


This example give the XL-Basic code for a program that will output the head (pool) and tail
gauge heights (measured using SDI-12 Shaft encoders) to a remote display using the RS-232
Com Port 3 of the H-350XL™. All lines that begin with REM are remarks or comments that are
used to document the program. These lines are not executed / interpreted by the Basic interpreter.
In the logging options of the H-350XL™ could have the following columns defined for
reporting: Date, Time, SDI11, SDI21, and BASIC1. SDI11 and SDI21 are the shaft encoders
used to measure the head and tail gauge levels. BASIC1 would call the XL-Basic program named
xlbasic1.bas which would output the gauge levels to the remote display. Also note that at the end
of the XL-BASIC program the battery voltage is assigned to the variable BASIC1. The battery
voltage value will then be logged into the data file once the XL-BASIC program has terminated.
This eliminates the need to select Batt as a source in the logging options and it also eliminates an
extra column in the data file.

REM XL-BASIC PROGRAM TO DISPLAY STAGE LEVELS (POOL AND TAIL)
REM MEASURED FROM TWO SDI-12 SHAFT ENCODERS TO A IEE 2 X 20
REM REMOTE VACUUM FLUORESCENT DISPLAY CONNECTED TO RS-232 PORT 3.

REM OPEN COM PORT 3 FOR COMMUNICATION
OPENCOM3

REM REMOTE DISPLAY CONTROL COMMANDS
REM 0AH = LF (VERTICAL SCROLL FROM BOTTOM LINE; CURSOR POSITION STAYS)
REM 0DH = CR (RETURN CURSOR TO LEFT MOST POSITION OF CURRENT LINE)
REM 0EH = TURN CURSOR OFF
REM 12H = TURN OFF AUTO CR
REM 14H = RESET DISPLAY

REM REMOTE DISPLAY INITIALIZATION
REM RESET DISPLAY, TURN OFF AUTO CR, TURN CURSOR OFF
PRINT3 &14,&12,&0E

REM PRINT POOL VALUE ON TOP LINE AND TAIL VALUE ON BOTTOM LINE
PRINT3 "POOL = ",SDI11+125.25," FEET"
PRINT3 "TAIL = ",SDI21+125.25," FEET";