Z Technology, Inc.

R500 Series

Quick Basic

Control Software

Application note

By the

Engineering Staff

Z Technology, Inc.

December 19, 1997

Version 2

Table of Contents

Introduction

 

Getting Started

Equipment Needed

Computer

Software

Interconnecting Cables

 

Setting up the System

 

Quick Basic Control Software Programs

Using the Control Software

MENU.BAS and MENU.EXE

MEAS_NOW.BAS and MEAS_NOW.EXE

SINGLE.BAS and SINGLE.EXE

SCAN.BAS and SCAN.EXE

FIL_CTL.BAS and FIL_CTL.EXE

STAT.BAS and STAT.EXE (simplest program)

 

Creating Custom Software

R-500 Series command protocol (syntax)

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

Computer

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

Software

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.

Interconnecting Cables

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

 

Setting up the System

For proper communications between R-500 series meter and computer, the communications parameters between the meter and your PC must match. The Factory default R-500 Series meter parameters are set as follows:

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

Setting the computer's communications parameters: The computer's baud rate, number of data bits, type of parity, number of stop bits and remote address must match those of the R-500 Series meter (Baud rate, 8,N,1 and remote address).

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:

  1. Press the FUNCtion button on the front panel, then use the TUNE-Knob to select "F59".

  2. Press the TUNE-Knob -- the meter will immediately return to its previous operating mode.

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

To change the baud rate or remote address:

  1. Use the FUNCtion button and TUNE-Knob to select function "F43" to change the baud rate or select function "F44" to change the remote address. When you press the TUNE-Knob, the present value will be displayed on the large right LCD. To change it, rotate the TUNE-Knob until the desired value is displayed and press the TUNE-Knob to store the new setting. Press the FUNCtion button to exit the setup function.

You are now ready to control the R-500 Series meter using the Quick Basic Control software provided on the disk.

Quick Basic Control Software Programs

Z Technology provides with each meter a 3.5" floppy disk containing several Quick Basic programs. They can be used as is, or as examples of how to control the R-500 Series meter through the serial port. Programs range from simple to the complex. Each program demonstrates a unique method of data collection. Some programs were written for specific measurement requirements. Users with similar requirements may find these programs useful, just as written. For those users with unique requirements, these programs will be useful as a starting point in developing your own custom programs.

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.

Using the Control Software

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.

MENU.BAS and MENU.EXE

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

After the meter is correctly connected to the PC, press the ENTER ("Return") key.

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:

Address = 1
Baud rate = 9600

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

20 Set frequency
24 Lock attenuator range
29 Report state of meter
61 Read meter at command 60 freqs
35 Read meter
32 Unlock attenuator range
60 Set frequencies for command
62 Set freq & read meter

----------------------- SET PARAMETERS --------------------------

1 Change address
19 Exit Remote
38 Enable/disable freq. cal.
2 Set baud rate
30 Reset meter
37 Enable/disable detector cal.

----------------------- TIME FUNCTIONS --------------------------

3 Read alarm time
4 Set alarm time
9 Turn alarm ON
10 Turn alarm OFF
33 Read the year
5 Read alarm date
6 Set alarm date

13 Read the time
14 Set the time
34 Set the year
7 Turn alarm date ON
8 Turn alarm date OFF
15 Read the date
16 Set the date
12 Check power to the clock

------------------ MEMORY/STORAGE FUNCTIONS ---------------------

25 Transfer log record to PC
26 Recall a setup from memory
17 Read data from Meter memory
51 Enable freq offset control
11 Calculate checksums
27 Store setup in memory
44 Write data to Meter memory
52 Disable freq offset control
To use highlighted functions go to 'Setup'
Enter a number; ('X' to EXIT, 'S' for Setup)?

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:

  1. Delays before and between signal measurements.
  2. Number of signal measurements taken which are averaged and sent to the RS-232 port or the LCD display.
  3. Data Logging Enabled/Disabled.

The following screen appears on the PC:

 
Current New Recommended
Item Address Data Data Data
A 1880 04 04 04

Delay before each group of
4 readings (8.2mS per digit)

B 1888 00 00 00 Fast RS-232 response = 00
Data Logging enabled = 01
C 18AA 0F 0F 0F Delay between each of the 4
signal readings (1mS per digit)
D 18AB 04 04 04 Number of readings averaged before
responding to command 35, 61 or 62

Use A, B, C, or D to change data in the New Data column. Do this for all
addresses to be changed. Then enter U to update all 4 addresses simultaneously.

Recommended Data is suggested for normal serial port response time.
To use Data Logging Mode, address 1888 (item B) must be set to 01.
Highlighted main menu functions are active only during Data Logging Mode

