10 ! mode = 1 volt, 2 time, 3 step time, 4 varistor
20 ! 2024-01-29
30 CLEAR SCREEN
40 OPTION BASE 1
50 GOSUB Fileopen
60 GOSUB Inst_open
70 GOSUB Measure
80 GOSUB Inst_close
90 GOSUB Fileclose
100 STOP
110 Measure: !
120 ! OUTPUT @Pt301;""
130 OUTPUT @File;"No.,Time[s],Load Curr[A],Burden Volt[V], Ripple V[mV], Noise V[mV]"
140 Curr_start=0 !!!!!!!!!!!!!!!!!!!
150 Curr_stop=1 !!!!!!!!!!!!!!!!!!!
160 Nop=101
170 Volt=Volt_start
180 I=0
190 GOSUB Chart_var
200 GOSUB Init_chart
210 T0=TIMEDATE
220 LOOP
230 I=I+1
240 Curr_set=Curr_start+(Curr_stop-Curr_start)*(I-1)/(Nop-1)
250 OUTPUT @Pt301;"A";Curr_set !!!!!!!!!!!!!!!!!!!!!!!!!!
260 Time=TIMEDATE-T0
270 WAIT .2 !!!!!!!!!!!!!!!!!!!!!!!!
280 GOSUB Reading
290 IF I=1 THEN Volt_save=Volt
300 ! X(1)=Curr_set
310 Y(1)=Ripp
320 CONTROL @Strip;SET("POINT LOCATION":Curr_set,"VALUES":Y(*)) !!!!!!!!!!!!!!!!!!!!!!!!!!!
330 PRINT "Count=";I;", T=";PROUND(Time,-2);" I=";Curr;", V=";Volt;", Ripple=";Ripp;", Noise=";Nois
340 OUTPUT @File;I,Time,Curr,Volt,Ripp,Nois
350 EXIT IF ABS((Volt-Volt_save)/Volt_save)*100>50 !직전 전압에 비해 50% 이상 변하면
360 EXIT IF Curr>Max_curr+.1
370 EXIT IF Volt>Max_volt+1
380 EXIT IF Ripp>2000
390 EXIT IF Nois>2000
400 EXIT IF I=Nop
410 Volt_save=Volt
420 END LOOP
430 RETURN
440 Reading: !
450 OUTPUT @Pt301;"M0"
460 ENTER @Pt301;Curr
470 OUTPUT @Pt301;"M1"
480 ENTER @Pt301;Volt
490 OUTPUT @Pt301;"M3"
500 ENTER @Pt301;Ripp
510 OUTPUT @Pt301;"M4"
520 ENTER @Pt301;Nois
530 RETURN
540 Fileopen: !
550 DIM Filename$[20],Dhms$[8]
560 Time$=TIME$(TIMEDATE)
570 Date$=DATE$(TIMEDATE)
580 Dhms$=Date$[1;2]&Time$[1;2]&Time$[4;2]&Time$[7;2]
590 Filename$=Dhms$&".txt"
600 CREATE Filename$,1
610 ASSIGN @File TO Filename$;FORMAT ON
620 RETURN
630 Fileclose: !
640 ASSIGN @File TO *
650 RETURN
660 Inst_close: !
670 OUTPUT @Pt301;"A";0 !!!!!!!!!!!!!!!!!!!!!!!!!!
680 RETURN
690 Inst_open: !
700 DIM Id$[25]
710 ASSIGN @Pt301 TO 702
720 OUTPUT @Pt301;"V" !check version
730 ENTER @Pt301;Id$
740 DISP Id$
750 Max_volt=VAL(Id$[8;3])
760 Max_curr=VAL(Id$[13;3])
770 RETURN
780 Chart_var: !
790 X_origin=Curr_start
800 X_range=Curr_stop-Curr_start
810 X_axis_label$="Current [A]"
820 Y_origin=0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!
830 Y_range=Max_volt !!!!!!!!!!!!!!!!!!!!!!!
840 Y_axis_label$="Ripple [mV]" !!!!!!!!!!!!
850 RETURN
860 Init_chart: !
870 DIM X_axis_label$[25],Y_axis_label$[25]
880 INTEGER Trace_num
890 INTEGER Screen_dims(1:2),Gwindow_dims(1:4)
900 REAL Y(1:1)
910 GESCAPE CRT,36;Screen_dims(*) ! Get screen width and height.
920 !
930 ! Set the dimensions of the graphics window using GESCAPE 33 so
940 ! that it is centered on the screen.
950 !
960 Gwindow_dims(1)=Screen_dims(1)*.25 ! X of upper left.
970 Gwindow_dims(2)=Screen_dims(2)*.01 ! Y of upper left.
980 Gwindow_dims(3)=Screen_dims(1)*.7 ! Width.
990 Gwindow_dims(4)=Screen_dims(2)*.6 ! Height.
1000 GESCAPE CRT,33;Gwindow_dims(*) ! Set graphics window geometry.
1010 !
1020 GESCAPE CRT,35 ! Move the graphics window to the top.
1030 !
1040 ! Create a stripchart. Make it invisible until all changes are made.
1050 !
1060 ASSIGN @Strip TO WIDGET "STRIPCHART";SET("VISIBLE":0)
1070 !
1080 ! Set the overall attributes.
1090 !
1100 CONTROL @Strip;SET("TITLE":"Data Logger")
1110 CONTROL @Strip;SET("MINIMUM SCROLL":2)
1120 CONTROL @Strip;SET("MOVABLE":0)
1130 CONTROL @Strip;SET("MAXIMIZABLE":0)
1140 CONTROL @Strip;SET("X":0,"Y":0)
1150 !
1160 ! Size the stripchart to exactly fill the graphics window.
1170 !
1180 Vert_borders=26
1190 Horiz_borders=8
1200 Height=Gwindow_dims(4)-Vert_borders
1210 Width=Gwindow_dims(3)-Horiz_borders
1220 CONTROL @Strip;SET("WIDTH":Width,"HEIGHT":Height)
1230 !
1240 CONTROL @Strip;SET("CURRENT AXIS":"X")
1250 CONTROL @Strip;SET("ORIGIN":X_origin,"RANGE":X_range)
1260 CONTROL @Strip;SET("AXIS LABEL":X_axis_label$)
1270 !CONTROL @Strip;SET("DIGITS":5)
1280 !
1290 CONTROL @Strip;SET("CURRENT AXIS":"Y")
1300 CONTROL @Strip;SET("ORIGIN":Y_origin,"RANGE":Y_range)
1310 CONTROL @Strip;SET("AXIS LABEL":Y_axis_label$)
1320 !
1330 CONTROL @Strip;SET("VISIBLE":1) ! Show the stripchart.
1340 !
1350 RETURN
1360 END