macsbug

Just another WordPress.com site

Resistance Logger for HTBasic

leave a comment »

HTBasic で、レジスタンス・ロガーを作成。                  2015.06.07


デジタルマルチメーターのオームレンジで抵抗値を測定しグラフで表示する。
軸:縦は抵抗値、横は時間(分)で抵抗値の変化をグラフ化する。
スライドバー:左は縦軸の変更、右は時間軸の変更(測定中に変更可)。
警告音:リミット値を超えるとスピーカーから音が出る。



HTBasic は、Rocky Mountain BASIC (RMB) 言語のためのBASICインタープリタです。
GPIBインターフェースを通じ計測器(GPIB付)をコントロールしデーターを取得します。
OS環境:Windows。
使用計測器:Agirent 3458A 叉は、Agirent 34401A
汎用性:縦軸の抵抗値をDC電圧に変更すると、DC LOGGERになります。
時間間隔:約0.5秒で低速です。
未装備:オートレンジは組み込んでいませんが、追加は簡単です。


メモ:
今時、HTBasicの話は極めて少ないと思いますが、PLUS MODULE が素晴らしく、備忘録としました。
高性能で高価な計測器を自在に扱えると便利ですし、仮想の計測装置が作れます。
参考:HP-BASIC入門。 HTBasic Tip


プログラムを以下に示します。


