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 | HomeIEEE-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 CONTENTSAbout This Programming Guide .............................................................. ., .. 1Computer Programming Syntax ................................. .: .. ., ............ ; .............. 3Single Channel Programming ................................... I ............................... 7Dual Channel Programming ................. -~__ __ ................................................ 11Single and Continuous Trigger Arming .............................................. .,.......... 17SRQ~andErrorHandling.. ................... ;...:~ ........... .: .... .._..... .... ..I ...... .._ ....... 21Binary DataTransfer .......................................................................... 29Reading Buffer Operation ................................... _. .. .,............................. 37Using Translator ................................................... ._._. ................ ._.~. ...... 41Using External Sample Triggering ................................ _ ....................... .,_ .,.... 47Generating Bus Time Information ............................................... _ ............... 55Appendix A - Device-Dependent Commands~ ...................... .~~.;.:, .I. : ........... .,......... ~A-1Appendix B - Data Formats ................................................................... B-lAppendix C - Status Words and SRQ Format I .................................. .I .............. C-lAppendix D - Front Panel Modes and Equivalents IEEE-488 Commands ........................... D-lAppendix E - Data~Transmission and NRFD Hold-off Times ...... ; .............................. E-lABOUT THIS PROGRAMMING GUIDEThis programming guide is intended as a tt.&xial on a number of programming conceptssassociated with the Model 194A. It is not intended to replace the IEEE-488 programmingsection of the Instruction Manual, which should be consulted for detailed programminginformation.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, referenceinformation such as device-dependent commands, data formats, and error words is alsosupplied. l/2COMPUTER PROGRAMMINGSYNTAXAll the example programs in this guide are written in Hewlett=Packard BASIC 4.0, whichis used on the Series 200 and 300 computers. This programming language was chosen forthese 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. Thefollowing provides a brief overview of some of the statements you will encounter in the variousprograms in this guide. Refer to the BASIC 4.0 Reference for more detailed information.OUTPUTOUTPUT 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 theinstrument. FlX is a literal string that will be transmitted to the instruments when the state-ment~is executed.ENTERENTER 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 theinstrument. .A$ is a string variable into which incoming data is placed. Keep in mind thatA$ 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 theproper instrument data format is used.SPOLLSPOLL 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- 3ment is executed. The status byte-can then be checked by ANDing or BIXng S to determinethe status of the required bits. These bits can yield certain information such as reading,overflowand ready for a new command.BITBIT 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.TRIGGERTRIGGER 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 thisthe A/D converter must be armed. Note that programming a trigger mode over the busautomatically arms the A/D converter.ASSIGNASSIGN 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 codeand primary address. Another form of ASSIGN is used to-define the IiO~buffer: ASSIGM IZufTU BUFFER k8 `~TRANSFERTRANSFER is used to perform a rapld I/O data transfer sequence. Usualli, TRANSFER isused with the binary dump feature oft the Model 194A for most~rapid data transfer. Usingthis 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~IlIn this instance, a total of 1000 bytes will be tr~mitted from the Model 194A to~~the~internalbuffer.4STATUSSX4TUS allows access to certain computer status registers. Most often, this statement is usedto 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 INTRThese two statements work together to enable interrupts and to tell the computer where togo for next line execution. A typical ON INTR statement is:In this case, when the computer detects an IEEE-488 interrupt, it-begins executing thesubroutine at line 4000.SRQ is the most often used type of interrupt for the IEEE-488 bus. Using BASIC 4.0, SRQinterrupts are enabled as follows:Once enabled, an SRQ Wi cause the computer to branch to the line number specified bythe ON INTR statement. Typically, an error handling subroutine will be incorporated at thatpoint to determine the reason for the SRQ and to handle any other required tasks. 5/6SINGLE CHANNEL PROGRAMMINGPROGRAMMING CONCEPTSl Sending command strings to the Model 194A.l Obtaining data and displaying iton the computer CRTPROGRAMMING CONSIDERATIONSAt the very least, it will be necessary to send commands to the instrument to set it up asdesired, 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 toF rogTam 2.PROGRAM OPERATIONProgram 1 below demonstrates fundamental programming techniques for a single-channelunit. 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 calledCommand!& Now we can send the command string to the instrument with the `X" characterappended 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 converterbefore 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 FlowchartNote 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 necessaryto trigger the unit before the unit will collect samples. Once PB ose samples are stored and tprocessed 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-lRUNNING THE PROGRAM1. Enter the program into the computer.2. Run the program by pressing the RUN key. The computer wti promptyou to type in your command: 93. 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 TRANSFERThe Model 194A can be used to capture a waveform and then send the data as a series ofreadings representing the individual samples. Each individual data string will represents thevoltage 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 quotesbecause 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 samplescan 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 thisguide on binary data transfer.Program 1. Single Channel Operation102030405060708090100$10 10DUAL-CHANNEL PROGRAMMINGPROGRAMMING CONCEPTSl 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 CONSIDERATIONSProgramming 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 OPERATIONProgram 2 below demonstrates dual-channel programming. Figure 3 is a flowchart showinggeneral program flow. 11 t I I ARM AND TRIGGER CHANNEL 2 I_! READINGFigure 3. Dual Channel Operation FlowchartUsually, an instrument is sent a command at the start of a program to return it to some defaultstate. In the program below, this operation is performed by sending an SDC (Stile&d DeviceClear) 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 programmingcommands as follows: 3M REMOTE 76'3Now we can program channel 1 and channel 2 as required. For channel 1, we will selectthe 32OmVrange (Rl) and TRMS function (F2) as follows:In a similar manner, channel 2 is programmed for the ZOOVrange (R4) using the averagefunction (Fl):In both cases, you will note that the channel select (C) command is included at the frontsof 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 Ccommand is not required, but it does no harm).At this point, we have programmed both channels; however, since the range and functionwere 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 triggercommand that arms the AID converter. Here again, the immediate trigger mode vZ6) is usedso 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 afterarming them.Now that both A/D converters are running and readings are being processed, it is a simplematter to set up a loop to request and display readings:This loop repeats indefinitely, with one reading per loop accessed and displayed.RUNNING THE PROGRAM1. 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 CHANNELIn 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' 3Similarly, 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 triggerinput~for that channel. Another way to disable a channel is to use T27 which causes onlyone trigger; no further triggers will oCcur even with external triter input noise.SELECTING CHANNEL OUTPUTAs 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 immediatelyrequesting 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 END14With 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 alarge difference in processing speed between the two channels.Program 2. Dual-Channel Programming10 OIM ReadlngBlSOl oincnalo" reading string20 CLEAR 709 Return the 194.4 to default conditions30 RErlOTE 709 Put the 134 into renotc mode40 0UiP"T 709;"CIXRIF:X- Program chl far the 320mU range and TRMS50 0"iP"T 709i"C:XR4FiX" Program ch2 for the 200" range and Rverags60 OUTPUT 709i"CIXT?fiX' Am channci I70 OUTPlJT 709; ~CZXT26X" Am channel 2 ENTER 709,Readimp Get a reading fron the !94A PRINT Reading* Print the rcadlng GOT" 80 ReDeat TN,, I5116SINGLE AND CONTINUOUSTRIGGER ARMINGPROGRAMMING CONCEPTSl 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 CONSIDERATIONSBefore 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, oran IEEE-488 GET, X, or t& command. However, it will notrespond to a trigger unless theA/D converter is first-armed and ready for a trrgger.Basically, there are two A/D arming modes: single and continuous. With single arming, theA/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 eachmeasurement.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), armsthe 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 sendthe 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 OPERATIONProgram 3 below demonstrates single arming using the GET trigger source. Figure 4 is aflowchart of the program.Once the unit is in remote, we can program the trigger source and arm the channel 1 A/Dconverter as follows:In this particular instance we have selected the single arm, GET trigger mode (T3X); afterthe 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 ReadingsHere 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 becausea single-arm trigger mode is jn effect. If instead we had branched back only to line 30, onlyone reading would be taken the first time through the loop.18 SENDGETTO TRIGGER READING Figure 4. Single Arming FlowchartRUNNING THE PROGRAM1. 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 ARMINGProgram 3 can be modified for continuous, GET arming by changing the lines below. Figure5 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 computerdisplay. Now, however, it is n&necessary to %rmthe converter each time--merely triggerit--to obtain each reading. PROGRAM CHANNEL 1 CONTINUOUSGET. ARM A/D SEND GETTO TRlGGERREADlNG Figure 5. Continuous Arming FlowchartProgram 3. Arming and Triggering10 REMOTE 70920 OUTPUT 709;`C,XT3X~30 TRIGGER 70940 ENTER 709,4ead,ng550 PRINI RPsdlng*60 FOTO 2070 END20SRQ AND ERROR HANDLINGPROGRAMMING CONCEPTSl Programming the [email protected] 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 CONSIDERATIONSThe SRQ line on the IEEE488 bus gives the user a great deal of flexibility in determiningif the instrument~requires controller servicing. By sending the appropriate command (Table2), you can program the Model p4A to notif the controller when it re uires service for avariety of different conditions including rea kg oveflow, data (buffer ?i.zll,`/2full, plotterdone), 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 byadding 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 thestatus byte to determine whether that instrument did in fact request service, and if so, whatconditions 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 causedthe 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: interruptand po!.ling. The interrupt~method is by far the more versatile, since it is possible for thecontroller to perform other tasks until the instrument requests service. With the pollingmethod, the controller must periodically check the status of the SRQ line to determine ifthe 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 OPERATIONProgram 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. Figure9 gives a flowchart of key sections of the first part of the program, while Figure 10 outlinesthe error handling routmes. 23Highlights 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. Whenan 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 PROGRAM1. 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.245. 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)26USING POLLED SRQThe 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_routineWith this modification, the controller must check the status of the SRQ line each time it goesthrough its main task loop. Although from a user's standpoint the program may appear tooperate the same, the additional controller overhead necessary for p4led SRQ uv3ybecomqrestrictive in larger applications.Iii0 OUTPUT 7091 -M40X" (Program 4. SRQ and Error Handling (Cont.)28BINARY DATA TRANSFERPROGRAMMING CONCEPTSl Data transfer speed considerations.l Transferring binary data from the Model 194A to the computer.l Converting binary data into displayable form.PROGRAMMING CONSIDERATIONSWhen a relatively large number ofsamples must be transferred from the Model 194A to thecomputer, 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 datafrom 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) fewerbytes are transferred per sample in the binary mode.In order to take full advantage of binary transfer speed, the computer must be ca able oftransferring at a rate at least as high as that of the Model 194A--approximately 9I& bytesper second in binary mode. The HP9816 used for the example program below can operateat rates as high as l30K bytes per second using fast handshake transfer, but other controllersmay 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 1000samples. In binary mode using fast handshake, these sam les can be transmitted in only65msec 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 additionto the one or two bytes for each sample, a~~&byte status word and byte count (G7 only) isadded to the front of each byte sequence. The statis word contains unportant informationsuch as range, channel, function, as well as the exponent for the data. In order to displaythe data, it must first be converted into ASCII form, as demonstrated in Program 5 below.PROGRAM OPERATIONProgram 5 below demonstrates fundamental concepts for obtaining bii data and convertingit 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 Formats303. 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 TransferProgram32I 0 0 ~11 RANGES r-l 0 0 CHANNEL 0 1 ~BME 2 AND 0011 0 0 0 0~ ~(~~4810) 0011 0 0 0.0i 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 BitsRUNNING THE PROGRAM1. 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. 33Program 5. Binary Data Transfer10 Initializegrog: !30 INTEGER 8( 32000) I DiFlenei0n tntcrxr40 REAL A I Reserves storage for floatiig mint variable41 OIM A$[320001 SUFFER I Dlnaneio" buffar50 ASSIGN 80194 TO 703 ~! *seign I/D path n*ne to 194660 WiGIGN @Suf TO BUFFER A$ I Rsalgn I/O path name to BUFFER70 OUTPUT KBOICHR$( 2% )&CHR8(75 )i I Clear em-can30 I"li ielize~1~S4: I35 REMOTE 703 ! Put 194R in renote90 PRINT "ENTER NUMBER OF SAPIPLES' ! ~PrOFlpt for tt w&npl+a100 INPUT Samples ! Input * sanplea110 PRINT "ENTER RE&OING RRTE IN US 120 INPUT Pate I Input rate121 ! Progren 194130 OUTPUT 709;"F0R,NB,"&"ALs(S~~~~~,~~"S0."6VALO(Rete~~.G7O0~.140 OUT~PUT 709, `T27X" I Arm the 194A150 Test_reading:l160 S=SPOLLC 709 1 I Perforn serial poll170 IF SIT
1B0 setup-tranefei: !190 IF Rate/l.OE-5 THEN Numb&r-bytes-l ( Oeterninc X bytea PCP aanele200 IF Rate:,, .0E-5 THEN Nunhcr-bytes-2 ! Detern~ne P bytes per ~anple210 Perfarn-transf: I211 ! Transfer 194pI Data us`ng fast hand,haks. Te~ll how maw212 bytes are ta be tranafered.220 TRANSFER 00134 TO WufiCOUNT ~(Nunber_bytes+Sanpis.)t6,WnTTZZ, : Read 194A status fran buffer230 Rend-statue:!240 ENTER Wuf USING ~X.W,B.B.R.B~;Count,Statual ,Stat~.Z.Statu.3,Statu.4260 Read-data:!250 FOR Data=, TO Sample5270 IF Ratei,.0E-5 THEN ENTER R&f USING `%.B"r3(0ata) I Read 8 bit word271 ! fro,, buffer.280 IF Rate:,.0E-5 rHEN ENTER B&f USING `%.W*iE(Data) 1 Rea~d 16 bit word281 ! from buffer.290 GDS"9 canvert I Goaub ta ravtina that converta raw binary300 PRTNT Oat a .Reading .Hessaoes310 NEXT Data320 SENO 7,UN1330 STOP340 convert: I3G0 A=BtOata)360 IF Rate:, ."E-5 THEN Rij+weight-256 ! Dsteinlne bit we,pht for 8361 ! bit mode.370 IF Rate,,.OE-5 THEN Bit-weight-1 I Deternlne bit weight for 16~371 1 bit node.3303904004104204304404504G1 ! et.tu.460 IF Range-0 THEN Reading-R*i.OE-5 1 Scale reading for.320V range470 IF Range=, THEN Reeding=R*I.OE-4 / Scale reading for 3.~2" range480 IF Range-2 THEN Readlng=R*I.OE-3 ! Scale readying for 32V range490 IF Range-3 THEN Read,ng=R.i.BE-2 ! Scale reading for 200" range34Program 5. Binary Data Transfer (Cont.) 35136READING BUFFER OPERATIONPROGRAMMING CONCEPTSl 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 CONSIDERATIONSThe reading buffer is a 100 location buffer into which processed readings can be stored asthey become available. By sending the appropriate command, you can operate the readingbuffer 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 untilthe buffer is completely emptied. With the circular buffer, the instrument will store 100readings 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) onthe reading string. Of course, you can also turn off an unused channel by programmingfor a trigger condition that~willnotebe met. For example, to turn off channel 2, send C2XT7Xover 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 immediatemode, the instrument will fill the buffer without requiring additional triggers. However, inthe remaining trigger modes, yen ,must supply one trigger per measurement in order to fillthe buffer.Once your data is stored in the buffer, there am several ways to access it. with the GOthroughGZ data formats, one buffer location will be sent with each request. However, you can alsodump 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 thebytes in the data string.By using the B3 command, you can dictate how many oftthe reading buffer locations willbe 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 transmittedwhen requested. 37It~isimportant to clarify the operation of the buffer location suffix, which is shown in Figure2. This value does not represent the buffer location number; rather, it shoti the numberof 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 number1, but the suffix will show 0019, meaning that there are still 19 locations left to access. Thisvalue will decrement once per buffer location until it shows a value of 0000 with the accessof the last buffer location.PROGRAM OPERATIONProgram 6 below demonstrates fundamental operation of the reading buffer. Figure 14 is aflowchart 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 PROGRAM1. 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 [email protected] 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.38Figure 14. Flowchartfor Reading Buffer Program 39Program 6. Reading Buffer OperationI0 OIM RaadlnQG~20001 I oinanaion readings20 REMOTE 703 ! Put the 1948 in rcnotc30 OUTPUT 709:`CIT7X" ! Turn off channel 140 OUTPUT 709i"CZT,X' f Turn off channel 250 OUTPUT 703i"CIN0.,050,iE-6X" ! Program rats and * sanplca for60 ! channa, 1.70 OUTPUT 703:"QIX" ! Enable linear bvffer80 FOR I-1 TO 100 1 Take I00 readinps30 OUTPUT 709i"T3X" .I Program trfpper mode and arm AI0I00 ! charm*, I.110 TRIGGER 703 ! Trrwer the 1348120 NEXT I ! Triggsr another reading130 OUTPUT 7a3,`GSB3.:0X" ! Program 194R to ,end140 ! readings 1-20150 !160 ENTER 709iReadrngB ! Read buffer Iocatlons I-20170 PRINT Readings lKPFi"i rcading$160 END40USING TRANSLATORPROGRAMMING CONCEPTSl Using Translator tom make programs easier to read.l Instrument emulation using Translator.PROGRAMMING CONSIDERATIONSThe 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 alongwith the associated device-dependent-comaqd string. For example, to define the wordSAMPLES 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 placeof device-dependent commands, for example:In this case, the word SAMPLES would program 1000 samples because SAMPLES waspreviously defied as NO,lOOOX.MAKING PROGRAMS READABLEProgram 7 below gives an example of how Translator can be used to make programs morereadable. Figure 15 is a flowchart of the program. SENDSELECTIVE DEVICECLEAR Figure 15. Flowchartfor Program7Program OperationKey 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).42Running the Program1. 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 EMULATIONProgram 8 demonstrates the use of [email protected]' to emulate the TRMS measurement of an ACwaveform. 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 Operation1. 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 Program1. 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 Flowchart44Program 7. Using Translator for Program Readability10 ProQram-aetupL20 "a,tneter=709 !~Oaflne194.A~ address30 CLERR Voltmeter !LReiclrn to default40 REMOTE "altmcter I Pui 194A rn rcmoic50 OUTPUT Voltneteri"RLIA5 ZERO CIZ4X :" 1 Define trans1a+or word60 OUTPUT "oltneteri'ALIA5 SETUP1 CIXF3R311X :" I 0efine translator word70 OUTPUT "oltnetcrr"RLIAS SETUP2 ClXFiXRZX i- I 0efinc irans,ator ward80 OUTPUT "o,tneter,"ALIAS 1000SAMPLES N0.1000X i- I Define trans1atar word90 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 RcadlngB180 rest-z: 1190 DUTPUT Uoitmeterr"SETU~2"260 OUTPUT Uoitneteri'l000SAMPLES210 OUTPUT "oiinctcri "ARM"220 ENTER U~ltmeter~Rc~din~S230 PRINT r?.adinq%240 ENDProgram 8. Using Translator for Instrument EmulationI 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"