Enter item (A, B, C, or D) to change, or
U to Update and exit or N to exit with No change:

Enter A,B,C, or D to change the corresponding parameter.

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.

When the delay and number of signal readings are set as shown, the total time between serial port measurements will be approximately 205 msec.

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
frequency. The data is displayed on the screen and can be
saved to a file -- including date and time stamps.

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 first screen display is shown above. The second, third and fourth are presented below.

The Meter is normally shipped with the following settings:

Address =
Baud rate = 9600

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) ?

 

Enter Frequency (3.000 to 1000.000) MHz , [0] to exit

 

Freq = 103.3 PC Comm Port = 1 Meter Address = 1 Baud rate = 9600

 

 

 

RETURN
F
R
Q
Proceed without saving results to a file
Specify Filename to save results
Restart this program
Quit this program
F, R, Q or RETURN ---

 

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

Enter a file name of your choice where 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.

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:

 
Test start date: 12-15-1997 Frequency = 103.3 MHz
Time Reading Comments
08:59:09
09:00:11
09:10:25
09:11:43
09:12:51
09:14:38
09:16:58
99.3 dBuV
94.5 dBuV
96.3 dBuV
97.2 dBuV
92.5 dBuV
90.6 dBuV
89.9 dBuV

On Highway I-5 @ Milepost 292
I-5 @ MP 291
I-5 @ MP 290 at HW 217
I-5 @ MP 289
I-5 @ MP 288
I-5 @ MP 287 Exit to 205
I-5 @ MP 285

 

Press [ENTER] to take a reading or enter [Q] to Quit

 

SINGLE.BAS and SINGLE.EXE

This program takes measurements at one frequency. The measured signal levels are displayed on the PC screen and can be saved in a file.

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
frequency. The results can be saved to a file or printed
on the screen

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:

Address = 1
Baud rate = 9600

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) ?

 

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.

 
Press [ENTER] to restart
 

Test start
Time
 

 

date: 12-15-1997
Reading
 

07:37:21
07:37:23
07:37:25
07:37:27
07:37:29
07:37:31
07:37:33
07:37:37
07:37:39

75.6 dBuV
75.4 dBuV
75.7 dBuV
74.7 dBuV
75.4 dBuV
76.2 dBuV
77.1 dBuV
76.2 dBuV
77.0 dBuV

 

 

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:

 

WELCOME TO Z TECHNOLOGY'S 'SCAN' PROGRAM Ver. 2.00

This program will take measurements at a sequence of evenly

spaced frequencies AND report the results.

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:

Address = 1
Baud rate = 9600

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) ?

 

 

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
Number of steps ? 12

Select ENTER to start the program and to display information to the PC screen. Select "F" to display information and save to a file of your choice. (See detailed description above). The screen which follows used a start frequency = 88.3 MHz, frequency step size = 200 KHz and number of steps=12.

 
88.300
88.500
88.700
88.900
89.100
89.300
89.500
89.700
89.900
90.100
90.300
90.500
MHz 72.3 dBuV
MHz 42.0 dBuV
MHz 30.0 dBuV
MHz 68.3 dBuV
MHz 34.3 dBuV
MHz 83.5 dBuV
MHz 43.1 dBuV
MHz 28.8 dBuV
MHz 24.5 dBuV
MHz 87.4 dBuV
MHz 25.1 dBuV
MHz 23.7 dBuV

Press [F10] to terminate

 

 

 

 

 

Press [ENTER] to continue

 

 

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:

 

WELCOME TO Z TECHNOLOGY'S 'FIL_CTL' PROGRAM Ver. 2.00

This program allows you to create and use a file to control
meter measurement sequences -- including frequencies,
time interval between measurements, and the number of times
to run the measurements.

Connect the meter's 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

 

 

 

MAIN MENU

1 ..... Create a New Measurement Sequence
2 ..... Run a Measurement Sequence
Q ..... Quit (exit program)

Enter a command?

 

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:

 
Create a New Control File
Command
Code

Function
Present
Value
A
B
P
T
S
I
M
[ENTER]
Set address
Set baud rate
Select comm port on PC
Start time
Number of scans
Interval between scans
Return to previous menu
Accept present values
1
9600
1
Interactive
Interactive
Interactive
Enter a command code?

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
Channel/video tuning state
Remote communications state
Field strength meter state

Frequency = 205.250 MHz
Software version # 1.08
Baud rate = 9600

C:\ >

After the meter responds to the Report Status command control returns to the DOS prompt.

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.

Creating Custom Software

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