Text preview for : 194A_903_01A.pdf part of Keithley 194A 903 01A Keithley 194 194A_903_01A.pdf



Back to : 194A_903_01A.pdf | Home

IEEE-488 Programming Guide
Model 194A
High Speed Voltmeter




Ql.987, Keithley Instruments, Inc.
Instrument Division
Cleveland, Ohio, U.S.A.
Document Number: l94A-903-01 Rev. A
TABLE OF CONTENTS

About This Programming Guide .............................................................. ., .. 1

Computer Programming Syntax ................................. .: .. ., ............ ; .............. 3

Single Channel Programming ................................... I ............................... 7

Dual Channel Programming ................. -~__ __ ................................................ 11

Single and Continuous Trigger Arming .............................................. .,.......... 17

SRQ~andErrorHandling.. ................... ;...:~ ........... .: .... .._..... .... ..I ...... .._ ....... 21

Binary DataTransfer .......................................................................... 29

Reading Buffer Operation ................................... _. .. .,............................. 37

Using Translator ................................................... ._._. ................ ._.~. ...... 41

Using External Sample Triggering ................................ _ ....................... .,_ .,.... 47

Generating Bus Time Information ............................................... _ ............... 55

Appendix A - Device-Dependent Commands~ ...................... .~~.;.:, .I. : ........... .,......... ~A-1

Appendix B - Data Formats ................................................................... B-l

Appendix C - Status Words and SRQ Format I .................................. .I .............. C-l

Appendix D - Front Panel Modes and Equivalents IEEE-488 Commands ........................... D-l

Appendix E - Data~Transmission and NRFD Hold-off Times ...... ; .............................. E-l
ABOUT THIS PROGRAMMING GUIDE

This programming guide is intended as a tt.&xial on a number of programming conceptss
associated with the Model 194A. It is not intended to replace the IEEE-488 programming
section of the Instruction Manual, which should be consulted for detailed programming
information.


Programming concepts discussed in this guide include:

l Programming a single-channel unit and obtaining data.
l Programming a dual-channel unit and requesting data.
l Single/continuous arming and~triggering.
l Using binary data transfer to optimize speed.
l Using SRQ and error word to minimize controller overhead.
l Buffer operation, including use of buffer pointers.
l Using Translator to increase readability and emulate-other instrumentation.


In addition to these fundamental concepts, applications programs for external sample tig-
gering, plotting data, and trigger performance and timing are also included. Fmally, reference
information such as device-dependent commands, data formats, and error words is also
supplied.




l/2
COMPUTER PROGRAMMING
SYNTAX

All the example programs in this guide are written in Hewlett=Packard BASIC 4.0, which
is used on the Series 200 and 300 computers. This programming language was chosen for
these examples because of its ease of understanding, as well as its powerful subset of com-
mands and statements controlling the IEEE-488 bus.


Most BASIC 4.0 statements are very similar to those used~.in other BASIC languages; however,
there are some statements associated with IEEE-488 bus Ii0 that require discussion. The
following provides a brief overview of some of the statements you will encounter in the various
programs in this guide. Refer to the BASIC 4.0 Reference for more detailed information.


OUTPUT

OUTPUT allows you to send a variable or string over the bus, and it may take on one c$
several forms. A typical syntax is:




In this instance, 7 specifies the interface select code, while 09 is the primary address of the
instrument. FlX is a literal string that will be transmitted to the instruments when the state-
ment~is executed.


ENTER

ENTER performs the opposite-function,~ allowing the transmission of data from the instru-
ment to the computer. Typical syntax for this statement is;




Again, 7 specifies the interface select code, while 09 represents the primary address of the
instrument. .A$ is a string variable into which incoming data is placed. Keep in mind that
A$ must be dimensioned large enough to hold all Rpected characters. As an alternative,
the ENTER statement-can directly input the data into a numeric variable, assuming that the
proper instrument data format is used.


SPOLL

SPOLL serial polls the instrumentand places its status byte in a numeric variable as follows:




Here again, 709 represents the interface select code and primary address of the instrument.
S is a numeric variable which will contain the decimal value of the status byte after the state-


3
ment is executed. The status byte-can then be checked by ANDing or BIXng S to determine
the status of the required bits. These bits can yield certain information such as reading,overflow
and ready for a new command.


BIT

BIT can be used to detetie the bit status of numeric variables:




In this example, the status of bit 5 of the variable S is placed into A.


TRIGGER

TRIGGER sends a GET (Group Execute Trigger) to a device as follows:




A GET is one of many methods that can be used~& initiate a~Model 194A +?v+urement~
In order to~~use~~ form of triggering, the GET t$ger mode must be programmed, and
this
the A/D converter must be armed. Note that programming a trigger mode over the bus
automatically arms the A/D converter.


ASSIGN

ASSIGN is used to assign an I/O path, as in the following example:




Following ASSIGN execution, the attribute D194 will be associated with the interface code
and primary address. Another form of ASSIGN is used to-define the IiO~buffer:

ASSIGM IZufTU BUFFER k8 `~


TRANSFER

TRANSFER is used to perform a rapld I/O data transfer sequence. Usualli, TRANSFER is
used with the binary dump feature oft the Model 194A for most~rapid data transfer. Using
this combination, data can be transferred at a rate as high as 90K bytes per second.


Typical syntax for TRANSFER is:

TRAHSFER I?11194 TO WUF; COU~KT-i00B,W~Il


In this instance, a total of 1000 bytes will be tr~mitted from the Model 194A to~~the~internal
buffer.




4
STATUS

SX4TUS allows access to certain computer status registers. Most often, this statement is used
to either determine if aii SRQ has occurred, or dear an SRQ interrupt. Typical syntax is:




Here, 7 is the interface select code, and the second 7 is the status register being accessed.
The value of the status register is placed in the variable S when the statement is executed.


ON INTR and ENABLE INTR

These two statements work together to enable interrupts and to tell the computer where to
go for next line execution. A typical ON INTR statement is:




In this case, when the computer detects an IEEE-488 interrupt, it-begins executing the
subroutine at line 4000.


SRQ is the most often used type of interrupt for the IEEE-488 bus. Using BASIC 4.0, SRQ
interrupts are enabled as follows:




Once enabled, an SRQ Wi cause the computer to branch to the line number specified by
the ON INTR statement. Typically, an error handling subroutine will be incorporated at that
point to determine the reason for the SRQ and to handle any other required tasks.




5/6
SINGLE CHANNEL PROGRAMMING

PROGRAMMING CONCEPTS

l Sending command strings to the Model 194A.
l Obtaining data and displaying iton the computer CRT


PROGRAMMING CONSIDERATIONS

At the very least, it will be necessary to send commands to the instrument to set it up as
desired, and to request data back from the unit. The program below demonstrates~the basic
recess for doing so. Note that if you have a dual-channel unit, you should proceed to
F rogTam 2.


PROGRAM OPERATION

Program 1 below demonstrates fundamental programming techniques for a single-channel
unit. Figure 1 is a flowchartof the program.


Before we can program the Model 194A, we must place the unit in remote as follows:




Next a prompt for the user to enter the desired command is displayed by the following pro-
gram statements:




Following execution of these two lines, the command suing resides in a string variable called
Command!& Now we can send the command string to the instrument with the `X" character
appended to the string to force command execution:




