macsbug

Just another WordPress.com site

DYNAMIC RANGE Mesurement of HTBasic

leave a comment »

HTBasicでスピーカーのダイナミックレンジ測定アプリを作る。              2015.07.11

計測器は、Audio Analyzer,DVM,Sound Level Meter。画像はシュミレーション画像。

! RE-STORE "DYNAMIC RANGE ANALYZER"
! ***********************************************************************
! BPLUS                             ! ORG 2008.06.27    macsbug
! HANDSET DYNAMIC RANGE ANALYZER    ! REV 2015.07.11    macsbug
! ***********************************************************************
! Black=0,White=1,Red=2,Yellow=3,Green=4,Cyan=5,Blue=6,Magenta=7
     LOAD BIN "BPLUS"         ! PLUS MODULE LOADING
      COM @C                  ! SUB VALUE SET
      COM M$(0:3)[20],T$[80]  ! Menu,TEXT
    M$(0)="Loop Test=OFF"     ! SYSTEM MENU = Loop Test  ON/OFF
    M$(1)="Printer=ON "       ! SYSTEM MENU = Printer    ON/OFF
    M$(2)="Print"             ! SYSTEM MENU = Printout
    M$(3)="Quit"              ! SYSTEM MENU = Quit
 Io_initialize:!--------------!-----------------------------------------
  CONTROL 10,102;1            ! PRINTER SELECT   = LAN PRINTER
    CLEAR SCREEN              ! SCREEN           = CLEAR
      KEY LABELS OFF          ! MENU KEY DISPLAY = OFF
    REMOTE 7                  ! HPIB SETUP:SYSTEM SELECT=7
      Aan=708                 ! 08:AUDIO ANALYZER : 8903B
      Dvm=722                 ! 22:DIGITAL VOLT METER : HP34401A
    OUTPUT Aan;"AUFR1000HZ"   ! AAN:FREQUENCY
    OUTPUT Aan;"AP4000MV"     ! AAN:0.4 VOLT AC OUTPUT
    OUTPUT Aan;"M1"           ! AAN:AC VOLT
    OUTPUT Dvm;"F2"           ! AC
     WAIT 3                   !
 Agc_chart:!------------------------------------------------!-----------
   ASSIGN @C TO WIDGET "STRIPCHART"                         ! MODULE
  CONTROL @C;SET ("SYSTEM MENU":M$(*))                      ! MENU
  CONTROL @C;SET ("TITLE":" DYNAMIC RANGE ANALYZER")        ! TITLE
  CONTROL @C;SET ("SHOW GRID":1,"TRACE BACKGROUND":1)       ! 1=White
  CONTROL @C;SET ("X":10,"Y":5,"WIDTH":760,"HEIGHT":270*2)  ! X,Y,W,H
  CONTROL @C;SET ("CURRENT AXIS":"X","ORIGIN":100,"RANGE":1720)! HORIZON
  CONTROL @C;SET ("CURRENT AXIS":"X","AXIS LABEL":"FREQ(Hz)")! X LABEL
  CONTROL @C;SET ("CURRENT AXIS":"Y","ORIGIN":60,"RANGE":60)! VERTICAL
  CONTROL @C;SET ("CURRENT AXIS":"Y","AXIS LABEL":"DB")     ! Y LABEL
  CONTROL @C;SET ("TRACE PEN":2,"VISIBLE":1)                ! 2=Red
  CONTROL @C;SET ("TRACE COUNT":20,"CURRENT TRACE":0)       !
  CONTROL @C;SET ("POINT CAPACITY":100000)                  !
       ON EVENT @C,"SYSTEM MENU" GOSUB Sysmenu              ! MENU EVEN
