Z Technology, Inc.
R500 SeriesQuick Basic
Control Software
Application noteBy the
Engineering Staff
Z Technology, Inc.
December 19, 1997
Version 2
Table of Contents
Introduction
Quick Basic Control Software Programs
STAT.BAS and STAT.EXE (simplest program)
Transmissions to the R-500 Series Meter
Transmissions from the R-500 Series Meter
Introduction
Many features of the R-500 series field strength meter are accessible through the RS-232 serial communication port. Use of the RS-232 port along with a personal computer (PC) allows operation of the instrument via computer programs or directly from the PC keyboard.
Several control software programs are provided which can be used to control the field strength meter with a computer. The purpose of this application note is to help the R-500 series operator effectively use the R-500 Series Quick Basic Control Software Disk made available by Z Technology.
Getting Started Equipment Needed ComputerTo remotely control the R-500 series field strength meter a "controller" is necessary. Any computing device with the ability to transmit and receive the necessary RS-232 communications can control the instrument. For the purpose of this application note, the controller recommended to run the supplied programs is an IBM compatible personal computer.
The examples described herein were written using the high level programming language QBASIC. It is a universal language and is distributed with MSDOS version 6.2 and earlier. This language includes RS-232 communication capabilities. QBASIC is an interpretive language meaning the QBASIC interpreter interprets a line of source code at a time while running. To make executable files Microsoft QUICK BASIC ver 4.5 is used.
The PC must have one of its serial ports correctly connected to the R-500 series field strength meter. Proper connections are assured if you use the standard "straight through" RS-232 cable provided with the meter. The standard "straight through" RS-232 cable has a DB9 male connector on one end and DB9 female connector or the other end. If your PC is equipped with only a DB25 male connector serial port, use a DB25 female to DB9 male adapter available from your local computer supplier. For reference in building a custom cable below is a pinout of the R-500 Series DB9 Female Connector.
R-500 Series DB9 Female Connector |
|
Pin # |
RS-232 Name |
1 |
|
2 |
RD (R-500 sending) |
3 |
TD (R-500 receiving) |
4 |
DTR |
5 |
Signal Ground |
6 |
DSR |
7 |
RTS |
8 |
CTS |
9 |
|
Factory R-500 Series Communication Parameters |
|
Baud rate: |
9600 (default) or as adjusted, see below |
Data bits: |
8 |
Parity type: |
None |
Stop bits: |
1 |
Remote Address: |
1 ( default) or as adjusted, see below |
R-500 Series meter data bits, stop bits, and parity parameters cannot be changed, the computer's must be set to match those of the instrument. The baud rate and remote address parameters must be set to the same value for both instrument and PC.
Changing the R-500 Series meter's baud rate and remote address: The meter can be set to operate at 1200, 2400, or 9600 baud. Usually, you will want to use the highest baud rate to minimize communications time between the meter and the computer. The remote address can be set to any number between 0 and 255, 1 is the factory default.
The FUNCtion to set baud rate and to set remote address are "locked out" to prevent accidental changes. To access and change them:
To unlock the control functions:
Press the FUNCtion button on the front panel, then use the TUNE-Knob to select "F59".
Press the TUNE-Knob -- the meter will immediately return to its previous operating mode.
Repeat steps 1 and 2 two more times. Function "F59" has now been consecutively selected three times; therefore, the baud rate and remote address functions are unlocked.
You are now ready to control the R-500 Series meter using the Quick Basic Control software provided on the disk.
If you choose to develop your own custom program, it is suggested refer to the Creating Custom Software section later in this application note, and study the STAT.BAS program on the Control Software disk. STAT.BAS is the simplest of all the programs, it has no error checking and uses just one simple command, so it is the easiest to follow. Once you have an understanding of STAT.BAS, you are ready to look at one of the more complex programs. SINGLE.BAS is a good next step. By analyzing these programs, an experienced programmer will quickly understand the communication protocols and the steps required to develop custom programs.
Programs residing on the Quick Basic Control Software disk are presented in both .BAS (basic) and .EXE (executable) formats. At the time this programs note is being written, the following programs are available:
MENU
MEAS_NOW
SINGLE
SCAN
FILE_CTL
STAT
Descriptions of these programs are in the next section of this application note.
All Quick Basic Control Software run in the DOS environment. If you have the Windows operating system, we recommend completely exiting Windows before running a program. (Use of the Program Manager, MSDOS Prompt icon to get to DOS is not recommended, it sometimes causes erratic behavior due to the non real-time nature of the Windows operating system which would still be running.)
Files that end in .BAS must be run from QBASIC. QBASIC is provided with MSDOS version 6.2 or earlier. Those with a .EXE ending are run by simply typing the file name after the DOS C:> prompt.
Each Control program begins with a short description screen. User instructions and requests for necessary input parameters will be displayed before the measurement begins.
This application note reviews each program and gives a brief report of its use.
This program in both .BAS and .EXE form is included for several reasons. It provides a defacto index of useful Commands for controlling the R-500 Series meters and gives the user an easy way to exercise each command. Since all important Commands are presented in this program, it provides a good set of examples for those developing there own custom programs.
A very useful function of this program is in revising Setup parameters for the R-500 Series meter. Timing parameters can be set or modified and the instrument's Data Logging capability enabled and disabled.
The program begins by displaying instructions for connecting the R-500 series meter to a PC. The PC screen is shown in the box below.
| WELCOME TO Z TECHNOLOGY'S 'MENU' PROGRAM Ver. 2.00
Connect the Meter RS-232 port to your PC's communications port Place the Meter in remote mode by pressing the FUNC Button Adjust the TUNE Knob for F93 and push the TUNE Knob Press [ENTER] when ready to continue |
A new set of text is displayed as a reminder of meters normal settings for Address and Baud rate. These two parameters must then be chosen for this session. Finally you are asked to identify the communications or serial port being used by the PC to interface with your R-500 Series meter. Notice the defaults in square brackets match the meter factory defaults.
The Meter is normally shipped with
the following settings:
Choose Meter settings. (Default values are in brackets) Address of Meter? ([1] - 255)? Baud rate? (1200, 2400, or [9600])? Identify the PC communications port you are using PC communications port, ([1], or 2) ? |
The three (3) questions above are each answered in sequence before the next one appears. If the value to be used is the one in square brackets simply press the ENTER key.
Once the user completes the above procedure the following screen is displayed:
| R-505 CONTROL PROGRAM V.
2.00 ----------------------- TAKE READINGS ---------------------------
----------------------- SET PARAMETERS --------------------------
----------------------- TIME FUNCTIONS --------------------------
------------------ MEMORY/STORAGE FUNCTIONS ---------------------
|
|||||||||||||||
Follow the directions of the last line or type in a number corresponding to its associated command then press ENTER. Entering "
X" exits the programs.To Setup special R-500 Series meter parameters enter "
S". This option allows the user to tailor three (3) different types of instrument settings:
|
||||||||||||||||||||||||||||||||||||||||||
Address 1888
When "B", 1888, is set to 01 Resident Data Logging is enabled. On the R-505 only, while set to 01 (enabled), the RS-232 port communication has approximately 500 msec added to every serial port command or exchange. When 1888 is set to 00 (disabled) Resident Data Logging is not possible; however, in this mode serial communication speed is increased dramatically since the above mentioned 500msec is eliminated. It is our experience that most users are concerned with RS-232 port speed. Since this is the case, the standard R-505 is shipped with Resident Data Logging disabled. That is, at the factory, 1888 is loaded with 00. (The following timing values assume 1888 is set to 00 on the R-505).
Note: Certain highlighted main-menu functions set features that can be used only in the Data Logging Mode. The functions in this category are 3, 4, 5, 6, 13, 14, 15 and 16. These items are active, only when address 1888 it set to 01.
Address 18AB
"D", 18AB, sets the number of "readings" which are averaged before a "measurement" is sent to the serial port or the front panel. In order to increase meter measurement accuracy, multiple readings are recommended. The instrument is normally calibrated with this parameter set to 04. In that case, a "measurement" is the averaged of four (4) "readings".
All Data (for all addresses) must be entered in Hex. For instance, to have a measurement be the average of 15 readings, enter the Hex value "0F".
Addresses 1880 & 18AA
"A", 1880, and "C", 18AA, are used to set delays between "readings" (A) or between groups of "measurements" (C).
An example will help to understand the sequence of these values. When 1880, 18AA and 18AB are set at the above default values, four (4) "readings" will be taken, with 10msec of delay between each reading, and a delay of 24.6 msec is added between each group of four "readings". In addition to these delays, a normal system delay of approximately 150msec is inherent in the instrument. Below is a diagram of "measurement" cycle time.