Since sending any AID (Analog-to-Digital) converter programming command to the instru-
ment will disarm the AID converter (see Table 1), you should always arm the AID converter
before requesting a reading. In this particular program, the AID converter is armed by sen-
ding the T26 command in the following manner:




7
I PUT ,944
IN REM3T.E
I




INPUT COMMAND
STRING



c

OUTPUT COMMAND
STRING TO 194.4



c

ARM AND TRIGGER
/vD CONVERTER




c
r I




Figure 1. Single Channel Operation Flowchart


Note that the immediate trigger mode is used in this instance, so it is not necessary to~~trig-
ger the unit to process a measurement; however, with other tri er modes, it will be necessary
to trigger the unit before the unit will collect samples. Once PB ose samples are stored and
t
processed into a reading, the data is requested and displayed on the computer CRT as follows
(see Figure 2 for ASCII data format):

80 ENTER 70'3; Readings
YMPEItKReading8
PREFIX BUFFER EOIASSERTED~
(GO G-2, G3. GS) SUFFIX (G2, GS) WITH CF


+-I A I
N DCV * 1.2345 E + 0. CH2, 80050 TERMlNATOR




N=NORMAL A kdST TM,, &&;ToRicRLF
0 = OVERFLOW NUMBER
Z=ZEROED
READING EXFCNENl
I = INVALID
MEASUREMENT

RMS = TRMS ~ ~~~
NOTE: SUFFER LCCATDN SHOWS
A"G = AVERAGE SAMPLE nnnni, IN WAVE
+PK = +PEAK FORM MODE
-PK = -PEAK
DIF = CHI CH2
RAT = CH1ICH2
DEV I STANDARD DE",AT,ON
P.P = PEAK TO PEAK
INT= INlEGRAL
DC" = WAVEFORM
RCL = RECALL




Figure 2. ASCII Data Format


Table 1. CommandsThat Disarm the A/D Converter


Command Description
I
Recall setup
Function
$P~z?
Number of samples
Filter
Range
Rate
Trigger
w Delay
Z 7mv-l


RUNNING THE PROGRAM

1. Enter the program into the computer.
2. Run the program by pressing the RUN key. The computer wti promptyou to type in your
command:




9
3. Type in the desired command string and then press ENTER. Note that is not necessary
to add the "X" character as it is automatically added by the program. For example, to pro-
gram the average function and select autoranging, type in FlRO and press ENTER.
4; Once the measurement is completed and the reading is processed, the data string will
appear on the computer display. A typical example is:




ACQUIRING A WAVEFORM USING ASCII DATA TRANSFER

The Model 194A can be used to capture a waveform and then send the data as a series of
readings representing the individual samples. Each individual data string will represents the
voltage of that-particular sample.


To use the Model 194A in this manner, program the instrument for the waveform (FO) func-
tion, and then repeatedly request readmgs until all samples have been transferred. For ex-
ample, to collect 100 samples and read them into a computer, modify Program 1 as follows:

75 FUR I = 1 TU i0EI ! Loop 100 times.
35 HEYT I
c , ! Loop back for next sample.


