Home

HP 13B User's Manual

image

Contents

1. The RUN command is executed in two phases prerun initialization and program execution The prerun initialization phase consists of a Reserving memory space for variables specified in COM both labeled and blank DIM REAL or INTEGER statements or implied in the main program segment Numeric variables are initialized to 0 string variables are initialized to the null string a Checking for syntax errors that require more than one program line to detect Included in this are errors such as incorrect array references and mismatched parameter or COM lines After prerun has been successfully completed the program will begin the execution phase Program lines will be executed until one of the following events occurs 1 An END or STOP statement is encountered in the program 2 The hardkey is pressed to reset the instrument 3 The softkey is pressed to pause the program 4 A PAUSE statement is encountered in the program Pausing a Program s available softkey Press When an IBASIC program is running on the analyzer a softkey menu i This Program Running menu has seven user defined softkeys and a the softkey to suspend execution of a program is the eighth softkey and is represented by on an external keyboard The program can also be paused by inserting a PAUSE statement in the program The instrument responds as if you had pressed the softkey Refer to Chapter 5 Developing Programs to learn how
2. e VALS XO INT Sc 200 VAL CINT Sc 15 a amp VAL XO INT Sc 200 VAL CINT Sc 15 amp VAL XO INT Sc 200 EVAL CINT Sc 15 amp VEVAL XO INT Sc 200 SVAL CINT Sc 15 amp VAL XO INT Sc 265 amp VAL CINT Sc 70 amp EVAL XO INT Sc 230 760 OUTPUT ORfna DISP WIND1O amp VAL CINT Sc 10 770 OUTPUT Rfna DISP WIND10 amp VALS YO INT Sc 85 780 OUTPUT CRfna DISP WIND10 EVAL SCINT Scx 3 790 OUTPUT GRfna DISP WIND10 amp eVAL YO INT Sc 50 800 OUTPUT CRfna DISP WIND1O 810 OUTPUT Rfna DISP WINDiO 2 EVALS YO INT Scx 15 820 OUTPUT GRfna DISP WIND O 830 OUTPUT Rfna DISP WIND10 amp amp VAL YO INT Sc 15 840 OUTPUT Rfna DISP 850 SUBEND WIND1O GRAP GRAP GRAP GRAP GRAP GRAP GRAP MOVE GRAP GRAP RECT MOVE RECT MOVE CIRC MOVE CIRC CIRC ZVAL INT Sc 20 amp gVAL XO INT Sc 275 e VALS CINT Sc 50 amp VAL XO INT Sc 295 amp VAL CINT Sc 8 e VALS XO INT Scx245 e VAL CINT Sc 4 SVAL XO INT Scx325 VAL CINT Sc 4 B60 n ne nnn nn nn nn enn en nnn nnn nn nn nnn eee 870 SUB Draw dut INTEGER 880 wa o o nnn nnn nn nn ee nn nnn nn nn enn enn ene 890 900 910 920 930 This subprogram draws a device under test dut and connects it to the HP 8711 that was drawn with an origin at X0 YO and a
3. Labeling with Different Partitions eee ee eee 7 10 pe SCPI Graphics Commands caros a AA A a SR A 7 11 Contents 2 8 Interfacing with External Devices Communication with Devices a e ee ee hia e 8 1 HP IB Device Selectors 4 bes ah cates cag de JO 8 1 Moving Data Through the HP IB SN 8 2 General Structure of the HP IB TER 8 3 The System Controller a boa id a alee e a o a 8 3 Using the Serial and Parallel Ports 8 3 Using the Analyzer Ports in IBASIC programs 04 8 4 Writeable Ports gps eo e AR ok A e A mE 8 4 Readable Ports I READIO A B 1 E Se Ae Se Be Seats ei i 8 4 General Bus Management ee ee 8 5 REMOTE ga ae ee te en Ge i AAN St a a si 8 6 Host Instrument a ma A RS ee A Se eS Far 8 6 LOCAL LOCKOUT e a aa He a O we e E fae a a 8 6 Host Instrument asa ay Gee Macca Gp Bs eit ede oe at OR ein a i ey E cd 8 6 LOCAL ss a eco ap Sy ae HG a A we eS ate 8 7 Host instrument as sd lsat A A A LES 8 7 TRIGGER a de A ARS bobo 8 7 Host Instrument e ER A Se ae 8 7 CLEAR poo aradin de ses al Be ag ae Ser Boats A Ca GE hs ene ae au 8 7 Host Instrument ao Go ae ew the Ae es tes as an a 8 7 ABORT aod Sy coin ht ete NE Do E ed He Se as oh eae alt e de das a 8 8 Aborting the Internal Bus D E di BA ie a 8 8 HP IB Service Requests 2 2 ee ee TEE 8 8 Set
4. Sc is a scaling factor for the figure being drawn 1900 Label SUB Label Text Xpos Ypos Size Lorg Ldr Pen 1910 1920 1930 1940 1950 1960 COM Scale Sc INTEGER X Y LORG Lorg LDIR Ldr CSIZE Size Sc 1 MOVE X Xpos 5c Y Ypos Sc PEN Pen Graphics and Display Techniques 7 7 1970 1980 1990 2000 LABEL Text PEN 1 SUBEND The following program displays a HELP screen and demonstrates many of the techniques discussed so far Running this program produces the screen display shown in Figure 7 5 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 DIM A 58 String t000 ASSIGN 6Hp8711 TO 800 OUTPUT Hp8711 DISP PROG FULL WAI GINIT GCLEAR MOVE 0 89 RECTANGLE 200 14 PRINT TABXY 24 2 HELP OUTPUT A This program demonstrates how to print several String String xA OUTPUT A lines of text at one time This method offers String String amp As QUTPUT A the fastest possible print speed String String 2A PRINTER IS CRT WIDTH 1000 Prevent auto cr 1f PRINT TABXY 1 5 String END SS mee ee aes IAE i ES This program demonstrates how id gi severai ines of text ot one time nis method offers the fastest prt print speed AA Figure 7 5 HELP program output pe a 7 8 Graphics and Display Techniques Graphics Exceptions The following graphics commands do not conform to the keyword description found in the HP Instrument BASIC User
5. It is sometimes useful to review the last error encountered by a program that is being run This is done from the command line by examining the value assigned to the variable name ERRM This value will include the error number and message of the last error encountered by the program An additional method of displaying the error message is to use an error trapping subroutine For example insert the following line at the beginning of a program ON ERROR GOSUB Errormsg The subroutine Errormsg should then be included at the end of the program after execution is stopped but before the END command 100 Errormsg 110 DISP ERRM 120 PAUSE 130 RETURN The error message is automatically shown on the display line of the IBASIC window and program execution is paused when an error message is encountered You may also encounter SCPI errors in addition to IBASIC errors SCPI errors can occur when using the OUTPUT command to control the analyzer when a command syntax is unrecognized or incorrect For more details on SCPI errors refer to the Programmer s Guide 6 4 Debugging Programs Graphics and Display Techniques The analyzer has two measurement channels which can be displayed simultaneously The instrument s screen can be split into two trace areas for this purpose upper for channel 1 and lower for channel 2 Additionally the two measurements can be overlaid onto one full size screen the default setting For more informatio
6. Note SCPI mnemonics entered in a program during a recording session do not have a one to one correlation with the actual keys that are pressed during that session The fact that the generated SCPI mnemonics do not exactly correspond to the keys actually pressed is important to remember As you press a sequence of keys to perform an operation the corresponding SCPI mnemonic for that operation is generated The operation may take one keystroke or several but the mnemonic is not generated until after a valid sequence of keystrokes is completed In other words it is the functional operation of the instrument that is recorded as a mnemonic not the keystrokes that it takes to perform that operation For example recording the simple key sequence POWER ooo equires six keystrokes and produces only one mnemonic SOUR1 POW 10 dBm which is generated after the sequence is completed This is then automatically formed into the command OUTPUT Rfna SOUR1 POW 10 dBm and inserted into the program This means that if you accidentally press the wrong key in a sequence it may not show up in the recorded program Additionally you cannot exactly mimic keystrokes to leave the instrument in a specific front panel state unless it is a state that appears as a natural consequence of a completed operation As shown in the above example pressing the hardkey in a recording session has the effect of bringing up the menu but does not by itself gen
7. Then press the key Enable the user defined by pressing When is enabled the softkeys will be labeled Setup1 Setup2 and Setup3 To recall each setup select the appropriate softkey USER_BIT Using the USER bit This program demonstrates how to read and write to the USER bit The USER bit is a TTL signal accessible by a BNC connector on the analyzer s rear panel IBASIC s graphics commands are used to draw the USER bit value to the display USERKEYS Customized softkeys This program provides an example of how the analyzer s softkeys can be customized The example demonstrates how to set up six instrument states store them to the analyzer s internal memory and setup two interactive softkey menus to choose between them Example Programs 11 3 pies BARCODE STATS DATALOG Bar Code Programs You may use bar code readers to simplify your measurement setups The HPCK 1210 KeyWand scanner or compatible bar code scanner will work with the analyzer Connect your bar code scanner to the DIN keyboard connector You may connect a keyboard or other DIN key input device in parallel with the bar code scanner The bar code scanner will work in place of or in addition to your keyboard The INPUT statement is used to read the bar code from the scanner When the input statement is encountered the program will wait until the user has completed an input The input is completed whenever a carriage return i
8. 1050 1060 1070 1080 1090 1100 1110 1120 1130 1140 1150 1160 1170 1180 1190 1200 1210 1220 1230 1240 1250 1260 1270 1280 1290 1300 1310 1320 1330 1340 1350 1360 1370 1380 1390 1400 1410 1420 1430 1440 3 Take a measurement sweep and wait for it to complete Perform a 3 dB bandwidth search t OUTPUT ORfna INIT1 0PC ENTER Rfina Ope OUTPUT Rfna CALC1 MARK1 ON MARK BWID 3 l Select the parallel port and the printer s control language as the hardcopy device Set the printer resolution and margins turn off automatic form feed 1 OUTPUT Rfna HCOP DEV LANG PCL PORT CENT OUTPUT CRfna HCOP DEV RES 300 OUTPUT ORfna HCOP PAGE MARG LEFT 40 OUTPUT Rina HCOP PAGE WIDT 110 OUTPUT GRfna HCOP ITEM FFE STAT OFF i Send the measurement data graph and marker values to the printer i OUTPUT Rfna HCOP i Select the fonts and send the footer information for the report 1 CALL Send_line Banner 1 CALL Send_line 1 CALL Send_line 1 CALL Send_line IN STOCK IMMEDIATE DELIVERY 1 CALL Send_line Medium i CALL Send_line 0 CALL Send_line For more information Call 1 800 Filter 1 t Send a form feed to the printer t WRITEIO 15 0 12 END Example Programs 11 21 1450 The subprogram sends a string to the parallel port 1460 I 0 port 15 The Crlf flag determines whether 1470 a carriage return ASCII 13 and l
9. DIV DROUND EXP FRACT INT LET LGT LOG MAX MAXREAL MIN MINREAL MOD MODULO PI PROUND RANDOMIZE RND SGN SQR SQRT Binary Functions BINAND BINCMP BINEOR BINIOR BIT ROTATE SHIFT Trigonometric Operations ACS ASN ATN COS DEG EK P EK P EK P EK P EK P EK P EK P EK P EK P EK P EK P EK P EK P EK P EK P EK P EK P EK P EKP EK P EK P EK P EK P FP EK P FP EK P FP EK P FP EK P FP EK P FP EK P FP EK P FP EK P FPEK P FP EK P FPEK P FP EK P Abs vals less than 1 7083127722e 10 IBASIC Keyword Summary 10 9 Table 10 2 Categorical List of IBASIC Keywords continued HP Instrument BASIC Keyword Support Exceptions FP Front Panel EK External Keyboard P Programmable 2 10 10 RAD SIN TAN String Operations amp CHR DVALS DVAL IVALS IVAL LEN LWC MAXLEN NUM POS REVS RPTS TRIMS UPCS VALS VAL Logical Operations AND EXOR NOT OR Mass Storage CAT COPY CREATE CREATE ASCH CREATE BDAT CREATE DIR GET IBASIC Keyword Summary FPEK P FPEK P FPEK P FPEK P FPEK P FPEK P FPEK P FPEK P FPEK P FP EK P FPEK P FP EK P FPEK P FPEK P FPEK P FPEK P FPEK P FPEK P FP EK P FPEK P FP EK P FPEK P FP EK P FP EK P FP EK P FP EK P EK P EK P FPEK P Supports 58 columns See manual Table 10 2 Categorical List of IBASIC Keywords continued HP Instrument BASIC Keyword Support Exceptions FP Front Panel EK External Ke
10. Pr lt ENTER gt A DISP Loading program on HP 8711 OUTPUT Na PROG EXEC GET DATA_INT INTERNAL OUTPUT Na OPC 11 6 Example Programs 460 ENTER Na Ope i 470 480 Read the analyzer s event status register and 490 check for any errors when loading file 500 1 510 OUTPUT Na ESR 520 ENTER Na Esr 530 IF Esr gt 0 THEN 540 BEEP 550 DISP Error occurred while loading DATA INT stopped 560 STOP 570 END IF 580 590 Determine the HP IB address of the controller 600 and set the pass control back address 610 620 INTEGER Stat Addr 630 STATUS 7 3 Stat 640 Addr BINAND Stat 31 650 OUTPUT Na PCB Addr 660 670 Send the command to run the DATA INT program 680 690 DISP Running the program 700 OUTPUT Na PROG STAT RUN Tio 720 Monitor the program s status When it has 730 paused set the variable for the controller s 740 HP IB address 750 760 OUTPUT Na PROG STAT 770 ENTER Na Prog 780 IF Prog PAUS THEN GOTO 760 790 OUTPUT Na PROG NUMB Host Scode 100 Addr 800 OUTPUT Na PROG STAT CONT 810 1 820 Pass control of the bus to the HP 8711 830 840 PASS CONTROL Na 850 860 Wait until addressed to talk by the HP 8711 870 then send the name of the disk to catalog 880 o 890 OUTPUT Scode INTERNAL 900 910 Wait until addressed to listen by the HP 8711 920 then read the directory from the analyzer
11. 1 DOWNLOAD example program 11 1 downloading programs 8 17 DRAW871X example program 11 2 drawing figures 7 7 DUALCTRL example program 11 2 editor HP BASIC 5 2 errors displaying 6 4 example program ADJ_110 11 5 BARCODE 11 4 DATA_EXT 11 1 DATA INT 11 1 DATALOG 11 4 DOWNLOAD 11 1 DRAWS871X 11 2 DUALCTRL 11 2 Index 1 REPORT 11 2 STATS 11 4 TRICTRL 11 2 UPLOAD 11 3 USERBEG 11 3 USERBEGI 11 3 USERBEG2 11 3 USER BIT 11 3 USERKEYS 11 3 external bus 8 11 external controller interfacing with 8 13 external keyboard 3 2 5 5 E file ASCII 4 2 GET 4 1 graphics 7 5 SCPI commands 7 11 H HP BASIC editor 5 2 HP IB general structure 8 3 HP IB buffer 2 2 HP IB device selectors 8 1 HP IB echo 2 9 IBASIC synchronize with an external controller 8 14 i p 2 8 internal bus 8 11 K keyboard external 3 2 5 5 keyboard overlay 3 2 keystroke recording 2 1 L label window 5 7 LOAD 4 1 local 8 7 local lockout 8 6 Index 2 lockout local 8 6 M message windows 7 5 mnemonics SCPI 2 3 O operations IBASIC 2 6 QUTPUT 2 3 overview 1 2 pP parallel port 8 3 partitions display 5 10 7 1 PASS CONTROL 8 12 passing control 8 10 PAUSE 3 2 pausing a program 3 2 pop up messages 7 5 ports serial and parallel 8 3 PRESET 2 8 preset operation 2 8 program to pause 3 2 to recall 4 3 to run 3 1 to stop 3 3
12. 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 To Modify This is an example User Defined BEGIN program This progra Demonstrates fast recall of a previously defined files SETUP1 SETUP2 and SETUP3 The following line is required DO NOT REMOVE User Begin Program Use IBASIC EDIT or IBASIC Key Record Delclare storage for variables DIM Name 60 Stri 60 Str2 60 Str3 60 Clear the softkey labels OUTPUT Rfna DISP MENU2 KEY8 WAI Re define softkey labels here OUTPUT Rfna DISP OUTPUT Rfna DISP OUTPUT Rfna DISP OUTPUT Rfna DISP OUTPUT Rfna DISP OUTPUT Rfna DISP t MENU2 MENU2 MENUZ MENU2 OUTPUT Rfna DISP MENU2 MENU2 MENU2 KEY 1 KEY2 KEY3 KEY4 KEY5 KEYG KEY7 Setupl WAT Setup2 WAI Setup3 WAI WAI 7 WAT 3 WAT WAL The following 2 lines are required DO NOT REMOVE User pause PAUSE GOTO User pause l User_key1 Define softkey 1 here OUTPUT Rfna MMEM LOAD STAT 1 MEM SETUPi GOTO User pause User_key2 Define softkey 2 here OUTPUT GR na MMEM LOAD STAT 1 MEM SETUP2 GOTO User pause 1 User_key3 Example Marker Function OUTPUT Rfna MMEM LOAD STAT 1 GOTO User_pause MEM SETUP3 User key4 Example Title Entry GOTO User_
13. Beep on Beeper 1 RETURN Beep off Beeper 0 RETURN END Example Programs 11 37 USERKEYS Customized softkeys 10 SSS Se Sen E ENS ITY 20 30 IBASIC program USERKEYS Customized softkeys 40 i 50 This program provides an example template for use 60 in customizing the HP 871X s softkeys The example t H 1 1 1 70 demonstrates how to set up six instrument states i 1 1 1 80 store them to the analyzer s internal memory and 90 setup two interactive softkey menus to choose 100 between them 110 120 AAN A e eee ee a Sree eS eee eee 130 140 Assign an I 0 path name to the internal bus preset 150 the analyzer wait until the preset is complete 170 and reference values 180 190 ASSIGN Rfna TO 800 200 OUTPUT Rfna SYST PRES 0OPC T 210 ENTER C Rfna Dpc 220 OUTPUT Rfna ABOR INIT1 CONT OFF WAI 230 OUTPUT ORfna DISP WIND1 TRAC Y PDIV 20 dB RLEV 60 dB RPOS 5 n 160 turn on Trigger HOLD mode and set the display scale i i 240 250 Setup six instrument states and store them to the 260 internal memory 270 280 GOSUB Save 1 290 GQSUB Save 2 300 GOSUB Save 3 310 GOSUB Save 4 320 GOSUB Save 5 330 GOSUB Save 6 E 340 350 Setup the Main Menu keys te 360 370 GOSUB Menu 1 380 390 Wait until a softkey is pressed 400 410 Suspend 420 WAIT 100000 430 GOTO Suspend 440 STOP 450 1 460 This subroutine sets up the so
14. CHp871x DISP ANN MESS DATA amp Message amp MEDIUM idisplay message 1070 GOTO User_pause return to softkey loop 1080 1090 END Example Programs 11 31 USERBEG1 The default 10 20 30 40 50 am 60 70 80 90 i t BASIC program USRBEG1 100 ER begin ASSIGN Rfna TO 800 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 To Modify This is the default User Defined BEGIN program This progr will automatically install if the User BEGIN key is selected and a progam has not been previously loaded The following line is required DO NOT REMOVE User Begin Program Use IBASIC EDIT or IBASIC Key Record Delclare storage for variables DIM Name 60 Stri 60 Str2 60 Str3 60 Clear the softkey labels OUTPUT Rfna DISP MENU2 KEYS WAI Re define softkey labels here OUTPUT Rfna DISP OUTPUT Rfna DISP OUTPUT Rfna DISP OUTPUT Rfna DISP OUTPUT Rfna DISP OUTPUT Rfna DISP OUTPUT Rfna DISP MENUZ MENUZ MENU2 MENU2 MENUQ MENU2 MENU2 KEY1 KEY2 KEY3 KEY4 KEYS KEY6 KEY7 oe WHAT de WAI Mkr gt Max WA1 Title and Clock WAI 2 s WAL WAI gt k NAT The following 2 lines are required DO NOT REMOVE User_pause PAUSE GOTO User
15. Devices Downloading and Uploading Programs Programs can be transferred between an external controller and program memory using the HP IB download command PROGram SELected DEFine and its upload query _ PROGram SELected DEFine Programs that use these mnemonics are run in the external controller Downloading Program data transferred downloaded from the external controller to the instrument is always transferred as an arbitrary block The arbitrary block may be a definite length or indefinite length block The indefinite length block is by far the easiest and is simply a block of data that begins with the characters 0 preceding the first line and ends with a line feed character accompanied by an EOI signal on the HP IB interface When using the mnemonic PROG DEF to download program lines the 0 must not be followed by a line feed Each program line must have a line number at its beginning and a line feed at its end To end the arbitrary block of program lines a single line feed must be output with the OUTPUT END parameter which sends the EOI End or Identify signal on the HP IB control lines Refer to Chapter 11 Example Programs for a listing of the example program DOWNLOAD Notice that the OUTPUT statement on line 460 is terminated with a semicolon This suppresses the line feed that would otherwise occur As each line of the program is downloaded it is checked for syntax If an error is found the erro
16. IBASIC program To start the editor press th softkey in the menu or F4 on an external keyboard You will see the program appear on the display with a cursor on the first line of the program as shown in Figure 5 1 If the program buffer is empty the first line number 10 appears with the cursor positioned to begin entering text ra PRINT ABORT SUB SUBEND DATA LOCAL DIM BIT ABCDEFGHIJKLM ES Edit 40 il Se sr me Ena das mesa po turn rn ean nu E SER eee O re er even ee a a ad e e ne e a E i i A insert 20 This program measures the transmission and Line 30 i reflection characteristics of a bandpass filter 50 ASSIGN Hp87i1 TO 800 Char 60 ON KEY O LABEL TRAN CALL Transmission 70 ON KEY 1 LABEL REFL CALL Reflection Delete 80 ON KEY 3 LABEL SETUP CALL Setup_diag Line 90 ON KEY 5 LABEL EXIT GOTO Enc prog Recall 100 LOOP iine 110 DISP WAITING FOR SELECTION 120 END LOOP 130 End prog DISP Delete 140 END Char 350 _ _ A ER Sos as Vaca doa soa Ga OO SS R TA ES a Cs dam pa Se 160 SUB Transmission Enter 170 Transmission 180 OUTPUT GHp8711 CONF FILT TRAN 190 OUTPUT Hp8711 DISP ANN FREQ 1 MODE CSPAN 200 OUTPUT QHp8711 SENSL FREQ CENT 175 MHZ Prior Menu Figure 5 1 The HP IBASIC Program Editor The analyzer editor is accompanied by a Label Window at the top of the screen This window is filled with characters and IBASIC keyword commands and has
17. LABEL SCAN ANOTHER GOSUB Scan_next ON KEY 5 LABEL DONE GOSUB Exit LOOP DISP SELECT A SOFTKEY WAIT 1 DISP WAIT 3 11 46 Example Programs 500 END LOOP 510 END LOOP 520 l 530 Exit 540 CLEAR SCREEN 550 DISP PROGRAM PAUSED 560 LOCAL ORfna 570 PAUSE 580 RETURN 590 600 Scan next 610 LOOP 620 Scan dut Model Serial Cent Span Loss 630 IF Model ABORT THEN GOTO Exit 640 IF NOT N THEN Curr model Model 650 EXIT IF Model Curr_model 660 DISP Inconsistent Model Try again 670 BEEP 2100 1 680 WAIT 1 690 END LOOP 700 CLEAR SCREEN 710 PRINT TABXY 1 4 Device currently under test 720 PRINT Model Model Serial Serial 730 PRINT TABXY 1 6 Avg d N 740 PRINT TABXY 1 7 Status of Serial amp Serial amp MEASURING fi 750 GOSUB Set stim 760 RETURN 770 780 Avg this 790 PRINT TABXY 1 7 Status of Serial amp Serial amp READING D ATA 800 Read_fdata Chan A 810 N N 1 820 PRINT TABXY 1 7 Status of Serial Serial 2 AVERAGING 830 IF Nei THEN 840 MAT M A 850 OUTPUT Rfna TRAC CH2SMEM CH2SDATA 860 OUTPUT Rfna CALC2 MATH IMPL DISP WIND2 TRAC ON TRAC2 ON WAL 870 OUTPUT Rfna ABOR INIT2 CONT ON WAI 880 ELSE 890 FOR I 1 TO Points 900 MCI N 1 N MCI A 1 N 910 NEXT 1 920 END IF 930 PRINT TABXY 1 6 Averaged N 940 PRINT TABXY 1 7 Status of Serial amp Serial gz WRITING D ATA 950 Write
18. OUTPUT GRfna DISP WINDIO amp amp VAL CYO INT Sc 40 660 OUTPUT Rfna DISP WIND10 amp VAL INT Sc 8 670 OUTPUT Rina DISP WIND10 amp amp VAL YO INT Sc 30 680 OUTPUT Rfna DISP WIND1O amp VAL CINT Sc 8 690 OUTPUT GR na DISP WINDIO amp amp VAL YO INT Sc 20 700 OUTPUT Rfna DISP WIND10 amp VAL CINT Sc 8 710 OUTPUT Rfna DISP WIND10 g e VAL YO INT Scx10 720 OUTPUT Rfna DISP WIND10 amp VAL CINT Sc 8 730 OUTPUT Rfna DISP WIND10 amp amp VAL CYO INT Sc 80 740 OUTPUT Rfna DISP WIND10 amp VAL CINT Sc 13 750 OUTPUT ORfina DISP WIND10 amp amp VAL CYO INT Sc 81 11 14 Example Programs GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP MOVE RECT MOVE RECT MOVE RECT MOVE RECT MOVE RECT MOVE RECT MOVE RECT MOVE RECT MOVE RECT MOVE RECT MOVE RECT MOVE VAL XO amp LVAL CYO VAL CINT Sc 350 amp gVAL XOF INT Sc 10 amp VAL INT Sc 180 amp VAL XO INT Sc 200 VAL INT Sc 15 amp SVAL XO INT Sc 200 VAL CINT Sc 15 amp amp VAL XO INT Sc 200 VAL CINT Sc 15 amp VAL XO INT Sc 200 EVAL CINT Sc 15 amp
19. Sc INTEGER X Y MOVE X Xpos Size 2 Sc Y YposxSc POLYGON Size Sc 3 3 SUBEND Example Programs 11 45 STATS Using Bar Code Reader 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 IBASIC program STATS Collects statistics i This HP 8711 IBASIC program uses a barcode reader Displays running average of selected BPF passbands Finds linear avg of log data ie Avg of 1dB amp 5dB 3 Expects to see BARCODE with the following format Model Number 6 char space Serial Number 5 char Valid Models BPF175 BPF200 SAWi34 REV A 01 00 930615 JVV e na a a TT O o COM Hpib Rfna COM Csub loaded DIM A 1 1601 M 1 1601 INTEGER Points N I Chan Points 201 of trace points Chan 2 ASSIGN Rfna TO 800 IF NOT Csub_loaded THEN LOADSUB Read fdata FROM XFER MEM 0 0 LOADSUB Write fmem FROM XFER MEM 0 0 Csub_loaded 1 END IF OUTPUT Rfna SYST PRES 0OPC ENTER Rfna Opc OUTPUT Rfna DISP PROG UPP GINIT GCLEAR OUTPUT Rfna DISP ANN MESS STAT O OUTPUT Rfna SENS1 STAT OFF SENS2 STAT ON OUTPUT Rina SENS2 SWE POIN Points points OUTPUT ORfna DISP WIND2 TRAC Y RPOS 9 PDIV 1 DB 0PC7 ENTER Rfna Opc N 0 Setup LOOP GOSUB Scan next ON KEY 1 LABEL AVER THIS DATA GOSUB Avg this ON KEY 3
20. The byte is output serially according to the configuration for the serial port See above Readabie Ports I READIO A B READIO READIO READIO READIO READIO 9 0 15 0 15 1 15 2 15 10 Reads the serial port Reads the 8 bit data port Cent DO through D7 Reads the user bit Reads the limit test pass fail bit Reads the 8 bit status port e DO Cent acknowledge D1 Cent busy D2 Cent_out_of_paper D3 Cent on line D4 Cent_printer_err An example program REPORT demonstrating peripheral control over the parallel port is provided in Chapter 11 Example Programs Refer to Automating Measurements in the Users Guide for further explanation and examples of how to access the analyzer s I O ports 8 4 Interfacing with External Devices General Bus Management The HP IB standard provides several mechanisms that allow managing the bus and the devices on the bus Here is a summary of the IBASIC statements that use these control mechanisms ABORT abruptly terminates all bus activity and resets all devices to their power on HP IB states CLEAR sets selected or all devices to a pre defined device dependent HP IB state LOCAL returns selected or all devices to local front panel control LOCAL LOCKOUT disables selected or all devices front panel controls REMOTE puts selected or all devices into their device dependent remote modes SPOLL performs a s
21. Write corr INTEGER Chan N REAL A Write complex error coef MATH Define Complex Array Operations Cmplx mag REAL Cdata Mag INTEGER Sz Mag of complex array Cmpix arg REAL Cdata Arg INTEGER Sz lArg of complex array Cmplx_conjg REAL A B Complex conj of array A to B Define Complex Number Operations Cadd REAL Opi INTEGER Row1 REAL Op2 INTEGER Row2 REAL Ans INTEGER Rowans Complex Ans Op1 Op2 Csub REAL Opi INTEGER Rowi REAL Op2 INTEGER Row2 REAL Ans INTEGER Rowans Complex Ans Op1 Op2 Cmul REAL Op1 INTEGER Row1 REAL Op2 INTEGER Row2 REAL Ans INTEGER Rowans Complex Ans Op1 Op2 Cdiv REAL Op1 INTEGER Rowi REAL Op2 INTEGER Row2 REAL Ans INTEGER Rowans Complex Ans Op1 Op2 SUB Rpg function INTEGER function Redirect RPG amp STEP keys function O normal imActvy MKR amp INPUT 2 Actv MKR amp LABELS Using Subprograms 9 3 Example Programs 1 Example use of built in subprograms 10 LOADSUB Read_fdata FROM XFER MEM 0 0 Appends Read_data sub pro gram to end of this program This subprogram can now be called 20 30 40 50 REAL Trace_array 1 201 Reads Channel 1 data into 60 Read fdata 1 Trace_array Trace array 70 LOADSUB ALL FROM MATE MEM O 0 Appends all math subprograms defined in MATH to the end
22. a Serial Poli of the specified device the program must currentiy be the active controller in order to execute this function Examples ASSIGN Device TO 700 Status bytez SPOLL Device Spol1 724 SPOLL 724 The Serial Poll is meaningless for an interface since it must poll individual devices on the interface Therefore primary addressing must be used with the SPOLL function Passing and Regaining Control Active control of the bus can be passed between controllers using the PASS CONTROL command The following statements first define the HP IB interface s select code and the new active controller s primary address and then pass control to that controller 100 Hp ib 7 110 New ac addr 20 120 PASS CONTROL 100 Hp ibtNew ac addr Once the new active controller has accepted active control the controller passing control assumes the role of a non active controller on the specified HP IB interface The concept of using pass control with IBASIC is discussed in the next section The IBASIC HP IB Model 8 10 Interfacing with External Devices The IBASIC HP IB Model The fact that IBASIC resides in and coexists with an instrument poses a large set of possible interactions both internal to the instrument and externally with other controllers and instruments This section defines the principal players and rules of order when IBASIC is running within the host instrument External and Internal Busses There is physically only one H
23. aa rs e 2 6 Active Control of the HP IB Interface 2 1 2 7 Mnemonics With No Corresponding Front Panel Operation 2 7 Avoiding Recording Errors le o a E Ge we a qn 2 8 Use Instrument Preset o cs ES 2 8 Specifically Select Parameters 2 1 1 4 2 8 Use HP IB Echo da E EE E EEEE oe 2 9 Running Pausing and Stopping Programs Starting Programs Automatically 0 2 Se Gh shh ce a 3 1 Running and Continuing a Program cms es a ee a s 3 1 Pausing a Program aaa aoaaa a EO O a EL A 3 2 Stopping a Program a aoa soa a EC a a A 3 3 Saving and Recalling Programs Selecting a Disk a e a do a a Gr gt me 4 2 Saving a Program a E a dE e ia Gr T 4 2 AUTOS Programs i e a wh a e den A Bw AN a x 4 Recalling a Program ss ss qem a Se ay E AC E EA A 4 3 Contents 1 5 Developing Programs 5 Peternak Editors o 4 unt a kee BS ea A AS eS 5 2 HP BASIC mento a aod Ade a OE a ia TA 5 2 ASCII Word Prociesar E A RE Bd HL RD a 5 2 Editing Your Program Using oe sae A A OS The IBASIC Editor Softkeys 3 og ka ks a ee A HE RS 5 4 Recording into an Existing Program a 2 ee 5 4 Editing with an External RS dS a E See a o At O SL 5 5 Inserting Lines Scar mo ge ob le AA RA BE RE A Re a A a a A 5 6 EAT LINES TA PG A a ge ee al ee i e 5 6 a Entering Program Lines de o m o SO ee eS 3 6 d Editing trom the Front Pan
24. and or programming manuals for each device describe the device s capability to request service and conditions under which the device will request service To request service the device sends a Service Request message SRQ to the active controller The mechanism by which the active controller detects these requests is the SRQ interrupt Interrupts allow an efficient use of system resources because the system may be executing a program until interrupted by an event s occurrence If enabled the external event initiates a program branch to a routine which services the event executes remedial action Setiing Up and Enabling SRQ Interrupts In order for an HP IB device to be able to initiate a service routine in the active controller two prerequisites must be met the SRQ interrupt event must have a service routine defined and the SRQ interrupt must be enabled to initiate the branch to the service routine The following program segment shows an example of setting up and enabling an SRQ interrupt 100 Hpib 7 110 ON INTR Hpib GOSUB Service_routine 120 130 Mask 2 140 ENABLE INTR Hpib Mask Since IBASIC recognizes only SRQ interrupts the value assigned to the mask is meaningless However a mask value may be present as a placeholder for compatibility with HP Series BASIC programs 8 8 Interfacing with External Devices When an SRQ interrupt is generated by any device on the bus the program branches to the service routine when t
25. can lead to erroneous data being collected For more information on synchronizing the execution of commands refer to Synchronizing the Analyzer and a Controller chapter in the Programmer s Guide What s in a Recorded Program If you look at any program created using keystroke recording you will find that it is composed of three fundamental IBASIC statements ASSIGN OUTPUT and END The following simple program demonstrates these statements 1 ASSIGN ORfna TO 800 2 OUTPUT Rfna SQUR1 POW 10 dBm 10 END The ASSIGN and END statements are automatically created when keystroke recording is used to create a new program as opposed to modifying an existing one There will only be one ASSIGN statement at the beginning of a program and one END statement at the end but in a typical program there will be many OUTPUT statements Since the OUTPUT statement does the actual work of controlling the analyzer let s take a closer look at how it is used Note The ASSIGN statement which is automatically created will vary depending on the model of analyzer you have HP 8711A B ASSIGN Hp8711 TO 800 HP 8712B ASSIGN Hp8712 TO 800 HP 8713B ASSIGN Hp8713 TO 800 HP 8714B ASSIGN 0Hp8714 TO 800 2 2 Recording Programs The OUTPUT Statement The IBASIC statement OUTPUT lt destination gt lt data gt tells the internal computer to send some information lt data gt to a device at a specific address lt destination gt The destinatio
26. correct size for a full screen partition will appear half as big if a GINIT is performed after the analyzer has been set to either the upper or lower half partition This is because the CSIZE command scales according to display height not width Since the display height is one half the character size will also be one half Labels that are scaled properly for full screen displays will not be scaled properly for half screen displays and vice versa 7 10 Graphics and Display Techniques SCPI Graphics Commands In addition to the commands described earlier in this chapter there are several SCPI mnemonics that can be used to create graphics and messages on the display of the analyzer These commands are instrument specific mnemonics not standard IBASIC commands They are also different from the previously described IBASIC commands in that they do not require an IBASIC display partition This means that they can be used to write or draw directly to a measurement window i These commands listed in Table 7 2 are SCPI mnemonics and are programmable from an external controller as well as from IBASIC The commands are of the form DISPlay WINDow 1 2 10 GRAPhics lt command gt The number specified in the WINDow part of the command selects where the graphics are to be written WINDow1 draws the graphics to the channel 1 measurement window WINDow2 draws the graphics to the channel 2 measurement window WINDow10 draws the graphics to an IBASIC di
27. display partition is present For information on creating an IBASIC display partition see Using IBASIC Display in Chapter 5 Developing Programs You may also activate the command line when no IBASIC window is partitioned by pressing the key on the external keyboard A cursor will appear in the lower left portion of the screen when the command line is active Strike the key again to de activate Once the command line is active a variable can be examined in two ways Both methods require the use of an external keyboard 1 Enter the variable name without a line number on the command line This results in the value assigned to that variable being shown in the display line of the IBASIC window 2 Execute the command PRINT Value from the command line where Value is the name of the variable being examined This results in the value assigned to that variable being shown on the print screen of the IBASIC window To examine a variable without accessing a command line it is necessary to add the statement PRINT Value or DISP Value to the program before the PAUSE statement that temporarily stops the program PAUSE PRINT and DISP are all keywords that are included in the IBASIC editor s label window see Chapter 5 Developing Programs for a description of the label window 6 2 Debugging Programs softkey Fs on an external keyboard that is available Note An IBASIC display partition must be active to view th
28. e e ek a SU we ee 9 4 Avoiding Multiple Loads of Subprograms 0 eee 9 4 o 10 IBASIC Keyword Summary 11 Example Programs Example Program Summaries 2 1 e 11 1 DATA_EXT Data transfer between internal and external programs 11 1 DATA_INT Data transfer between internal and external programs 11 1 DOWNLOAD Download program to analyzer 7 11 1 DRAW871X Drawing setup diagrams r a 11 2 m DUALCTRL Two controller operation 2 a a a ee ee ee 11 2 REPORT Using the parallel port 2 1 ee ee ro 11 2 TRICTRL External controller with local IBASIC controllers 11 2 E UPLOAD Upload program from 11 3 11 3 e 11 3 hen 11 3 USER_BIT Using the USER bit ee a a te 11 3 USERKEYS Customized softkeys a 11 3 BARCODE STATS DATALOG Bar Code Programs 11 4 d ADJ_110 Automated procedure for service adjustment 110 B amplitude o J pa uy do geao e e ae ae e Ge are A SG ae A 11 5 i Example Program Listings a a ess aoe ce Soe ele a EAN Se EU 11 6 y DATA EXT Data transfer between internal and external programs 11 6 a DATA_INT Data transfer between internal and external programs 11 9 Ls DOWNLOAD Download program to analyzer a eee 11 11 DRAWS871X Drawing setup diagrams r e 11 13 ba DUALCTRL Two control
29. fail limit test w User TTL bit to be used as needed for example to use with a foot pedal Interfacing with External Devices 8 3 Using the Analyzer Ports in IBASIC programs IBASIC can directly control the serial port the parallel port the Pass Fail TTL bit and the User bit without using HP IB commands with READIO and WRITEIO READIO and WRITEIO are faster than HP IB commands Writeable Ports WRITEIO WRITEIO WRITETO WRITELO WRITEIO 15 0 4 15 14 15 254 15 3 4 9 0 4 Outputs 8 bit data to the Cent_D0 through D7 lines of the Centronics port Cent DO is the least significant bit Cent D7 is the most significant bit Sets Printer_select signal high de select Checks Centronics status lines for e Out of Paper e Printer Not on Line e BUSY e ACKNOWLEDGE Sets clears the user bit according to the least significant bit of A A least significant bit equal to 1 sets the user bit high least significant bit of 0 clears the user bit Sets clears the limit pass fail bit according to the least significant bit of A A least significant bit equal to 1 sets the pass fail bit high A least significant bit of O clears the pass fail bit Outputs 8 bit data to the Cent DO through D7 lines of the Centronics port Cent DO is the least significant bit Cent_D7 is the most significant bit Sets Printer select signal high de select Does not check Centronics status lines Outputs a byte to the serial port
30. line change the line number first press and then delete the original line If you want to create an edited copy of the current line edit the line and then change the line number and press edits will only appear in the copied line If you are inserting a program line and you change the line number the line will move to its new location when you ENTER it The editor will remain in insert mode at the new location in the program You will notice that when the cursor is in the line number field entries operate in an overtype fashion rather than in the insert fashion as in the text portion of the program line Also the lt backspace key simply moves the cursor over line numbers without deleting the number Note To renumber the entire program IBASIC supports the RENumber command BUT you need an external keyboard to execute it The command can be executed by following the steps listed below 1 EXIT the edit mode by pressing menu is active until the SYSTEM OPTIONS 2 Partition an IBASIC display as described next in this chapter 3 Enter the command REN x y where x is the new beginning line number and y is the increment from the command line of the IBASIC display 4 Another way to renumber program lines with an external keyboard is to use the COPYLINES and MOVELINES commands Use the INDENT command to make your code more readable Developing Programs 5 9 Pressing the softkey E7 on a
31. must be the last line in the main program segment The program remains in the program buffer a the program buffer press SYSTEM OPTIONS the instrument ed To clear For more information on the PAUSE and STOP statements see the HP Instrument BASIC Language Reference section of the HP Instrument BASIC Users Handbook contained in this binder Running Pausing and Stopping Programs 3 3 Saving and Recalling Programs IBASIC programs can reside in memory on disk or in an external computer To transfer a p SAVE RECALL menu To access the SAVE RECALL keyboard use Ga for and for The GET SAVE LOAD STORE RE STORE and RE SAVE commands can be used within a program or from an IBASIC command line to transfer program files to and from mass storage An autoload feature also exists to allow for a program named AUTOST or AUTOST BAS to be automatically recalled from the internal non volatile RAM disk or the built in floppy disk and run at power up menu using an external Another mode of program transfer is between the analyzer and an external controller such as an HP Series 200 300 700 controller Using an external controller you can combine the convenience of keystroke recording in IBASIC with the ease of program editing in a dedicated external workstation by re
32. number by one record if any remainder exists Although this simple method works for many uploaded programs there may still be a problem with the file size caused by the OUTPUT statement in line 490 This is because every ASCII line in a LIF file contains a two byte length header and possibly one additional pad byte to make the length an even number of bytes These extra bytes are not included in the definite length block header information You can account for this extra overhead by allocating an extra 10 to 15 percent of space when you create the ASCII file For example the Gpenfile subroutine could be rewritten as 570 SUB Openfile File Filename Fsize 680 ON ERROR GOTO Openerr 715 Fsize Fsize Fsize 0 15 720 IF Fsize MOD 256 gt 0 THEN Fsize Fsizet256 730 CREATE ASCII Filename Fsize DIV 256 8 18 Interfacing with External Devices 9 Using Subprograms Analyzer products shipped with the IBASIC option can run subprograms The subprograms may be user created or built in User Created Subprograms You can use the LOADSUB keyword with subprograms of your own creation LOADSUB enables you to append subprograms to other programs and is supported as described in the RMB manual When using LOADSUB keep in mind the following a Subprograms must be stored to files using the STORE keyword when first created m Subprograms may be stored from the external keyboard or from the front panel if the File Type format is BIN u BIN typ
33. pause User keyl Define GOSUB Message Remove GOTO User pause t User_key2 Define GOSUB Message Remove GOTO User_pause i softkey 1 here this line softkey 2 here this line User key3 Example Marker Function OUTPUT Rina CALC1 MARKi ON OUTPUT Rfna CALC1 MARK FUNC MAX GOTO User_pause l User_key4 Example Title Entry 11 32 Example Programs 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 INPUT Enter Title Line 1 Press Enter when done Name OUTPUT Rfna DISP ANN TITLi DATA amp Name OUTPUT Rfna DISP ANN TITL ON GOTO User pause i User_key5 Define softkey 5 here GOSUB Message Remove this line GOTO User pause t User key6 Define softkey 6 here GOSUB Message Remove this line GOTO User_pause i User_key 7 Define softkey 7 here GOSUB Message Remove this line GOTO User_pause Message Stri This key is programmable Str2 To modify select Str3 System Options IBASIC Edit OUTPUT Rfna DISP ANN MESS 2Stri CHR 10 4Str2 CHR 10 8Str3 MEDIUM 710 720 730 RETURN i END Example Programs 11 33 USERBEG2 Fast recall of instrument states 10 20 30 40 50 m 60 70 80 90 BASIC program USRBEG2 will recall the named file 100 User begin ASSIGN Rfina TO 800 110 120 130 140 150 160 170 180 190 200 210 220
34. program buffer 2 1 program recording 2 1 programs downloading and uploading 8 17 Q querying variables 8 16 R READIO 8 4 recording keystroke 2 1 recording programs 2 1 reference material 1 1 remote 8 6 renumbering 5 9 REPORT example program 11 2 RE SAVE 4 1 RE STORE 4 1 RUN 3 1 running a program 3 1 S sample bar codes 11 54 SAVE RECALL 4 1 SCPI mnemonics 2 3 selecting a disk 4 2 serial poll 8 10 serial port 8 3 service requests 8 8 setting variables 8 16 SRQs 8 8 STATS example program 11 4 status information 8 14 STOP 3 3 stopping a program 3 3 STORE 4 1 strings 6 3 subprograms 9 1 synchronization 2 6 8 14 system controller 2 7 T template keyboard 3 2 text to display 7 4 timing 2 6 transferring data 8 15 TRICTRL example program 11 2 trigger 8 7 typographical conventions 1 3 U UPLOAD example program 11 3 uploading programs 8 17 USERBEG example program 11 3 USERBEG1 example program 11 3 USERBEG2 example program 11 3 USER BIT example program 11 3 USERKEYS example program 11 3 5 12 Vv variables 6 2 setting and querying 8 16 W window label 5 7 word processors 5 2 WRITEIO 8 4 index 3
35. result in unpredictable behavior or deadlocks For example If the external controller executes OUTPUT 716 lt command gt and IBASIC simultaneously executes OUTPUT 800 lt command gt the results are unpredictable To avoid overlapped commands you must ensure that only the controller is allowed to send commands or only IBASIC is allowed to send commands at any one time One possible method to avoid overlap is described below For this method when the respective controller is done sending commands the other controller is informed The alternate controller then may begin sending commands After each set of commands is completed the alternate controller is informed and given a signal to send commands to the analyzer See example program TRICTRL in Chapter 11 Using Status information Status information must also be synchronized between the IBASIC program and a program running on an external controller The status information is shared between these programs Commands which affect the status information should not overlap between the IBASIC program and the external controller For example From an external controller OUTPUT 716 lt command gt 0PC ENTER 716 0pc From IBASIC simultaneously execute OUTPUT 800 CLS may cause the external controller to not complete execution The CLS command clears status information which the external controller may be waiting for The commands which affect status inform
36. scale of Sc 940 man nnn nn nn nn e e m m 950 960 amp RVAL CYO INT Sc 1i5 970 OUTPUT Rfna DISP amp amp VAL CYO INT Sc 20 980 OUTPUT Rfna DISP amp amp VAL CYO INT Sc 20 990 OUTPUT Rfna DISP amp VAL CYO INT Sc 22 1000 OUTPUT Rfna DISP amp VAL INT Sc 4 1010 OUTPUT Rfna DISP amp amp VAL CYO INT Sc 20 1020 OUTPUT Rfna DISP amp VAL CYO INT Sc 20 1030 OUTPUT Rfna DISP amp amp VAL CYO INT Sc i5 1040 SUBEND ASSIGN Rfna TO 800 OUTPUT Rfna DISP WIND10 WIND10 WIND O WIND10 gt WIND10 WIND O WIND10 WIND1IO GRAP GRAP GRAP GRAP GRAP GRAP GRAP GRAP MOVE DRAW DRAW MOVE RECT MOVE DRAW DRAW g VAL XO INT Sc 245 e VAL XO INT Scx245 e VALS XO INT Scx 265 VAL XO INT Scx 265 amp VAL CINT Sc 40 amp e VAL XO INT Scx 305 amp VAL XO INT Sc 325 eg VALS XO INT Sc 325 Example Programs 11 15 DUALCTRL Two controller operation 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 e t ooo O A AO id a da ci do rd o O E A O MA LM A a a e ett A A G BASIC program DUALCTRL Two controller operation T
37. to insert statements in your recorded program Note that PAUSE is one of the IBASIC keywords included in the editor s label window also described in Chapter 5 3 2 Running Pausing and Stopping Programs To continue the program from a paused state press the softkey in the SYSTEM OPTIONS menu or on an external keyboard This menu automatically appears when a program is paused Continuing a paused program resumes program operation from where it was paused retaining the current program context variable values etc Pausing a program does not close any files that have been opened by the program You will not be able to perform any of the following disk operations after pausing a program that has left a file open on that medium e RENAME FILE w DELETE FILE w DELETE ALL FILES m COPY FILES m COPY DISK a FORMAT DISK To close all open files you must complete the execution of the program or perform an IBASIC RESET This can be done by pressing the hardkey The hardkey is represented by on an external keyboard Keystroke recorded programs do not open files and therefore avoid this problem Stopping a Program To stop a program completely press the hardkey at any time while the program is running This causes an IBASIC RESET Placing a STOP statement in your program will also terminate the program but does not perform an IBASIC RESET operation The END statement can also be used to stop program execution but it
38. while a program is running is if the program is currently the active controller on select code 7 and passes control to the instrument Normally the active controller on the 7 bus can pass control to any device on the interface by using the statement PASS CONTROL 7xx where xx represents the address of the device on the bus Because an IBASIC program does not interface with the host instrument over select code 7 a different method is used to pass control in this case To pass active control of the external interface from an IBASIC program to the host instrument use the statement PASS CONTROL 8xx where xx represents any two digit number from 00 to 99 This allows the instrument to control external plotters printers and disk drives When the instrument is finished with its HP IB control activity it automatically passes control back to the program Note Control over the internal bus is used to govern access to the external bus When the instrument is given control over the internal bus it is actually given access to the external HP IB hardware A et 8 12 interfacing with External Devices IBASIC as a Non Active Controller IBASIC programs are always the active controller on the internal interface There are two cases where an IBASIC program does not have control of the external HP IB interface m When the host instrument is set as Talker Listener and active control has NOT been passed _ from an external device m When the ho
39. 0 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 RD O TT END LOOP Close the new file ASSIGN File TO END onto o o O O O O IND O O ON O ath SS Yt A A A O HEE O SO CE IE COE GO SOE SE PE VE IR SH ao A SAE te AHIR SARL A O HV YI ILD A A O A O A O A O OE END EEE GR a O q SR SE CO ee This subprogram creates an ASCII file with the name Filename of the specified size Fsize Error trapping is used to detect any errors in opening the file If the controller is HP IBASIC for Windows a DOS file is created otherwise the LIF format is used O ESI IO Ge Cm m o E O SEP O EN OO O ee em me en ee me ets ci o o is lalo tnt tr tk te A ido int ON ERROR GOTO Openerr IF SYSTEM SYSTEM ID IBASIC WINDOWS THEN CREATE Filename 1 ELSE IF Fsize MOD 256 gt 0 THEN Fsize Fsize 256 CREATE ASCII Filename Fsize DIV 256 END IF Openerr IF ERRN54 THEN PRINT ERRM SUBEND 11 28 Example Programs USERBEG Set up user defined 10 Filename USERBEGIN 20 70 80 Description Program to set up the User Begin softkeys 90 l 100 A This program creates User Begin softkeys which allow 110 the user to Save or Recall one of two instrument t t t f 120 t states set the marker to maximum set the scale div I i 1 i 130 and compute some measurement statistics at the marker 140 150 B In order to run this program do the following 160 1 Load t
40. 00 140 50 9 1560 DATA LMAX 210 240 7 30 1570 F2 DATA 200 100 1 200 MHz BPF 1580 DATA LMIN 196 204 3 3 1590 DATA LMAX 180 190 40 10 1600 DATA LMAX 210 220 10 40 1610 F3 DATA 134 40 22 134 MHz SAW BPF 1620 DATA LMIN 128 140 27 27 1630 DATA LMAX 123 125 65 30 1640 DATA LMAX 143 145 30 65 1650 SUBEND 1660 1670 Box SUB Box Xpos Ypos Xsize Ysize 1680 COM Scale Sc INTEGER X Y 1690 MOVE X Xpos Xsize 2 Sc Y Ypos Ysize 2 Sc 1700 RECTANGLE Xsize Sc Ysize Scx 1 79 1 79 8711 Pixel H W Ra tio 1710 SUBEND 1720 1730 Circle SUB Circle Xpos Ypos Radius 1740 COM Scale Sc INTEGER X Y 1750 MOVE X Xpos Sc Y Ypos Sc 1760 POLYGON Radius Sc 16 16 1770 SUBEND 1780 1790 Connect SUB Connect X1 Y1 X2 Y2 How 1800 COM Scale Sc INTEGER X Y 1810 MOVE X X1x Sc Y Y1x Sc 1820 SELECT How 1830 CASE 1 diagonal 1840 DRAW X X2 Sc Y Y2 Sc 1850 CASE O 1860 DRAW X XixSc Y Y2x5c 1870 DRAW X X2 Sc Y Y2 Sc 1880 CASE 1 1890 DRAW X X2x Sc Y YixSc 1900 DRAW X X2 Sc Y Y2x Sc 1910 END SELECT 1920 SUBEND 1930 11 44 Example Programs 1940 Label SUB Label Text Xpos Ypos Size Lorg Ldr Pen 1950 1960 1970 1980 1990 2000 2010 2020 2030 2040 2050 2060 2070 2080 2090 COM Scale Sc INTEGER X Y LORG Lorg LDIR Ldr CSIZE Size Sc i MOVE X Xpos Sc Y Ypos Sc PEN Pen LABEL Text PEN 1 SUBEND 1 Amp SUB Amp Xpos Ypos Size Draws gt Triangle COM Scale
41. 000 70 OUTPUT Temp This is the first line of text 80 Big Big amp Temp 90 OUTPUT Temp This is the second line of text 100 Big Big amp Temp 110 PRINTER IS CRT WIDTH 2000 120 PRINT Big The OUTPUT statements in this example are used to copy each line of the message into the variable Temp and append a carriage return You can also print to the screen using the OUTPUT statement in conjunction with the display address 1 For example line 150 below writes a string to the screen 150 OUTPUT CRT OUTPUT 1 WORKS WELL TOO Pop up Message Windows and Custom Annotations From your IBASIC program you can replace instrument annotations with user defined annotations You can change the X axis labels and channel annotations to customize the display Pop up messages may also be used to display permanent or temporary messages Refer to Automating Measurements in the User s Guide Graphics Initialization and Scaling In all partitions display coordinate 0 0 is at the bottom left corner and clipping occurs automatically if the X Y coordinate exceeds the displayable range of the current partition Figure 7 4 shows the different partitions and the pixel dimensions GESCAPE values for each After a GINIT command the display is dimensioned as 100 GDU s Graphical Display Units high and 245 GDU s wide assuming full partition This gives a RATIO result of 2 45 and provides the same results as issuing a WINDOW 0 245 0 100 comm
42. 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 ess 430 440 450 BASIC program DATA EXT Data transfer external 1 t This program demonstrates how to transfer data from an IBASIC program running on the HP 8711 to an HP BASIC program or an IBASIC program running externally This program was designed to run on a computer or PC It loads a program into the HP 8711 f runs it and then gives it control of the bus This program then acts as a device on the bus sending and receiving data I J i i Before running this program a disc with the program DATA_LINT should be in the HP 8711 s internal drive gt Ds o a o OR o a OE SEE SS ye et o se ne ae i Initialize variables for the interface select code and the HP IB address of the HP 8711 1 Scode 7 Address 16 Na Scode 100 Address t Abort any bus traffic clear the input output queues i of the analyzer clear the analyzer s status registers and the display i ABORT Scode CLEAR Na OUTPUT Na x CLS CLEAR SCREEN I Dimension an array to hold the catalog listing t E DIM Directory 1 100 85 Prompt the operator to insert the disk in the HP 8711 load the program and wait until done i INPUT Put disc with program DATA_INT into the HP 8711
43. 30 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990 1000 OUTPUT Na CLS OUTPUT Na SRE 0 OUTPUT Na xESE 0 OUTPUT Na STAT PRES t Set up the status registers to generate an interrupt on negative transition of the Program Running bit bit 14 in the Operational Status register i OUTPUT Na STAT OPER NTR HFFFF OUTPUT Na STAT OPER ENAB 16384 OUTPUT Na CLS OUTPUT Na SRE 128 Run the program read and display the variables DISP Running the program OUTPUT Na PROG EXEC RUN Display res Na Scode OUTPUT Na PROG EXEC RUN Display res Na Scode Return the analyzer to front panel control this is the end of the program i LOCAL Na DISP DONE END i This subprogram waits for an SRQ interrupt to signal that an IBASIC program running on the analyzer has finished It then reads and clears the HP IB status registers The values of two program variables are then read and displayed i 1 Setup branching to an interrupt handling routine enable the interrupts and wait until one occurs i ON INTR Scode GOTO Read results ENABLE INTR Scode 2 Idle GOTO Idle Read_results a The program has finished running read and clear Example Programs 11 17 1010 th
44. 60 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 BASIC program UPLOAD Upload program from HP 871X in the HP 871X s program buffer to an ASCII file j i t This program uploads the current IBASIC program t on the controller s current mass storage device t Assign an 1 0 path name to the HP 8711 initialize the variables and clear the analyzer s input output queues ASSIGN Rfina TO 716 DIM Prog line 256 CLEAR GRfna i Enter the name of the file to be created i INPUT ENTER NAME OF FILE TO UPLOAD PROGRAM TO Filename PRINT Filename H Query the HP 8711 for the contents of its program buffer E OUTPUT Rina PROG DEF t Read the block header the number of digits in the file size and the file size E ENTER Rfna USING A D Prog_line Ndigits ENTER Rfna USING amp VAL Ndigits amp D Nbytes Create the target ASCII file on the current mass storage device and assign it an 1 0 path name Openfile File Filename Nbytes ASSIGN File TO Filename FORMAT ON i Read the program one line at a time and write it to the new file Print each line on the display as it is read i LOOP ENTER Rfna Prog_line EXIT IF LEN Prog_line 0 PRINT Prog _line OUTPUT File Prog_line Example Programs 11 27 500 510 520 530 540 550 56
45. 8 105 12 Drive 1050 Box 375 88 75 4 1060 Circle 365 60 15 Knob 1070 Circle 300 15 10 E Out i 1080 Circle 410 15 10 t in 1090 Box 15 20 7 10 Switch 1100 Circle 15 33 4 1110 Label RF OUT 300 28 8 5 0 1 1120 Label RF IN 410 28 8 5 0 1 1130 SUBEND 1140 1150 Draw_dut SUB Draw dut INTEGER Pen 1160 This connects DUT to HP 8711 1170 PEN Pen 1180 Connect 300 15 320 20 0 1190 Box 355 20 70 15 1200 Connect 410 15 390 20 0 1210 PEN 1 1220 SUBEND 1230 1240 Scan dut SUB Scan dut Scan Cent Span Loss Lim 1250 LOOP 1260 Invalid 0 1270 Scan BPF175 12345 Default model serial 1280 BEEP 500 05 1290 INPUT Connect and scan the Device Scan SCAN BARCOD E HERE 1300 IF LEN Scan lt i2 THEN IValid device needs 12 char 1310 Invalid 1 1320 ELSE 1330 Model Scan 1 6 1340 SELECT UPC TRIM Model 1350 CASE BPF1i75 BPF177 1360 RESTORE Fi 1370 CASE BPF200 1380 RESTORE F2 1390 CASE SAW134 1400 RESTORE F3 1410 CASE ELSE 1420 Invalid 1 1430 END SELECT 1440 END 1F Example Programs 11 43 1450 EXIT IF NOT Invalid 1460 DISP Scan lt lt is INVALID Try again 1470 BEEP i500 2 1480 WAIT 4 1490 END LOCP 1500 BEEP 3000 03 1510 READ Cent Span Loss Lim 1520 Limit lines format Center Span Loss LIM TYPE STRT STP STRTAB STPdB 1530 F1 DATA 175 250 2 t 175 MHz BPF 1540 DATA LMIN 160 190 5 5 1550 DATA LMAX 1
46. 80 Dev_count2 Dev_count2 1 1290 PRINT Inst Na2 Dev Dev_count2 1300 OUTPUT Na2 PROG NUMB Ctlr flag 0 Clear the IBASIC flag 1310 LOCAL Na2 1320 END IF 1330 END IF 1340 1350 ENABLE INTR 7 1360 RETURN 1370 1380 Dnid Download example program to analyzer 1390 OUTPUT Prog PROG DEF 0 1400 OUTPUT Prog i0 COM INTEGER Ctir flag 1410 OUTPUT Prog 20 OUTPUT 800 ABOR INIT1 CONT OFF 1420 OUTPUT Prog 30 ON KEY 1 LABEL Test 1 GOSUB Do test 1430 OUTPUT Prog 40 ON KEY 3 LABEL Done Test GOSUB Send srq 1440 OUTPUT Prog 50 Idle GOTO Idle 1450 OUTPUT Prog 60 STOP 1460 OUTPUT Prog 70 Send srg 1470 OUTPUT Prog 80 BEEP 1480 OUTPUT Prog 90 Ctlr_flag 1 Example Programs 11 25 1490 1500 1510 1520 1530 1540 1550 1560 1570 1580 1590 1600 1610 1620 1630 OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT RETURN END Prog 100 Prog 110 Prog 120 Prog 130 Prog 140 Prog 150 Prog 160 Prog 170 Prog 180 OUTPUT 800 SYST KEY USER DISP Waiting for CTLR Stall IF Ctlr_flag 1 THEN GOTO Stall DISP Hi 3113 RETURN DO TEST OUTPUT 800 INIT1 0PC ENTER 800 0pc RETURN END Prog CHR 10 END Prog opc ENTER OProg U0pc 11 26 Example Programs UPLOAD Upload program from analyzer 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 1
47. 930 940 DISP Reading data 950 ENTER Scode Directory Program Example Programs 11 7 960 970 980 990 1000 1010 1020 1030 1040 1050 1060 1070 1080 1090 1100 1110 1 Print the catalog to the controller s display l FOR I 1 TO 100 IF LEN Directory 1 gt 0 THEN PRINT Directory I NEXT 1 t Try to return the HP 8711 to LOCAL control If the analyzer is still the active controller an error will be generated and the program will loop until control of the bus is received i ON ERROR GOTO 1090 LOCAL Na DISP Ho END 11 8 Example Programs DATA INT Data transfer between internal and external programs 10 E ee e q q a q mm 20 30 IBASIC program DATA INT Data transfer internal 40 50 This program demonstrates how to transfer data to 60 and from an external controller In this example a t E l 3 i 70 catalog listing is transferred from the HP 8711 to i i l t l E 80 the external controller For more information look 90 at the program listing for DATA_EXT 100 110 This IBASIC program is intended to run on the 120 HP 8711 s internal controller 130 2 140 mm 150 160 Dimension an array to hold the catalog listing 170 1 180 DIM Directory 1 100 85 190 200 Pause the program and wait for the controller to 210 set the Host variable with its HP IB address 220 The controller continues this program aft
48. D Inserts the character or word highlighted by the label window cursor at the position marked by the program cursor E Inserts a space at the position marked by the program cursor E Deletes the character highlighted by the program cursor F4 Deletes the last character before the program cursor F5 Enters the edited program line Ea Returns to the edit menu and de activates the label window The Label Window The label window is a scrolling list of the most common characters symbols and keywords used in IBASIC programming It contains the uppercase alphabet the numbers 0 to 9 symbols such as single and double quotation marks parentheses signs for mathematical and string operations as well as numerous other characters and symbols It also contains the following IBASIC keywords ABORT ENTER NOT ASSIGN FOR OUTPUT BIT GOTO PAUSE CALL IF PRINT CLEAR INPUT SUB DATA INTEGER SUBEND DIM LIST THEN DISP LOCAL TO END WEXT WAIT Developing Programs 5 7 Inserting Lines To insert one o am lines above any existing line place the cursor on the existing line and press This causes the cursor to move to a new line that appears above the existing one Enter and store the inserted line and another inserted line will appear Remember each line must be ENTERed or any changes will be lost when the cursor is moved to a different line Removing Program Text You can remove individual characters or entire line
49. EK External Keyboard P Programmable MAX EK P MAXLEN FP EK P MAXREAL EK P MIN EK P MINREAL EK P MOD EK P MODULO EK P MOVE EK P MOVELINES EK MSI FP EK P MSI may be altered by the instr NOT FP EK P NUM FP EK P ONJOFF CYCLE ON OFF ERROR ONOFF INTR Interface Select Code 7 or 8 ON OFF KEY Key selectors 1 through 7 ON OFF TIMEOUT Interface Select Code 7 or 8 OPTION BASE OR FP EK P OUTPUT EK P Select Code 1 7 8 PASS CONTROL EK P Select Code 7 or 8 PAUSE EK FP P PDIR EK P PEN EK P O erase 1 draw PENUP EK P PI EK P PIVOT EK P PLOT EK P POLYGON EK P FILL not supported Scaling diffs POLYLINE EK P POS FP EK P PRINT EK P PRINTER IS EK P PROUND EK P IBASIC Keyword Summary 10 5 Table 10 1 Alphabetical List of IBASIC Keywords continued HP IBASIC Keyword Support Exceptions FP Front Panel EK External Keyboard PRT EK P PURGE FP EK P RAD FP EK P RANDOMIZE EK P RATIO EK P RE SAVE FP EK P RE STORE FP EK P READ EK P READIO EK P Select Code 9 or 15 See manual REAL P RECTANGLE EK P FILL not supported Scaling diffs REDIM EK P REM P REMOTE EK P Select Code 7 REN EK RENAME FP EK P REPEAT UNTIL P RESTORE P RETURN P REV FP EK P RND EK P ROTATE FP EK P RPLOT EK P Fill not supported Scaling diffs RPTS FP EK P RUN EK FP P SAVE FP EK P SCRATCH FP EK Front Panel executes SCRATCH A SECURE FP EK SELECT P SET TIME foo FP EK P SET TIMEDATE foo EK P SGN EK P SHIFT FP EK P SHOW EK P 10 6 IBASIC K
50. EY4 Recall State 2 WAI 470 OUTPUT Hp87ix DISP MENU2 KEYS Mkr gt Max WAI 480 OUTPUT 0Hp871x DISP MENU2 KEY6 Scale Div WAI 490 OUTPUT 0Hp871x DISP MENU2 KEY7 MarkerStatistics WAI 500 y 510 User pause PAUSE iIpause the program until a softkey is press ed 520 GOTO User_pause return to program pause after a softkey p ress 530 y 540 AR a ap hme eG ee E 550 Define softkey routines 560 570 User keyi Define softkey 1 save state 680 OUTPUT CHp871x MMEM STOR STAT 1 MEM UBEGN1 STA save sta te 1 590 GOTO User pause return to softkey loop 600 1 610 User key2 Define softkey 2 recall state 1 620 OUTPUT Hp871ix MMEM LOAD STAT 1 MEM UBEGN1 STA recall s tate 630 GOTO User_pause return to softkey loop 640 650 User_key3 Define softkey 3 save state 2 660 OUTPUT Hp amp 871ix MMEM STOR STAT 1 MEM UBEGN2 STA save sta te 2 670 GOTO User pause return to softkey loop 680 1 690 User_key4 Define softkey 4 recall state 2 700 OUTPUT Hp871x MMEM LOAD STAT 1 MEM UBEGN2 STA recall state 2 710 GOTO User_pause return to softkey loop 7120 730 User_key5 Define softkey 5 set marker to max 740 OUTPUT Hp87ix CALC1 MARK FUNC MAX imarker gt max 750 GOTO User pause 760 770 User key6 Define softkey 6 adjust the scale dB Div of the trace 780 INPUT Enter the scale dB Div Vert_scale ask user
51. Handbook Supplement _ Using HP Instrument BASIC with the HP 8711B 12B 13B 14B RF Network Analyzers PD picaro HP Part No 08712 90006 Printed in USA February 1995 Microwave Instruments Division or yen y O Copyright Hewlett Packard Company 1995 E A gt All Rights Reserved Reproduction adaptation or translation without prior written Naa permission is prohibited except as allowed under the copyright laws 1400 Fountaingrove Parkway Santa Rosa CA 95403 1799 USA Contents 1 Introduction Overview of HP Instrument BASIC 2 Ue Sky ae amp h 1 2 Using HP Instrument BASIC posses ene Se mara a a DARA 1 2 Typographical Conventions ee 0 re a 1 3 Recording Programs Keystroke Recording e 3 eS ee we ee es pea A 2 1 What is Keystroke Recording 2 2 baie a 2 1 IBASIC Programs and the HP IB Buffer 2 2 What s ina Recorded Program 1 2 ee eee 2 2 The OUTPUT Statement supe 2 ak A wha Bee ee a 2 3 The ASSIGN Statement 2 sie wane dps a eae we GS 2 3 SCPI Mnemonics sms ER ve o e ATA A a 2 3 How Recording Works sais oe dp ee ees ee Ae Ge e Gana a 2 4 Operations That Do Not Record A Sb dios Se vals SR 2 5 Front Panel Operations Without Mnemonics 0 2 5 HP Instrument BASIC Operations 88 a 2 6 Operations Requiring Additional Programming 2 2 2 aod 2 6 Synchronization a geme Em a E RS le
52. NIT2 WAI 1280 RETURN 1290 1300 Load_3 DISP Setup 3 1310 OUTPUT Rfna MMEM LOAD STAT 1 MEM STATES STA WAI 1320 OUTPUT ORfna INIT2 WAI 1330 RETURN 1340 1350 Load 4 DISP Setup 4 1360 OUTPUT Rfna MMEM LOAD STAT 1 MEM STATE4 STA WAI 1370 OUTPUT CRfna INIT1 WATI 1380 RETURN 1390 1400 Load_5 DISP Setup 5 1410 OUTPUT Rfna MMEM LOAD STAT 1 MEM STATES STA WAI 1420 OUTPUT QRfna INIT1 WAI 1430 RETURN 1440 1450 Load_6 DISP Setup 6 1460 OUTPUT Rfna MMEM LOAD STAT 1 MEM STATEG STA WAI 1470 OUTPUT Rfna INIT1 WAr 1480 RETURN 1490 END 11 40 Example Programs BARCODE Using Bar Code Reader 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 4 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 IBASIC program BARCODE Using barcode reader E f This HP 8711 IBASIC program was written for a barcode reader but it is not required Sets the 8711 s state depending on model of DUT being measured Expects to see BARCODE with the following format Model Number 6 char space Serial Number 5 char Valid Models BPF175 BPF200 SAWi34 REV 4 02 00 930615 JVV i COM Hpib Rfna COM Scale Sc INTEGER X Y DIM Name 50 Stat 50 Scan 90 Lim 1 3 1 5 30 Test 0 1 INTEGER Tab Fail
53. NUMBer and PROGram SELected STRing mnemonics and their query counterparts are part of the analyzer HP IB commands The internal program must not be running when these commands are executed The command PROG NUMB lt string gt lt value gt sets the value of a numeric variable in the program The command PROG STR lt string gt lt value gt sets the value of a string variable in the program In both the PROG NUMB and PROG STR commands and queries lt string gt is the variable name and must be string data in quotes In the PROG STR command lt value gt is also string data in quotes Numeric and string parameters can also be queried The query PROG NUMBer lt string gt returns the value of the specified numeric variable Arrays of REAL or INTEGER type may be sent or queried but arrays of strings are not allowed Array elements are separated by commas Examples OUTPUT 716 PROG NUMBER Test 99 OUTPUT Ibasic PROG STRING A String Data OUTPUT 716 PROG NUMB Iarray x The following program segment sends both numeric and string variable queries and enters the resulting data 10 ASSIGN Prog TO 716 20 OUTPUT Prog FORM ASCII 3 30 OUTPUT Prog PROG NUMB Test 40 ENTER Prog Testval 50 PRINT The value of the variable Test Testval 60 OUTPUT Prog PROG STR A 70 ENTER Prog Str 80 PRINT A Str 90 END 8 16 Interfacing with External
54. O path name for the internal bus and declare and initialize variables 1 COM Cset Block 50 Titie 507 Slant 50 Banner 50 Medium ASSIGN Rfna TO 800 Esc CHR 27 i Preset the analyzer put it in Trigger HOLD mode allocate the full IBASIC display and clear the screen i OUTPUT Rina SYST PRES WAI OUTPUT Rfna ABOR INIT CONT OFF WAI OUTPUT Rina DISP PROG FULL CLEAR SCREEN i Define the escape sequence for each font that is used Refer to your printer manual i Block Esc amp amp 100 amp Esc amp 8U amp Esc amp s1p10h12v080b0T Title Esc amp 4100 kEsc amp SU gEsc amp sip8hi2v0s0boT Slant Esc amp amp 100 amp EscS amp 7 J amp Esc amp sOp6hi4visOboT Banner Esc amp amp 100 amp Esc amp 7J amp Esc amp s0p4h24v0s0b0T Medium Esc amp amp 100 amp Esc amp 7 J amp Esc k sOp8hi4v0s0b0T Select the font to use writing the company name and address send the company name and address 1 CALL Send_line Title 1 CALL Send line COMPANY NAME 1 CALL Send_line CITY STATE COUNTRY 1 Example Programs 11 19 490 CALL Send_line 1 500 E 510 Select the font to use writing the device name 520 t send the device name 530 E 540 CALL Send line Bannerg 1 550 CALL Send_line _ 0 560 CALL Send_line _ 1 570 CALL Send_line 1 580 CALL Send_line 1 590 CALL Send_line BPF 175 Bandpass Filter 1 600 CALL Se
55. ORT Using the parallel port This program uses the analyzer to generate a report making a hardcopy on a printer connected to the parallel port It uses a subprogram to send the output to the parallel port one line at a time Before using this program be sure that your printer is configured to ignore the Printer_select Centronics signal since the WRITE10 command does not assert this signal TRICTRL External controller with local IBASIC controllers This example program demonstrates how an external controller can be used with two instruments running IBASIC Run this program on an external controller Connect two instruments via HP IB cables to the external controller Set one instrument to address 16 set the other instrument to address 18 This program insures that only the analyzer or the local IBASIC is sending SCPI commands at one time This is one possible implementation of synchronizing the analyzer and a controller Refer to Automating Measurements in the User s Guide The external controller is responsible for downloading the IBASIC program to each analyzer The external controller sets the status reporting to send a SRQ whenever a user requested service request occurs When all instrument configuration has completed the externa controller sends a run program command to each analyzer and then goes into an idle loop The external controller remains in the idle loop until either instrument sends an SRQ While the e
56. OS volume NVOL RAM 82 01 24 10 28 32 00 Paget 1 MEM Bytes Free 48391 E FILE NAME Lt IN Se e Li Save XPARENT gt lt DIR gt Program PROGO BAS DOS 7873 2t OCT O4 40 37 pce STATEO STA DOS 13058 17 JAN 92 13 52 Program TRANS STA pds 3328 19 JAN 92 08 14 Ss REFLS STA bos 3328 19 uAN 9Z 08 20 pas Type Recail Program Seve AUTOST IBASIC Prior Menu AENA qua el cp ib Figure 4 1 The Screen 4 2 Saving and Recalling Programs If you are re saving a program that is saving a file to a disk that already contains the file name press nd use the arrow keys to highlight the name of the file to be re saved Then press and the file is saved The disk is automatically catalogued when the menu is selected softkey can also be used to save a new program with a non default file name Pres Enter the new program s name using the external keyboard or the internal label maker If no file with that name exists on the disk a new file is created AUTOST Programs IBASIC allows you to designate a program to be automatically loaded and run when the instrument is first powered up To make an autoloading program save it with the file name AUTOST on the internal floppy disk drive or internal non volatile RAM disk This can be done from the SAVE RECALL menu by pressing oftkey and entering the file name AUTOST When the analyzer is powered up it automatically searches first
57. P IB port and one HP IB address for the analyzer IBASIC has access to two HP IB ports the real external port select code 7 and a virtual internal port select code 8 through which it communicates with the analyzer The analyzer has only one output buffer one input buffer and one set of status registers Commands and data from both ports are placed in the same input buffer and data read out of both ports comes from the same output buffer The instrument will not provide any kind of arbitration between an external controller and an IBASIC program The analyzer always behaves as if there is only one controller If an IBASIC program is running it is assumed to be the controller and therefore will receive all SRQs from the host instrument via the internal port Service Request Indicators An external controller may perform a serial poll SPOLL at any time without affecting a running IBASIC program There are two Service Request Indicators SRI one for the external port and one for the internal port The internal SRI can only be cleared by an IBASIC program performing an SPOLL on device 800 The external SRI can only be cleared by an SPOLL from an external controller and can only be set when there is not an active IBASIC program The two SRI s will be set to their OR d value when a program starts and again when it finishes This assures that any pending SRQ s can be serviced by the instrument s new controller The pa
58. RETURN Save 2 OUTPUT Rfna SENS2 STAT ON WAI OUTPUT Rfna SENS2 FUNC XFR POW RAT 1 0 DET NBAN WAI OUTPUT Rfna DISP ANN FREQ2 MODE CSPAN OUTPUT Rina SENS2 FREQ CENT 200 MHz SPAN 300 MHz WAI OUTPUT ORfna INIT2 WAI OUTPUT Rfna MMEM STOR STAT 1 MEM STATE2 STA RETURN Save_3 OUTPUT Rfna CALC2 FORM SWR OUTPUT ORfna INIT2 WAI OUTPUT ORfna MMEM STOR STAT 1 MEM STATE3 STA OUTPUT ORfna CALC2 FORM MLOG RETURN Example Programs 11 39 1000 Save_4 QUTPUT Rfna SENS2 STAT OFF 1010 OUTPUT Rfna SENS1 SWE POIN 1601 WAI 1020 OUTPUT Rfna INIT1 wWAL 1030 OUTPUT Rfna MMEM STOR STAT 1 MEM STATE4 STA 1040 RETURN 1050 1060 Save 5 OUTPUT Rfna CALC1 MARK BWID 3 FUNC TRAC ON 1070 OUTPUT Rfna INIT1 WAI 1080 OUTPUT Rfna MMEM STOR STAT 1 MEM STATES STA 1090 RETURN 1100 1110 Save 6 0UTPUT Rfna SENSi BWID 250 Hz WAI 1120 OUTPUT Rfina SENS1 SWE POIN 101 WAI 1130 OUTPUT CRfna INIT1 WAI 1140 OUTPUT CRfna MMEM STOR STAT 1 MEM STATE6 STA 1150 RETURN 1160 1170 These six subroutines each recall one of the 1180 measurement setups that were stored earlier 1190 1200 Load 1 DISP Setup 1 1210 OUTPUT CRfna MMEM LOAD STAT 1 MEM STATE1 STA wAI 1220 OUTPUT Rfna INIT1 WAI 1230 RETURN 1240 1250 Load 2 DISP Setup 2 1260 OUTPUT Rfna MMEM LOAD STAT 1 MEM STATE2 STA WAI 1270 OUTPUT Rina I
59. SIC Language Reference Table 10 2 contains the same information as Table 10 1 but is organized by category Table 10 1 Alphabetical List of IBASIC Keywords HP IBASIC Keyword Support Exceptions FP Front Panel EK External Keyboard P Programmable FP EK P EK P EK P EK P K P P EK P Select Code 7 8 9 15 EK P FP EK P ALLOCATE AND ASN ASSIGN ATN AXES BEEP BINAND BINCMP BINEOR BINIOR BIT EK P FP EK P FP EK P EK P FP EK P EK P EK P FP EK P FP EK P FP EK P FP EK P FP EK P IBASIC Keyword Summary 10 1 Table 10 1 Alphabetical List of IBASIC Keywords continued HP IBASIC Keyword CALL CASE CASE ELSE CAT CHRS CLEAR CLEAR SCREEN CLS COM CONT COPY COPYLINES COs CREATE CREATE ASCH CREATE BDAT CREATE DIR CRT CSIZE DATA DATE DATES DEALLOCATE DEF FN DEG DEL DELSUB DET DIM DISABLE DISABLE INTR DISP DIV DOT DRAW 10 2 IBASIC Keyword Summary Support FP Front Panel EK External Keyboard Programmable EK P P P FP EK P FP EK P EK P EK P EK P P EK FP FP EK P EK FP EK P EK P EK P EK P EK P P EK P EK P EK P P FPEK P FP EK EK P EK P Exceptions Supports 58 columns See manual Select Code 7 8 9 15 Line number support from EK only Abs vals less than 1 7083127722e 10 ENTER CRI ENTER 1 not supported Front Panel deletes only 1 line Interface Select Code 7 or 8 Table 10 1 Alphabetical List of IBASIC Keyw
60. SSIGN CHpib device TO 702 330 OUTPUT Hpib_device Data message 340 ENTER CHpib device Number 440 OUTPUT 800 SOUR1 POW 10 dBm 480 ENTER 724 Readings 8 2 Interfacing with External Devices General Structure of the HP IB Communications through the HP IB are made according to a precisely defined standard the IEEE 488 1 standard The rules set by IEEE 488 1 ensure that orderly communication takes place on the bus For more information about the structure of the HP IB and the IEEE 488 1 standard refer to the Tutorial Description of the Hewlett Packard Interface Bus Devices that communicate over the HP IB perform one or more of the following three functions m Talk send data over the bus E Listen receive data over the bus m Control control the exchange of data on the bus The System Controller The controller is a device that has been designated to control the communication occurring on the bus It specifies which device talks which device listens and when the exchange of data takes place An HP IB system can have more than one device with the ability to control the bus but only one of these devices is allowed to control the exchange of data at any given time The device that is currently controlling the exchange of data is called the Active Controller One device must be able to take control of the bus even if it is not the active controller The device designated as the System Controller is the only devi ith th
61. ST ERR ENTER Rfna Err EXIT IF NOT VAL Err GOSUB Trap err END LOOP OUTPUT Rina MMEM MSIS MEM DEL x gt SUBEXIT Trap_err IF VAL Err 250 THEN SUBEXIT no file to xfer BEEP 2000 5 CLEAR SCREEN PRINT TABXY 1 4 DISK ERROR DETECTED PRINT xx YErr amp xxx INPUT Fix above problem then press ENTER Ans CLEAR SCREEN SUBEND Example Programs 11 53 aum ST uM DRE ml HEN TO MEMO wn CT A OS mo OT Ul TT A a MN au OR UU ul mi I w D ll TO MN nt UU LENE CORRIGAN Index E E TC A ABORT 8 8 active controller 2 7 ADJ 110 example program 11 5 annotations custom 7 5 arrays 6 3 ASCII file 4 2 ASCII word processors 5 2 ASSIGN 2 3 AUTOSTART 4 3 AUTOSTART programs 3 1 B BARCODE example program 11 4 bar codes sample 11 54 binary file 4 2 breakpoints setting 6 2 buffer HP IB 2 2 program 2 1 bus external 8 11 internal 8 11 bus management general 8 5 C character entry 5 7 CLEAR 8 7 codes bar 11 54 continue command 3 1 control passing 8 10 controller active 2 7 synchronization 8 14 system 2 7 controller external interfacing with 8 13 conventions typographical 1 3 D DATA EXT example program 11 1 DATA INT example program 11 1 DATALOG example program 11 4 data transfer 8 15 debugging 6 1 deleted text to recall 5 9 deleting text 5 8 disk to select 4 2 displaying text 7 4 display partitions 5 10 7
62. TH WRITEIO Select Code 9 or 15 See manual Display and Keyboard Control CLEAR SCREEN CLS Array Operations DET DOT MAT MAT foo IDN MAT foo INV bar MAT foo CSUM bar MAT foo RSUM bar MAT REORDER MAT REORDER BY REDIM SUM TRN 10 14 IBASIC Keyword Summary 11 Example Programs Example Program Summaries This chapter contains listings of the example programs referred to throughout this manual These programs are all available on the BASIC Example Programs Disk that accompanies this manual In addition to these example programs there are two additional disks of examples for the analyzer These disks are the Example Programs Disk DOS Format and the Example Programs Disk LIF Format These disks are included with the network analyzer when it is delivered All the programs on these disks are designed to run on the analyzer s internal IBASIC controller The example programs on the BASIC Example Programs Disk some of which are listed in this chapter include the following DATA EXT Data transfer between internal and external programs This program is designed to run on an external controller either HP IBASIC for Windows running on a PC or HP BASIC running on an HP workstation This program demonstrates how to transfer data from an IBASIC program running on the analyzer to an HP BASIC or IBASIC program running externally It loads a program into the HP 8711 runs it sets a variable and then gives it
63. TPUT Rina SENS2 SWE POIN 201 201 points OUTPUT Rfna DISP WIND2 TRAC Y RPOS 9 OUTPUT ORfna MMEM MSIS MEM OUTPUT OR na MMEM INIT MEM DOS OUTPUT Rfna MMEM STOR STAT IST OFF CORR OFF TRAC OFF 0PC ENTER Rfna Opce Setup LOOP GOSUB Scan next ON KEY 1 LABEL STORE THIS DATA GOSUB Stor mem ON KEY 2 LABEL STORE MEM TO DISK CALL Store disk ON KEY 3 LABEL SCAN ANOTHER GOSUB Scan next ON KEY 5 LABEL DONE GOSUB Exit LOOP DISP SELECT A SOFTKEY WAIT 1 11 50 Example Programs 500 DISP 510 WAIT 3 520 END LOOP 530 END LOOP 540 1 550 Exit 1 560 Store disk 570 CLEAR SCREEN 580 DISP PROGRAM PAUSED 590 LOCAL Rfna 600 PAUSE 610 RETURN 620 630 Scan next i 640 Scan dut Model Serial Cent Span Loss 650 IF Model ABORT THEN GOTO Exit 660 CLEAR SCREEN 670 PRINT TABXY 1 3 Device currently under test 680 PRINT 690 PRINT Model Model Serial amp Serial 700 PRINT TABXY 1 7 Status of Serial amp Serial amp MEASURING 710 GOSUB Set_stim 720 RETURN 730 740 Stor_mem j 750 PRINT TABXY 1 7 Status of Serial amp Serial amp STORING T 0 RAM 760 Store ram Model Serial 770 PRINT TABXY 1 7 Status of Serial amp Serial amp STORING D ONE 780 GOSUB Scan next 790 RETURN 800 810 Set stim Set Freqs 820 OUTPUT Rfna DISP ANN FREQ MODE CSPAN 830 OUTPUT Rfna SENS FREQ CENT amp Cent amp MHZ SPAN amp Span am
64. UT statement This message can be sent to all devices on the external interface by specifying the bus address 7 Specifying a single address on the bus i e 722 sends the command to only the device at that address The Local Lockout message is cleared when the Local message is sent by executing the LOCAL statement However executing the ABORT statement does not cancel the Local Lockout message Host Instrument The Local Lockout message is not supported for the host instrument since front panel control is always necessary in order to pause or abort the program Specifying the internal interface in a LOCAL LOCKOUT statement will not generate an error but will have no effect 8 6 Interfacing with External Devices LOCAL During system operation it may be necessary for an operator to interact with one or more external devices For instance an operator might need to work from the front panel to make special tests or to troubleshoot It is also good systems practice to return all devices to local control when remote control operations are complete Executing the LOCAL statement returns the specified devices to local front panel control If primary addressing is specified the Go to Local message is sent only to the specified device s However if only the interface select code is specified LOCAL 7 the Local message is sent to all devices on the external interface and any previous Local Lockout message which is still in effect is autom
65. _fmem Chan M Example Programs 11 47 960 PRINT TABXY 1 7 Status of Serial amp Serial amp AVG COMPL ETE 970 GOSUB Scan_next 980 RETURN 990 t p 1000 Set_stim Set Freqs em 1010 OUTPUT Rina DISP ANN FREQ MODE CSPAN i 1020 OUTPUT Rfna SENS FREQ CENT amp Cent amp MHZ SPAN amp Span amp MHZ 1030 OUTPUT Rfna DISP WIND2 TRAC Y RLEV amp Loss amp DB 0PC 1040 ENTER ORfna UOpc 1050 RETURN 1060 1070 END 1080 1090 SUBPROGRAMS 8 484 1100 1110 Scan_dut SUB Scan dut Model Serial Cent Span Loss 1120 ALLOCATE Scan 80 1130 LOOP 1140 Invalid 0 1150 Scan ABORT 1160 Scan BPF175 12345 These 3 lines for demo on ly 4170 S VAL RND 1 E 9 H HH H Generates random S N 1180 Scan 8 12 S 3 7 Delete all to enable abor TS 1180 BEEP 500 05 1200 INPUT Connect amp scan DUT or leave blank to exit Sca n SCAN BARCODE 1210 IF LEN Scan lt 12 THEN Valid device needs 12 char 1220 Invalid 1 1230 ELSE 1240 Model Scan 1 6 1250 SELECT UPC TRIM Model 1260 CASE BPF175 BPF177 1270 RESTORE Fi 1280 CASE BPF200 1290 RESTORE F2 1300 CASE SAW134 1310 RESTORE F3 1320 CASE ELSE 1330 invalid 1 1340 END SELECT 1350 END IF 1360 EXIT 1F NOT Invalid 1370 IF POS UPC Scan ABORT THEN 1380 Model ABORT 1390 SUBEXIT 1400 END IF 1410 DISP Scan lt lt is INVALID Try again 11 48 Example Pr
66. a 7 8 11 1 Sample Bar Codes E o cedo a A e cn A e 11 54 Tables 5 1 IBASIC Display Partitions da oe ey a ee 5 10 7 1 IBASIC Display Partitions A A hog eh ae a Se 7 2 7 2 SCPI Graphics Commands O d o eden hh ee oli BE cd 7 12 10 1 Alphabetical List of IBASIC Keywords e poate 10 1 10 2 Categorical List of IBASIC Keywords at Sere 10 8 Contents 5 tem ny t roomed of Introduction A built in HP Instrument BASIC IBASIC controller option 1C2 can be ordered with the analyzer An upgrade HP model no 86224B is also available to add the controller to an analyzer that was not purchased with this option This manual describes creating and using IBASIC software on the analyzer It demonstrates how to use IBASIC s programming editing and debugging features It also describes how to save and recall programs and how certain instrument specific IBASIC features are implemented in the analyzer The reader should become familiar with the operation of the analyzer before programming it This manual introduces the IBASIC operating and programming environment and provides examples of intermediate and advanced IBASIC programs It assumes familiarity with the analyzer and HP BASIC Related information can be found in the following references Contact a Hewlett Packard sales or service office if you wish to order any of these d
67. a program line to store it into the program buffer you must ENTER it in one of four ways 1 Use the key on the front panel of the analyzer 2 Use the oftkey on the instrument 3 Use the or key on the external keyboard 4 Use the function key on the keyboard F6 that represents the analyzer s The computer checks the line for syntax errors and converts letter case to the required form for names and keywords IBASIC commands If no errors are detected it then stores the line Note If you edit or enter text on the current program line and then move off the line without pressing ENTER all editing on the line will be lost 5 6 Developing Programs Editing from the Front Panel Use the step keys to move the cursor up and down the lines in the program When the cursor is located at the beginning of a line you want to change use the knob to position the cursor within the line Character Entry The character entry menu and the associated label window are activated by pressing the softkeys The knob and step keys now move the cursor in the label window Use the knob or step keys to letter or keyword and pres indow s cursor until it highlights the desired Continue editing until the line is correct The computer checks the line for syntax and then stores it in the program if the syntax is correct Press to return to the edit menu The character entry menu provides the following softkeys E
68. a section of a larger measurement sequence be sure to specifically activate every instrument setting that you will need in your automated For example if you want the data format to be Log Mag press and then even though Log Mag is already the default setting This will generate a program line to specifically set the data format to Log Mag In some cases you may have to select another setting first and then re select the original setting in order to generate the correct program line For example if you want to generate a program line to set the sweep trigger to Continuous and you discover that it is already set to Continuous when you start recording press E rst then press You can easily remove unwanted program lines generated by this procedure in the editor Note Do not rely on the step keys or front panel knobs to set parameters Use of step keys are not recommended because the results may depend on the function s step size which may change as other parameters change 2 8 Recording Programs Use HP IB Echo HP IB Echo is a useful analyzer feature that allows you to view the SCPI mnemonic or mnemonics corresponding to the front panel To turn on HP IB Echo press After doing this you will see a mnemonic appear in a dialogue ox on the screen as you complete any key sequence that has a matching SCPI mnemonic This is the exact mnemonic that is generated in your recorded program during a recording session Usin
69. above which you want the recorded statements inserted to exit the editor o activate keystroke recording 5 Record the measurement sequence or front panel operation 6 Press SYSTEM OPTIONS The inserted recording acts the same as if you had pressed generated OUTPUT statements in insert mode o conclude the recording session in the editor and Note The ASSIGN Hp8711 to 800 statement is NOT generated when you are recording into an existing program and MUST be included in your program prior to any recorded OUTPUT commands If you initially created the program using recording this statement should already exist If it does not exist you will need to enter it 5 4 Developing Programs Editing with an External Keyboard With an external keyboard connected to the analyzer it is easy to edit or create an IBASIC program using the internal editor Note that the Front Panel Editor described in the next section is always available even when an external keyboard is in use Note The analyzer and the IBASIC editor work with IBM PC AT compatible keyboards US only that have a standard DIN interface Non US language keyboards will not cause an error they simply will not be recognized as different from the US keyboard A compatible keyboard can be purchased by ordering option 1CL with the analyzer Keyboards with a mini DIN connector will need a mini DIN to DIN adapter HP part number C1405 60015 The PC AT keyboard Fi
70. ads a program file PROGO from the internal floppy disk drive 3 Watch the IBASIC display as the program is loaded syntax errors result in error messages displayed on the screen 4 Edit the program to correct any errors found HP BASIC The HP BASIC editor checks for the syntax of the version of HP BASIC being used Because IBASIC is a subset of HP BASIC it may not find all of the errors the most common error is the use of HP BASIC commands that are not supported by IBASIC For a listing of the commands supported by IBASIC refer to Chapter 10 IBASIC Keyword Summary ASCII Word Processors When an ASCII word processor is used to edit a program no syntax checking occurs until the program is loaded by the instrument Another complication with using a word processor is that program line numbers are not automatically renumbered when new lines are inserted It is recommended that you renumber the program as described later in this chapter to reduce the possibility of errors Errors in numbering lines usually do not result in a syntax error they write over other program lines 5 2 Developing Programs Editing Your Program Using The built in editor may be used for creating and altering lines in an IBASIC program Those familiar with the editor found in HP BASIC will find it somewhat similar to the instrument s IBASIC editor others should find it easy to learn and use This section tells you how to edit and enter an
71. ake use of the extensive set of analyzer HP IB commands that interface with IBASIC programs These mnemonics fall under the subsystem PROGram and allow the external controller to remotely perform many of the IBASIC front panel activities This includes the ability to run stop pause continue and delete an internal program You can also remotely query or set the values of numeric and string variables Also included in the analyzer HP IB command set are commands that allow you to transfer programs and program data to and from the instrument Programs can be transferred uploaded and downloaded between an external controller and the program buffer in the instrument and data can be transferred between an external program and a non running internal program by setting and querying internal program variables These SCPI mnemonics are described in the Programmer s Guide Also refer to example programs included on the BASIC Example Programs Disk DUALCTRL TRICTRL UPLOAD and DOWNLOAD These programs demonstrate using IBASIC with an external controller Interfacing with External Devices 8 13 Synchronizing IBASIC with an External Controller Using OUTPUT and ENTER statements Commands sent to the analyzer with OUTPUT and ENTER statements from IBASIC and from the external controller at the same time must be synchronized by the programmer These commands cannot be allowed to overlap Overlapped commands sent from the external controller and IBASIC will
72. ale ASSIGN Rfna TO 800 I Preset the analyzer and wait until it is done OUTPUT CRfna SYST PRES 0PC ENTER Rina Opc t Allocate the full screen as an IBASIC display and clear the graphics buffer OUTPUT GRfna DISP PROG FULL OUTPUT GR na DISP WINDiO GRAP CLEAR f Setup the origin and scale parameters for the drawing Draw the network analyzer and dut t X0 100 Y0 100 Scale 1 CALL Draw_na X0 Y0 Scale CALL Draw dut X0 Y0 Scale END This subroutine draws the HP 8711 at origin XO YO and scale Sc The drawing is done to the IBASIC Example Programs 11 13 480 490 graphics commands 500 510 520 ASSIGN Rfna TO 800 530 OUTPUT Rfna DISP WIND10 540 OUTPUT Rfna DISP WIND10 LVAL INT Sc 100 550 OUTPUT GRfna DISP WINDIO amp VAL YO INT Sc 10 560 OUTPUT GR fna DISP WINDIO amp VAL CINT Sc 80 570 OUTPUT CRfna DISP WIND1O display window 10 using the HP 8711 s user amp VAL CYO INT Sc 80 580 OUTPUT Rfna DISP WIND10O amp VAL CINT Sc 8 590 OUTPUT ORfna DISP WIND10 amp amp VAL CYO INT Sc 70 600 OUTPUT ORfna DISP WIND10 amp VAL CINT Sc 8 610 OUTPUT CRfna DISP WIND10 2 SVAL YO INT Sc 60 620 OUTPUT Rfna DISP WIND10 amp VAL CINT Sc 8 630 OUTPUT Rfna DISP WIND10 e amp VAL YO INT Sc 50 640 OUTPUT Rina DISP WIND1O amp VAL INT Sc 8 650
73. alyzer The analyzer will respond to any address on the internal interface from 800 to 899 800 is typically used SCPI Mnemonics The data sent to the analyzer by the OUTPUT command is called a SCPI Standard Commands for Programmable Instruments mnemonic and is found in quotes following the device selector path name and semicolon OUTPUT Rina SOUR1 POW 10 dBm SCPI is a standard instrument control programming language providing commands that are common from one product to another reducing the number of device specific commands It Recording Programs 2 3 uses easy to learn self explanatory syntax that provides flexibility for both novice and expert programmers The SCPI mnemonic codes used by IBASIC are the same ones used to control the instrument remotely via an external computer External computers communicate with the analyzer over the external HP IB bus while IBASIC programs communicate with it over the internal bus In our example the mnemonic SOUR1 POW 10 dBm tells the instrument to set the source power to 10 dBm For more information on HP IB interfacing using IBASIC refer to Chapter 8 Interfacing with the HP IB The SCPI mnemonics for the analyzer are documented in the Programmer s Guide How Recording Works To fully understand IBASIC recording it is important to understand the relationship between front panel instrument operation and the program that is generated to emulate that operation
74. am listing is not provided here However there are several routines that may be useful in other applications The following subprograms and functions may be of particular interest FNSelect A routine that allows selection of one of many possible choices by scrolling an arrow down the list of choices The number of choices may exceed one screen The front panel hard keys or knob can be used for scrolling In addition user defined softkeys can also be chosen The user has the option of using the front panel keyboard or an external AT style keyboard With a slight modification described within the code this routine can also be used on an HP RMB controller e g an HP 9000 Series 300 computer FNSel_softkey A routine that displays a user defined message and allows the operator to select one of seven possible softkeys FN Yes A simple program that displays a user defined question and allows the user to select a YES or NO answer via the softkeys Returns the number 1 for YES and 0 for NO Softpause Another simple routine that displays a user defined message and waits for the operator to press a RESUME softkey Note These routines require the Beeper and or the Clear screen subprograms which are also part of this program However both can be replaced with their IBASIC equivalent commands BEEP and CLEAR SCREEN Example Programs 11 5 Example Program Listings DATA EXT Data transfer between internal and external programs
75. and In order to prevent circles from appearing oval shape this ratio should be maintained You can also issue a WINDOW 0 861 0 351 command This will maintain the same ratio but the display will now be dimensioned in actual pixel unit This may be more useful than the default GINIT values since fractional display units are not needed allowing integers only to be used thus speeding execution These are also the same values that are returned by utilizing the GESCAPE command see BARCODE program example The GESCAPE command will always set the current pixel dimension sizes Because the results of this command can vary drastically with partition size you must first partition the display BEFORE executing the GINIT and GESCAPE commands Note Upon power up the default display coordinates are 0 861 0 351 and will remain that until a GINIT is performed It is recommended that a GINIT command always be part of any graphics program and that it be executed only after the display partition is set Graphics and Display Techniques 7 5 0 351 881 351 0 158 865 188 UPPER slopiay partition 10 0 851 0 FULL dleplay partition pre 0 157 861 187 LOWER disptey portltion 0 0 A 881 0 0 6 861 0 pdbja Figure 7 4 Pixel Dimensions with Available Display Partitions Using Graphics IBASIC s graphics commands are easy to understand and use You can use the MOVE statement to move the pen to a speci
76. annel 1 only 5 10 Developing Programs Note When the UPPER or LOWER display partition is selected the measurement display automatically selects the split screen format This format uses half of the CRT to display each channel s measurement data Channel 1 data is always shown on the upper half of the screen channel 2 data is shown on the lower half The split screen format allows measurement data to be viewed simultaneously with IBASIC program output For more information about the split screen format or other parts of the measurement display refer to the analyzer User s Guide Most display allocation should be handled by your program via the SCPI mnemonics These softkeys are best utilized during program development An IBASIC partition can be very useful during program development It can be used to view program output to query variables and to execute IBASIC commands such as GET and REN outside of your program Figure 5 3 shows the relative size and location of the different IBASIC partitions and their command and display lines E gt Displayiine CL 0 NT FULL partition lGeamand Tine LOWER partition Display ling 0 Display line _ Command line eens Command line ESA EE i Figure 5 3 The IBASIC display partitions More information about using display partitions within a program is available in Chapter 7 Graphics and Display Techniques Developing Programs 5 11 Pressing th
77. ate the lower display partition 370 380 OUTPUT Rfna DISP PROG LOW 390 i 400 Setup a softkey menu to enable and disable the a 410 beeper Clear the analyzer s input output queues 420 430 ON KEY 1 LABEL Beep Enable GOSUB Beep on 440 ON KEY 2 LABEL Beep Disable GOSUB Beep_off 450 CLEAR Rfna 460 470 Trigger 100 sweeps Beep if the beeper flag is set 480 and toggle the USER bit after each sweep 11 36 Example Programs 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 DISP USER bit example program End of sweep toggles USER bit PRINT Draw the end of sweep USER bit value MOVE 0 50 FOR I TO 100 OUTPUT Rfna INIT1 0OPC ENTER Rfna 0pc GOSUB Toggle NEXT I DISP End program STOP t The Odd flag s value alternates between 1 and 0 depending on the number of sweeps that have been taken It is the value that is written to the USER bit i Toggle IF Odd 0 THEN WRITEIO 15 1 0 Odd 1 ELSE WRITEIO 15 1 1 Odd 0 END IF IF Beeper 1 THEN BEEP END IF J Read the value of the USER bit and draw it to the IBASIC display l Val READIO 15 1 Val Val 30 DRAW 8 I 1 Val 50 DRAW 8 1 Val 50 RETURN t These two subroutines set a flag that is used to turn on or off the beeper E
78. atically cleared Host Instrument The LOCAL statement has no effect on the host instrument since it is always in remote control whenever an IBASIC program is running Specifying the internal interface in a LOCAL statement will not generate an error TRIGGER The TRIGGER statement sends a Trigger message to a selected device or group of devices The purpose of the Trigger message is to initiate some device dependent action for example it can be used to trigger a digital voltmeter to perform its measurement cycle Because the response of a device to a Trigger message is strictly device dependent neither the Trigger message nor the interface indicates what action is initiated by the device Specifying only the interface select code outputs a Trigger message to all devices currently addressed to listen on the bus Including a device address in the statement triggers only the device addressed by the statement Host Instrument The TRIGGER statement is supported by the analyzer Issuing a TRIGGER command will initiate a single sweep assuming the analyzer is in TRIGGER hold mode TRIGGER is ignored if not in hold mode CLEAR The CLEAR statement provides a means of initializing a device to its predefined device dependent state When the CLEAR statement is executed the Clear message is sent either to all devices or to the specified device depending on the information contained within the device selector If only the interface select cod
79. ating in the Local Lockout mode each HP IB device has method usually a key to return itself to Local front panel control When the analyzer is being controlled by a program running on an external controller the oftkey is always available to return the analyzer to Local control The Remote message is automatically sent to all devices whenever the system controller is powered on reset or sends the Abort message A device also enters the Remote state automatically whenever it is addressed The REMOTE statement also outputs the Remote message which causes all or specified devices on the bus to change from local control to remote control The host instrument must be designated as the system controller before an IBASIC program can execute the REMOTE statement on select code 7 Host instrument The REMOTE statement has no effect on the host instrument since it is always in remote control whenever an IBASIC program is running Specifying the internal interface in a REMOTE statement will not generate an error but will have no effect LOCAL LOCKOUT The Local Lockout message effectively locks out the local switch present on most HP IB device front panels It maintains system integrity by preventing a user from interfering with system operations by pressing buttons As long as Local Lockout is in effect no bus device can be returned to local control from its front panel The Local Lockout message is sent by executing the LOCAL LOCKO
80. ation include 0PC 0PC WAI CLS RST SRE ESE and STAT PRES 8 14 Interfacing with External Devices Design Rules Design your IBASIC and External Controller with the following rules Do not overlap commands between the external controller and IBASIC a Do not change status information which is expected by the alternate controller Design programs such that status information does not overlap See the example program TRICTRL which implements a synchronization protocol between an external controller and two instruments running IBASIC programs Transferring Data Between Programs Using OUTPUT and ENTER statements All data sent from an external controller to the instrument s external port is received by the instrument and not by any program running in it Therefore a non active controller IBASIC program can never enter or output data via the external interface This means that in order to pass data between an external controller and an internal program using OUTPUT and ENTER statements the internal program must be given active control and the external controller must become the non active controller HP IBASIC for Windows and HP BASIC controllers have the ability to enter and output data via HP IB while acting as a non active controller Note Moving data through the HP IB and running a measurement in the host instrument at the same time can slow both operations significantly It is recommended that you do not perform the
81. ations that are not available from the front panel and which therefore cannot be recorded These include operations such as querying instrument status transferring data over HP IB setting and clearing status registers and general HP IB housekeeping These operations are useful for the more advanced HP IB programmer using IBASIC Because they fall outside the direct operating realm of the analyzer they cannot be recorded They can be added to a recorded program using the built in editor or another editing environment See the Programmer s Guide for a complete description of the analyzer s HP IB command set See also Built In High Speed Subprograms in Chapter 9 Recording Programs 2 7 Avoiding Recording Errors Use Instrument Preset In most cases it is recommended that the key operation be recorded as the first keystroke recorded This sets the instrument to its default state and avoids the risk of creating a program that depends on instrument settings that were present at the time of the keystroke recording but may be different when the program is run You can include the command to perform a preset in your program by pressing immediately after turning recording on This inserts the following line prior to all other OUTPUT statements in your program OUTPUT Rina SYST PRES WAI Specifically Select Parameters If you do not want the instrument preset before a recorded program is run for example you may be recording
82. control of the bus This program then acts as a device on the bus sending and receiving data DATA INT Data transfer between internal and external programs This program is designed to run on the analyzer s internal IBASIC controller This program demonstrates how to transfer data to and from an external controller In this example a catalog listing is transferred from the analyzer to the external controller A numeric variable value is also downloaded from the external controller to the analyzer s program DOWNLOAD Download program to analyzer This program demonstrates how to download an IBASIC program to the analyzer It is designed in HP BASIC or HP IBASIC for Windows to run on an external workstation or PC Example Programs 11 1 DRAW871X Drawing setup diagrams This program draws the network analyzer and a device under test to the full screen IBASIC display partition The drawing can be scaled to fit the application This program uses the analyzer s graphics commands for drawing To use the IBASIC drawing commands see the BARCODE program DUALCTRL Two controller operation This program demonstrates how the external controller and HP IBASIC can work together It is designed to run on an external controller in HP BASIC or HP IBASIC for Windows The program downloads an IBASIC program to the analyzer and runs it twice After each run two program variables are read from the analyzer and displayed REP
83. cording the measurement sequence and then uploading the program to the external controller for further editing Fully developed programs may be downloaded from an external controller as well The methods of transferring programs between the analyzer and an external controller are described in detail in Chapter 8 Interfacing with External Devices This chapter describes all program transfer operations between the program buffer and the analyzer internal non volatile RAM disk internal volatile RAM disk internal floppy disk drive and external mass storage devices disk drives Note The IBASIC file system can work with both LIF Logical Interchange Format and DOS Disk Operating System formatted disks When it catalogs or loads files from a disk the analyzer automatically recognizes the correct disk format Saving and Recalling Programs 4 1 Selecting a Disk When the SAVE RECALL selected disk or memory m Internal Non Volatile RAM Disk a Internal Volatile RAM Disk a Internal Floppy Disk Drive a External Disk Drive menu is selected the analyzer automatically catalogs the cted disk is one of the following mass storage devices oftkey in the SAVE RECALL menu he external disk To select a mass storage device press the Then press the key corresponding to drive is set under the SAVE RECALL Saving a Program To save the current contents of the analyzer program buffer to a file press B
84. d the HP IB address of the HP 8711 t Scode 7 Address 16 Na Scode 100 Address E Initialize variables abort any bus traffic and clear the input output queues of the analyzer DIM Line 255 ABORT Scode CLEAR Na t Get the program s filename and open the file Get filename INPUT Program to be transferred Filename ON ERROR GOTO No_ file DISP Checking file ASSIGN OBasic_prog TO Filename FORMAT ON OFF ERROR i Clear the contents of the analyzer s program buffer OUTPUT Na PROG DEL ALL i Change the EOL end of line character to line feed and initialize the line counter Transfer ASSIGN Prog TO Na EOL CHR 10 Line _count 0 1 Initiate the program transfer an indefinite length block data transfer 1 OUTPUT CProg PROG DEF 0 l Example Programs 11 11 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 850 860 870 Read each program line from the file and send it to the HP 8711 Loop until the end of file is reached t ON ERROR GOSUB End file LOOP ENTER Basic_prog Line OUTPUT CProg Line Line_count Line_count 1 DISP Lines transferred Line count END LOOP and close the file Return the analyzer to LOCAL 3 End the data transfer output a line feed with EOI i control and stop this program E
85. dB Loss Disp_result OUTPUT CRfna STAT QUES LIM COND ENTER Rfna Fail_flg Fail_flg BIT Fail_flg 1 Bit 1 is for ch2 IF Fail flg THEN BEEP 2100 5 Label Test Fail_flg 125 50 24 5 0 1 Continue CALL Draw dut 0 BEEP 300 05 INPUT Disconnect DUT Measure another Y n Ans EXIT IF UPC Ans 1 1 N Label Test Fail_flg 125 50 24 5 0 0 END LOOP OUTPUT Rfna ABOR INIT CONT ON STOP Set stim Set Freqs and Limit lines OUTPUT Rfna DISP ANN FREQ MODE CSPAN OUTPUT Rfna SENS FREQ CENT amp Cent amp MHZ SPAN amp Span amp OUTPUT Rfna DISP WIND2 TRAC Y RLEV PROUND VAL Loss 1 DB 840 FOR I 1 TO 3 SET LIMIT LINES 850 OUTPUT O Rfna CALC2 LIM SEGM amp VAL I amp TYPE amp Lim 1 1 amp STAT ON 860 OUTPUT ORfna CALC2 LIM SEGM amp VAL I amp FREQ STAR amp Lim I 2 amp MHZ STOP Lim 1 3 MHZ 870 OUTPUT Rfna CALC2 LIM SEGM amp VAL I amp AMPL STAR Lim 1 4 amp STOP amp Lim I 5 880 NEXT I 890 OUTPUT Rfna CALC2 LIM DISP ON STAT ON 900 RETURN 910 END 920 H HHHHEHE SUBPROGRAMS HHERRRHH 930 940 Draw na SUB Draw na 11 42 Example Programs 950 This draws HP 8711 at origin X Y 960 Box 231 50 460 100 Frame 970 Box 231 50 462 102 980 Box 125 50 180 72 CRT 990 Box 125 50 182 75 1000 FOR I 19 TO 82 STEP 9 Keys 1010 Box 235 1 15 5 1020 NEXT 1 1030 Box 285 88 15 7 BEGIN 1040 Box 375 8
86. e files are generally not transportable between the analyzer and other development systems only ASCII files are compatible with other systems Typical examples of LOAD STORE From an external keyboard LOAD MYFILE STORE MYFILE From the front panel Typical examples of LOADSUB LOADSUB subprogram_name FROM filename LOADSUB ALL FROM filename User created subprograms are appended to the end of the BASIC program currently stored in the EDIT buffer Using Subprograms 9 1 Built In High Speed Subprograms You can use LOADSUB to access pre compiled routines stored as instrument firmware in internal memory Any IBASIC program running on the analyzer can access these subprograms programs running on external computers cannot The external program must use the equivalent code listed in the table below in place of a built in subprogram IBASIC programs which use the built in subprograms are simpler and run faster For example most data transfer operations run twice as fast when using the built in subprograms math operations run many times faster Built in subprograms are stored in memory designated as MEM 0 0 To access a subprogram the subprogram first must be loaded into the main program using the LOADSUB keyword The LOADSUB keyword requires a filename be specified from which to load the subprogram Three built in files are XFER MATH and RPG u XFER file adds support to transfe
87. e is specified all devices on the specified HP IB interface are cleared If primary address information is specified the Clear message is sent only to the specified device Only the active controller can send the Clear message Host instrument The CLEAR statement is fully compatible on the internal interface interfacing with External Devices 8 7 ABORT This statement may be used to terminate all activity on the external bus and return the HP IB interfaces of all devices to reset or power on condition Whether this affects other modes of the device depends on the device itself The IBASIC program must be either the active or the system controller to perform this function If it is the system controller and has passed active control to another device executing this statement causes active control to be returned Only the interface select code may be specified primary addressing information such as 724 must not be included Aborting the internal Bus ABORT is not supported for select code 8 Executing ABORT 8 will not generate an error HP IB Service Requests Most HP IB devices such as voltmeters frequency counters and network analyzers are capable of generating a service request when they require the active controller to take action Service requests are generally made after the device has completed a task such as making a measurement or when an error condition exists such as a printer being out of paper The operating
88. e operational status register and status byte 1020 1030 A SPOLL Na 1040 OUTPUT Na STAT OPER EVEN 1050 ENTER Na Event 1060 OUTPUT Na CLS 1070 1080 Read a numeric variable Times run and a string 1090 variable Test and display the values 1100 l 1110 OUTPUT Na PROG NUMB Times run 1120 ENTER Na USING X K Times run 1130 OUTPUT Na PROG STR Test 1140 ENTER Na USING X K Test 1150 DISP Times run Times_run Test Test 1160 PRINT Times run Times_run Test Test 1170 SUBEND 11 18 Example Programs REPORT Using the parallel port 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 50 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 IBASIC program REPORT Using the parallel port 1 i This program uses the 871X to generate a report making a hardcopy on a printer connected to the parallel port It uses a subprogram to send the output to the parallel port one line at a time l k E E I I This example uses five different font types that may or may not be supported for your printer These character fonts are available for HP LaserJet printers Refer to your printer manual to modify the example fonts for your printer am a a ce Se SEE e e e Sem HRS UA ONP AA e a mm mm Assign an I
89. e results of a PRINT statement or to access a command line The display line accessed with the DISP command is available even when no IBASIC display is present Examining Strings Enter string variables as you would any other variable Any string variable entered without delimiters will display as much of the string as will fit on the display line of the screen up to 58 characters To select only a section of a string use the IBASIC substring syntax see the HP Instrument BASIC Programming Techniques section of the HP Instrument BASIC Users Handbook For example to examine the 7 character substring starting at the second character of A enter A 2 7 on the command line or execute the command PRINT A 2 7 Examining Arrays To select an array to be examined you can either select individual elements or the entire array For example the entry l_array 1 l_array 2 1_array 3 selects the elements 1 through 3 of the array I_array to be displayed You may select an entire array to be examined by entering the array variable name and specifying a wildcard for the element such as I_array If Larray 20 is an integer array and the first and second elements are set to 100 entering I array would display 100 100 0000 00 000 0 0 00 00 0 0 0 0 Individual array elements e g LLarray 17 can also be specified in the same way as any other single variable Debugging Programs 6 3 Displaying the Last Error Encountered
90. e softkey F6 on an external keyboard allows you to clear the program buffer allocate memory for program use or secure your program m Clear Program F1 mw Memory Size F2 E Secure F3 Executing the i erases the current program buffer and frees all memory currently allocated Memory size see below is reset to 8192 bytes You will be prompted to ensure you do not accidentally erase the program allows you to set stack memory to be used by your program At power up it is set by default to 8192 bytes However when a program is RUN the analyzer will try to automatically set the Memory Size large enough to accommodate the program s Stack and COM memory requirements For some programs the automatic memory sizing will be too small and you will get the message Error 2 in 100 Memory overflow When this error occurs you must manually set the o the value in bytes required by your program up to the available memory in your system is used to secure lines of your program Secured lines cannot be listed edited or isp ayed After you press this key you will see m Start Line softkey 1 a End Line softkey 2 m Perform Secure softkey 4 After you have set the start and stop line numbers execute the Caution Once you have secured your program lines there is no way to remove the security Therefore do not secure the only copy of your program Make a copy of your original program the copy and kee
91. eeded by the INPUT or DISP commands or when activated To activate the command line press on an external keyboard Figure 7 2 shows an example of the use of this display line When the INPUT command is being used the IBASIC editor s label window and character entry softkey menu appear Refer to Chapter 5 Developing Programs for a description of the IBASIC editor ABCDEFGHI JKL MNOPORSTUVWXYZ01 23456789 x lt gt amp SE a a Pena aa 2 Chan 2 Reflection Log Mag 410 0 0B Ref 6 00 dB Chi Mkri 175 760 MHz ne 0 59 cB onz mkri 475 760 MHz Be ao eat 200 00 dB 1 40 y H EO 20 RR H 80 pr Ate PO AA i 80 porra Enter Start Frequency MHz ADS H i Start 0 300 MHZ is Stop 1 300 000 MHz Figure 7 2 Using INPUT with no display partition Graphics and Display Techniques 7 3 In addition to the commands described above the analyzer has User Graphics commands that can write to any of the display partitions These commands can be used to write to measurement windows as well as the IBASIC window These commands are described in the SCPI Graphics Commands section of this chapter Displaying Text Most of IBASIC s text capabilities are covered in detail in the HP Instrument BASIC Programming Techniques section of the HP Instrument BASIC Users Handbook The PRINT statement works the same way in every display partition Information is printed start
92. el ds ga a Sah NR E A 5 7 Character Entry soa ss cy Slee Re AR Sele Gea 5 7 o Phe Label Widow s sxe as eA nv 0 ROD ES ES oe ee 5 7 r Seri Linas po gt h a BOS end PR E a r 5 8 T Removing Program Text io a a a e ty a a A A 5 8 B Deleting Characters n a ao e a es A we aa 5 8 Deleting Lines te By oh hin oh es ince eS eh ce SA Wey doe gt lap en e A 5 8 Recalling a Deleted e A Gs Mie a a 5 9 g Moving and dente Lies Sr shy ee de we e 5 9 5 10 5 oe 6 Debugging Programs no Setting Breakpoints a ie a LS aa a aa 6 2 Nas Examining Variables PER RA Ga oe Ee DE AR SO a 6 2 EXAMINING Strings es eao noosa eG a as Rs O a 6 3 Examining Arrays ED drug AE a CO dio he a a 6 3 Displaying the Last Error Trcoudtered ALS shina Mi ge te RS A E 6 4 ed 7 Graphics and Display Techniques La Using the Display Partitions o a2 we 4 oe Ww ee A 7 1 po Allocating Display Partitions 2 ee 7 2 De Allocating Display Partitions 2 eee ees 7 3 Operation with No Display Partition eee 73 Ee Displaying Text Las 7 4 Pop up Message Windows and Custom Annotations Rede se a a a E 7 5 Graphics Initialization and Scaling 0 202 582 5805 Ge 1 5 y Uso Graphics a a iv a a A id ae Bh E 7 6 o Drawing Figures sos e AAA AE AAA RNA ee RE 17 le Graphics Exceptions om 7 9 GRID RECTANGLE POLYGON and POLYLINE seli differences E 7 9
93. en look like this 30 ASSIGN CHp8711 TO 800 40 OUTPUT Hp8711 DISP PROG UPPer 42 OUTPUT Hp8711 DISP PROG 44 ENTER Hp8711 Screen 46 IF Screen lt gt UPP THEN GOTO 42 50 CLEAR SCREEN 60 PRINT This is the upper partition The mnemonic DISP PROG line 42 above requests the instrument to send the current partition status The ENTER statement on the next line reads that status and then continues 7 2 Graphics and Display Techniques De Allocating Display Partitions To return the display partition to the analyzer for use as a measurement screen use the DISP PROG OFF mnemonic This should be done before the termination of any program that has allocated a display partition It may also be required within the program to allow the user to view instrument measurement data The following example demonstrates this command 830 OUTPUT Hp8711 DISP PROG OFF Operation with No Display Partition IBASIC programs can also access the analyzer s display when no partition has been allocated This can be done through the use of certain areas of the screen One of these areas is to the right of the measurement display This area is reserved for softkey labels It can be accessed using the ON KEY statement A second area is a display line or command line that appears when no part of the display is allocated for use by IBASIC This display line which is located at the lower left corner of the active channel graticule appears when n
94. er the t 230 variable has been passed 240 250 Host 0 260 PAUSE 270 l 280 Address the external controller to talk read 290 the device to catalog If the HP 8711 is not 300 active controller on the bus an error will occur 310 and the program will loop until control is 320 received 330 340 ON ERROR GOTO 340 350 ENTER Host Stor dev 360 OFF ERROR 370 1 380 Catalog the requested storage device into 390 the string array 400 410 DISP Reading catalog 420 CAT Stor_dev TO Directory 430 440 Address the external controller to listen 450 send the catalog array to the controller 460 470 DISP Transferring data 480 OUTPUT Host Directory 490 Example Programs 11 9 500 t Pass control back to the external controller 510 520 PASS CONTROL Host 530 DISP DONE 540 END 11 10 Example Programs DOWNLOAD Download program to analyzer 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 BASIC program DOWNLOAD Download program to Rfna program to the 871x This program is designed to i i This program demonstrates how to download an IBASIC run on an external controller H O HH e a a mm a mm gt E t Initialize variables for the interface select code t an
95. erate a program line You could not therefore leave the instrument with the menu displayed 2 4 Recording Programs Operations That Do Not Record Although keystroke recording works automatically in most situations there are some operations that cannot be captured or can only be partially captured using this method These generally fall into one of the following areas w Front panel operations with no corresponding SCPI mnemonic such as transitional key sequences m IBASIC front panel operations such as some of the softkey operations found under the SYSTEM OPTIONS a Operations requiring additional programming steps such as passing control of the HP IB to the instrument for hardcopy output m HP IB operations with no front panel equivalent such as HP IB query commands or data transfer z Service menu keys in general Note Do not recall programs in keystroke record mode doing so will overwrite previously recorded program steps Front Panel Operations Without Mnemonics There are some areas of front panel operation which have no corresponding SCPI mnemonics mw Most operations on the front panel that require numeric entry allow you to use the knob to increment or decrement the current value This will not record as a program line You must always use the numeric keypad or step keys to enter any value if you want the operation to be recorded m During a measurement sequence it may take several key presses
96. erial poll of the specified device which must be capable of responding TRIGGER sends the trigger message to a device or selected group of devices These statements and functions are described in the following discussion However the actions that a device takes upon receiving each of the above commands are in general different for each device For external devices refer to the particular device s manuals to determine how it will respond All of the bus management commands with the exception of ABORT require that the program be the active controller on the interface A running IBASIC program is always active controller on the internal interface select code 8 For the program to be active controller on the external interface select code 7 the instrument must either be set as system controller or have control passed to it from an external controller The program automatically assumes the controller status of the host instrument For more information refer to The IBASIC HP IB Model section later in this chapter Note In this section the term Host Instrument refers to the instrument where the IBASIC controller is located Interfacing with External Devices 8 5 REMOTE Most HP IB devices can be controlled either from the front panel or from the bus If the device s front panel controls are currently functional it is in the Local state If it is being controlled through the HP IB it is in the Remote state Unless oper
97. es tested so far Also demonstrates the use of two of the built in CSUB routines for reading and writing trace data from to the analyzer DATALOG This program will very quickly store measured trace data for one of three filters to internal analyzer memory in a format that can be read by spreadsheet programs for further analysis Because the data is stored to RAM the time delay inherent with disks is not an issue trace data can be stored in a fraction of a second With 101 data points per trace selected the internal memory will hold over 200 device test results At this point the program automatically transfers the data to disk Of course more data points will take longer to store and fill the memory sooner The program will read the bar code and select the stimulus accordingly It then measures the device and upon request stores it under a unique name dependent upon model number and serial number Once the internal memory is full or at any user requested time all trace data is transferred to disk 11 4 Example Programs ADJ 110 Automated procedure for service adjustment 110 B amplitude correction This program is provided as a servicing tool to automate the B adjustment routine using IBASIC instead of using an external controller Description of this program is provided in the adjustment portion of the service manual Because this program was not intended to be an example program and due to its length gt 1200 lines the progr
98. eyword Summary Table 10 1 Alphabetical List of IBASIC Keywords continued HP IBASIC Keyword Support Exceptions FP Front Panel EK External Keyboard P Programmable SIN FP EK P SPOLL EK P Select Code 7 SQR EK P SQRT EK P STEP FP EK STOP FP P STORE FP EK P SUB SUBEND SUBEXIT SUM EK P SYSTEM PRIORITY P SYSTEMS EK P TABQ EK P EK P FP EK P EK P EK P EK P Select Code 7 FP EK P EK P FPEK P EK P FP EK P FP EK P VIEWPORT EK P WAIT EK P WHERE EK P WHILE P WIDTH EK P WINDOW EK P WRITEIO EK P Select Code 9 or 15 See manual EK P IBASIC Keyword Summary 10 7 Table 10 2 Categorical List of IBASIC Keywords HP Instrument BASIC Keyword Program Entry Editing COPYLINES DEL DELSUB EDIT INDENT LIST MOVELINES REM REN SECURE Program Debugging ERRL ERRLN ERRM ERRN STEP Memory Allocation ALLOCATE COM DEALLOCATE DELSUB DIM INTEGER LOADSUB OPTION BASE REAL SCRATCH Relational Operators LIRA gt gt gt General Math of 10 8 IBASIC Keyword Summary Support FP Front Panel EK External Keyboard P Programmable _ Exceptions Front Panel deletes only 1 line Front Panel EDITs default line See Manual Valid Device Selectors 7xx 7xxxx 9 15 Front Panel executes SCRATCH A Table 10 2 Categorical List of IBASIC Keywords continued HP Instrument BASIC Keyword Support Exceptions FP Front Panel EK External Keyboard P Programmable ABS
99. fer to Chapter 8 Interfacing with the HP IB Operations Requiring Additional Programming Some operations that work well when performed from the front panel have circumstances that require special attention when used in a program This is due to two kinds of problems synchronization and active control Synchronization Timing and synchronization must always be anticipated where one event must complete before another can occur One example of this is when you need to detect a state in the instrument before issuing the next command For example suppose you want your program to perform a limit test on data but only after a sweep has been completed You can record the command to perform the limit test by pressing key sequences However to detect when the instrument has completed a sweep you must edit the program and include a routine that waits for a status register to indicate the end of the sweep Note Synchronization is only a problem with overlapped commands such as the command to trigger a sweep that is commands that don t hold off the processing of subsequent commands The analyzer adds an extra command WAI when an overlapped command is created using keystroke recording WAI prevents the analyzer from executing any further commands until the overlapped command has finished For more information on synchronization see the Synchronizing the Analyzer and a Controller chapter in the Programmer s Guide 2 6 Recording Prog
100. fic pixel location without drawing and then draw a line from the current pen location to another pixel coordinate using the DRAW statement The GCLEAR statement removes all graphics The PEN command provides an easy method of erasing lines drawn by the DRAW command When PEN 1 is issued the default state all DRAW commands act normally drawing a line with the full intensity When PEN O is issued all DRAW commands erase any pixels their path encounters Where there are no lines in the path no change is visible As an example of using the MOVE and DRAW commands the following statement moves the logical pen to a point 100 units to the right of and 150 units above the lower left corner of the display 100 MOVE 100 150 This statement then draws a line to coordinates 200 10 110 DRAW 200 10 Finally these two statements erase the previously drawn line 120 PEN O 130 DRAW 100 150 Although text and graphics appear together you can clear them separately Use CLEAR SCREEN to clear the text Use GCLEAR to clear the graphics 7 6 Graphics and Display Techniques Drawing Figures Some IBASIC keywords listed below may be used to simplify drawings and setup diagrams See also the paragraph below titled Graphics Exceptions POLYGON Draws all or part of a regular polygon RECTANGLE Draws a rectangle LABEL Produces alphanumeric labels CSIZE Sets size and aspect ratio of labels LDIR Defines the angle at which a label i
101. flg G 1 4 init Test 0 PASS Test 1 FAIL ASSIGN Rfna TO 800 Sc 1 Scales the 8711 drawing and DUT X 5 Starting X posn of 8711 plot Y 35 sl y Tab 38 Tab position for text OUTPUT ORfna SYST PRES 0DPC ENTER Rfna Opc OUTPUT Rfna DISP PROG UPP GINIT GCLEAR GESCAPE 1 3 G x WINDOW G 1 G 3 G 2 G 4 OUTPUT Rfna SENS1 STAT OFF SENS2 STAT ON OUTPUT ORfna DISP WIND2 TRAC Y RPOS 9 OUTPUT Rfna ABOR INIT CONT OFF Setup BEEP 500 1 INPUT Enter Operator s Name Name BEEP 3000 03 INPUT Enter Station Number Stat BEEP 3000 03 OUTPUT Rfna SYST DATE ENTER Rfna Year Month Day CALL Draw na Draw Network Analyzer Box 670 35 340 130 Draw text box PRINT TABXY Tab 3 Oper Name 1 15 Example Programs 11 41 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 MHZ 830 PRINT TABXY Tab 4 Station Stat 1 11 PRINT TABXY Tab 5 Date Year Month Day Meas_dev LOOP CALL Draw dut 1 CALL Scan dut Scan Cent Span Loss Lim PRINT TABXY Tab 7 Model Scan 1 6 PRINT TABXY Tab 8 Serial Scan 8 12 GOSUB Set stim DISP MEASURING THE DEVICE OUTPUT Rfna ABOR INIT2 CONT OFF INIT2 WAI OUTPUT Rfna CALC2 MARK1 ON MARK FUNC MAX OUTPUT Rfna CALC2 MARK1i Y ENTER Rfna Loss PRINT TABXY Tab 9 Loss
102. for sc ale 790 OUTPUT GHp871x DISP WIND1 TRAC Y PDIV amp VAL Vert_scale s et the scale 800 GOTO User_pause 8i0 820 User key Define softkey 7 compute statistics for mar ker 830 OUTPUT CHp871x DISP ANN MESS DATA Computing marker statisti o oi 840 OUTPUT Hp871x CALC1 MARK1 ON fensure marker is on 11 30 Example Programs 850 FOR I 1 TO 30 iread marker 30 times 860 OUTPUT GHp871ix CALC1 MARK1 Y iget marker reading 870 ENTER 0Hp871x Mrkr data I 880 NEXT 1 890 Mrkr_mean SUM Mrkr_data 30 compute mean 900 910 Mrkr_sdev 0 finitialize standard d eviation 920 Mrkr_min Mrkr_data 1 tinitialize min 930 Mrkr max Mrkr_data 1 linitialze max 940 FOR I 1 TO 30 compute std dev min max 950 Mrkr_sdev Mrkr_sdev Mrkr_data I Mrkr_mean 2 sum square s of deviation 960 Mrkr min MIN Mrkr min Mrkr data I find min 970 Mrkr max MAX Mrkr max Mrkr data I Ifind max 980 NEXT 1 990 Mrkr_sdev SQRT Mrkr_sdev 29 finish computation of std dev 1000 1010 Message Marker Statistics amp CHR 10 ist line of message 1020 Message Message amp Mean amp VAL Mrkr mean amp CHR 10 2nd line of message 1030 Message Message amp Min amp VAL Mrkr min amp CHR 10 3rd line of message 1040 Message Message amp Max amp VAL Mrkr_max amp CHR 10 4th line of message 1050 Message Message amp Standard Deviation amp VAL Mrkr_sdev Sth line of message 1060 OUTPUT
103. ftkey menus 470 Menui sets up the main menu Menu2 sets up 480 the second level menu 11 38 Example Programs 490 500 Menu BEEP 510 520 530 540 550 560 570 580 DISP MAIN MENU ON KEY i LABEL Setup 1 GOSUB Load 1 ON KEY 2 LABEL Setup 2 GOSUB Load_2 ON KEY 3 LABEL Setup 3 GOSUB Load_3 ON KEY 5 LABEL Autoscale GOSUB Autoscale ON KEY 6 LABEL Next Menu GOSUB Menu_2 RETURN 590 Menu 2 BEEP 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990 DISP MORE MENU ON KEY 1 LABEL Setup 4 GOSUB Load 4 ON KEY 2 LABEL Setup 5 GOSUB Load_5 ON KEY 3 LABEL Setup 6 GOSUB Load 6 ON KEY 5 LABEL Autoscale GOSUB Autoscale ON KEY 6 LABEL Prior Menu GOSUB Menu 1 RETURN E This subroutine automatically sets the scale and reference values of the display t Autoscale OUTPUT ORfna DISP WIND TRAC Y AUTO ONCE OUTPUT Rfna DISP WIND2 TRAC Y AUTO ONCE RETURN i These six subroutines each set up the analyzer to make a different measurement and store that setup to the instrument s internal memory 1 Save 1 OUTPUT Rfna SENS1 STAT ON WAI OUTPUT ORfna DISP ANN FREQ1 MODE SSTOP OUTPUT Rina SENS1 FREQ STAR 100 MHz STOP 400 MHz HAI OUTPUT OrRfna INIT1 WAI OUTPUT GRfna MMEM STOR STAT 1 MEM STATE1 STA
104. g HP IB Echo you can preview the SCPI mnemonic commands that will be stored in your program before you actually record them While this is not essential it can be very useful when you are in doubt as to what a particular key sequence will record or precisely when a key sequence corresponding to a mnemonic is completed Recording Programs 2 9 Running Pausing and Stopping Programs Program control running pausing and stopping an IBASIC program can be managed from the analyzer front panel using various hardkeys and softkeys These actions and their corresponding keys are described in this chapter A special case is an autostart program which runs automatically on power up if it exists on the analyzer s built in floppy disk drive or RAM disk IBASIC programs may also be remotely controlled via SCPI commands over the HP IB For information on running pausing and stopping programs from an external controller see Chapter 8 Interfacing with External Devices Starting Programs Automatically When the analyzer is powered up it automatically searches first the internal non volatile RAM disk and then the built in floppy disk drive for a program named AUTOST or AUTOST BAS When an AUTOST program is found it is automatically loaded and executed The AUTOST program can be used for anything from configuring the analyzer for specific measurements much like an internal instrument state Save Recall register to diagramming measure
105. gure 5 2 has four major key areas the typewriter keypad the numeric keypad the cursor keypad and the function keys Alphanumeric text can be entered using the typewriter and numeric keypads as needed The cursor keypad can be used to move the cursor up down a line or left right to the next character positions The function keys of the keyboard map to the softkeys on the analyzer front panel FUNCTION KEYS O 162 ARE Sea OOO ___ TYPEWRITER KEYPAD CURSOR KEYPAD NUMERIC KEYPAD i i i H Zooo ESOO 0900 CM INAP DO NDOJD E OOOO ii con lt seseeesee REC O SE Sloco E a es ca rm em A O AAA e maT a e Figure 5 2 The PC Keyboard Connect the keyboard to the rear panel DIN connector of the analyzer with the power off the power and load the IBASIC program to be edited Select the menu and use the cursor keypad to position the cursor within the program for ns The Page Up and Page Down keys on the keyboard scroll through the e quickly and easily Developing Programs 5 5 Inserting Lines Insert one or more program lines above an existing line by placing the cursor on that line and pressing on the keyboard This key combination functions as a toggle to turn insert mode on and of As an example assume you want to insert some lines between two adjacent program lines numbered 90 and 100 Place line 100 in the current line position and press inser
106. he current line is exited either when the line s execution is finished or when the line is exited by a call to a user defined function The service routine in general must perform the following operations Determine which device s are requesting service Determine what action is requested Clear the SRQ line Perform the requested action Re enable interrupts Return to the former task if applicable o oF WN Ha Note The ON INTR statement must always precede the ENABLE INTR statement when the two are used in the same program Servicing SRQ Interrupts The SRQ is a level sensitive interrupt in other words if an SRQ is present momentarily but does not remain long enough to be sensed by the controller an interrupt will not be generated The level sensitive nature of the SRQ line also has further implications which are described in the following paragraphs Example Assume that only one device is currently on the bus The following service routine serially polls the device requesting service and clears the interrupt request In this case the controller does not have to determine which device was requesting service because only one device is present Since only service request interrupts are enabled in IBASIC the type of interrupt does not need to be determined either The service is performed and the SRQ event is re enabled to generate subsequent interrupts 500 Serv_rtn Ser_poll SPOLL Device 510 ENTER Dev
107. his program into the 871x 170 2 Press the BEGIN hardkey and the User Begin on OFF softkey 180 3 The User Begin function is now enabled which runs this 190 program This program re defines the softkeys displayed 200 whenever the BEGIN hardkey is pressed The functions 210 performed by these softkeys are defined by this 220 program Note that all front panel keys in the analyzer are 230 active as if there were no program running 240 4 Use the instrument as you normally would However when 250 the BEGIN hardkey is pressed the menu defined 260 by this program will be displayed instead of the usual 270 BEGIN softkeys until the User Begin ON off softkey 280 is pressed turning off the User Begin mode 290 300 bakoa e A a a a k 310 Initialize 320 330 User _begin ASSIGN Hp871ix TO 800 REQUIRED first line for User Begin program 340 350 REAL Vert scale Mrkr data 30 Mrkr mean Mrkr sdev 360 REAL Mrkr max Mrkr_min I 370 DIM Message 124 380 390 Fm mmr me a to emana mm mm 400 Write the softkey labels Maximum label length 20character s 410 420 OUTPUT QHp87ix DISP MENUZ2 KEYS WAT iclear all label 8 430 OUTPUT GHp871ix DISP MENU2 KEY1 Save State 1 WAI 440 OUTPUT CHp871x DISP MENU2 KEY2 Recall State 1 WAI Example Programs 11 29 450 OUTPUT GHp87ix DISP MENU2 KEY3 Save State 2 WAI 460 OUTPUT Hp87ix DISP MENU2 K
108. his program is designed to run on an external controller It demonstrates how the external controller and HP IBASIC can work together The program downloads an IBASIC program to the HP 871X f and runs it twice After each run two program variables are read from the analyzer and displayed TOOL O RS O O A o a Mi A do a a e O DA A A O A A ee ee e A E MO A Initialize the variables for the interface select code and the HP IB address of the HP 871X Scode 7 Address 16 Na Scode 100 Address Prepare the analyzer for remote operation clear the analyzer s input output queues the display and scratch any program in the buffer CLEAR Na CLEAR SCREEN OUTPUT Na PROG DEL ALL Download the program as an indefinite block length data transfer terminate the data transfer by sending a carriage return and EOI DISP Downloading the program ASSIGN Prog TO Na OUTPUT Prog PROG DEF 0 OUTPUT Prog 10 COM INTEGER Times run Test 10 OUTPUT Prog 20 Times run Times run 1 OUTPUT Prog 30 IF Times run 1 THEN Test PASS OUTPUT Prog 40 IF Times run 2 THEN Test FAIL OUTPUT Prog 50 FOR I 1 TO 20 OUTPUT Prog 60 BEEP OUTPUT Prog 70 NEXT I OUTPUT Prog 80 END OUTPUT Prog CHR 10 END Initialize interrupt registers clear the status byte the service request enable register the standard event enable register and preset the other status registers 11 16 Example Programs 500 510 520 5
109. ice Value 520 PRINT Value 530 ENABLE INTR 7 Use previous mask 540 RETURN The IEEE standard states that when an interrupting device is serially polled it is to stop interrupting until a new condition occurs or the same condition occurs again To clear the SRQ line a serial poll must be performed on the device By performing this serial poll the controller acknowledges to the device that it has seen the request for service and is responding The device then removes its request for service by releasing SRQ If the SRQ line had not been released the controller would have branched to the service routine immediately upon re enabling interrupts on this interface This is due to the level sensitive nature of the SRQ interrupt Also note that once an interrupt is sensed and logged the interface cannot generate another interrupt until the first interrupt is serviced The controller disables all subsequent interrupts from an interface until a pending interrupt is serviced Interfacing with External Devices 8 9 Conducting a Serial Poll A sequential poll of individual devices on the bus is known as a Serial Poll A byte of device specific status is returned in response to a Serial Poll This byte is called the Status Byte message and depending on the device may indicate an overload a request for service or a printer being out of paper The particular response of each device depends on the device The SPOLL function performs
110. ine feed ASCII 1480 10 are needed at the end of the string 1490 1500 a a pa a pa as e a 1510 INTEGER Length 1520 Length LEN String 1530 FOR 1 1 TO Length 1540 WRITEIO 15 0 NUMCString 1 1 1550 NEXT I 1560 IF Crlf 1 THEN 1570 WRITEIO 15 0 10 1580 WRITEIO 15 0 13 1590 END IF 1600 SUBEND 11 22 Example Programs TRICTRL External controller with local IBASIC controllers Lf sm q a a q e a a q em 20 30 BASIC program TRICTRL Three controller operation 40 One controller Two IBASIC instruments 50 I 60 This program is designed to run on an external 70 controller It demonstrates how the external 80 controller and multiple instruments running IBASIC 90 programs can be synchronized to work together 100 110 Run this program on an external controller Two HP871x 120 are needed Set one HP87ix to address 16 Set the 130 other to address 18 Connect HP IB cables between 140 the controller and the two analyzers 150 160 The program downloads IBASIC programs to two HP 871Xs 170 1 then runs each program Pressing softkey 1 on either 180 instrument triggers a sweep Pressing softkey 3 on 190 either instrument will trigger an SRQ The controller 200 will poll the instrument over the HP IB bus determine 210 which instrument has requested service log the SRQ 220 and release the instrument for more measurements by 230 setting the IBASIC variable Ctrl_flag O Pm mn ae m
111. ing at the top left corner of the current partition and continues until the display line of the partition is reached The screen then scrolls up to allow additional lines to be printed Figure 7 3 shows the different display partitions and the location of text printed to them Note that causing the screen to scroll does not affect any graphics displayed on the screen since text and graphics are written to different planes of the display All partitions have a width of 58 characters The height varies according to partition Both upper and lower partitions contain 10 lines while the full partition contains 22 lines This information is useful if you are using the PRINT TABXY statement to position text For example the following program segment prints a message in the center of the full partition assuming it has been allocated earlier in the program 100 Maxlines 22 110 Tabx 58 LEN This is CENTERED text 2 120 PRINT TABXY Tabx Maxlines 2 This is CENTERED text 1 4 58 1 This is CENTERED text 44 22 EEN 58 22 l Figure 7 3 Printing to a display partition 7 4 Graphics and Display Techniques A useful technique to get text onto the screen quickly is to write your display message to a long string using the OUTPUT statement and then print the string to the screen For large amounts of text this speeds up screen display time considerably The following program segment demonstrates this 60 DIM Temp 100 Big 2
112. inued HP Instrument BASIC Keyword Support Exceptions FP Front Panel EK External Keyboard P Programmable IPLOT EK P MOVE EK P PDIR EK P PEN EK P O erase I draw PENUP EK P PIVOT EK P PLOT EK P POLYGON EK P FILL not supported Scaling diffs POLYLINE EK P RECTANGLE EK P FILL not supported Scaling diffs RPLOT EK P FILL not supported Scaling diffs Graphics Axis and Labeling AXES EK P CSIZE EK P FRAME EK P GRID EK P LABEL EK P LDIR EK P LORG EK P HP IB Control ABORT EK P Select Code 7 8 9 15 CLEAR EK P Select Code 7 8 9 15 LOCAL EK P Select Code 7 only LOCAL LOCKOUT EK P Select Code 7 only PASS CONTROL EK P Select Code 7 or 8 REMOTE EK P Select Code 7 SPOLL EK P Select Code 7 TRIGGER EK P Select Code 7 Clock and Calendar DATE EK P DATES EK P SET TIME foo FP EK P SET TIMEDATE foo EK P TIME EK P TIMES EK P IBASIC Keyword Summary 10 13 Table 10 2 Categorical List of IBASIC Keywords continued HP Instrument BASIC Keyword Support Exceptions FP Front Panel EK External r Keyboard General Device Input Output ASSIGN BEEP CRT ENTER CRT ENTER 1 not supported DATA DISP ENTER IMAGE INPUT See Manual KBD Returns select code 2 OUTPUT Select Code 1 7 8 PRINT PRINTER IS PRT READ READIO Select Code 9 or 15 See manual RESTORE TAB TABXYO USING WID
113. is ability To designate the analyzer as the system controller use the softkey in the SYSTEM OPTIONS The system controller is generally designated before running a program and should not be changed under program control An exception to this is when an IBASIC program is running on the analyzer s internal controller If the IBASIC program controls other HP IB devices the analyzer must be designated as the system controller A SCPI mnemonic SYST COMM GPIB CONT lt ON OFF gt can be used to make the analyzer the system controller Program execution should be carefully synchronized using the Operation Complete command 0PC and waiting for a reply before any OUTPUT 7xx command is sent Refer to the Synchronizing the Analyzer and a Controller chapter in the Programmer s Guide for more information on the 0PC command ment Using the Serial and Parallel Ports The analyzer has two additional ports that can be used to control peripherals material handlers or other devices Active control of the HP IB interface is not needed when these ports are being used These ports are a parallel port and a serial port for use with hardcopy output to non HP IB printers and plotters In addition to the serial and parallel ports there are also two BNC connectors on the rear panel of the analyzer These connectors provide access using TTL signal levels to two programmable bits a Limit Test TTL bit indicates the results of a pass
114. ition on the next highest numbered line is pressed when the cursor is on the last program line the line text is removed but the line number remains with the cursor resting in the first column of line This puts the editor in insert mode on the last line of the program see Inserting Lines To get out of insert mode simply move the cursor up one line Pressing will NOT remove a subprogram line with the SUB keyword in it unless all program lines belonging to that subprogram have already been deleted A block of program lines can be deleted by executing the command DELETE x y from an IBASIC command line where x is the first line number in the block and y is the last line number Wh ing an external keyboard there are other keys that perform the same function as the softkey These are in the cursor keypad and the function key E3 that maps to the oftkey in the edit menu 5 8 Developing Programs Recalling a Deleted Line The last line that was deleted using is buffered in the analyzer To recall this softkey or on an external keyboard Press line press the to restore the line to the es Renumbering Copying Moving and Indenting Lines If you want to change the line number of an edited program line simply move the cursor to the line number field and enter the line number you want Changing the line number causes a copy operation not ove Therefore if you only want to move the
115. its own cursor The current program line the line containing the cursor always appears as two lines on the screen allowing you to enter up to 108 characters if needed All other lines have only their first 51 characters displayed excluding line numbers Each line has a numeric field in the first 6 columns in which program line numbers are right justified Although program lines are automatically numbered by the editor you can edit the current line number to copy or move it to a different location in the program The range of line numbers is from 1 to 32767 To end an editing session press the Developing Programs 5 3 The IBASIC Editor Softkeys The editor has two sets of softkey menus the Edit keys and the Character Entry keys The edit menu is activated when you press The menu box above the softkeys shows the label Edit The edit menu provides the following softkeys ED E ES ED E5 ES 6D E The character entry menu is described in the Editing from the Front Panel section of this chapter Recording into an Existing Program One way to enter lines into your program is to use the keystroke recording capabilities of IBASIC To record measurement sequences or other front panel operations into your program follow the procedure described below 1 Activate the editor by pressing 2 Use the step keys on the analyzer or the cursor keypad on an external keyboard to position the cursor on the line
116. ler operation 11 16 eo REPORT Using the parallel port de Ss ae he Jaca tee OM Bees 11 19 e TRICTRL External controller with local IBASIC controllers 11 23 ie UPLOAD Upload program from 11 27 USERBEG Set up user defined oftkeys de Satay xd os os 11 29 L USERBEG1 The default program Semi pas a 11 32 a USERBEG2 Fast recall of instrument states a 11 34 USER BIT Using the USER bit ee 11 36 A USERKEYS Customized softkeys 11 38 be BARCODE Using Bar Code Reader 28 11 41 j STATS Using Bar Code Reader oona aa a a a a e 11 46 ES DATALOG Using Bar Code Reader 11 50 Index Contents 4 Figures 4 1 The SAVE RECALL Screen 2 dE cio EE Os ee 4 2 5 1 The HP IBASIC Program Editor 006 4 ee we ares 5 3 5 2 The PC Keyboard BR do Sha cee Ox we de a ee TE Stet A 5 5 5 3 The IBASIC display partition a a the A las ugh geese A f 5 11 7 1 Display partitions on the analyzer 2 a a e a a a a a 7 1 7 2 Using INPUT with no display partition a 7 3 7 3 Printing to a display partition 4 6 6 6 aa ds ee es 7 4 7 4 Pixel Dimensions with Available Display Partitions ES oe mt SO BAS i 7 6 7 5 HELP program output O E ale ct a SS St he
117. ly inserted into the existing program Refer to Chapter 5 Developing Programs for a description of how to record into existing programs program can then be run by pressin Recording Programs 2 1 gone prem IBASIC Programs and the HP IB Buffer Recorded programs work by sending HP IB commands to the instrument These commands are queued into an input buffer by the instrument An IBASIC program generally outputs the commands much faster than the instrument can execute them This often causes the program to complete while the instrument is still executing commands in the input buffer The instrument continues processing these commands until the buffer is empty This may have some side effects if you are not aware of this interaction For example it may not be immediately obvious that the program has actually finished since the instrument is still functioning remotely This could cause confusion if you try to pause and continue a program that has actually completed You can clear the buffer from within your program by inserting the statement CLEAR 8 at the beginning of your program see Chapter 5 for information on editing programs Another side effect of the speed with which the analyzer processes commands is that it is possible for a command to execute before a previous command has completed execution The most common example of this is a data query that executes before a measurement sweep is complete This interaction
118. m mm am e e q q q e q q e mm mm 250 1 260 Initialize the variables for the interface select 270 code and the HP IB address of the HP 871X 280 290 Scode 7 300 Address1 16 310 Address2 18 320 Nai Scode 100 Address1 330 Na2 Scode 100 Address2 340 Dev counti 0 350 Dev count2 0 360 370 Prepare the analyzer for remote operation clear 380 the analyzer s input output queues and scratch i 1 390 any program in the buffer 400 1 410 ABORT 7 420 CLEAR Nal 430 CLEAR Na2 440 CLEAR SCREEN 450 460 OUTPUT Nal SYST PRES x0PC Preset analyzer 1 470 ENTER Nai 0Opc 480 OUTPUT Na2 SYST PRES 0PC Preset analyzer 2 490 ENTER Na2 0pc Example Programs 11 23 500 610 OUTPUT Nai PROG STAT STOP Stop all programs 520 REMOTE Nat 530 OUTPUT Nai PROG DEL ALL Scratch the programs 540 OUTPUT Na2 PROG STAT STOP 550 REMOTE Na2 560 OUTPUT Na2 PROG DEL ALL 570 580 Initialize interrupt registers clear the status byte 590 the service request enable register the standard event 600 enable register and preset the other status registers 610 620 OUTPUT Nai CLS 630 OUTPUT Nal SRE 0 640 OUTPUT Nai ESE O 650 OUTPUT Nal STAT PRES DPC 660 ENTER Nai Opc 670 680 OUTPUT Na2 CLS 690 OUTPUT Na2 SRE 0 700 OUTPUT Na2 ESE 0 710 OUTPUT Na2 STAT PRES 0PC 720 ENTER Na2 0pc 730 740 ON INTR 7 2 GOSUB User sra i Define the SRQ service ro uti
119. ment setups using graphics commands as in a guided measurement sequence Refer to Chapter 4 Saving and Recalling Programs for information on using the analyzer to name programs before they are saved Running and Continuing a Program To run an BASIC program that is ahs hy in the analyzer program buffer press the softkey in the an external keyboard in either of two ways enu The RUN command can also be executed from Press the function key that corresponds to the oftkey see note below m Type RUN on a command line and press Enter A command line is always available when an IBASIC display is partitioned See Chapter 5 Developing Programs for information about display partitions You can also activate a command line from an external keyboard with no IBASIC displays partitioned by pressing the key on your external keyboard Running Pausing and Stopping Programs 3 1 rem Note When an external keyboard is connected its function keys Fi through always represent the analyzer s eight softkeys The analyzer s hardkeys are each represented by a combination of or and one of the function keys Refer to the analyzer s User s Guide for more information on the external keyboard interface The menu can be accessed from an external keyboard using for and for IBASIC A keyboard template showing which keys to press for specific analyzer functions was supplied with your analyzer HP part number 08712 80004
120. n ABORT THEN Model ABORT SUBEXIT END IF DISP Scan lt lt is INVALID Try again BEEP 1500 2 WAIT 1 END LOOP BEEP 3000 03 Serial Scan 8 12 READ Cent Span Loss Data format Center Span Loss F1 DATA 175 300 2 175 MHz BPF F2 DATA 200 100 1 200 MHz BPF F3 DATA 134 30 22 134 MHz SAW BPF SUBEND i SUB Store_ram Model Serial COM Hpib Rfna 11 52 Example Programs 1470 1480 1490 1500 1510 1520 1530 1540 1550 1560 1570 1580 1590 1600 1610 1620 1630 1640 1650 1660 1670 1680 1690 1700 1710 1720 1730 1740 1750 1760 1770 1780 1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 Id Model 3 4 amp _ amp Serial 2 unique chars Ser ALLOCATE Err 80 DISABLE REPEAT OUTPUT Rfna CLS OUTPUT Rina MMEM MSIS MEM OUTPUT Rfna MMEM STOR TRAC CH2FDATA amp Id ae WAI OUTPUT Rfina SYST ERR ENTER Rfna Err SELECT VAL Err CASE 0 No Problem CASE 254 Internal Mem full CALL Store disk CASE 257 dupl file name OUTPUT Rfna MMEM DEL amp Td amp WAI ERASE OLD CASE ELSE BEEP 2000 5 DISP Err INPUT Fix Press ENTER Ans END SELECT UNTIL VAL Err 0 ENABLE SUBEND SUB Store_disk H COM Hpib Rfna ALLOCATE Err 80 BEEP 700 1 DISP Standby Transferring internal files to disk LOOP OUTPUT Rfna CLS OUTPUT Rina MMEM COPY INT WAI OUTPUT Rfna SY
121. n refer to Automating Measurements in the User s Guide IBASIC programs have the ability to allocate portions of the instruments display for program output including text and graphics This section provides a description of the various programming techniques used to do both Any of the three measurement display areas called display partitions can be used by an IBASIC program These partitions are shown in Figure 7 1 chan 1 Trenshission Log Mag 10 0 dy Ref 0 00 8 Pchan 2 Aeflastion Log Mag 6 0 dar Raf 0 00 2 t i an Cha NE cin poe ms uma O a ce gt ERA a EE i 30 q E AD N Conter 175 000 MHz Span 300 000 hira 40 Pehar 2 Refioction Los Mao S 0 9Bs Ref 0 00 8 AT E om a mi ELENA t JN HE E 3 80 Is a RA E Vd ay i woe ai Al man MA Canter 475 000 wz Span 300 000 Maz Center 175 000 Maz Sean 300 000 Mz Figure 7 1 Display partitions on the analyzer Using the Display Partitions Many IBASIC commands such as PRINT DISP CLEAR SCREEN MOVE DRAW and GCLEAR require a display as an output device These commands output data to the screen by writing to a screen buffer Since IBASIC programs share all the hardware resources with the instrument the display must be shared for instrument and program use Graphics and Display Techniques 7 1 In order to view this output buffer a portion of the display must be released from the instrument W i ing you can do this manually
122. n can be a device selector number example OUTPUT 800 or a name representing a number called a path name example OUTPUT Rfna The data can take several forms but in recorded IBASIC programs it is a string containing commands for the instrument a mnemonic Although the OUTPUT command is very flexible it is used only one way when generated by a recording The following represents a typical OUTPUT command from a recording session OUTPUT Rfna SOUR1 POW 10 dBm Notice that the OUTPUT command is followed by a name representing a device selector Rfna followed by a semicolon and the data SOUR1 POW 10 dBm The ASSIGN Statement The destination in an OUTPUT statement specifies the address of the device In recorded programs this address is represented by the I O path name Rfna The following line appears in all recorded programs before any OUTPUT statements ASSIGN Rfna to 800 The ASSIGN statement allows you to substitute an I O path name a variable preceded by the symbol for a device selector number Therefore after the above ASSIGN statement the program line OUTPUT ORfna SOURi POW 10 dBm is equivalent to OUTPUT 800 SOUR1 POW 10 dBm The device selector 800 specifies the host instrument as the destination of any data sent by the OUTPUT command The program communicates with the analyzer via select code 8 the internal HP IB interface which is only used for communication between IBASIC programs and the an
123. n external keyboard allows you to allocate a partition of the analyzer s display to be used by your program or alternately to return any allocated partition to the analyzer The analyzer display is divided into two small partition areas Upper and Lower or one large area Full which encompasses both the Upper and Lower partition areas Ali screen output commands such as PRINT and DRAW require that you allocate a partition of the screen in order to view the results of the command This can be performed in your program or interactively using the oftkey Allocating display partitions can be accomplished from within your program using the SCPI mnemonic DISP PROG and specifying the parameter UPPER LOWER or FULL For example the statement OUTPUT 800 DISP PROG FULL allocates the entire display corresponding to selecting F An IBASIC display partition cannot occupy the same location as a measurement channel display When an IBASIC display is partitioned it limits the amount of the CRT available to simultaneously show measurement data Table 5 1 shows the menu softkeys their corresponding SCPI mnemonics their functions and the a that can be viewed when the display partition is allocated Table 5 1 IBASIC Display Partitions SOFTKEY SCPI MNEMONIC ALLOCATES VISIBLE DATA DISPlay PROGram OFF No Display Channels 1 and 2 DISPlay PROGram UPPer Upper Channel men Channel 2 only DISPlay PROGram LOWer Lower Channel Area Ch
124. nd_block OUTPUT Prog CHR 10 END ASSIGN Basic_prog TO DISP Transfer complete LOCAL Na STOP This subroutine is the error handler for opening the file if the file won t open it returns to get a new file name E No file BEEP DISP CAN T OPEN Filename GOTO Get filename RETURN i This subroutine is the error handler for the data transfer When the end of file is reached it generates an error Execution is resumed I outside of the transfer loop E End file IF ERRN 59 THEN GOTO End block DISP ERRM occured during data transfer STOP RETURN END 11 12 Example Programs DRAW871X Drawing setup diagrams 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 IBASIC program DRAW871X Drawing setup diagrams 1 i This program draws the HP 871X network analyzer and a device under test to the full screen IBASIC display partition The drawing can be scaled to fit the application Setting the scale factor to 1 0 creates a drawing of about 400 pixels wide 1 2 screen width and 100 pixels high 1 3 screen height t ome o cr cn 000 00 00 00 ae oue O O O 0 O nt eh mm t a Setup an I O path name for the internal bus and declare variables l INTEGER X0 YO REAL Sc
125. nd_line 1 610 CALL Send line 1 620 CALL Send line _ 0 630 CALL Send line _ 1 640 CALL Send line 1 650 660 Select the font to use writing the device 670 specifications send the information 680 690 CALL Send _line Slant 1 700 CALL Send line 1 710 CALL Send_line PASS BAND MHZ 3 dB 60 5 1 720 CALL Send_line 1 730 CALL Send_line 20 dB 90 5 1 740 CALL Send_line 1 750 CALL Send_line 40 dB 120 5 1 760 CALL Send_line 1 770 CALL Send_line SWR PASSBAND typical 1 8 1 1 780 CALL Send_line 1 790 CALL Send line SiHR STOPBAND typical 1 8 1 1 800 CALL Send_line 1 810 CALL Send_line Cost per unit 36 95 1 820 830 t Select the font to use for the performance data 840 title send the title 850 860 CALL Send_line Block 1 870 CALL Send line v0 880 CALL Send_line Transmission Characterist ics 1 890 1 900 Return the display to the analyzer 910 920 OUTPUT Rfna DISP PROG OFF 930 940 Setup the device measurement This example 950 measures the transmission response of a 11 20 Example Programs 960 970 980 990 1000 1010 bandpass filter at 175 MHz E OUTPUT Rfna DISP ANN FREQ1 MODE SSTOP OUTPUT Rfna SENS1 FREQ STAR 10 MHz STOP 400 MHz WAI OUTPUT Rina DISP WIND1 TRAC Y PDIV 20 dB RLEV 50 dB RPOS 5 OUTPUT CRfna DISP ANN TITL ON TITL1 DATA HP 8711 RF NETWORK ANALYZER 1020 1030 1040
126. ne 750 GOSUB Usermask l Enable the user SRG 760 ENABLE INTR 7 2 770 780 Download the program as an indefinite block length 790 data transfer terminate the data transfer by 800 sending a carriage return and EOI 810 820 DISP Downloading the programs 830 ASSIGN Prog TO Nai 840 GOSUB Dnld 850 ASSIGN Prog TO Na2 860 GOSUB Dnld 870 880 Run the programs 890 DISP Running the programs 900 OUTPUT Nai PROG STAT RUN 0PC 910 ENTER Nai Opc 920 930 OUTPUT Na2 PROG STAT RUN 0PC 940 ENTER Na2 0pc 950 960 BEEP 970 DISP Waiting for srq 980 990 LOCAL Nal 11 24 Example Programs 1000 LOCAL Na2 1010 Idle GOTO Idle 1020 STOP 1030 Enable SRQs to occur when the user srq bit is set 1040 Usermask i 1050 OUTPUT Nai ESE 64 x SRE 32 1060 OUTPUT Nai x0PC 1070 ENTER Na1 0Opc 1080 OUTPUT Na2 ESE 64 SRE 32 1090 OUTPUT Na2 x0PC 1100 ENTER Na2 0pc 1110 RETURN 1120 1130 User_srq This routine is called to service SRQs 1140 Stb SPOLL Nai Poll the first instrument 1150 IF BINAND Stb 64 0 THEN 1160 OUTPUT Na xESR 1170 ENTER Nai Stat 1180 Dev_counti Dev_counti i 1190 PRINT Inst Nai Dev Dev_counti 1200 OUTPUT Nai PROG NUMB Ctlr flag 0 Clear the IBASIC f lag 1210 LOCAL Nal 1220 ELSE 1230 1240 Stb SPOLL Na2 Poll the second instrument 1250 IF BINAND Stb 64 0 THEN 1260 OUTPUT Na2 ESR 1270 ENTER Na2 Stat 12
127. ocuments A list of HP sales and service offices can be found in the Specifications chapter of your User s Guide m Information on the IBASIC language including keyword descriptions error messages interface specifics and programming techniques is available in the HP Instrument BASIC Users Handbook m Information on operating the analyzer is available in the analyzer s User s Guide m Information on programming the analyzer including example programs is available in the analyzer s Programmer s Guide m Information on the analyzer s HP IB command mnemonics is also available in the analyzer s Programmer s Guide m Information on the SCPI Standard Commands for Programmable Instruments programming language is available in A Beginners Guide to SCPI m Information on using the HP IB is available in the Tutorial Description of the Hewlett Packard Interface Bus Introduction 1 1 peor Overview of HP Instrument BASIC When installed in your analyzer HP Instrument BASIC IBASIC can be used for a wide range of applications from simple recording and playback of measurement sequences to remote control of other instruments IBASIC is a complete language with over 200 keywords IBASIC is a complete system controller residing inside your analyzer It communicates with the analyzer via HP IB commands over an internal interface bus select code 8 It can also communicate with other instruments computers and peripherals u
128. of this program 80 END 90 SUB Read fdata INTEGER Chan REAL A Read real formatted data 100 SUB Cmplx_mag REAL Cdata Mag INTEGER Sz Mag of complex array 110 SUB Cmplx_arg REAL Cdata Arg INTEGER Sz Arg of complex array LAO cites Note Built in subprograms cannot be edited since they are compiled and built into the firmware However any subprogram can be deleted by the DELSUB keyword support in revision 2 IBASIC RUNTIME Built in subprogram Errors Improper or inconsistent dimensions found which specify array size Using the wrong number of subscripts when referencing an array element Wrong type or number of parameters An improper parameter list for a machine resident function Avoiding Multiple Loads of Subprograms To avoid multiple LOADS of a subprogram which has already been loaded the following example may be used 10 ON ERROR GOTO 30 20 DELSUB Read_fdata 30 LOADSUB Read_fdata FROM XFER MEM O 0 40 OFF ERROR 9 4 Using Subprograms 10 IBASIC Keyword Summary This chapter summarizes the HP Instrument BASIC keyword implementation in the analyzer Table 10 1 is alphabetical It indicates the type of support for each entry and notes exceptions if any Exceptions are major differences between the keywords descriptions in the HP Instrument BASIC Language Reference and their implementation in the analyzer When differences are too extensive to be summarized see the HP Instrument BA
129. ograms 1420 1430 1440 1450 1460 1470 1480 BEEP 1500 2 WAIT 1 END LOOP BEEP 3000 03 Serial Scan 8 12 READ Cent Span Loss Data format Center Span Loss 1490 Fi DATA 175 50 2 175 MHz BPF 1500 F2 DATA 200 12 1 200 MHz BPF 1510 F3 DATA 134 15 22 134 MHz SAW BPF 1520 SUBEND Example Programs 11 49 DATALOG Using Bar Code Reader 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 O O O O A A O O O O O A A a a a A A a a a m a a c an n A A o a IBASIC program DATALOG Logs trace data This HP 8711 IBASIC program uses a barcode reader Stores ASCII trace data in internal memory until full Then copies stored files to disc Expects to see BARCODE with the following format Model Number 6 char space Serial Number 5 char Valid Models BPF175 BPF200 SAWi34 REV A 01 00 930615 JVV mm O O O A O O O ME O O O A O O O O A a lo o a kk o a e a e e a Init COM Hpib Rfna IF POS SYSTEM SYSTEM 1D HP 871 THEN ASSIGN Rfna TO 800 ELSE ASSIGN Rfna TO 716 ABORT 7 CLEAR 716 END IF OUTPUT Rfna SYST PRES 0PC ENTER Rfna 0pc OUTPUT ORfna DISP PROG UPP GINIT GCLEAR GOSUB Warning May be deleted OUTPUT Rfna DISP ANN MESS STAT 0 OUTPUT ORfna SENS1 STAT OFF SENS2 STAT ON OU
130. ords continued HP IBASIC Keyword Support Exceptions FP Front Panel EK External Keyboard P Programmable DROUND EK P DUMP ALPHA none Use HPIB command DVAL FP EK P DVALS FP EK P EDIT EFP EK Front Panel EDITs default line ELSE ENABLE ENABLE INTR END END IF END LOOP END SELECT END WHILE ENTER ERRL ERRLN ERRMS ERRN EXIT IF EXOR Interface Select Code 7 or 8 E PAD Oe Oe a a g FN FNEND FOR NEXT P FRACT EK P FRAME EK P GCLEAR EK P GET FP EK P GINIT EK P GOSUB GOTO GRID IDRAW IF THEN IBASIC Keyword Summary 10 3 Table 10 1 Alphabetical List of IBASIC Keywords continued HP IBASIC Keyword Support Exceptions FP Front Panel EK External Keyboard P Programmable NTEGER IPLOT IVAL IVALS KBD LABEL LDIR LEN LET LGT LIST LOAD LOADSUB LOADSUB ALL FROM LOCAL LOCAL LOCKOUT LOG LOOP LORG LWCS MAT MAT REORDER MAT REORDER BY MAT foo CSU M bar MAT foo IDN MAT foo IN V bar MAT foo RSUM bar 10 4 IBASIC Keyword Summary P EK P EK FP EK P P EK P P EK P FP EK P FP EK P P EK P EK P FP EK P EK P EK P EK P FP EK P FP EK P FP EK P EK P EK P EK P P EK P FP EK P EK P EK P EK P EK P EK P EK P EK P See Manual Returns select code 2 Valid Device Selectors Select Code 7 only Select Code 7 only Table 10 1 Alphabetical List of BASIC Keywords continued HP IBASIC Keyword Support Exceptions FP Front Panel
131. own programs from the ground up This chapter describes the operation of the following keys in the menu and any softkeys found in their underlying menus places you in the editor where you can make changes to your program on a line by line menu allows you to select what part if any of the CRT display is available BASIC An IBASIC display partition provides you with a command line you can use to execute IBASIC commands from an external keyboard It also provides an area for viewing graphics and program output allows you to Clear Programs from the program buffer allocate memory for program use or secure program lines Developing Programs 5 1 External Editors In addition to using the built in IBASIC editor programs can be developed in the following external environments a HP BASIC editors m ASCII word processors The external editing environments provide many advantages the most notable being speed and flexibility Precautions must be taken when using ASCII word processors because they do not provide the syntax checking available when using the internal editor After editing a program in an external environment the best practice is to GET the program from an IBASIC command line using the following procedure instead of using the keys described in Chapter 4 1 Partition an IBASIC display as described later in this chapter 2 Use an external keyboard to enter the command GET PROGO 4 this command lo
132. p MHZ 840 OUTPUT Rfna DISP WIND2 TRAC Y RLEV amp Loss amp DB 0PC 850 ENTER Rfna Opc 860 RETURN 870 880 Warning 890 BEEP 3000 3 900 PRINT TABXY 15 4 WARNING 910 PRINT This program will initialize the INTERNAL memory 920 PRINT Ali internally saved files will be lost 930 PRINT 940 PRINT Do you wish to continue y N 950 INPUT Continue Ans 960 CLEAR SCREEN Example Programs 11 51 970 980 990 1000 1010 1020 1030 1040 1050 1060 1070 1080 1090 1100 1110 IF UPC Ans 1 1 Y THEN RETURN END 1 H ESHHHH SUBPROGRAMS 444 i Scan_dut SUB Scan_dut Model Serial Cent Span Loss ALLOCATE Scan 80 LOOP Invalid 0 Scan ABORT Scan BPF175 12345 These 3 lines for demo only S VAL RND 1 E 9 1 Generates random S N Scan 8 12 S 3 7 Delete all to enable abort BEEP 500 05 INPUT Connect scan DUT or leave blank to exit Scan ISCAN BARCODE 1120 1130 1140 1150 1160 1170 1180 1190 1200 1210 1220 1230 1240 1250 1260 1270 1280 1290 1300 1310 1320 1330 1340 1350 1360 1370 1380 1390 1400 1410 1420 1430 1440 1450 1460 IF LEN Scan lt 12 THEN Valid device needs 12 char invalid 1 ELSE Model Scan 1 6 SELECT UPC TRIM Mode1 CASE BPF175 BPF177 RESTORE F1 CASE BPF200 RESTORE F2 CASE SAW134 RESTORE F3 CASE ELSE Invalid 1 END SELECT END IF EXIT IF NOT Invalid IF POS UPC Sca
133. p the original in a safe place This prevents unau users from listing your program 5 12 Developing Programs 6 Debugging Programs The process of creating programs usually involves correcting errors You can minimize these errors by using keystroke recording for measurements and other front panel sequences and by writing structured well designed programs Of course bugs can and do appear in even the best designed programs and IBASIC contains some features that can help you to track them down Some IBASIC capabilities useful for program debugging are simple and used properly can be very helpful Some of these capabilities are m RUN or CONTINUE your program STEP through your program executing one line at a time Display the last error encountered in your program Examine program variables By examining the values assigned to variables at various places in the program you can get a much better idea of what is really happening in your program By inserting a PAUSE statement in your program you can pause the program at any line and then examine the values of variables at that point in the program You can then press in the menu to resume operation to the next PAUSE tement or the program end S These capabilities can be used together to effectively examine the program s operation and solve your particular problems Note Most of the debugging techniques described in this chapter make use of an exte
134. pause 11 34 Example Programs 490 500 510 520 530 540 550 560 570 580 590 User key5 Define softkey 5 here GOTO User_pause t User key6 Define softkey 6 here GOTO User pause t User_key7 Define softkey 7 here GOTO User pause END Example Programs 11 35 USER BIT Using the USER bit 10 DS sc a a arn in R E a Sa ee 20 30 IBASIC program USER_BIT Using the USER bit 40 50 i This program reads and writes to the USER bit 60 IBASIC s graphics commands are used to draw the 70 USER bit value to the display 80 i 90 pq aa q ip oo ep S E a S Stn a en ee 100 110 Assign an I O path name to the internal bus and 120 initialize variables 130 140 ASSIGN Rfna TO 800 150 INTEGER Beeper Count 160 Count 0 170 Beeper 0 180 190 Preset the analyzer setup measurement and display 200 parameters for a measurement and put the analyzer 210 in Trigger HOLD mode 220 230 QUTPUT ORfna SYST PRES WAL 240 OUTPUT CRfna DISP ANN FREQ1 MODE SSTOP 250 OUTPUT Rfna SENS1 FREQ STAR 100 MHz STOP 400 MHz WAI 260 OUTPUT Rfna DISP WIND1i TRAC Y PDIV 20 dB RLEV 60 dB RPOS 5 H 3 270 OUTPUT Rfna SENS1 SWE POIN 101 TIME 1 s WAI 280 OUTPUT Rfna ABOR INIT1 CONT OFF WAI 290 300 Wait for all the setup operations to be complete 310 before continuing the program 320 330 OUTPUT Rfna 0PC 340 ENTER Rfna Qpc 350 360 Alloc
135. pting to plot a square 55 units on each side this would instead produce a rectangle A similar scaling is done with the POLYGON command If a POLYGON 80 command is given the analyzer will produce a circle with a horizontal radius of 80 but with a vertical radius of 44 7 GDU s even so it will appear circular The following is a simple rule to remember with GINIT values or the equivalent WINDOW ratio on the analyzer The analyzer will produce circles with the POLYGON POLYLINE command and squares with the RECTANGLE command assuming equal x y in all cases However the radius or width in GDU s will be accurate only in the horizontal axis and will be 1 79 times LESS in the vertical axis Try this simple program to demonstrate the above examples Un comment line 60 and comment out line 50 to show the difference in the two GRID statements The rectangle may be hard to see since it will partially lie on a gridline its lower left corner is at the centered dot 10 ASSIGN Hp8711 TO 800 20 OUTPUT Hp8711 DISP PROG FULL 30 GINIT 40 GCLEAR 50 GRID 10 10 makes rectangular grids 60 GRID 10 1 79 10 makes square grids Graphics and Display Techniques 7 9 70 MOVE 120 50 move to center 80 POLYGON i i make small dot 90 RECTANGLE 55 55 makes square 100 POLYGON 80 110 END Labeling with Different Partitions The LABEL command may be used to label graphs however the following should be noted Labels that may be of the
136. r message is displayed on the CRT and the line is commented and checked for syntax again If it still causes an error for example the line may be too long the line is discarded Any lines that currently exist in the memory buffer will remain unless they are overwritten by downloaded program lines This makes it easy to edit lines in an external controller and then download only the edited lines into an existing program If you want to completely overwrite the current program in memory you must delete the program first This can be done remotely using the extended command PROG DEL ALL see line 350 Interfacing with External Devices 8 17 Uploading The mnemonic PROG DEF is used to upload a program from the program buffer The entire program is then returned as a definite length arbitrary block A definite length block starts with the character followed by a single digit defining the number of following digits to read as the block length Refer to Chapter 11 Example Programs for a listing of the example program UPLOAD which demonstrates an uploading routine run on an external controller The subroutine Openfile lines 570 through 770 creates an ASCII file to save the uploaded program to The number of 256 byte records deciared in the CREATE ASCII statement line 730 is simply the file size declared in the definite block header divided by 256 Line 720 accommodates any remainder in this calculation by increasing the file size
137. r trace data between the instrument and the IBASIC program m MATH file adds high speed support for complex array operations m RPG file adds fast RPG rotary pulse generator front panel knob response for markers LOADSUB lt Subprogram name gt FROM lt Filename MEM 0 0 gt loads the named subprogram from the built in file FILENAME LOADSUB ALL FROM lt Filename MEM 0 0 gt loads all the subprograms in the named built in file FILENAME See the following table for subprogram names within the files XFER MATH and RPG 9 2 Using Subprograms Built in Subprogram Description Filenames found in MEM 0 0 Subprogram Name parameter list Read fdata INTEGER Chan REAL A Read real formatted data Read fmem INTEGER Chan REAL A Read reai formatted mem Read cdata INTEGER Chan REAL A Read complex data Read cmem INTEGER Chan REAL A Read complex memory Write fdata INTEGER Chan REAL A Write real formatted data Write fmem INTEGER Chan REAL A Write real formatted mem Write cdata INTEGER Chan REAL A Write complex data Write cmem INTEGER Chan REAL A Write complex memory Read rdata INTEGER Chan Input REAL A Read raw complex data Write rdata INTEGER Chan Input REAL A Write raw complex data Read_corr INTEGER Chan N REAL A Read complex error coef
138. rams Active Control of the HP IB Interface Some operations require the analyzer to be the active controller on the external HP IB bus This generally means that the analyzer must be the System Controller or active control must be passed to it from an external controller if one is connected When an IBASIC program begins running however the instruments active control of the external interface is automatically passed to the program so active control must be passed back to the analyzer before these operations can be performed These operations include all of the following actions when they are directed to HP IB devices Note that active control of the HP IB interface is only a problem if that bus is being used Hardcopy output to devices on the serial or parallel ports do not require control of the HP IB SAVE RECALL SAVE RECALL SAVE RECALL or 1 to external disk from external disk to external disk You can keystroke record any of these operations but you will not be able to successfully run the program that is generated You will need to enter the program lines necessary to first pass control to the analyzer and then wait for control to be passed back to the program See the Passing and Regaining Control section of Chapter 8 for an example of passing control to the analyzer Mnemonics With No Corresponding Front Panel Operation Several of the analyzer SCPI mnemonics for the instrument perform oper
139. rnal keyboard The analyzer and the IBASIC editor work with PC AT compatible keyboards US only that have a standard DIN interface Non US language keyboards will not cause an error they simply will not be recognized as different from the US keyboard A keyboard can be ordered with the analyzer by ordering option 1CL Debugging Programs 6 1 Setting Breakpoints A common method of debugging a program involves the use of breakpoints A breakpoint causes the program to stop before executing a specified line so that you can examine the program state at that point In IBASIC this can be accomplished by inserting PAUSE statements in the program code Note that PAUSE is one of the IBASIC keywords included in the editor s label window described in Chapter 5 Developing Programs When the program is then run you can use the command line to check or change variable values Execution of the program can be resumed in one of two ways m Press on an external keyboard to execute next program line Press Continue F2 on an external keyboard to continue the program until the next PAUSE STOP or END statement is encountered Examining Variables To examine a variable it is necessai accomplished by pressing the when a program is running or by inserting a PAUSE statement in your program to pause the program Pausing the program can be A command line becomes active when an IBASIC program is paused or stopped and an IBASIC
140. s m Control other instruments and peripherals a Create interactive prompts m Simplify keystrokes with the key a Keystroke record programs Run applications IBASIC also works in conjunction with an external controller which can download and run programs query variables and respond to Service Requests SRQs 1 2 Introduction Typographical Conventions The following conventions are used in this manual when referring to various parts of the HP Instrument BASIC and analyzer operation environments The name of a hardkey on the front panel of the analyzer This notation is also used to represent keys on an external keyboard connected to the analyzer s DIN interface The label of a softkey Upper case selection in a softkey indicates the state AFTER the softkey is pressed A series of hardkeys and softkeys represents the path to a given softkey or menu Angle brackets are used to signify a syntax element in a statement Introduction 1 3 Recording Programs IBASIC programs for the analyzer can be created from the instrument s front panel using an external PC keyboard option 1CL on an HP controller running HP BASIC or on a workstation or PC using a text editor Keystroke recording described in this chapter is ideal for creating simple programs or measurement sequences for instrument control If a program requires data processing decision making or prompts for an operator or graphical setup diagrams
141. s Handbook VIEWPORT Does not create isotropic units that are physically square Does not soft clip the display area CLIP The analyzer does not support graphics clipping SHOW Does not create isotropic units POLYLINE POLYGON RECTANGLE RPLOT The analyzer does not support the FILL or EDGE options Also see next paragraph GRID RECTANGLE POLYGON and POLYLINE scaling differences When the display is initialized using GINIT the display will be scaled to a height of 100 GDU s and a width of 245 GDU s The ratio is 2 453 and the pixel height to width ratio is fixed at 1 79 non square pixels This can cause scaling difficulties if not well understood and will produce different results than is seen on HP BASIC computers or workstations The following examples should help clarify some scaling issues After GINIT performing a GRID 10 10 command will produce a grid array 10 high and 24 5 wide The individual grids will be rectangular taller than wide To produce square grids perform a GRID 10 1 79 10 command This will produce square grids 10 high and just under 14 wide If you move the starting point to approximate center MOVE 120 50 and request a square 55 wide by 55 high RECTANGLE 55 55 the analyzer will automatically scale this so as to appear square The width will be 55 GDU s but the height will be 55 1 79 or 30 7 units high This will appear square and is quite a different result than would be obtained by attem
142. s from within the editor Deleting Characters oftkey removes the character under the cursor and moves all characters to the left one place Repeatedly pressing D will cause text to the right of the cursor to be removed one character at a time Th oftkey functions the same in both the line number and program statement fields When used in the line number field it deletes only line numbers to the right of the cursor not program statement characters external keyboard there are other keys that perform the same function as the softkey These are the key in the cursor keypad and the function key that maps to the appropriate softkey for the edit menu or for the character entry menu Another way to remove text on a line is by backspacing Pressing the hardkey or the softkey on the front panel of the analyzer removes the letter to the left of the cursor and moves the cursor and all characters to the right of the cursor one space to the left The function key or the key on the typewriter keypad of the external keyboard perform the same function When the cursor is on a line number using backspace simply moves the cursor back one position without deleting the number Deleting Lines The program line softkey allows you to remove the current program line When the current isappears all subsequent lines in the display move up one line but are not renumbered The cursor maintains its column relative pos
143. s received from the keyboard or a bar code has been successfully scanned by the bar code scanner The following three programs designed to run on the analyzer s internal IBASIC controller demonstrate the use of bar code scanner applications as well as other useful applications While a bar code scanner is useful in demonstrating these programs it is not required one can simply press ENTER and the program will input default values Sample bar codes are provided for experimentation at the end of this chapter The three programs are as follows BARCODE This program demonstrates basic bar code scanning to select one of three filter setups depending upon what is scanned RF stimulus is set and response limits are read set and tested for each device Depending upon result the program prints PASS or FAIL on the CRT Most useful in this program is a subprogram to draw an analyzer representation on the CRT This code can be re used in any user application that may require a guided setup The analyzer image and DUT image can be both scaled to any size and offset in the X or Y axis as required This is an excellent program to familiarize yourself with graphic routines using IBASIC graphics commands STATS This program first reads a DUT bar code and sets the RF stimulus accordingly It then displays a running average of all similar devices and constantly updates the display with both the current DUT and the current average of all devic
144. s to be drawn LORG Defines the relative origin of a label These keywords are used in the BARCODE program example listed in Chapter 11 Example Programs and on the IBASIC Example Programs Disk The keywords appear in the subprograms Box Circle and Label described below 1620 1621 1622 1623 1624 Draw a box in the active IBASIC partition Xpos Ypos specify the CENTER of the box Xsize Ysize are width and height dimensions Sc is a scaling factor for the figure being drawn 1 79 is a correction factor used by the 8711 only 1630 Box SUB Box Xpos Ypos Xsize Ysize 1640 1650 1660 1670 1681 1682 1683 1684 COM Scale Sc INTEGER X Y MOVE X Xpos Xsize 2 Sc Y Ypos Ysize 2 Sc RECTANGLE Xsize Sc Ysize Sc 1 79 18711 Pixel H W Ratio SUBEND Draw a circle in the active IBASIC partition Xpos Ypos specify the center of the circle Radius is the size of the circle Sc is a scaling factor for the figure being drawn 1690 Circle SUB Circle Xpos Ypos Radius 1700 1710 1720 1730 1890 1891 1892 1893 1894 1895 1896 COM Scale Sc INTEGER X Y MOVE X Xpos Sc Y Ypos Sc POLYGON Radius Sc 16 16 SUBEND Creates a label in the active IBASIC partition Text is the alphanumeric label Xpos Ypos is the position of the label Lorg references the label orientation to Xpos Ypos Ldr is the angle in which the label will be drawn Pen is pen number 0 erases
145. se operations simultaneously One method of passing data between the two controllers is to set the instrument as Talker Listener and run a program on the external controller that starts the IBASIC program and passes control to it The IBASIC program can then output data to and enter data from the external controller Two programs that are listed in Chapter 11 Example Programs demonstrate how to transfer data between an internal program and an external controller program The first program DATA_EXT is run from an external controller It assumes that a disk containing the corresponding IBASIC program DATA_INT is in the disk drive of the analyzer It remotely loads the IBASIC program starts it and then transfers active control to it The IBASIC program DATA INT with active control of the interface queries the external program for name of the drive to catalog and then outputs the catalogued string to the external program and passes active control back After receiving the catalog data the external program goes into a loop line 1080 executing a command that continues to generate an error until the host computer again becomes active controller when control is passed back Interfacing with External Devices 8 15 Setting and Querying Variables Another means of transferring data between an internal and an external program involves the ability to set and query internal program variables from an external program The PROGram SELected
146. sing the external HP IB interface select code 7 or the serial select code 9 or parallel select code 15 I O ports Note The analyzer can also be controlled by an external controller It has a factory default external HP IB address of 16 When using IBASIC to control other instruments no other device should use the same address The external HP IB address can keys under the SYST CONM GPIB ADDR nged using either the front panel _ menu or the SCPI mnemonic Using HP Instrument BASIC You need not be proficient in a programming language to successfully use HP Instrument BASIC TBASIC In keystroke recording mode IBASIC automatically builds an executable program by capturing measurement sequences as they are performed With little or no editing of these program lines you can immediately put your program to work controlling and automating your analyzer IBASIC s programming interface includes an editor Softkeys are available to allow you to run or continue a program or configure the display The IBASIC command set is a subset of the command set of HP BASIC In fact IBASIC programs can be run on any HP BASIC workstation with very few changes When an external PC keyboard with a DIN connector is connected to the analyzer the IBASIC user interface emulates the user interface of the HP BASIC The PC keyboard can be used for command entry editing and program inputs Using IBASIC you can m Create on screen graphic
147. splay partition Tip When SCPI graphics commands are used to write directly to a measurement window they write to the static graphics plane the same plane where the graticule is drawn There is no sweep to sweep speed penalty once the graphics have been drawn Graphics and Display Techniques 7 11 Table 7 2 SCPI Graphics Commands SCPI COMMAND FORM DESCRIPTION DISPlay WINDow 1 21 10 GRAPhics command only Draw a circle of the specified Y axis radius CIRCle lt radius gt centered at the current pen location radius is in pixels DISPlay WINDow 1 2 10 GRAPhics command only Clear the user graphics and graphics buffer a CLEar for the specified window DISPlay WINDow 112110 GRAPhics Set the color of the user graphics pen COLor lt num gt choose from 0 for erase 1 for bright and 2 for dim DISPlay WINDow 1 2 10 GRAPhics command only Draw a line from the current pen position DRAW lt x gt lt y gt to the specified new pen position x and y are the new absolute X and Y coordinates in pixeis DISPlay WINDow 1 2 10 GRAPhics command only Draw a label with the lower left corner at LABel lt string gt the current pen location DISPlay WINDow 1 2 10 GRAPhics CHAR Select the user graphics label font choose LABel FONT lt font gt from SMALI HSMall NORMal HNORmal BOLD EBOLA SLANt HSLant DISPlay WINDow 112 10 GRAPhics NRI NR1 Move the pen to the specified new pen MOVE l
148. st instrument is set as System Controller and the program has passed control to either the host instrument or another device on the external interface In both of these cases the program cannot perform activities of any kind on the external interface Note An IBASIC program cannot act as a device on the external bus To communicate with an external controller the IBASIC program must be active controller and the external controller must act as the device see the Interfacing with an External Controller section that follows Interfacing with an External Controller So far we have discussed the ability to interface IBASIC programs with a network of external devices using the HP IB The idea of including an external controller in that network and interfacing an IBASIC program with a program running in that computer presents some new possibilities External controller programs can interface with IBASIC programs referred to as internal programs over HP IB in two basic ways First the two programs can pass data back and forth using simple OUTPUT and ENTER statements This requires coordination of both the internal and external programs and also requires that the internal program be the active controller during the interaction To get an internal program and an external program to work together successfully you should have a good understanding of the HP IB model presented earlier in this chapter Second the external program can m
149. t The program display opens and a new line number 91 appears between line 90 and line 100 Enter the inserted line and another inserted line number 92 will appear If after continuing to enter lines in this manner the inserted line number increments to 100 then the current line 100 will be renumbered one higher to accommodate the inserted line To stop inserting lines either press again or use the cursor keys to move to another program line Make sure you have entered any changes to your final inserted line with the key before exiting the insert mode Remember any changes you have made to the current line will be lost if you move the cursor to another line without pressing Enter Editing Lines Use the cursor keypad on the keyboard to move around the program for editing The left and right arrow keys move within a program line while the up and down arrow keys move between lines The alphanumeric keypad on the keyboard can be used for entering or editing text Another key that is useful is the key which deletes the character highlighted by the cursor When you finish editing or changing a program line store it into the program by pressing on the keyboard The computer checks the line for syntax errors and converts letter case to the required form for names and keywords IBASIC commands If no errors are detected it then stores the line in the program buffer Entering Program Lines When you finish entering or changing
150. t x gt lt y gt position x and y are the new absolute X and Y coordinates in pixels DISPlay WINDow i 2 10 GRAPhics command only Draw a rectangle of the specified size with RECTangle lt xsize gt lt ysize gt lower left corner at the current pen position xsize and ysize are the width and height in pixels For more information about the analyzer s user graphics commands refer to Chapter 7 of the Programmer s Guide Refer also to the example program titled GRAPHICS in Chapter 11 of the Programmer s Guide 7 12 Graphics and Display Techniques Interfacing with External Devices This section describes the techniques necessary for programming the HP IB interface It describes how this interface works and how to use it to control or interface with systems containing various HP IB devices It also describes how to interface with external devices using the serial and parallel interfaces The HP IB interface is Hewlett Packard s implementation of the IEEE 488 1 Digital Interface for Programmable Instrumentation The acronym HP IB stands for Hewlett Packard Interface Bus and is often referred to as the bus The interface is easy to use and allows great flexibility in communicating data and control information between an HP Instrument BASIC program and external devices IBASIC is an HP IB instrument controller residing inside an instrument It uses the instrument s HP IB interface for external communica
151. terface at select code 7 with a primary address of 22 use device selector 722 Secondary HP IB addressing is interfacing with External Devices 8 1 also supported for those devices requiring it These devices will have at least 5 digit service selection such as 72201 Since the analyzer is the only device on the internal interface its primary address on that interface is arbitrary and the instrument will respond to any primary address with a select code equal to 8 e g 800 811 822 etc Note Each device s address must be unique The analyzer is shipped from the factory with a primary address of 16 No other device on the bus should use the same address The procedure for setting the address of an HP IB device is given in the installation manual for each device To set the address of the analyzer use the softkeys in the menu or the SCPI mnemonic SYST COMM GPIB ADDR Moving Data Through the HP IB Data is output and entered into the program through the HP IB with the OUTPUT and ENTER statements respectively The only difference between the OUTPUT and ENTER statements for the HP IB and those for other interfaces is the addressing information within HP IB device selectors The following examples show several different syntax styles which you can use 100 Hpib 7 110 Device_addr 22 120 Device selector Hpib 100 Device _addr 130 E 140 OUTPUT Device selector FIR7T2T3 150 ENTER Device selector Reading 320 A
152. the internal non volatile RAM disk and then the built in floppy disk drive for a program named AUTOST or AUTOST BAS When an AUTOST program is found it is automatically loaded and executed Recalling a Program To recall a program file from mass storage to the program buffer use the menu to catalog the disk Select the desired mass storage device or disk use the arrow keys to highlight the file and pres The recalled program file is entered into the program buffer one line at a time and checked for syntax errors Lines with syntax errors are commented out and the IBASIC syntax error is displayed briefly in an error message and written to the CRT h To view error messages logged to the CRT use the allocate a screen partition for IBASIC Note Any program recalled to the program buffer using the menu will overwrite the current contents of the program buffer Be sure to save your current program before recalling another program from disk Saving and Recalling Programs 4 3 5 Developing Programs For many applications you can use keystroke recording to create and run programs without needing to alter the program code that is generated However with some knowledge of the IBASIC language and the program development capabilities of the analyzer you can significantly increase the power of your recorded programs or create your
153. these must be entered using another technique Alternative methods of program development may be used to supplement keystroke recording and create more sophisticated programs These methods are covered in Chapter 5 Developing Programs Keystroke Recording Of all the available methods of creating IBASIC programs keystroke recording is by far the easiest It requires only a couple of steps to set up and run and can be accomplished with very little knowledge of programming What is Keystroke Recording Keystroke recording is a way to automatically create IBASIC measu programs To enable recording simply press SYSTEM OPTIONS Then press the normal key sequences of a measurement on the analyzer SYSTEM OPTIONS to terminate the recording The resulting n the SYSTEM OPTIONS IBASIC programs communicate with the analyzer over an internal bus They use the same set of commands used by external controllers for remote operation of the instrument Keystroke recording works by finding the bus command called a SCPI mnemonic that fits each operation performed from the front panel and then building a program line to perform that operation when executed All program lines built by keystroke recording are entered into the analyzer s program buffer If the buffer contains no existing lines a complete executable program will be created If there is a program in the buffer when recording is turned on the recorded statements are simp
154. ting Up and Enabling SRQ Interrupts na OR 8 8 Servicing SRQ Interrupts A AR A A 8 9 PAM IN E RN SE 8 9 Conducting a Serial Poll re Sl do d bah et 8 10 Passing and Regaining Control te be hp SS SRD E MEIRA x 8 10 The IBASIC HP IB Model 0 280084 Slide ae He 8 11 External and Internal Busses 2 1 1 1 wee ee ee 8 11 Service Request Indicators ee ee a 8 11 IBASIC as the Active Controller E Cep da 8 12 Passing Active Control to the Instrument 2 E 8 12 IBASIC as a Non Active Controller TEE 8 13 Interfacing with an External Controller oaa aaa aa fai Bou 8 13 Synchronizing IBASIC with an External Controller e 8 14 Using OUTPUT and ENTER statements 2 E 8 14 Using Status information 4 2 078 Ca 8 14 Design Rules e ea A A E E EFI 8 15 Transferring Data Between Programs 2 a eS 8 15 Using OUTPUT and ENTER statements e Ve 8 15 Setting and Querying Variables ee a ORAIS 8 16 Downloading and Uploading Programs 2 Ro k 8 17 Downloading asse Go aa a Me aina we cae E ee PVE 8 17 Uploading a mb dvs ES EE ADE SEO ere a e E qe 8 18 Contents 3 9 Using Subprograms a User Created Subprograms s 6 1 6 ee ee ca 9 1 Built In High Speed Subprograms 2 1 ee 9 2 P Example Programs 9 a
155. tion and an internal HP IB interface to communicate with the instrument This unique arrangement presents a few differences between IBASIC s implementation of HP IB control and HP BASIC controllers A description of the interaction of IBASIC with the host instrument and the external HP IB interface is given in the section entitled The IBASIC HP IB Model later in this chapter Communication with Devices HP IB Device Selectors Since the HP IB allows several devices to be interconnected each device must be uniquely identified Specifying the select code of the HP IB interface such as 7 or 8 to which a device is connected is not enough to uniquely identify each specific device on the bus Each device on the bus has a primary address that identifies it This address can be set by the user It must be unique to allow individual access of each device When a particular HP IB device is to be accessed it must be identified with both its interface select code and its bus address The interface select code is the first part of an HP IB device selector IBASIC programs run inside an instrument and communicate with it over an internal bus interface select code 8 IBASIC programs can also communicate with external devices using the instrument s HP IB interface select code 7 The second part of an HP IB device selector is the device s primary address an integer in the range of 0 through 30 For example to specify the device on the in
156. to cause an operation that will generate a mnemonic The transitional sequences between actual instrument events are not recordable For example pressing the key displays the scale numeric entry but nothing is recorded until you enter a value for the scale parameter Any default states you setup prior to recording or encounter while recording and consequently do not select are not recorded Use of step keys are not recommended because the results may depend on the function s step size which may change as other parameters change Note Instrument states that are not specifically selected or changed are not recorded Since these default states are not recorded you must either actively select them to generate a program statement or make sure the instrument is in the same exact state when the program is run as when it was recorded This is discussed further in the Avoiding Recording Errors section of this chapter Recording Programs 2 5 HP Instrument BASIC Operations Some softkeys under the SYSTEM OPTIONS menu cannot be recorded Operations on programs such as and SAVE RECALL do not record You can however record display partitions and all other save and recall operations not having to do with IBASIC programs Although IBASIC operations cannot be recorded many do have corresponding SCPI mnemonics that allow an external controller to control and communicate with internal IBASIC programs For more information re
157. using or termination of a program will cause the Program Running bit in the Device Status register to go low This can be used to generate an external SRQ For an example see the DUALCTLR example in Chapter 11 Example Programs Interfacing with External Devices 8 11 iBASIC as the Active Controller The IBASIC program is always the active controller on the internal interface select code 8 When a program starts running the HP IB controller status of the instrument is automatically passed to the program For example if the instrument is set as System Controller a program running in the instrument automatically becomes system controller and active controlier on the external bus and the instrument relinquishes active control When the program stops the instrument regains active control Also if an instrument set as Talker Listener is passed control from an external controller an k 2 y program running in the instrument becomes active controller on the external interface Thus there are two cases where a program running in an instrument can be active controller on the external interface w When the host instrument is set as System Controller and the program has not passed control E When the host instrument is set as Talker Listener and the instrument has been passed control from an external controller Passing Active Control to the Instrument The only way that the analyzer can gain active control of the external interface
158. using the E softkey menu To do this within a running program requires sending a command to the analyzer both to borrow a part of the display and again to return it for the instrument s use This process is called the allocation of display partitions Manual allocation of display partitions is described in Chapter 5 Developing Programs Table 7 1 below includes a summary of the available partitions their locations and the SCPI mnemonic used to select each partition Table 7 1 BASIC Display Partitions SCPI MNEMONIC Tone DISPlay PROGram OFF DISPlay PROGram FULL DISPlay PROGram UPPer DISPlay PROGram LOWer Allocating Display Partitions To request a display partition from the analyzer for use by an BASIC program send the instrument the corresponding SCPI mnemonic DISP PROG UPPer allocates the upper partition DISP PROG LOWer allocates the lower partition and DISP PROG FULL allocates the full screen partition For example to print a message to the upper partition area you might use a program segment like this 30 ASSIGN 6Hp8711 TO 800 40 OUTPUT Hp8711 DISP PROG UPPer 50 CLEAR SCREEN 60 PRINT This is the upper partition To be sure that you are not writing to a partition that has not yet been assigned you should include a WAIT statement or even better add a SCPI query command followed by an ENTER statement to synchronize the program with the instrument The previous example might th
159. xternal controller is idle each instrument can freely send various SCPI commands Each instrument may ask for service by triggering an SRQ Once a SRQ has been triggered the instrument must remain in an idle loop until the external controller indicates it is done _ servicing the SRQ This is done using the program variable Ctlr_flag The flag is cleared when the external controller is done and has returned to its idle loop 11 2 Example Programs UPLOAD Upload program from analyzer This program uploads the IBASIC program in the analyzer s program buffer to an ASCII file on the external controller s current mass storage device USERBEG Set up user defined This program creates two instrument states set the marker to maximum set the scale div and compute some measurement statistics at the marker USERBEG1 The default The default program is created automatically when there is no IBASIC program installed In this default program softkey 3 is defined to be the marker to max function softkey 4 prompts the user for a title and also enables the clock You may edit this program to change the functions you need USERBEG2 Fast recall of instrument states This example program demonstrates the fast recall of previously defined instrument states The instrument states SETUP1 SETUP2 and SETUP3 must have been previously saved to the analyzer s internal non volatile RAM disk Load the program into the analyzer
160. yboard P Programmable INITIALIZE FP EK P LOAD FP EK P LOADSUB FP EK P LOADSUB ALL FROM FP EK P MSI FP EK P MSI may be altered by the instr When save recalling programs to from DOS subdirectories PURGE RE SAVE RENAME RE STORE SAVE STORE Program Control CALL FP EK P FP EK P FPEK P FPEK P FP EK P FPEK P EK P CASE CASE ELSE CONT Line number support from EK only DEF FN ELSE END END IF ND LOOP END SELECT END WHILE EXIT IF FN FNEND POR NEXT GOSUB GOTO IF THEN LOOP PAUSE REPEAT UNTIL a Mz o Ala a a da TV mi IBASIC Keyword Summary 10 11 Table 10 2 Categorical List of IBASIC Keywords continued HP Instrument BASIC Keyword RETURN RUN SELECT STOP SUB SUBEND SUBEXIT SYSTEMS WAIT WHILE Event Initiated Branching DISABLE DISABLE INTR ENABLE ENABLE INTR ON OFF CYCLE ON OFF ERROR ONJOFF INTR ONJOFF KEY ONJOFF TIMEOUT SYSTEM PRIORITY Graphics Control GCLEAR GINIT RATIO SHOW VIEWPORT WHERE WINDOW Graphics Plotting DRAW IDRAW IMOVE 10 12 IBASIC Keyword Summary Support Exceptions FP Front Panel EK External Keyboard P Programmable P EK FP P P FP P Interface Select Code 7 a 8 Interface Select Code 7 or 8 Must not precede an ON INTR statement Interface Select Code 7 or 8 Must precede ENABLE INTR statement Key selectors 1 through 7 Interface Select Code 7 or 8 Table 10 2 Categorical List of IBASIC Keywords cont

Download Pdf Manuals

image

Related Search

Related Contents

TriStar  Metrologic Instruments IS6520 User's Manual  取扱説明書  exacqVision IP Camera Quickstart Guide  平成26年度 放射線取扱業務従事者再教育  DISPOSITIFS DE MANUTENTION PERSONNALISÉS  NEC X464UN    Ford 6000cd User's Manual  

Copyright © All rights reserved.
Failed to retrieve file