4284all-bas
10 !LCR-4284A.bas 4284A, 2017/03/10 20 OPTION BASE 1 30 INTEGER I,Count,Btn 40 DIM Msg$[50],Id$[50],String$[50] 50 CLEAR SCREEN 60 GOSUB Fileopen 70 GOSUB Setup 80 GOSUB Funcselect 90 GOSUB Typeselect 100 OUTPUT @Lcr;"TRIG:SOUR INT" 110 STOP 120 Setup: ! 130 ASSIGN @Lcr TO 717 140 REMOTE @Lcr 150 !OUTPUT @Lcr;"*RST" 160 OUTPUT @Lcr;"*CLS" 170 OUTPUT @Lcr;"*ESE 60" 180 OUTPUT @Lcr;"*SRE 32" 190 ON INTR 7 CALL Errors 200 ENABLE INTR 7;2 210 OUTPUT @Lcr;"*IDN?" 220 ENTER @Lcr;Id$ 230 PRINT Id$ 240 OUTPUT @Lcr;"TRIG:SOUR BUS" 250 OUTPUT @Lcr;"ABORT;:INIT" 260 RETURN 270 Fileopen: ! 280 DIM Filename$[20],Dhms$[8] 290 Time$=TIME$(TIMEDATE) 300 Date$=DATE$(TIMEDATE) 310 Dhms$=Date$[1;2]&Time$[1;2]&Time$[4;2]&Time$[7;2] 320 Filename$=Dhms$&".txt" 330 CREATE Filename$,1 340 ASSIGN @File TO Filename$;FORMAT ON 350 RETURN 360 Typeselect: ! 370 INTEGER Type_size,Type_length,Typeno 380 Type_size=8 !문자열 배열의 크기 390 Type_length=15 !문자열의 길이 400 ALLOCATE Type$(Type_size)[Type_length] 410 Type$(1)="Norm" 420 Type$(2)="Freq Sweep" 430 Type$(3)="Freq-48 Sweep" 440 Type$(4)="DC Bias Sweep" 450 Type$(5)="Osc Level Sweep" 460 Type$(6)="Time Sweep" 470 Type$(7)="Freq St-Sp" 480 Type$(8)="Freq 1k-1M" 490 Msg$="테스트 종류를 선택하십시오." 500 DIALOG "LIST",Msg$,Btn;SET("ITEMS":Type$(*),"COLUMNS":Type_length,"ROWS":Type_size),RETURN("SELECTION":Typeno) 510 Typeno=Typeno+1 520 SELECT Type$(Typeno) 530 CASE "Norm" !샘플이 있는지 없는지 자동 인식 540 INTEGER Go_count 550 Msg$="A-value lower limit" 560 DIALOG "STRING",Msg$,Btn;RETURN("VALUE":String$) 570 IF Btn=-1 OR Btn=1 THEN A_lcl=2.5E-11 580 A_lcl=VAL(String$) 590 Msg$="A-value upper limit" 600 DIALOG "STRING",Msg$,Btn;RETURN("VALUE":String$) 610 IF Btn=-1 OR Btn=1 THEN A_ucl=3.5E-11 620 A_ucl=VAL(String$) 630 Msg$="유효값 연속 횟수" 640 DIALOG "STRING",Msg$,Btn;RETURN("VALUE":String$) 650 IF Btn=-1 OR Btn=1 THEN Go_limit=5 660 Go_limit=VAL(String$) 670 Msg$="허용오차 [%]" 680 DIALOG "STRING",Msg$,Btn;RETURN("VALUE":String$) 690 IF Btn=-1 OR Btn=1 THEN A_err=.1 700 A_err=VAL(String$) 710 OUTPUT @File;"No, A, B, Vm[V], Im[A]" 720 Count=0 730 LOOP 740 Count=Count+1 750 REPEAT!샘플이 있나? 760 GOSUB Reading 770 UNTIL A>A_lcl AND A<A_ucl !LCL=lower control limit, UCL=upper control limit 780 Go_count=0 790 A_pre=A 800 REPEAT 810 GOSUB Reading 820 A_cur=A 830 IF A_cur=0 THEN STOP 840 A_delta=ABS((A_cur-A_pre)/A_cur)*100 850 IF A_delta<A_err THEN 860 Go_count=Go_count+1 870 ELSE 880 Go_count=0 890 END IF 900 A_pre=A_cur 910 UNTIL Go_count=Go_limit 920 PRINT "No.=";Count;",A=";A;",B=";B 930 OUTPUT @File;Count,A,B,Vm,Im 940 BEEP 950 REPEAT!샘플이 없나? 960 GOSUB Reading 970 UNTIL A<A_lcl OR A>A_ucl 980 END LOOP 990 CASE "Freq Sweep" 1000 GOSUB Oscselect 1010 OUTPUT @File;"No, Freq[Hz], A, B, Vm[V], Im[A]" 1020 OUTPUT @Lcr;"FREQ:CW? MIN" 1030 ENTER @Lcr;Freq_min !20Hz 1040 OUTPUT @Lcr;"FREQ:CW? MAX" 1050 ENTER @Lcr;Freq_max !1MHz 1060 Freq_octv=20 !20:std 50:nexvel spk:50 1070 ! Freq_min=1000!nexvel=20 spk=100 !!!!!!!!!!!!!!!!!!!!!!!!! 1080 ! Freq_max=10000 !nexvel=20,000 spk=10,000 !!!!!!!!!!!!!!!!!!!! 1090 Freq=Freq_min 1100 Count=0 1110 LOOP 1120 Count=Count+1 1130 IF Freq>Freq_max THEN Freq=Freq_max 1140 OUTPUT @Lcr;"FREQ:CW ";Freq !command 1150 Freq=Freq*10^(1/Freq_octv) 1160 OUTPUT @Lcr;"FREQ:CW?" 1170 ENTER @Lcr;Freq_level 1180 GOSUB Reading 1190 PRINT "No.=";Count;",Freq=";Freq_level;"Hz,A=";A;",B=";B 1200 OUTPUT @File;Count,Freq_level,A,B,Vm,Im 1210 BEEP 1220 EXIT IF Freq>=Freq_max*1.01 1230 END LOOP 1240 OUTPUT @Lcr;"VOLT:LEV 1V" !init 1250 CASE "Freq St-Sp" 1260 GOSUB Oscselect 1270 OUTPUT @File;"No, Freq[Hz], A, B, Vm[V], Im[A]" 1280 Freq_min=1000 1290 Freq_max=5000 1300 Freq=Freq_min 1310 Count=0 1320 FOR Freq=Freq_min TO Freq_max STEP 10 1330 Count=Count+1 1340 OUTPUT @Lcr;"FREQ:CW ";Freq !command 1350 OUTPUT @Lcr;"FREQ:CW?" 1360 ENTER @Lcr;Freq_level 1370 GOSUB Reading 1380 PRINT "No.=";Count;",Freq=";Freq_level;"Hz,A=";A;",B=";B 1390 OUTPUT @File;Count,Freq_level,A,B,Vm,Im 1400 BEEP 1410 NEXT Freq 1420 OUTPUT @Lcr;"VOLT:LEV 1V" !init 1430 CASE "Freq-48 Sweep" 1440 GOSUB Oscselect 1450 GOSUB Freq48 1460 OUTPUT @File;"No, Freq[Hz], A, B, Vm[V], Im[A]" 1470 FOR I=1 TO 48 1480 OUTPUT @Lcr;"FREQ:CW ";Freq48(I) 1490 GOSUB Reading 1500 PRINT "No.=";I;",Freq=";Freq48(I);"Hz,A=";A;",B=";B 1510 OUTPUT @File;I,Freq48(I),A,B,Vm,Im 1520 BEEP 1530 NEXT I 1540 OUTPUT @Lcr;"VOLT:LEV 1V" !init 1550 CASE "Freq 1k-1M" 1560 GOSUB Oscselect 1570 GOSUB Freq1k1m_read 1580 OUTPUT @File;"No, Freq[Hz], A, B, Vm[V], Im[A]" 1590 FOR I=1 TO 279 1600 OUTPUT @Lcr;"FREQ:CW ";Freq1k1m(I) 1610 GOSUB Reading 1620 PRINT "No.=";I;",Freq=";Freq1k1m(I);"Hz,A=";A;",B=";B 1630 OUTPUT @File;I,Freq1k1m(I),A,B,Vm,Im 1640 BEEP 1650 NEXT I 1660 OUTPUT @Lcr;"VOLT:LEV 1V" !init 1670 CASE "DC Bias Sweep" 1680 GOSUB Freqselect 1690 GOSUB Oscselect 1700 OUTPUT @File;"No, DC-Bias[V], A, B, Vm[V], Im[A]" 1710 OUTPUT @Lcr;"BIAS:VOLT:LEV? MIN" 1720 ENTER @Lcr;Bias_min 1730 OUTPUT @Lcr;"BIAS:VOLT:LEV? MAX" 1740 ENTER @Lcr;Bias_max 1750 OUTPUT @Lcr;"BIAS:STAT ON" ! DC BIAS ON 1760 Count=0 1770 ! FOR Bias=Bias_min TO Bias_max STEP .5 !0~40V 1780 FOR Bias=-40 TO +40 STEP .2 !0~5V NOP=100 1790 Count=Count+1 1800 OUTPUT @Lcr;"BIAS:VOLT:LEV ";Bias !command 1810 GOSUB Reading 1820 PRINT "No.=";Count;",Bias=";Bias;"V,A=";A;",B=";B 1830 OUTPUT @File;Count,Bias,A,B,Vm,Im 1840 BEEP 1850 NEXT Bias 1860 OUTPUT @Lcr;"BIAS:VOLT:LEV 0V" !command 1870 OUTPUT @Lcr;"BIAS:STAT OFF" ! DC BIAS OFF 1880 CASE "Osc Level Sweep" 1890 GOSUB Freqselect 1900 OUTPUT @File;"No, Osc-Level[V], A, B, Vm[V], Im[A]" 1910 OUTPUT @Lcr;"VOLT:LEV? MIN" 1920 ENTER @Lcr;Osc_min !5mV 1930 OUTPUT @Lcr;"VOLT:LEV? MAX" 1940 ENTER @Lcr;Osc_max !20V 1950 Osc_octv=20 1960 Osc=Osc_min 1970 Count=0 1980 LOOP 1990 Count=Count+1 2000 OUTPUT @Lcr;"VOLT:LEV ";Osc !command 2010 Osc=Osc*10^(1/Osc_octv) 2020 OUTPUT @Lcr;"VOLT:LEV?" 2030 ENTER @Lcr;Osc_level 2040 GOSUB Reading 2050 PRINT "No.=";Count;",Osc=";Osc_level;"V,A=";A;",B=";B 2060 OUTPUT @File;Count,Osc_level,A,B,Vm,Im 2070 BEEP 2080 EXIT IF Osc>Osc_max 2090 END LOOP 2100 OUTPUT @Lcr;"VOLT:LEV 1V" !init 2110 CASE "Time Sweep" !몇 초 간격으로 몇 회 2120 INTEGER Nop,L1,L2 2130 Msg$="시간간격 [ms]" 2140 DIALOG "STRING",Msg$,Btn;RETURN("VALUE":String$) 2150 IF Btn=-1 OR Btn=1 THEN STOP 2160 Period=VAL(String$) 2170 Msg$="측정횟수 " 2180 DIALOG "STRING",Msg$,Btn;RETURN("VALUE":String$) 2190 IF Btn=-1 OR Btn=1 THEN STOP 2200 Nop=VAL(String$) 2210 GOSUB Freqselect 2220 OUTPUT @File;"No, Time[S], A, B, Vm[V], Im[A]" 2230 Count=0 2240 T0=TIMEDATE 2250 T=TIMEDATE-T0 !second. 2260 LOOP 2270 Count=Count+1 2280 GOSUB Reading 2290 T1=Period/1000.*(Count-1) 2300 PRINT "No.=";Count;",Time=";T1;"s,A=";A;",B=";B 2310 OUTPUT @File;Count,T,A,B,Vm,Im 2320 BEEP 2330 LOOP 2340 T=TIMEDATE-T0 !second. 2350 IF T>3276.7 THEN 2360 L1=INT(T) 2370 L2=INT(Period/1000) 2380 ELSE 2390 L1=INT(T*10) 2400 L2=INT(Period/100) 2410 END IF 2420 EXIT IF (L1 MOD L2)=0 2430 END LOOP 2440 EXIT IF Count=Nop 2450 END LOOP 2460 END SELECT 2470 RETURN 2480 Funcselect:! 2490 INTEGER Func_size,Func_length,Funcno 2500 Func_size=20 !문자열 배열의 크기 2510 Func_length=5 !문자열의 길이 2520 ALLOCATE Funcdis$(Func_size)[Func_length] 2530 DATA "Cp-D","Cp-Q","Cp-G","Cp-Rp","Cs-D","Cs-Q","Cs-Rs" 2540 DATA "Lp-Q","Lp-D","Lp-G","Lp-Rp","Ls-D","Ls-Q","Ls-Rs" 2550 DATA "R-X","Z-deg","Z-rad","G-B","Y-deg","Y-rad" 2560 FOR I=1 TO Func_size 2570 READ Funcdis$(I) 2580 NEXT I 2590 ALLOCATE Func$(Func_size)[Func_length] 2600 DATA "CPD","CPQ","CPG","CPRP","CSD","CSQ","CSRS" 2610 DATA "LPQ","LPD","LPG","LPRP","LSD","LSQ","LSRS" 2620 DATA "RX","ZTD","ZTR","GB","YTD","YTR" 2630 FOR I=1 TO Func_size 2640 READ Func$(I) 2650 NEXT I 2660 Msg$="테스트 종류를 선택하십시오." 2670 DIALOG "LIST",Msg$,Btn;SET("ITEMS":Funcdis$(*),"COLUMNS":Func_length,"ROWS":Func_size),RETURN("SELECTION":Funcno) 2680 IF Btn=-1 OR Btn=1 THEN STOP 2690 Funcno=Funcno+1 2700 OUTPUT @Lcr;"FUNC:IMP:TYPE ";TRIM$(Func$(Funcno)) 2710 RETURN 2720 Oscselect: ! 2730 INTEGER Osc_size,Osc_length,Oscno 2740 Osc_size=5 !문자열 배열의 크기 2750 Osc_length=5 !문자열의 길이 2760 ALLOCATE Oscdis$(Osc_size)[Osc_length] 2770 Oscdis$(1)="0.02V" !diode 2780 Oscdis$(2)="0.05V" 2790 Oscdis$(3)="0.1V" 2800 Oscdis$(4)="0.5V" 2810 Oscdis$(5)="1V" 2820 Msg$="측정 전압을 선택하십시요" 2830 DIALOG "LIST",Msg$,Btn;SET("ITEMS":Oscdis$(*),"COLUMNS":Osc_length,"ROWS":Osc_size),RETURN("SELECTION":Oscno) 2840 IF Btn=-1 OR Btn=1 THEN STOP 2850 Oscno=Oscno+1 2860 OUTPUT @Lcr;"VOLT ";TRIM$(Oscdis$(Oscno)) 2870 RETURN 2880 Freqselect: ! 2890 INTEGER Freq_size,Freq_length,Freqno 2900 Freq_size=2 !문자열 배열의 크기 2910 Freq_length=4 !문자열의 길이 2920 ALLOCATE Freqdis$(Freq_size)[Freq_length] 2930 Freqdis$(1)="1KHZ" 2940 Freqdis$(2)="1MHZ" 2950 Msg$="주파수를 선택하십시오." 2960 DIALOG "LIST",Msg$,Btn;SET("ITEMS":Freqdis$(*),"COLUMNS":Freq_length,"ROWS":Freq_size),RETURN("SELECTION":Freqno) 2970 IF Btn=-1 OR Btn=1 THEN STOP 2980 Freqno=Freqno+1 2990 OUTPUT @Lcr;"FREQ ";TRIM$(Freqdis$(Freqno)) 3000 RETURN 3010 Freq48: ! 3020 DIM Freq48(48) 3030 DATA 20,25,30,40,50,60,80 3040 DATA 100,120,150,200,250,300,400,500,600,800 3050 DATA 1000,1200,1500,2000,2500,3000,4000,5000,6000,8000 3060 DATA 10000,12000,15000,20000,25000,30000,40000,50000,60000,80000 3070 DATA 100000,120000,150000,200000,250000,300000,400000,500000,600000,800000 3080 DATA 1000000 3090 FOR I=1 TO 48 3100 READ Freq48(I) 3110 NEXT I 3120 RETURN 3130 Freq1k1m_read: ! 3140 DIM Freq1k1m(279) 3150 DATA 1,1.00806,1.01351,1.01695,1.02459,1.0274,1.03448,1.04167,1.05263,1.05634 3160 DATA 1.05932,1.07143,1.07759,1.08696,1.0909,1.09649,1.10294,1.11111,1.11607,1.1194 3170 DATA 1.13208,1.13637,1.15385,1.15741,1.17188,1.17647,1.17925,1.19048,1.2,1.20192 3180 DATA 1.20968,1.22449,1.22549,1.22951,1.25,1.27119,1.27551,1.2766,1.2931,1.30208 3190 DATA 1.30435,1.31579,1.32979,1.33929,1.3587,1.36364,1.38889,1.39535,1.41509,1.42045 3200 DATA 1.42857,1.44231,1.45349,1.46341,1.47059,1.4881,1.5,1.52439,1.53061,1.53846 3210 DATA 1.5625,1.57895,1.59574,1.60256,1.62612,1.63043,1.64474,1.66667,1.68919,1.70455 3220 DATA 1.71429,1.73611,1.74419,1.76471,1.78571,1.81818,1.82927,1.83824,1.875,1.89394 3230 DATA 1.92308,1.93548,1.95313,1.97368,2,2.01613,2.02703,2.06897,2.08333,2.14286 3240 DATA 2.15517,2.20588,2.22222,2.23214,2.27273,2.30769,2.31481,2.34375,2.4,2.40385 3250 DATA 2.41935,2.5,2.58621,2.60417,2.6087,2.67857,2.71739,2.72727,2.77778,2.84091 3260 DATA 2.85714,2.88462,2.97619,3,3.125,3.15789,3.26087,3.28947,3.33333,3.40909 3270 DATA 3.47222,3.52942,3.57143,3.67647,3.75,3.90625,3.94737,4,4.16667,4.28571 3280 DATA 4.41176,4.46429,4.61538,4.6875,4.80769,5,5.17241,5.20833,5.21739,5.35714 3290 DATA 5.43478,5.45455,5.55556,5.68182,5.71429,5.76923,5.95238,6,6.25,6.31579 3300 DATA 6.52174,6.57895,6.66666,6.81818,6.94444,7.05882,7.14286,7.35294,7.5,7.8125 3310 DATA 7.89474,8,8.33333,8.57243,8.82352,8.92857,9.23077,9.375,9.61538,10 3320 DATA 10.3448,10.4167,10.4348,10.7143,10.8696,10.9091,11.1111,11.3636,11.4286,11.5385 3330 DATA 11.9048,12,12.5,12.6316,13.0435,13.1579,13.3333,13.6364,13.8889,14.1176 3340 DATA 14.2857,14.7059,15,15.625,15.7895,16,16.6667,17.1429,17.6471,17.8571 3350 DATA 18.4615,18.75,19.2308,20,20.6897,20.8333,20.8696,21.4286,21.7391,21.8182 3360 DATA 22.2222,22.7272,22.8571,23.0769,23.8095,24,25,25.2632,26.087,26.3158 3370 DATA 26.6667,27.2727,27.7778,28.2353,28.5714,29.4118,30,31.25,31.5789,32 3380 DATA 33.3333,34.2857,35.2941,35.7143,36.9231,37.5,38.4615,40,41.6667,42.8571 3390 DATA 43.6364,45.4545,46.1538,48,50,53.3333,54.5455,55.5556,60,62.5 3400 DATA 66.6666,68.5714,72.4286,75,80,83.3333,85.7143,96,100,120 3410 DATA 125,150,160,166.667,200,240,250,300,320,333.333 3420 DATA 400,480,500,600,640,666.667,800,960,1000 3430 RESTORE 3150 3440 FOR I=1 TO 279 3450 READ Freq1k1m(I) 3460 Freq1k1m(I)=Freq1k1m(I)*1000. 3470 PRINT Freq1k1m(I) 3480 NEXT I 3490 RETURN 3500 Reading: ! 3510 OUTPUT @Lcr;"TRIGGER:IMMEDIATE" 3520 OUTPUT @Lcr;"FETC:IMP?" 3530 ENTER @Lcr;A,B,Status 3540 OUTPUT @Lcr;"FETC:SMON:VAC?" 3550 ENTER @Lcr;Vm 3560 OUTPUT @Lcr;"FETC:SMON:IAC?" 3570 ENTER @Lcr;Im 3580 RETURN 3590 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3600 END 3610 SUB Errors 3620 DIM Err$[50] 3630 Sp=SPOLL(717) 3640 IF BIT(Sp,5) THEN 3650 OUTPUT 717;"*ESR?" 3660 ENTER 717;Esr 3670 PRINT "Event Status Resister = ";Esr 3680 LOOP 3690 OUTPUT 717;"SYST:ERR?" 3700 ENTER 717;Err$ 3710 EXIT IF VAL(Err$)=0 3720 PRINT Err$ 3730 END LOOP 3740 END IF 3750 ENABLE INTR 7;2 3760 SUBEND