When the computer prompts~you for a command, type in `~ONO,lOO" (include the quotes
because of the comma) and then press ENTER. You should see 100 successive readings ap-
pear on the display. Each reading is the numeric value of that particular sample. These samples
can also be placed into a BASIC array for further processing, if required.


For a larger number of samples, or for higher speed data transfer, refer to the section in this
guide on binary data transfer.


Program 1. Single Channel Operation

10
20
30
40
50
60
70
80
90
100
$10




10
DUAL-CHANNEL PROGRAMMING

PROGRAMMING CONCEPTS

l Basic command programming of a dual-channel Model 194A.
l Obtaining data fmn a dual-channel Model 194A.
l Demonstrating that both channels share a single IEEE-488 output.
l How to turn off an unused channel for maximum speed and to ensure that data comes
only from the desired channel.


PROGRAMMING CONSIDERATIONS

Programming a dual-channel unit is somewhat more complex than a single-channel unit,
even for the most basic measurements. In particular, there are several important aspects~~to-
keep in mind:

1. Before sending programming commands to the instrument, select the desired channel
by sending ClX for channel 1, or C2X for channel 2. Doing so will ensure that the com-
mands you send will affect the desired channel. Note that sOme commands such as data
format (G), SRQ (M), and terminator (Y) affect both channels, so it is not necessary to
select the channel before using them.
2. The two channels share a common IEEE-488 output and reading buffer. As a result, there
is no way to dictate which channel has the currentoutput when both channels are run-
ning simultaneously. Thus, it will be necessary~for~youuse the channel suffii in the data
string (Figure 2) to determine the source of the data. Alternatively, you can use the reading
buffer for storage and request data later.
3. If one channel is not being used, it should be disabled by sending a trigger command
for a tri er stimulus that will not occur. For example, if you are not using external trigger-
ing, se*9 the co rnmand string CXI7X to disarm channel 1, or send C2XM( to disable
channel 2. Turning off an unused channel will accomplish two things: (1) maximize
throughput for the channel being used, and (2) make sure that data comes only from the
channel in use.
4. Another way to keep the reading from both channels separated is to use the F command
to re-calculate a reading. Even If a reading has already been calculated, you can force
another calculation for the desired channel to place the result in the reading buffer. For
example, send C2FlX to compute the average of the channel 2 measurement and place
the results in the reading buffer. Keep in mind that the other channel must not be run-
ning fast enough to overwrite this data between the time it is calculated and the time it
is requested.


PROGRAM OPERATION

Program 2 below demonstrates dual-channel programming. Figure 3 is a flowchart showing
general program flow.




11
t
I I
ARM AND TRIGGER
CHANNEL 2




I_! READING




Figure 3. Dual Channel Operation Flowchart
Usually, an instrument is sent a command at the start of a program to return it to some default
state. In the program below, this operation is performed by sending an SDC (Stile&d Device
Clear) as follows:




This statement instructs the Model 194A to assume its power-up (setup 1) configuration.


Next, we must make certain that the instrument is in remote before sending programming
commands as follows:

3M REMOTE 76'3


Now we can program channel 1 and channel 2 as required. For channel 1, we will select
the 32OmVrange (Rl) and TRMS function (F2) as follows:




In a similar manner, channel 2 is programmed for the ZOOVrange (R4) using the average
function (Fl):




In both cases, you will note that the channel select (C) command is included at the fronts
of the command string containing range and function commands, followed by an execute
(X) character to assure proper channel selection. (Note that the X immediately after the C
command is not required, but it does no harm).


At this point, we have programmed both channels; however, since the range and function
were changed, we must arm both A/D converters. First, for channel 1, we have:




Again, each command string includes the channel selection command prior to the trigger
command that arms the AID converter. Here again, the immediate trigger mode vZ6) is used
so that no further triggering is necessary to start the AID converters. With other trigger sources,
you will be required to apply the necessary trigger stimuli to start the A/D converters after
arming them.


Now that both A/D converters are running and readings are being processed, it is a simple
matter to set up a loop to request and display readings:
This loop repeats indefinitely, with one reading per loop accessed and displayed.


RUNNING THE PROGRAM

1. Enter the program into the computer.
2. Press the computer RUN key tostart the program.
3. The program will send the commands to the instrument and then request readings from
the Model 194A. Note that data will alternate between channel 1 and channel 2 depen-
ding on which channel has the most current reading.


USING ONE CHANNEL

In order to use only one channel, program the other channel for an unused trigger source.
For example, to turn off channel 1, modify line 60 as follows:

6'3 OUTPUT7B9j 6 gtCl:XTTK' 3


Similarly, to disable channel 2, modify line 70 to read:




In both instances, the disabled channel is programmed for the external trigger mode. Thus,
in order for that~channel to remain disabled, no trigger signal can be applied to the trigger
input~for that channel. Another way to disable a channel is to use T27 which causes only
one trigger; no further triggers will oCcur even with external triter input noise.


SELECTING CHANNEL OUTPUT

As discussed previously, you can dictate which channel has the current-output by program-
ming the desired channel for a particular function (so&as average), and then immediately
requesting a reading. In order to demonstrate this process, eliminate lines 80-110 from Pro-
gram 2, and add the following lines:

20 OIJTPUT 789; L dCIFiX" ! Compute channel 1 reading.
90 ENTER 7B9; ReadingB ! Get channel 1 reading.
1BW PEIMT &adiigB ! Display channel 1 reading.
110 OUTPUT70'3; 6 GCZFlX"" ! Corn ute channel 2 reading.
12'3 EMTEE 7W3; Readings ! Get
jtl annel2 reading.
130 PEIMT Readings ! Display channel 2 reading.
i4k3 GOTO 80 ! Repeat
159 END




14
With these modifications, the computer display will alternate between channel 1 and chan-
nel 2 readings. Note, however, that one channel may still overwrite the other if there is a
large difference in processing speed between the two channels.


Program 2. Dual-Channel Programming
10 OIM ReadlngBlSOl oincnalo" reading string
20 CLEAR 709 Return the 194.4 to default conditions
30 RErlOTE 709 Put the 134 into renotc mode
40 0UiP"T 709;"CIXRIF:X- Program chl far the 320mU range and TRMS
50 0"iP"T 709i"C:XR4FiX" Program ch2 for the 200" range and Rverags
60 OUTPUT 709i"CIXT?fiX' Am channci I
70 OUTPlJT 709; ~CZXT26X" Am channel 2
ENTER 709,Readimp Get a reading fron the !94A
PRINT Reading* Print the rcadlng
GOT" 80 ReDeat
TN,,




I5116
SINGLE AND CONTINUOUS
TRIGGER ARMING

PROGRAMMING CONCEPTS

l Sending the arming command ~once with continuous arming.
l Sending the arming command before each trigger with single arming.
l Triggering the measurement with single and continuous arming.


PROGRAMMING CONSIDERATIONS

Before the Model 194A will take a measurement, it must be triggered with the stimulus deter-
mined by the selected trigger source: immediate, input signal, external, other channel, or
an IEEE-488 GET, X, or t& command. However, it will notrespond to a trigger unless the
A/D converter is first-armed and ready for a trrgger.


Basically, there are two A/D arming modes: single and continuous. With single arming, the
A/D converter must be re-armed before each trigger. However, in continuous, the A/D con-
verter need be armed only once, as the converter is automatically rearmed after each
measurement.


Over the IEEE-488 bus, arming takes place when the programming command for that par-
ticular trigger mode is received. For example, sending l3X (single arm, trigger on GET), arms
the A/D converter. Once armed, the measurement will be initiated when GET (Group Ex-
ecute Trigger) is received. In this instance, the T3X~command must be sent before each trig-
ger to arm the A/D converter. In contrast, if using continuous GET (TUC), you need send
the command only once before the first trigger, after which the A/Dconverter will automatical-
ly rearm itself after each measurement.


To summarize, there are several steps to programming and using triggers:

1. Fit select the channel to be armed and triggered. For example, to select channel 1, send
ax.
2. Send the command to select the trigger source and arm the A/D converter. For example,
toselect single, GET, send `l'3X.
3. Repeat steps 1 and 2 for the other channel, if desired.
4. Apply the necessary trigger stimulus to initiate the measurement. For example, issue the
GET command to initiate the measurement.
5. If you have selected a single arming mode, remember to re-arm the converter before each
trigger by sending the appropriate command over the bus.
PROGRAM OPERATION