!-----------------------------------------------------------!-----------
 Memo_chart:!                                               !
   ASSIGN @M TO WIDGET "PRINTER";SET ("BACKGROUND":1)       !
  CONTROL @M;SET ("X":775,"Y":5,"WIDTH":220,"HEIGHT":210)   !
  CONTROL @M;SET ("TITLE":" LRU MEMO")                      !
  CONTROL @M;SET ("APPEND TEXT":"HANDEST DYNAMIC RANGE")    !
     CALL Date(D$)                                          ! DATE READ
  CONTROL @M;SET ("APPEND TEXT":"DATE : "&D$)               ! DATE PRT
  CONTROL @M;SET ("APPEND TEXT":"TIME : "&TIME$(TIMEDATE))  ! TIME PRT
  CONTROL @M;SET ("APPEND TEXT":"")                         ! SPACE
     BEEP                                                   !
       L$="P/N"                                             !
    GOSUB Lru_memo                                          ! P/N
       L$="S/N"                                             !
    GOSUB Lru_memo                                          ! S/N
 Info_chart:!-----------------------------------------------!-----------
   ASSIGN @P TO WIDGET "PRINTER";SET ("BACKGROUND":1)       !
  CONTROL @P;SET ("X":775,"Y":220,"WIDTH":220,"HEIGHT":100) !
  CONTROL @P;SET ("TITLE":" MEMU INFO")                     !
  CONTROL @P;SET ("APPEND TEXT":M$(0))                      !
  CONTROL @P;SET ("APPEND TEXT":M$(1))                      !
 Data_chart:!-----------------------------------------------!-----------
   ASSIGN @D TO WIDGET "PRINTER";SET ("BACKGROUND":1)       !
  CONTROL @D;SET ("X":775,"Y":325,"WIDTH":220,"HEIGHT":190) !
  CONTROL @D;SET ("TITLE":"DATA")                           !
!-----------------------------------------------------------!-----------
 Mesure_setup:!                                             !
       Vr=4000                                              ! START VOL
 L1: WAIT .2                                                !
   OUTPUT Aan;"AP"&VAL$(Vr)&"MV"                            ! VOLT ADJ
   OUTPUT T$ USING "12A,4D,5A";"SG OUTPUT = ";Vr;" mVAC"    ! SG OUT
  CONTROL @D;SET ("APPEND TEXT":T$)                         ! SG OUT
     WAIT .5                                                !
    ENTER Dvm;V                                             ! READ INPUT
   OUTPUT T$ USING "12A,4D,5A";"INPUT VOL = ";V*1000;" mVAC"! INPUT VOL
  CONTROL @D;SET ("APPEND TEXT":T$)                         ! INPUT VOL
       IF ((V>.98) AND (V<1.02)) THEN GOTO Measure          ! SETUP END
       IF (V<1) THEN D=INT(100*(1/V))                       ! 4V 0.8 +125
       IF (V>1) THEN D=-1*INT(100*(V/1))                    ! 4V 1.2 -120
       Vr=Vr+D                                              !
     GOTO L1                                                ! new setup
!-----------------------------------------------------------!-----------
 Measure:    !                                              ! x axis
  CONTROL @M;SET ("APPEND TEXT":"")                         ! SPACE
  CONTROL @M;SET ("APPEND TEXT":"SG OUT: "&VAL$(Vr)&"mVAC") ! SG OUT
       Va=INT(V*1000)                                       !
  CONTROL @M;SET ("APPEND TEXT":"INPUT : "&VAL$(Va)&"mVAC") ! INPUT VOL
   OUTPUT Aan;"LG"                                          ! DB
   FOR Freq=100 TO 1800 STEP 20                             ! FREQ LOOP
       OUTPUT Aan;"FR"&VAL$(Freq)&"HZ"                      ! AAN FREQ
         WAIT .5                                            !
        ENTER Aan;V                                         ! y axis
            V=-1*(V-80)                                     !
       OUTPUT T$ USING "9A,DDD.D,3A";"OUTPUT = ";V;" DB"    !
      CONTROL @D;SET ("APPEND TEXT":T$)                     !
      CONTROL @C;SET ("CURRENT TRACE":1,"TRACE PEN":2)      ! DRAW SET
      CONTROL @C;SET ("POINT LOCATION":Freq,"VALUE":V)      ! DRAW SP
   NEXT Freq                                                ! +Freq
!-----------------------------------------------------------!-----------
       IF M$(1)="Printer=ON " THEN CALL Print_out           ! PRINT OUT
       IF M$(0)="Loop Test=ON " THEN                        !
  CONTROL @C;SET ("CURRENT TRACE":0,"VALID POINTS":0)       ! DRAW CLR
     GOTO Measure                                           ! LOOP
      END IF                                                !
     GOTO Finish                                            !