1000 ! RE-STORE "RESISTANCE_LOGGER"
1010 !***********************************************************************
1020 ! RESISTANCE LOGGER PROGRAM  !
1030 !-----------------------------------------------------------------------
1040 !     COPYRIGHT              ! ORG               : BY macsbug
1050 !     ORG 2008.07.--         ! BPLUS DESIGN      : BY macsbug
1060 !     REV 2015.05.--         ! Resistance Logger : BY macsbug
1070 ! **********************************************************************
1080 ! Black=0,White=1,Red=2,Yellow=3,Green=4,Cyan=5,Blue=6,Magenta=7
1090 LOAD BIN "BPLUS"             ! PLUS MODULE LOADING
1100 DIM M$(0:4)[20],T$[80]       ! Menu,TITLE
1110     ! I/O -------------------!
1120 Hpib=8                       ! HPIB SYSTEM No.
1130 Dvm=803                      ! DVM HPIB ADDRESS. HP3478A(Agilent 34401A)
1140     ! Variable --------------!
1150 M$(0)="Loop Test=OFF"        ! SYSTEM MENU = Loop Test     ON/OFF
1160 M$(1)="Printer=OFF"          ! SYSTEM MENU = Printer       ON/OFF
1170 M$(2)="Sound=ON "            ! SYSTEM MENU = Sound Monitor ON/OFF
1180 M$(3)="Print"                ! SYSTEM MENU = Printout
1190 M$(4)="Quit"                 ! SYSTEM MENU = Quit
1200 T$=" RESISTANCE LOGGER"      ! TITLE
1210 R_limit=10                   ! RESISTOR LIMIT
1220 CLEAR SCREEN                                                  !
1230 CALL Date(D$)                                                 ! DATE
1240 KEY LABELS OFF                                                !
1250 !------------------------------------------------------------------------
1260 ! DATE                                                        !
1270 !------------------------------------------------------------------------
1280  ASSIGN @Dt TO WIDGET "PRINTER";SET ("BACKGROUND":1)          !
1290 CONTROL @Dt;SET ("X":815,"Y":10,"HEIGHT":70,"WIDTH":200)      !
1300 CONTROL @Dt;SET ("TITLE":"DATE")                              !
1310 CONTROL @Dt;SET ("FONT":"20 BY 20,BOLD")                      ! FONT SIZE
1320 CONTROL @Dt;SET ("APPEND TEXT":"   "&D$)                      !
1330 !------------------------------------------------------------------------
1340 ! CLOCK                                                       !
1350 !------------------------------------------------------------------------
1360  ASSIGN @Clock TO WIDGET "CLOCK"                              !
1370 CONTROL @Clock;SET ("TITLE":" TIME","BACKGROUND":37)          !
1380 CONTROL @Clock;SET ("X":815,"Y":85,"HEIGHT":200,"WIDTH":200)  !
1390 !------------------------------------------------------------------------
1400  Io_set_up:!--------------------------------------------------!---------
1410 CONTROL 10,102;1             ! PRINTER SELECT     = LAN PRINTER
1420 CLEAR SCREEN                 ! SCREEN             = CLEAR
1430 KEY LABELS OFF               ! MENU KEY DISPLAY   = OFF
1440 REMOTE Hpib                  ! HPIB SETUP
1450 CLEAR Dvm                    ! DIGITAL VOLT METER HP3458A = CLEAR
1460 WAIT 1                       !
1470 OUTPUT Dvm;"PRESET"          ! DVM Agirent 3458A = RESISTOR MODE
1480 WAIT 1                       ! DVM Agirent 3458A
1490 OUTPUT Dvm;"NORM"            ! DVM Agirent 3458A
1500 WAIT 1                       ! DVM Agirent 3458A
1510 OUTPUT Dvm;"OHM"             ! DVM Agirent 3458A
1530 !OUTPUT Dvm;"F3R2N3T1Z1"     ! DVM 34401A:R1=30,R2=300ohm,RA=AUTO RANGE
1540 WAIT 1                       !
1550 !------------------------------------------------------------------------
1560 ! VERTICAL SIZE SLIDER
1570 !------------------------------------------------------------------------
1580 Yh=300                                                        ! VERTICAL
1590  ASSIGN @S1 TO WIDGET "SLIDER"                                ! SLIDER
1600 CONTROL @S1;SET ("TITLE":"Y")                                 !
1610 CONTROL @S1;SET ("X":815,"Y":290,"WIDTH":80,"HEIGHT":253)     ! POSITION
1620 CONTROL @S1;SET ("MINIMUM":1,"MAXIMUM":20000)                 ! OHM 1-20000
1630      ON EVENT @S1,"DONE" GOSUB Cg1                            !
1640 !------------------------------------------------------------------------
1650 ! HORIZONTAL SIZE SLIDER SET UP                               !
1660 !------------------------------------------------------------------------
1670 Xh=30                                                         ! HORIZONTAL
1680  ASSIGN @T1 TO WIDGET "SLIDER"                                ! SLIDER
1690 CONTROL @T1;SET ("TITLE":"X")                                 !
1700 CONTROL @T1;SET ("X":900,"Y":290,"WIDTH":80,"HEIGHT":253)     ! POSITION
1710 CONTROL @T1;SET ("MINIMUM":30,"MAXIMUM":180)                  ! TIME min
1720      ON EVENT @T1,"DONE" GOSUB Cg2                            ! -> Cg2
1730 !------------------------------------------------------------------------
1740 !Resistance_chart_set_up:!------------------------------------!----------
1750 ASSIGN @P TO WIDGET "STRIPCHART"                              ! MODULE
1760 CONTROL @P;SET ("SYSTEM MENU":M$(*))                          ! MENU
1770 CONTROL @P;SET ("TITLE":T$)                                   ! TITLE
1780 CONTROL @P;SET ("SHOW GRID":1,"TRACE BACKGROUND":1)           ! 1=White
1790 CONTROL @P;SET ("X":10,"Y":5,"WIDTH":800,"HEIGHT":270*2)      ! X,Y,W,H
1800 CONTROL @P;SET ("CURRENT AXIS":"X","ORIGIN":0,"RANGE":30)     ! 30min
1810 CONTROL @P;SET ("CURRENT AXIS":"X","AXIS LABEL":"minutes")    ! X LABEL
1820 CONTROL @P;SET ("CURRENT AXIS":"Y","ORIGIN":0.,"RANGE":Yh)    ! VERTICAL
1830 CONTROL @P;SET ("CURRENT AXIS":"Y","AXIS LABEL":"ohm")        ! Y LABEL
1840 CONTROL @P;SET ("TRACE PEN":2,"VISIBLE":1)                    ! 2=Red
1850 CONTROL @P;SET ("TRACE COUNT":10,"CURRENT TRACE":0)           !
1860 CONTROL @P;SET ("POINT CAPACITY":216000)                      ! 3600*60*3
1870 ON EVENT @P,"SYSTEM MENU" GOSUB Sysmenu                       ! MENU EVEN
1880 !Main Routine ------------------------------------------------!----------
1890  Measure: S=TIMEDATE                                          ! START T
1900  Loop:! RESISTOR ---------------------------------------------!----------
1910 WAIT .5                                                       ! SICL time
1920 ENTER Dvm;D                                                   ! RESISTOR
1930 IF M$(2)="Sound=ON " AND D>R_limit THEN BEEP                  ! LIMIT OUT
1940 CONTROL @P;SET ("CURRENT TRACE":1,"TRACE PEN":2)              ! DRAW SET
1950 CONTROL @P;SET ("POINT LOCATION":(TIMEDATE-S)/60,"VALUE":D)   ! DRAW
1960 DISP "TIME = "&VAL$(INT(TIMEDATE-S))&" sec",                  ! DISP TIME
1970 DISP "RESISTOR = "&VAL$(D)&" ohm",                            ! DISP DATA
1980 DISP M$(0),M$(2),M$(1)                                        ! DISP MENU
1990 !-------------------------------------------------------------!----------
2000 IF (TIMEDATE-S)<(Xh*60-10) THEN GOTO Loop                     ! LOOP
2010        !------------------------------------------------------!
2020 IF M$(1)="Printer=ON " THEN CALL Print_out                    ! PRINT OUT
2030 IF M$(0)="Loop Test=ON " THEN                                 !
2040 CONTROL @P;SET ("CURRENT TRACE":0,"VALID POINTS":0)           ! RESET
2050 GOTO Measure                                                  ! RE-START
2060 END IF                                                        !
2070 GOTO Finish                                                   ! END
2080 !=============================================================!==========
2090 ! SYSTEM MENU EVENT ROUTINE                                   !
2100  Sysmenu: !---------------------------------------------------!
2110 STATUS @P;RETURN ("SYSTEM MENU EVENT":N)                      !
2120 IF N=3 THEN CALL Print_out                                    ! Print
2130 IF N=4 THEN GOTO Finish                                       ! Quit
2140 IF M$(N)="Loop Test=ON " THEN T$="Loop Test=OFF"              ! N=0
2150 IF M$(N)="Loop Test=OFF" THEN T$="Loop Test=ON "              ! Loop Test
2160 IF M$(N)="Printer=ON " THEN T$="Printer=OFF"                  ! N=1
2170 IF M$(N)="Printer=OFF" THEN T$="Printer=ON "                  ! Printer
2180 IF M$(N)="Sound=ON " THEN T$="Sound=OFF"                      ! N=2
2190 IF M$(N)="Sound=OFF" THEN T$="Sound=ON "                      ! Sound
2200 IF N=0 OR N=1 OR N=2 THEN                                     !
2210 M$(N)=T$                                                      ! MENU CG
2220 CONTROL @P;SET ("SYSTEM MENU":M$(*))                          ! MENU SET
2230 END IF                                                        !
2240 RETURN                                                        !
2250 !-------------------------------------------------------------!
2260 ! REGISTOR SLIDER SELECT                                      !
2270 !-------------------------------------------------------------!
2280  Cg1:!                                                        !
2290    STATUS @S1;RETURN ("VALUE":Yh)                             ! SLIDER
2300    CONTROL @P;SET ("CURRENT AXIS":"Y","ORIGIN":0.,"RANGE":Yh) ! VERTICAL
2310    RETURN                                                     !
2320 !-------------------------------------------------------------!
2330 ! HORIZONTAL SLIDER SELECT                                    !
2340 !-------------------------------------------------------------!
2350  Cg2:!                                                        !
2360    STATUS @T1;RETURN ("VALUE":Xh)                             ! SLIDER
2370    CONTROL @P;SET ("CURRENT AXIS":"X","ORIGIN":0,"RANGE":Xh)  ! min
2380    RETURN                                                     !
2390 !=============================================================!==========
2400  Finish: !----------------------------------------------------! END
2410 INPUT "MONITOR END ? (ENTER)",A$                              !
2420 ASSIGN @P TO *                                                !
2430 ASSIGN @S1 TO *                                               !
2440 END                                                           !
2450 !========================================================================
2460 ! CALL SUBROUTINE                                             !
2470 !========================================================================
2480 SUB Print_out                                                 !
2490 GINIT                                                         !
2500 GCLEAR                                                        !
2510 AREA PEN 1                                                    ! White
2520 RECTANGLE 1024,768,FILL,EDGE                                  ! FILL
2530 RECTANGLE 10,10,FILL,EDGE                                     ! BG=White
2540 CONFIGURE SYSTEM ("DUMP;PLUS")                                ! MODULE
2550 CONFIGURE DUMP TO "WIN-DUMP;INVERT"                           ! INVERT
2560 DUMP GRAPHICS #10                                             ! PRINT OUT
2570 CLEAR SCREEN                                                  !
2580 SUBEND                                                        !
2590 !-------------------------------------------------------------!----------
2600  SUB Date(Ymd$)                                               ! CALCURATE
2610 !-------------------------------------------------------------!----------
2620 DIM Y$(12)[3],X$(12)[3]                                       ! DATE
2630 DATA Jan,01,Feb,02,Mar,03,Apr,04,May,05,Jun,06                ! 1 TO  6
2640 DATA Jul,07,Aug,08,Sep,09,Oct,10,Nov,11,Dec,12                ! 7 TO 12
2650   FOR I=1 TO 12                                               ! 1 TO 12
2660       READ Y$(I),X$(I)                                        ! DATA READ
2670   NEXT I                                                      !
2680   D$=DATE$(TIMEDATE)                                          ! TODAY
2690   Mon$=D$[4,6]                                                ! MONTH
2700   FOR I=1 TO 12                                               ! 1 TO 12
2710       SELECT Mon$                                             ! SEL MANTH
2720       CASE Y$(I)                                              ! SEL YEAR
2730       Mon$=X$(I)                                              ! SET MANTH
2740       Day$=D$[1,2]                                            ! SET DAY
2750       IF Day$[1,1]=" " THEN Day$="0"&Day$[2,2]                ! " " = 0
2760          Year$=D$[8,11]                                       ! SET YEAR
2770          Ymd$=Year$&"."&Mon$&"."&Day$                         ! YYYY.
2780       END SELECT                                              ! MM.DD
2790   NEXT I                                                      !
2800 SUBEND                                                        !
2810 !=============================================================!==========


Written by macsbug

6月 7, 2015 @ 7:39 am

カテゴリー: Knowledge

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト / 変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト / 変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト / 変更 )

Google+ フォト

Google+ アカウントを使ってコメントしています。 ログアウト / 変更 )

%s と連携中

%d人のブロガーが「いいね」をつけました。