10 !RE-SAVE "LSTG_83480" !HP Basic for HP-IB interface, rev 2.0 20 !******************************************************************* 30 !* This program reads and returns the learn string from and to a * 40 !* 83480 Oscilloscope. * 50 !* ******************** * 60 !* ******************** * 70 !* Begin MAIN PROGRAM * 80 !******************************************************************* 90 COM /Io/ @Scope,Hpib 100 Readme !Description of the program 110 Initscope !initialize interface and scope 120 Length=FNStsize !find setup string size. 130 Get_learnstr(Length) !save 3 configurations on disk 140 Recall_learnstr(Length) !select & recall 1 of 3 setups 150 PRINT 160 BEEP 15,1 170 PRINT "program done" 180 !*************************************************************** 190 !* End of Main Programs * 200 !*************************************************************** 210 END 220 !*************************************************************** 230 !* Begin Sub Programs * 240 !*************************************************************** 250 SUB Initscope 260 !********************************************************** 270 !* This sub program initializes the INTERFACE AND SCOPE * 280 !********************************************************** 290 COM /Io/ @Scope,Hpib 300 Hpib=7 310 Scope=7 320 ASSIGN @Scope TO Hpib*100+Scope !scope address 330 CLEAR Hpib !clear HPIB interface 340 OUTPUT @Scope;"*RST" !set scope to default config 350 OUTPUT @Scope;":AUTOSCALE" !AUTOSCALE 360 OUTPUT @Scope;":SYST:HEAD OFF" 370 OUTPUT @Scope;"*OPC?" !wait for scope to finish auto 380 ENTER @Scope;Opc 390 SUBEND 400 ! 410 SUB Readme 420 !********************************************************************* 430 !* This sub program displays a message about the program for the * 440 !* user. * 450 !********************************************************************* 460 CLEAR SCREEN 470 PRINT "This sample program will prompt the user to set up the" 480 PRINT "scope in three different configurations and will store" 490 PRINT "them to the computer disk. Any of the three configurations" 500 PRINT "may then be recalled from the disk and sent to the scope" 510 PRINT 520 PRINT "The program assumes that the system is configured such that:" 530 PRINT " HP-IB interface is at address 7" 540 PRINT " scope is at address 7" 550 PRINT " a signal is attached to channel 1" 560 PRINT 570 PRINT "If these addresses are incorrect, break program and set addresses" 580 PRINT "as needed in the Initialize in the ASSIGN statements." 590 PRINT 600 PRINT "Press CONTINUE when ready to start. Scope will first autoscale" 610 PRINT "on signal on channel 1 and will then prompt for user to setup" 620 PRINT "scope as desired before saving configurations in computer." 630 PRINT 640 PAUSE 650 CLEAR SCREEN 660 SUBEND 670 ! 680 SUB Get_learnstr(Length) 690 !************************************************************** 700 !* This sub program will get the learn string from the 83480 * 710 !* and place it in SET$. Then it will create a BDAT file * 720 !* called "JSETUPS" which holds 3 records. If this file is * 730 !* already created it will be PURGED! * 740 !************************************************************** 750 COM /Io/ @Scope,Hpib 760 ON ERROR CALL Ertrap 770 CREATE BDAT "JSETUPS",3,Length !create 3 files for 3 different 780 !setups. 790 ALLOCATE Set$[Length] !temp variable to hold string. 800 ASSIGN @Path TO "JSETUPS" !open file 810 FOR I=1 TO 3 820 CLEAR SCREEN 830 LOCAL @Scope 840 PRINT "PLEASE HAVE SETUP #";I;" READY AND PRESS RETURN" 850 INPUT A$ 860 OUTPUT @Scope;":SYSTEM:SETUP?" !query learnstring from scope 870 ENTER @Scope USING "-K";Set$ !read learn string from scope 880 IF Set$[1;1]="#" THEN 890 OUTPUT @Path,I;Set$ !store setup string to disk 900 ELSE 910 CLEAR SCREEN 920 PRINT "Received bad data. No setup saved." 930 END IF 940 NEXT I 950 ASSIGN @Path TO * !close file 960 DEALLOCATE Set$ 970 SUBEND 980 ! 990 SUB Ertrap 1000 !*********************************************************** 1010 !* The program will branch to this Error Trap if the * 1020 !* ON ERROR is ON and an error occurs. It reset the * 1030 !* ON ERROR to OFF the return to where it was called. * 1040 !*********************************************************** 1050 IF ERRN=54 THEN ! Error 54 is Duplicate File Name 1060 PURGE "JSETUPS" 1070 OFF ERROR 1080 ELSE 1090 CLEAR SCREEN 1100 PRINT ERRM$ 1110 BEEP 1120 PAUSE 1130 END IF 1140 SUBEND 1150 ! 1160 SUB Recall_learnstr(Length) 1170 ! 1180 ! This sub program lets the user select which of the 3 setups 1190 ! that have been stored on the disk in "JSETUPS1, 2, or 3 to 1200 ! use to setup the scope. It will loop until the user selects 1210 ! (E) to exit. 1220 ! 1230 COM /Io/ @Scope,Hpib 1240 ASSIGN @Path TO "JSETUPS" !open file 1250 ALLOCATE Set$[Length] !create temp variable. 1260 Done=0 1270 REPEAT 1280 CLEAR SCREEN 1290 PRINT "Please enter (1) to recall setup 1" 1300 PRINT " (2) to recall setup 2" 1310 PRINT " (3) to recall setup 3" 1320 PRINT " (E) to exit" 1330 INPUT A$ 1340 SELECT UPC$(A$) 1350 CASE "1","2","3" 1360 ENTER @Path,VAL(A$);Set$ !read data from disk. 1370 IF Set$[1;1]="#" THEN !Have good data. 1380 ! 1390 ! Add command header to setup string and send entire string to scope. 1400 ! 1410 OUTPUT @Scope USING "#,K";":SYSTEM:SETUP ";Set$ 1420 ELSE 1430 CLEAR SCREEN 1440 PRINT "Received bad data, no string entered." 1450 END IF 1460 CASE "E" 1470 Done=1 1480 END SELECT 1490 UNTIL Done 1500 DEALLOCATE Set$ 1510 ASSIGN @Path TO * 1520 SUBEND 1530 ! 1540 DEF FNStsize 1550 ! 1560 !The setup string size can vary, depending on operating system 1570 !revision. Must read the header to determine the proper lengths. 1580 !The format of the data is #NX...X. Then I 1590 !add 5 for the bdat file management headers. 1600 ! 1610 COM /Io/ @Scope,Hpib 1620 DIM Psign$[1] 1630 INTEGER Length,Cnt,L 1640 ON TIMEOUT Hpib,3 CALL Tout 1650 !Set the bus timeout so if there is no/bad data, can't find 1660 !the # sign, we will stop and let the operator know. 1670 OUTPUT @Scope;":SYSTEM:SETUP?" 1680 !Query scope for the setup string. 1690 Cnt=0 1700 REPEAT 1710 ENTER @Scope USING "#,A";Psign$ 1720 !Enter a character at a time until find the # sign. It 1730 !indicates the beginning of the block header. 1740 Cnt=Cnt+1 1750 !FN must keep track of the number of characters before the # 1760 !sign for cases where the system headers are ON. 1770 UNTIL Psign$="#" 1780 ENTER @Scope USING "#,A";Psign$ 1790 !Next character tells the number of digits in the header. 1800 ENTER @Scope USING "#,"&Psign$&"D";Length 1810 !Length is the number of data values to follow before the NL. 1820 ALLOCATE Temp$[Length+1] 1830 ENTER @Scope USING "#,-K";Temp$ 1840 L=7+Cnt+VAL(Psign$)+Length 1850 DEALLOCATE Temp$ 1860 RETURN L 1870 FNEND 1880 ! 1890 SUB Tout 1900 !Branching here says that the HPIB bus was idle for 3 seconds. 1910 !This would be caused by reaching the end of the setup data without 1920 !finding a # sign. 1930 CLEAR SCREEN 1940 PRINT "Bad Data, query aborted." 1950 BEEP 1960 PAUSE 1970 SUBEND