MEAS_NOW.BAS and MEAS_NOW.EXE
This program performs a field strength measurement at a specified frequency on command. The time is recorded and a "Comments" field is provided for recording notes after each measurement.| WELCOME TO Z TECHNOLOGY'S 'MEAS_NOW' PROGRAM Ver. 2.00
This program will repeatedly take measurements at
a specified Connect the Meter RS-232 port to your PC's communications port Place the Meter in remote mode by pressing the FUNC Button Adjust the TUNE Knob for F93 and push the TUNE Knob Press [ENTER] when ready to continue |
The Meter is normally shipped with the following settings:
Choose Meter settings. (Default values are in brackets)
Identify the PC communications port you are using PC communications port, ([1], or 2) ? |
| Enter Frequency (3.000 to 1000.000) MHz , [0] to exit |
| Freq = 103.3 PC Comm Port = 1 Meter Address = 1 Baud rate = 9600
|
||||||
Respond with F, R, Q, or RETURN. A RETURN command immediately begins the measurement routine. Choosing F will clear the screen and create the following message:
| Enter file name, DIR, CD, or MD |
When this step is finished, the program begins the measurement routine. Information is displayed on the screen and recorded to the named file. A sample of the display with the Comment field utilized follows:
|
||||||||||||
The following information is displayed when run:
| WELCOME TO Z TECHNOLOGY'S 'SINGLE' PROGRAM Ver. 2.00
This program will repeatedly take
measurements at a single Connect the Meter RS-232 port to your PC's communications port Place the Meter in remote mode by pressing the FUNC Button Adjust the TUNE Knob for F93 and push the TUNE Knob Press [ENTER] when ready to continue |
The Meter is normally shipped with the following settings:
Choose Meter settings. (Default values are in brackets)
Identify the PC communications port you are using
|
| Enter Frequency (3.000 to 1000.000) MHz , [0] to exit 103.3 Time interval between samples (in seconds)? 2 Enter <F> to save results to a file |
If the user responds with the letter "
F" the program displays:| Enter file name, DIR, CD, or MD |
Enter a file name of your choice where the measured data is to be
stored -- or --
Enter "DIR" to display all files and directories on the current disk.
Enter "CD" to choose one of these existing Directories.
Enter "MD" to set up a new Directory.
If the [ENTER] key is selected rather than the letter "
F", the program will begin repeatedly to command the meter to take signal level measurements and display them along with the time. If a file or directory was chosen, the measurements will be displayed on screen and also recorded to the named file. Any key stroke stops the process.A sample of the screen output is printed below. This example uses 2 sec. time intervals.
|
||||||
SCAN.BAS and SCAN.EXE
Choose this program to read a sequence of signal levels at evenly spaced contiguous frequencies. The user chooses the starting frequency and frequency step size. Information will be displayed directly on the PC screen and can be stored in a file.
The following information is displayed when run:
|
The Meter is normally shipped with the following settings:
Address of Meter? ([1] - 255)? Baud rate? (1200, 2400, or [9600])?
PC communications port, ([1], or 2) ?
|
| Start Frequency (3.000 to 1000.000) MHz , [0] to exit 88.3
Frequency step in kHz (must be in
multiples of 5 kHz) ? 200 |
|
FIL_CTL.BAS and FIL_CTL.EXE
This program allows you to create and use a file to control meter measurement sequences. This is most useful when interested in a number of unrelated frequencies. Parameters you select include frequencies, time interval between measurements, and the number of times to run the measurement sequences. Results will be displayed on the PC screen, and can be sent to a file or a printer.
When run, the following information is displayed on screen:
|
|
Enter "
2" to run an existing measurement sequence which you have previously created. To create a new sequence, enter "1". The user is lead through a series of steps accessed via a menu which displays the following:
|
||||||||||||
STAT.BAS and STAT.EXE (simplest program)
This program is a very simple example intended to help the programmer get started creating custom programs for the R-500 Series meter.The screens for the STAT program are shown below.
| STATUS: REPORTS THE STATUS OF THE METER
Address of meter? |
Default address of meter is 1
| STATUS OF THE METER AT REMOTE ADDRESS 1
Frequency tuning state Frequency = 205.250 MHz C:\ > |
STAT.BAS uses the meter Command 29 to "Report the status of the meter". It provides a good example of the meters send and receive communication packet structure. As well as demonstrating how these structures can be implemented in a group of reusable sub-programs. The structure of this example is the basis of all the programs on the Quick Basic Control Software disk.
| STAT.BAS sub-programs | |
Setcom () |
Sets the PC communication parameters, and opens a COM port for communication. |
SendCommand() |
Assembles a packet with a meter command embedded. Likely commands are #20 set the frequency, #35 read the meter, or as in this case, #29 report meter status. |
GetResponse() |
Collects the incoming string of characters from the meters response to a command. Uses COM trapping via the ReadMeter() sub program to collect the individual characters. Remains in this sub program until the specified number in the packet have been received. |
TranslateResponse() |
Decodes the received packet to get to the wanted data, in this case, the meter status. |
ReadMeter() |
Each time a character arrives at the PC COM port this sub program moves it from the PC's input buffer to a string that can be manipulated by the programmer. |
CalcChkSum%() |
Each packet sent to the meter requires an included checksum. This function calculates the checksum. |
The programs on the QUICK BASIC CONTROL SOFTWARE disk provide abundant examples of controlling the R-500 Series meter via its serial port. A good place to start studying an example is to look at the STAT program. The previous section has a brief description of the building blocks (or sub programs) of a control program. All the Quick Basic Control Software programs use these basic building blocks. The blocks are designed to implement the required communication protocol between PC (host) and Meter.
R-500 Series command protocol (syntax)
The R-500 Series meter has a specific command protocol. The following section describes the packet structure used for communication. The meter must be in REMOTE state (FUNCtion 93) for RS-232 communications to take place.
Transmissions to the R-500 Series Meter
The format of the transmissions from the host (computer) to the R-500 Series meter consists of 8 to 24 bytes containing:
Synchronization bytes: Three bytes, each binary "1" (0000 0001)
Host status Flag: Not implemented. Use binary "0" (0000 0000)
Meter's remote address: default = "1" (0000 0001)
Packet size: Total number of bytes being sent.
Command to be executed: Refer to the Operators Manual RS-232 COMMAND PROTOCOL section for definitions of available commands.
Data bytes: Data (from 0 to 16 bytes) as required by the command being sent.
Packet Checksum: The logical compliment of an 8-bit sum of all bytes in the packet excluding the checksum byte.
| Host to Meter data packet structure | |||||||||||
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
... |
n-1 |
n |
Sync |
Sync |
Sync |
Status flag ("0") |
Remote address |
Packet size |
Command |
1st data byte |
2nd data byte |
... |
Last data byte |
Checksum |
Transmissions from the R-500 Series Meter
The R-500 Series meter will respond with a packet consisting of 8 to 24 bytes formatted as follows:
Synchronization bytes: Three bytes, each binary "1" (0000 0001)
Status Flag: Status flag from Meter the bits represent the following:
Bit
Status
0
Always "0"
1
Unable to perform last command
2
Unsuccessful read/write to EEPROM
3
Data log timer needs to be reprogrammed
4
Data log timer has expired
5
Not used
6
Not used
7
Not used
Meter's remote address: default = "1" (0000 0001)
Packet size: Total number of bytes being sent.
Command Echo: Command being responded to.
Data bytes: Data (from 0 to 16 bytes) as required by the command being sent.
Packet Checksum: The logical compliment of an 8-bit sum of all bytes in the packet excluding the checksum byte.
Host to Meter data packet structure |
|||||||||||
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
... |
n-1 |
n |
Sync |
Sync |
Sync |
Status flag |
Remote address |
Packet size |
Command |
1st data byte |
2nd data byte |
... |
Last data byte |
Checksum |