Program 3 below demonstrates single arming using the GET trigger source. Figure 4 is a
flowchart of the program.


Once the unit is in remote, we can program the trigger source and arm the channel 1 A/D
converter as follows:




In this particular instance we have selected the single arm, GET trigger mode (T3X); after
the command is sent, the A/D converter will be armed.


Now that the A/D converters is armed, we can trigger a measurement by sending GET:




The next two lines request a reading from the Model 194A and display a reading on the CRT:

40 ENTER 709;EeadingS
5W PR I t.IT Readings


Here the incoming data string is stored in Readmg$.


One final line necessary to complete the loop is:




Note that this branch goes back to the line containing the re-arm (T3X) command because
a single-arm trigger mode is jn effect. If instead we had branched back only to line 30, only
one reading would be taken the first time through the loop.




18
SENDGETTO
TRIGGER READING




Figure 4. Single Arming Flowchart


RUNNING THE PROGRAM

1. Enter the program into the computer.
2. Press the RUN key to execute the program.
3. The prc~gram will setup the Model 194A for the single, GET trigger mode, bigger a reading,
and display it; A loop is set up to repeat the sequence indefinitely.
4. To demonstrate the importance of reaming, modify the pmgram as follows:

60 GOTO38 ! Laop back to trigger.

5. Run the modified program and note that only one reading from channel 1 is displayed.
With this change, the program now branches back to the trigger statement (line 30) in-
stead of the arming statement (line 20). As a result, only one measurement and reading
from channel 1 are processed on the fiist~time through.


CONTINUOUS ARMING

Program 3 can be modified for continuous, GET arming by changing the lines below. Figure
5 shows a flowchart for this modification.


19
20 O,JTPClT 70'3; 6 ~I:l: GET.
co GOT0 30 ! Branch back to trigger statement.


Upon running this program, you will note that repeated readings appear on the computer
display. Now, however, it is n&necessary to %rmthe converter each time--merely trigger
it--to obtain each reading.




PROGRAM CHANNEL 1
CONTINUOUSGET.
ARM A/D




SEND
GETTO
TRlGGERREADlNG




Figure 5. Continuous Arming Flowchart


Program 3. Arming and Triggering
10 REMOTE 709
20 OUTPUT 709;`C,XT3X~
30 TRIGGER 709
40 ENTER 709,4ead,ng5
50 PRINI RPsdlng*
60 FOTO 20
70 END




20
SRQ AND ERROR HANDLING

PROGRAMMING CONCEPTS

l Programming the h@ument to generate an SRQ on reading done and error conditions.
l Servicing the SRQ and determining the exact condition that caused it.
l Taking appropriate action tin the SRQ condition.


PROGRAMMING CONSIDERATIONS

The SRQ line on the IEEE488 bus gives the user a great deal of flexibility in determining
if the instrument~requires controller servicing. By sending the appropriate command (Table
2), you can program the Model p4A to notif the controller when it re uires service for a
variety of different conditions including rea kg oveflow, data (buffer ?i.zll,`/2full, plotter
done), front panel button pressed, reading done, ready for cotiand, and a number of er-
ror conditions. The instrument-can be programmed for multiple SRQ conditions simply by
adding up the command values. For example, to program for reading done (M8) and error
(M32), M40 would be used.


Once the controller has received the SRQ, it can serial poll the instxument and obtain the
status byte to determine whether that instrument did in fact request service, and if so, what
conditions caused it to do so (Figure 6). For data and error conditions (bits 1 and 5 respec-
tively), you can check the Ul and U;?status words to determine the exact condition that caused
the SRQ, as shown in Figures 7 and 8.



DECIMAL
WEIGHTING

BIT
POSITION




Figure 6. Status Byte Format




21
M3DEL
NUMBER TERMINATOR
I
I I I ' I
I I I I I I I I I I I I I I I I I I I I
I119141~ I110 I110 Il/O I110 Il/O I110 I1/o Il/O I1/o I110 Il/O I110 I, I CR I LF I
1/o 110



1 = IDDC (ILLEGAL -
COMMAND)
1 = IDDCO (ILLEGAL SAMPLES CONFLICT
COMMAND OPTION)
I= iRANSLATWi ERROR




COMMAND ILLEGAL
[FUTURE EXPANSION)
Basically, there are two different methods the controller can use to detect the SRQ: interrupt
and po!.ling. The interrupt~method is by far the more versatile, since it is possible for the
controller to perform other tasks until the instrument requests service. With the polling
method, the controller must periodically check the status of the SRQ line to determine if
the instrument requires service.


Table 2. SRQ Commands


Description