!===========================================================!===========
! SYSTEM MENU EVENT ROUTINE                                 !
 Sysmenu:!--------------------------------------------------!
   STATUS @C;RETURN ("SYSTEM MENU EVENT":N)                 !
       IF N=2 THEN CALL Print_out                           ! Print
       IF N=3 THEN GOTO Finish                              ! Quit
       IF M$(N)="Loop Test=ON " THEN T$="Loop Test=OFF"     ! N=0
       IF M$(N)="Loop Test=OFF" THEN T$="Loop Test=ON "     ! Loop Test
       IF M$(N)="Printer=ON " THEN T$="Printer=OFF"         ! N=1
       IF M$(N)="Printer=OFF" THEN T$="Printer=ON "         ! Printer
       IF N=0 OR N=1 THEN                                   !
          M$(N)=T$                                          ! MENU CG
          CONTROL @C;SET ("SYSTEM MENU":M$(*))              ! MENU SET
          END IF                                            !
  CONTROL @P;SET ("APPEND TEXT":M$(0))                      !
  CONTROL @P;SET ("APPEND TEXT":M$(1))                      !
 RETURN                                                     !
!===========================================================!==========
 Lru_memo:!-------------------------------------------------!
       B$=" LRU MEMO"                                       !
       T$="Please enter LRU "&L$                            !
   DIALOG "STRING",T$;SET ("TITLE":B$),RETURN ("VALUE":U$)  !
  CONTROL @M;SET ("APPEND TEXT":L$&" "&U$)                  !
 RETURN                                                     !
!===========================================================!==========
 Finish:!---------------------------------------------------!
    WAIT 2                                                  !
  DIALOG "QUESTION","Finish",Btn;SET ("TITLE":"Finish")     !             
  ASSIGN @C TO *                                            !
  ASSIGN @D TO *                                            !
  ASSIGN @M TO *                                            !
  ASSIGN @P TO *                                            !
 END                                                        !
!===========================================================!==========
! CALL SUB ROUTINE                                          !
!===========================================================!==========
 SUB Print_out                                              !
     GINIT                                                  !
     GCLEAR                                                 !
     AREA PEN 1                                             ! White
     RECTANGLE 1024,768,FILL,EDGE                           ! FILL
     RECTANGLE 10,10,FILL,EDGE                              ! BG=White
     CONFIGURE SYSTEM ("DUMP;PLUS")                         ! MODULEs
     CONFIGURE DUMP TO "WIN-DUMP;INVERT"                    ! INVERT
          DUMP GRAPHICS #10                                 ! PRINT OUT
         CLEAR SCREEN                                       !
 SUBEND                                                     !
!===========================================================!==========
 SUB Date(Ymd$)                                             ! CALCURATE
!-----------------------------------------------------------!----------
      DIM Y$(12)[3],X$(12)[3]                               ! DATE
     DATA Jan,01,Feb,02,Mar,03,Apr,04,May,05,Jun,06         ! 1 TO  6
     DATA Jul,07,Aug,08,Sep,09,Oct,10,Nov,11,Dec,12         ! 7 TO 12
      FOR I=1 TO 12                                         ! 1 TO 12
          READ Y$(I),X$(I)                                  ! DATA READ
     NEXT I                                                 !
       D$=DATE$(TIMEDATE)                                   ! TODAY
     Mon$=D$[4,6]                                           ! MONTH
      FOR I=1 TO 12                                         ! 1 TO 12
          SELECT Mon$                                       ! SEL MANTH
            CASE Y$(I)                                      ! SEL YEAR
                 Mon$=X$(I)                                 ! SET MANTH
                 Day$=D$[1,2]                               ! SET DAY
                  IF Day$[1,1]=" " THEN Day$="0"&Day$[2,2]  ! " " = 0
                 Year$=D$[8,11]                             ! SET YEAR
                 Ymd$=Year$&"."&Mon$&"."&Day$               ! YYYY.
          END SELECT                                        ! MM.DD
     NEXT I                                                 !
   SUBEND                                                   !
!===========================================================!==========

Written by macsbug

7月 11, 2015 @ 6:46 am

カテゴリー: Knowledge

コメントを残す

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

WordPress.com ロゴ

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

Twitter 画像

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

Facebook の写真

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

Google+ フォト

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

%s と連携中

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