SRQ disabled
Reading overflow
Data (Buffer full, Yz full, plotier done)
Front panel button pressed
Reading done
Ready for new command
Error (IDDC, IDDCO, tiot in remote, trigger overrun, channel 2
not installed waveform invalid, composite mode, translator,
samples 07 delay conflict.

*Pro am multi le SRQ conditions by ad&g individual command values. For example, send
M4 f X for SR cf on error, and when reading is done.



KXEL
NUMBER TERMINATOR




BUFFER HALF FULL CONVERTER ARMED
1 = PLOTTER 1 i CHANNEL 1AX?
DONE CONVERTER ARMED




Figure 8. U2 Status Word Format (Data Conditions)


PROGRAM OPERATION

Program 4 below demonstrates interrupt SRQ handling and error status checking. The pro-
gram can be broken into two sections: initialization and main task, and error handling. Figure
9 gives a flowchart of key sections of the first part of the program, while Figure 10 outlines
the error handling routmes.




23
Highlights of the first part of the program include:

1. The Model 194A is returned to default by sending an SDC (line 20).
2. The unit is serial polled in order to clear a peiiding SRQ (line 30).
3. The service routine that will detect andservice the SRQ on an interrupt basis is then defined
(lines 70-100).
4. Channel 2 of the instrument is disabled by sending czT7X (line 120).
5. The user command string is requested and sent to the instrument (lines 130-150).
6. The instrument is programmed to generate~an SRQ on reading done or error conditions
by sending the command M40X (line 160).
7. The unit is programmed for continuous, GET trigger by sending T2X (line 770). Note that
the channel 1 A/D converter will continuously arm in this mode; it-will not be necessary
to re-arm the converter before every trigger.
8. Since the A/D converter will be armed at this point, it is only necessary to send a GET
command to trigger the unit and initiate the measurement (lie 180).
9. The user's main task then begins execution. In thjs instance, the "main task" is a simple
incremental counter to indicate that the propam is looping (lines 200-220).


When executing, the program will stay in the main task until an SRQ is detected. When
an SRQ occurs, the program will service the SRQ as follows:

1. The Model 194A is first serial polled to obtain the status byte (line 250).
2. Next, the state of bit 6 in the status byte is tested to determine if the SRQ was, in fact,
generated by the Model 194A (line 270). Jf this bit is set, the program will continue check-
ing other bits in the states byte. Otherwise, the program returns tu the main task. This
steps is essential only when more than one instrument is on the bus.
3. Bit 5 of the status byte is then checked (line 290) to determine if an error condition oc-
cured. Jf so, the program branches to a subroutine (beginning at line 350) which requests
the Ul error word and then tests appropriate bits in the error word to determine the nature
of the error. A suitable message is then displayed if an error is found, and the program
then halts.
4. If no error is found, the program tests the state of bit 3 in the status byte (line 310). Jf
this bit is set, a reading is ready tom processed, and the program branches to a subroutine
be
to request and display a reading, and trigger a new one (liies 530-570). The subroutine
then returns to the use& main task.


RUNNING THE PROGRAM

1. Enter the program into the computer.
2. Execute the program by pressing the RUN key.
3. At theco mmand prompt; type in the desired string command. The command string should
contain only A/Dprogramming commands (range, function, filter, coupling, sample, and
rate). In order to allow sufficient time for the main task to run, choose a sampling rate
and number of samples resulting in a measurement duration of several seconds. For ex-
ample, to program a sampling interval of lmsec and 3ooOsamples, enter "SOJE-3NOJOCOX"
(quotes must be used because of the commas).
4. The computer will then display the incremental counter to show that the main task is
running.




24
5. Once the Model 194Abas taken its measwmnent~and processed the reading, the unit will
generate an SRQ, and the read&g will be displayed.
6. To demonstrate an SRQ-generated error message, type in an illegal command at the com-
mand prompt. For example, type in ElX; note that the computer displays the IDD~CERROR
because E is an illegal device-dependent command letter.




START



i>


SENDDNW




DEFINE BRANCH AND
ENABLE INTERRUPT




Figure 9. Program4 Flowchart (Initialization and Main Task Section)

25
SERlAL POLL




r-2-l
RE(xIEST ERROR




Figure 10. Program4 Flowchart(SRQ and Error Handling Section)




26
USING POLLED SRQ

The program can be modified for polled SRQ by making the modifications below:

1. Remove lines 70, SO, 90, lOO,-
and 550.
2. Add the following lines to the program:

211 STATILlS717; Bus-lines ! Read bus lines.
212 IF BIT IEusJines)=l I Check SRQ~bit status.
THEN GOSUH Service_routine



With this modification, the controller must check the status of the SRQ line each time it goes
through its main task loop. Although from a user's standpoint the program may appear to
operate the same, the additional controller overhead necessary for p4led SRQ uv3ybecomq
restrictive in larger applications.




Iii0 OUTPUT 7091 -M40X" (
Program 4. SRQ and Error Handling (Cont.)




28
BINARY DATA TRANSFER

PROGRAMMING CONCEPTS

l Data transfer speed considerations.
l Transferring binary data from the Model 194A to the computer.
l Converting binary data into displayable form.


PROGRAMMING CONSIDERATIONS

When a relatively large number ofsamples must be transferred from the Model 194A to the
computer, speed becomes an important consideration. The binary transfer mode of the in-
strument can significantly reduce the amount of time it takes to send 8 given amount of data
from the iwtrurnent to the computer. Binary transfer speeds up this operation for two reasons:
(1) the Model 194.4 is not required to process the data before s&ding it out, and (2) fewer
bytes are transferred per sample in the binary mode.


In order to take full advantage of binary transfer speed, the computer must be ca able of
transferring at a rate at least as high as that of the Model 194A--approximately 9I& bytes
per second in binary mode. The HP9816 used for the example program below can operate
at rates as high as l30K bytes per second using fast handshake transfer, but other controllers
may require use of DMA transfer to operate with sufficientspeed. In any event, the advan-
tage to using binary transfer can be seen by comparing the time necessary to~transfer 1000
samples. In binary mode using fast handshake, these sam les can be transmitted in only
65msec as opposed to 15 seconds required when using ASC E transfer and the ENTER state-
ment. (using an HP9816 computer).


The general binary formats for the G6 and G7 modes +weshown in Figure 11. In addition
to the one or two bytes for each sample, a~~&byte status word and byte count (G7 only) is
added to the front of each byte sequence. The statis word contains unportant information
such as range, channel, function, as well as the exponent for the data. In order to display
the data, it must first be converted into ASCII form, as demonstrated in Program 5 below.


PROGRAM OPERATION

Program 5 below demonstrates fundamental concepts for obtaining bii data and converting
it into displayable form. Figure I2 shows a general flowchart of the program.


Program highlights include:

1. The program first initializes variables and Ii0 paths (liies 10-70).
2. The instrument is then programmed for the waveform mode (FO), number of samples (NO),
sampling rate (SO), binary data format (G7), and reading buffer disabled (lines 80-140).



29
A. GS




STATUS WORD 4 wn3 *-Em MODE: EACH BYTE IS A SEPARATE SAMPLE.
SEE BELOW lS.S,T MODE: BYTE 1 IS MOST SIGNIFICANWYTE, BYTE 2 LEAST
SIGNIFICANT.


B. G7
EOI



MSB LSS I 2 3 4 MSS LSB MSB LSS MS8 LSS MSS LSS I..+$q


I I
5-5-+ww5----LT-l I
BYTE STATUS WORD SAMPLE SAfvwLE~ SAMPLE SAMPLE S!MJLE
COUNT (CBYTES) 1 2 3 N
(I-64K) SEESELOW (BYTE PER SAMPLE IN 8.SIT MODE;




1 j ; j j / j j 1 RANGE CHANNEL 1 ~TusED 1 FUNCT0N 1 EXPONENT 1
' ' ! ! ! ! ! sEESELOwl ,sEEBELow SEE BELOW 125 COMPLEMENTl

1 = 1S-BIT MODE
0 -8.SIT MODE
1 =ZERCED



RANGE CHPlNNEL F"NCTlON




6 0110 STANDARD DEVlATlON
7 0111 INTEGRAL
~8 1000 RECALL
IWTF ,


lN"ALlD NUMERIC: 1 = READING IS lN"ALlO
SUFFER IN"ALID: 1 = MEASUREMENT SUFFER CONTAINS lN"ALlD SAMPLE
OVERFLOW: I= READING SAMPLEO"~RFLOWED
WAVE FORM IN SUFFER: 1= MEASUREMENT SUFFER CONTAlPJSAWA"EFORM
8HG SIT MODE: 1 = ZEROED: 1 =zERO IS ENABLED




Figure 11. Binary Data Formats




30
3. Next, the program performs a test to see if the reading is done (lines 160 and 170). This
test is performed by serial polling the unit and testing the state of bit 3 in the status byte
(the reading done bit). If the bit is cleared, the reading (and thus the measurement) has
not been completed, and the program remains in the loop until bit 3 is set, indicating
that a reading is available.
4. Once it-has been determined that the reading is complete, the fast handshake transfer
is performed tom read the binary data into a computer I/O buffer (lines X30-221). In order
to properly terminate the transfer, it is necessary to know how many bytes are to be trans-
ferred. This value is determined from the number of samples programmed, as well as
whether the data is in eight or 16-bit format. A value of six is added to the total byte count
to account for the count and status bytes.
5. Next, the byte count and status are read from thenI/O buffer and placed into numeric
variables (line 240). In this case, the firststwo bytes represent the byte count; while the
last four bytes contain Model 194A status information, as shown in Figure 11(c).
6. Binary data is then read from the I/O buffer into-a numeric array, (line 770 or 280). The
transfer is in byte @-bit) or word (X-bit) format, de ending on the sam ling rate (the in-
strument stores S-bit-data at rates above lMlk&). R ote that the end oP the data for this
transfer is determined by EOI.
7 The binary data is then converted into displayable form (lines 350-410). This subroutine
must take into account the weight of each bit. In the g-bit mode, the bit weight is 256,
while in the 16-bit mode, the bit weight is 1.
8. The data is then scaled according to range by using~ the range information located in byte
2 of the status word..Since this range information is located in the most significant nibble,
it must be converted by ANDing with 48 and then dividing by 16. Figure 13 outlines this
conversion process. ~~.
9. Once final test is made to determine the status of the overflow bit located in byte 1 (lines
520-570). A normal or overflow reading message is determined by the status of this bit.




31
PROGRAM AND
TRlGGER 194.4




GEM
SAMPLE


1
CONVERT
SAMPLE


1
DWLAY
SAMPLE




Figure 12. Flowchartof Binary TransferProgram




32
I 0 0 ~11
RANGES
r-l
0 0
CHANNEL


0 1 ~BME 2
AND
0011 0 0 0 0~ ~(~~4810)



0011 0 0 0.0
i
A. ANDing WITH 48, o TO MASK OFF UNWANTED BITS



RANGE

000000E
--a
~8. DIVIDING BY 16 SHIFTS RANGE BITS ~FOIJR PLACES
TO RIGHT.




Figure 13. Converting Byte 2 Range Bits


RUNNING THE PROGRAM

1. Enter the program into the computer.
2. Execute the program by pressing the RUN key.
3. Apply a DC voltage oft less tbti 32OmV.
4. When the prompt for number of samples is displayed, type in the desired value. For ex-
ample, for 100 samples type in 100 and press the ENTER key.
5. When the computer prompts for the reading rate, type in the desired value. For example,
to program a lpec rate interval, type in ll?-6 andpress ENTER.~
6. The Model l94A will now process a measurement and then display the individual samples,
including sample number and a message as to whether the sample is normal or overflowed.
With less than 32OmV applied, the reading should always be normal.
7. Increase the applied voltage to 5oOmVand NIX the program again. Note that the overflow
message is now displayed because the 500mV applied signal is above the maximum input
voltage of the 320mV range.
8. Change the Rl range command in line 130 of the program to RO.This change will program
the Model 194A for autorange. Ream the program several times with different applied
voltages between 200mV and 200V and note that displayed data is automatically scaled
according to range.




33
Program 5. Binary Data Transfer

10 Initializegrog: !
30 INTEGER 8( 32000) I DiFlenei0n tntcrxr
40 REAL A I Reserves storage for floatiig mint variable
41 OIM A$[320001 SUFFER I Dlnaneio" buffar
50 ASSIGN 80194 TO 703 ~! *seign I/D path n*ne to 1946
60 WiGIGN @Suf TO BUFFER A$ I Rsalgn I/O path name to BUFFER
70 OUTPUT KBOICHR$( 2% )&CHR8(75 )i I Clear em-can
30 I"li ielize~1~S4: I
35 REMOTE 703 ! Put 194R in renote
90 PRINT "ENTER NUMBER OF SAPIPLES' ! ~PrOFlpt for tt w&npl+a
100 INPUT Samples ! Input * sanplea
110 PRINT "ENTER RE&OING RRTE IN US 120 INPUT Pate I Input rate
121 ! Progren 194
130 OUTPUT 709;"F0R,NB,"&"ALs(S~~~~~,~~"S0."6VALO(Rete~~.G7O0~.
140 OUT~PUT 709, `T27X" I Arm the 194A
150 Test_reading:l
160 S=SPOLLC 709 1 I Perforn serial poll
170 IF SIT1B0 setup-tranefei: !
190 IF Rate/l.OE-5 THEN Numb&r-bytes-l ( Oeterninc X bytea PCP aanele
200 IF Rate:,, .0E-5 THEN Nunhcr-bytes-2 ! Detern~ne P bytes per ~anple
210 Perfarn-transf: I
211 ! Transfer 194pI Data us`ng fast hand,haks. Te~ll how maw
212 bytes are ta be tranafered.
220 TRANSFER 00134 TO WufiCOUNT ~(Nunber_bytes+Sanpis.)t6,WnTT
ZZ, : Read 194A status fran buffer
230 Rend-statue:!
240 ENTER Wuf USING ~X.W,B.B.R.B~;Count,Statual ,Stat~.Z.Statu.3,Statu.4
260 Read-data:!
250 FOR Data=, TO Sample5
270 IF Ratei,.0E-5 THEN ENTER R&f USING `%.B"r3(0ata) I Read 8 bit word
271 ! fro,, buffer.
280 IF Rate:,.0E-5 rHEN ENTER B&f USING `%.W*iE(Data) 1 Rea~d 16 bit word
281 ! from buffer.
290 GDS"9 canvert I Goaub ta ravtina that converta raw binary
300 PRTNT Oat a .Reading .Hessaoes
310 NEXT Data
320 SENO 7,UN1
330 STOP
340 convert: I
3G0 A=BtOata)
360 IF Rate:, ."E-5 THEN Rij+weight-256 ! Dsteinlne bit we,pht for 8
361 ! bit mode.
370 IF Rate,,.OE-5 THEN Bit-weight-1 I Deternlne bit weight for 16~
371 1 bit node.
330
390
400
410
420
430
440
450
4G1 ! et.tu.
460 IF Range-0 THEN Reading-R*i.OE-5 1 Scale reading for.320V range
470 IF Range=, THEN Reeding=R*I.OE-4 / Scale reading for 3.~2" range
480 IF Range-2 THEN Readlng=R*I.OE-3 ! Scale readying for 32V range
490 IF Range-3 THEN Read,ng=R.i.BE-2 ! Scale reading for 200" range




34
Program 5. Binary Data Transfer (Cont.)




35136
READING BUFFER OPERATION

PROGRAMMING CONCEPTS

l Fundamental operation of the reading buffer.
l Disabling the unused channel so that only desired readings are stored in the reading buffer.
l Triggering each stored reading indiyidually.
l Operation of the reading buffer pointer.
l Dumping entire buffer contents in one string.


PROGRAMMING CONSIDERATIONS

The reading buffer is a 100 location buffer into which processed readings can be stored as
they become available. By sending the appropriate command, you can operate the reading
buffer in a linear configuration (Qi) or a circular mode (QZ). With a linear buffer, the instru-
ment will continue to store readings until all 100 locations are full and then stop storing until
the buffer is completely emptied. With the circular buffer, the instrument will store 100
readings and then stop. As old readings are taken from the buffer (in oldest to newest order),
new readings will be stored in the empty locations.


Since a single lOO-location reading buffer is shared by both channels (dual-channel units),
care must be taken when reading the buffer to determix the source of the dataIf both chan-
nels are running, data will be stored in the buffer on an as-available basis. Thus, to deter-
mine which channel is the data source, you should check the channel suffii (Figure 2) on
the reading string. Of course, you can also turn off an unused channel by programming
for a trigger condition that~willnotebe met. For example, to turn off channel 2, send C2XT7X
over the bus. Doing so will make certain that data comes only from the desired channel.


The way the buffer fills will depend on the programmed trigger mode. In the immediate
mode, the instrument will fill the buffer without requiring additional triggers. However, in
the remaining trigger modes, yen ,must supply one trigger per measurement in order to fill
the buffer.


Once your data is stored in the buffer, there am several ways to access it. with the GOthrough
GZ data formats, one buffer location will be sent with each request. However, you can also
dump the complete buffer in one operation by using G4 or G5. Remember, however, that~
the computer input buffer or string must be dimensioned large enough to handle all the
bytes in the data string.


By using the B3 command, you can dictate how many oftthe reading buffer locations will
be sent. Simply use B3,nX, where n represents the last location that will be transmitted.
For example, if you send the command B3,2OX, locations 1 through 20 will be transmitted
when requested.




37
It~isimportant to clarify the operation of the buffer location suffix, which is shown in Figure
2. This value does not represent the buffer location number; rather, it shoti the number
of readings left in the reading buffer after accessing this particular location. For example,
assume you send B3,2OXto set an end pointer of 20. The~firstlocation to be sent will be number
1, but the suffix will show 0019, meaning that there are still 19 locations left to access. This
value will decrement once per buffer location until it shows a value of 0000 with the access
of the last buffer location.


PROGRAM OPERATION

Program 6 below demonstrates fundamental operation of the reading buffer. Figure 14 is a
flowchart of the program.


Basically, the program operates as follows:

1. The string called Readi& is dimensioned to hold 2,KlO bytes (line lo), and the unit is
placed in remote (line 20).
2. Both channel 1 and channel 2 are disarmed by sending T7x to thenappropriate channel
(Iines 30 and 40). Channel 1 is disarmed to ensure that no readings are being processed
when the reading buffer is turned on; othqise, undesired readings will be stored. Chan-
nel 2 is turned off to avoid storing channel 2 readings at ail.
3. Channel 1 is programmed to take 10 samples (NO,lO)per measurement at the maximum
rate of l* (SOJE-6) by line 50.
4. The reading buffer is then enabled for the~linear configuration by sending QlX (line 70).
5. Next, a lOO- pointloop is set up to arm the A/D converter and trigger each measurement
(lines 80-I.&. Each trme through the loop, the A/D converter is armed by sending `I3X,
and a measurement is then triggered by GET. As each reading is processed, it is stored
in the reading buffer in the next sequential location.
6. After the loop is complete, the unit is programmed to dump the fast 20 readings of the
reading buffer in one long string (line l30)Jhe G5 command tells the instrument to out-
put all available buffer locations at once, while the B3,20 command limits the output to
the fast 20 locations only (Iocations l-20).
7. Finally, the reading string is requested and displayed on the computer screen (lines l6O-170).


RUNNING THE PROGRAM

1. Enter the program into the computer.
2. Press the RUN key to execute the program.
3. The program will send commands to the Model 194A, and 100 readings will be stored
in the reading buffer.
4. Once storage is complete, the complete reading string will be displayed on the computer
display. Note that the reading number suf@es decrement ram 19 down to 0 throughout
the reading string. As pointed out earlier, this number represents the number of readings
left to access at that~point--not the buffer location number.




38
Figure 14. Flowchartfor Reading Buffer Program




39
Program 6. Reading Buffer Operation

I0 OIM RaadlnQG~20001 I oinanaion readings
20 REMOTE 703 ! Put the 1948 in rcnotc
30 OUTPUT 709:`CIT7X" ! Turn off channel 1
40 OUTPUT 709i"CZT,X' f Turn off channel 2
50 OUTPUT 703i"CIN0.,050,iE-6X" ! Program rats and * sanplca for
60 ! channa, 1.
70 OUTPUT 703:"QIX" ! Enable linear bvffer
80 FOR I-1 TO 100 1 Take I00 readinps
30 OUTPUT 709i"T3X" .I Program trfpper mode and arm AI0
I00 ! charm*, I.
110 TRIGGER 703 ! Trrwer the 1348
120 NEXT I ! Triggsr another reading
130 OUTPUT 7a3,`GSB3.:0X" ! Program 194R to ,end
140 ! readings 1-20
150 !
160 ENTER 709iReadrngB ! Read buffer Iocatlons I-20
170 PRINT Readings lKPFi"i rcading$
160 END




40
USING TRANSLATOR

PROGRAMMING CONCEPTS

l Using Translator tom
make programs easier to read.
l Instrument emulation using Translator.


PROGRAMMING CONSIDERATIONS

The Translator feature allows you to substitute a group of ASCII characters for a device-
dependent command string. Basically, there are two chief reasons for using this feature: (1)
to make programs more readable, and (2) to emulate the operation of other instruments.


Translator words are defined with the ALIAS command by including the defied word along
with the associated device-dependent-comaqd string. For example, to define the word
SAMPLES to prograti 1000 samples, the ftiiiowing would be used:




Note that spaces are included to delimit the ALIAS command, the defined word (SAMPLES),
and the device-dependent command (NO,lOOOX). Also, the definition string must be ter-
minated with a semicolon.


Once Translator words are defined, using them is simply a matter of sending them in place
of device-dependent commands, for example:




In this case, the word SAMPLES would program 1000 samples because SAMPLES was
previously defied as NO,lOOOX.


MAKING PROGRAMS READABLE

Program 7 below gives an example of how Translator can be used to make programs more
readable. Figure 15 is a flowchart of the program.
SENDSELECTIVE
DEVICECLEAR




Figure 15. Flowchartfor Program7


Program Operation

Key points of the program include:

1. The variable Voltmeter is defined as 709 for use in subsequent OUTPUT statements (line 20).
2. The inshument is then returned to default conditions tid placed in remote (lines 30 and 40).
3. Next, the Translator words are defined by using the ALIAS command (lines 50-100).
4. Test 1 is then executed by sending the appropriate Trkslator words to program the various
operating modes (lines 120-170).
5. In a similar manner, Test 2 is performed by programming the &trument (lmes 190-240).




42
Running the Program

1. Enter the &xogmm into the computer.
2. Press RUN to execute the program.
3. The program wi!.l then send Translator words to the inshument to be defined. Two dif-
ferent readings should appear on the computer CRT, one each for Test 1 and Test 2.


INSTRUMENT EMULATION

Program 8 demonstrates the use of Tran$a@' to emulate the TRMS measurement of an AC
waveform. Notesthat TCR4? is the command string that is to be emulated by the Model 194%.
This command selects RMS, 1OVAC range, and DC coupling of the DVM being emulated.
Figure 16 gives a flowchart of the program.


Program Operation

1. The Translator word is first defined (line ~3).
2. The instrument is placed in remote (line 10).
3. The defined Translator word (TCR4?) is then sent to the instrument (line 20).
4. Finally, a loop is set up to request and display 10 readings (lines 40-70).


Running the Program

1. Enter the program into the computer.
2. Apply an AC signal of approximately 1OVRMS to the instrument INPUT jack.
3. Press the RUN key to execute the program.
4. The program will send the necessary Translator definition command to the instrument;
program the instrument accordingly, and then request and display 10 readings.




43
DEFINE TRANSLATOR
bm=a~


4

PUT 1~94A
INTOREMOTE



4
PROGRAM ~194ATO
EMULATE D"M
USING TR4NSLATOR




GET READING



c


DISPLAWEADING




Figure 16. Program 8 Flowchart




44
Program 7. Using Translator for Program Readability
10 ProQram-aetupL
20 "a,tneter=709 !~Oaflne194.A~
address
30 CLERR Voltmeter !LReiclrn to default
40 REMOTE "altmcter I Pui 194A rn rcmoic
50 OUTPUT Voltneteri"RLIA5 ZERO CIZ4X :" 1 Define trans1a+or word
60 OUTPUT "oltneteri'ALIA5 SETUP1 CIXF3R311X :" I 0efine translator word
70 OUTPUT "oltnetcrr"RLIAS SETUP2 ClXFiXRZX i- I 0efinc irans,ator ward
80 OUTPUT "o,tneter,"ALIAS 1000SAMPLES N0.1000X i- I Define trans1atar word
90 DUTPU, "oitneter;`ALIRS ARIl T2GX /- I Define translator ward
I00 OUTPUT "oiineier;"ALIRS OISPIBLECHZ CZXT7X i'l I Define translator word
II0 Test-l:,
120 OUTPUT Uoitnettr;`OISABLECHZ"
130 OUTPUT "altnetsr,"SET"PI'
140 OUTPVT "oIincter:`ZERO`
150 OUTPUT "01tmcteri'etR"`
I60 ENTER Uoltmetcr;ReadlnaB
170 PRINT RcadlngB
180 rest-z: 1
190 DUTPUT Uoitmeterr"SETU~2"
260 OUTPUT Uoitneteri'l000SAMPLES
210 OUTPUT "oiinctcri "ARM"
220 ENTER U~ltmeter~Rc~din~S
230 PRINT r?.adinq%
240 END




Program 8. Using Translator for Instrument Emulation

I I Line 3 translates the DVM commands to 134A cmnanda.
3 O"TP!,T 709,`ALIAS TCR47 C2TiXC1F:R3G11050,i66.7E-6N0.l000T26X 8"
10 REMOTE 709 1 Put ovn I"