⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 biquadconfig.frm

📁 设置滤波器类型
💻 FRM
📖 第 1 页 / 共 4 页
字号:
   Begin MSCommLib.MSComm MSComm1 
      Left            =   4680
      Top             =   8760
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
      InBufferSize    =   2
      InputLen        =   2
      OutBufferSize   =   4096
      RThreshold      =   2
      SThreshold      =   2
      EOFEnable       =   -1  'True
      InputMode       =   1
   End
   Begin VB.Image Image1 
      Height          =   1185
      Left            =   9480
      Picture         =   "Biquadconfig.frx":0876
      ToolTipText     =   "Bash technical support"
      Top             =   4080
      Visible         =   0   'False
      Width           =   2490
   End
   Begin VB.Menu File 
      Caption         =   "File"
      Begin VB.Menu load 
         Caption         =   "load"
      End
      Begin VB.Menu Saveas 
         Caption         =   "Save as"
      End
   End
   Begin VB.Menu compression1 
      Caption         =   "compression"
   End
   Begin VB.Menu compression_2ohm1 
      Caption         =   "compression_2ohm"
      Visible         =   0   'False
   End
   Begin VB.Menu compression 
      Caption         =   "Compression_4ohm"
      Visible         =   0   'False
   End
   Begin VB.Menu Portsetting 
      Caption         =   "Port_Setting"
   End
   Begin VB.Menu writetoflash 
      Caption         =   "Writetoflash"
   End
   Begin VB.Menu readflash 
      Caption         =   "Readflash"
      Visible         =   0   'False
   End
   Begin VB.Menu GetSampleWave 
      Caption         =   "GetSampleWave"
      Visible         =   0   'False
   End
   Begin VB.Menu Flash 
      Caption         =   "Flash"
      Visible         =   0   'False
   End
   Begin VB.Menu help 
      Caption         =   "Help"
      Begin VB.Menu help1 
         Caption         =   "help"
         Shortcut        =   {F1}
         Visible         =   0   'False
      End
      Begin VB.Menu About 
         Caption         =   "About Biquad Configuration"
      End
      Begin VB.Menu suport 
         Caption         =   "Indigo Tech. Suport"
         Visible         =   0   'False
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'/*
' *  Copyright 2006 by Indigo Manufacturing Inc.
' *  All rights reserved. Property of Indigo Manufacturing Inc.
' *                  September 8, 2006
' */
Dim bb(0) As Byte   'for transmit
Dim receive_buffer(0 To 25) As Byte   'for receiving data
Dim ba(0 To 15) As Single
Dim A(0 To 4) As Integer
Dim ffit As Single  'limit
Dim readfromflashbtn As Boolean
Dim readsamplewavebtn As Boolean
Dim pointer As Integer

Private Sub About_Click()
frmSplash.Show
End Sub





Private Sub autothreshold_LostFocus()
If (autothreshold.Text > 104) Then
    MsgBox ("Threshold should be less than 105mv!")
End If
End Sub

Private Sub centrefrequency_Click()
On Error Resume Next
tempedit3.Height = centrefrequency.CellHeight
tempedit3.width = centrefrequency.CellWidth
tempedit3.Top = centrefrequency.CellTop + centrefrequency.Top '+ 2 * centrefrequency.CellHeight
tempedit3.Left = centrefrequency.CellLeft
tempedit3.Text = centrefrequency.TextMatrix(centrefrequency.RowSel, centrefrequency.ColSel)
tempedit3.Visible = True
tempedit3.SetFocus
End Sub

Private Sub Command1_Click()
On Error Resume Next
Dim Filt_type As String
Dim fc, fh, fs, width, db_gain, pCoef As Single
pointer = 1
Open App.Path + "\parameter.flash" For Binary As #1
For i = 1 To 6

    For j = 0 To 4
        Put #1, pointer, 1
        pointer = pointer + 2
    
    Next
 
Next


For i = 1 To 50
'If ((i Mod 7) <> 0) Then
    Filt_type = eqconfig.TextMatrix(i, 1)
    returnfiltertype (Filt_type)
    
    A(1) = eqconfig.TextMatrix(i, 2)
    A(2) = eqconfig.TextMatrix(i, 3)
    A(3) = eqconfig.TextMatrix(i, 4)
    A(4) = eqconfig.TextMatrix(i, 5)
    For j = 0 To 4
        Put #1, pointer, A(j)
        pointer = pointer + 2
    
    Next
' End If
Next
Exit Sub
'centre frequency---all pass                        3
    Filt_type = "SO_ALLPASS"
    returnfiltertype (Filt_type)
    
    A(1) = centrefrequency.TextMatrix(1, 0)
    A(2) = centrefrequency.TextMatrix(1, 1)
    
    For j = 0 To 2
        Put #1, pointer, A(j)
        pointer = pointer + 2
    Next
    
'FFT                    feed forward                5
Filt_type = "SO_BUTT_HIGPASS"
    returnfiltertype (Filt_type)
    
    A(1) = feedforward.TextMatrix(1, 0)
    A(2) = feedforward.TextMatrix(1, 1)
    A(3) = feedforward.TextMatrix(1, 2)
    A(4) = feedforward.TextMatrix(1, 3)
    
    For j = 0 To 4
        Put #1, pointer, A(j)
        pointer = pointer + 2
    Next


        
  Dim volumedata(0 To 3) As Integer
    volumedata(0) = volume.TextMatrix(1, 0) 'max
    volumedata(1) = volume.TextMatrix(1, 1) 'min
    volumedata(2) = volume.TextMatrix(1, 2) * 2 'step
'    volumedata(3) = volume.TextMatrix(1, 3) 'default
    
'volume parameter                                   3
For i = 0 To 2
    
        Put #1, pointer, volumedata(i)
        pointer = pointer + 2
    Next
For i = 0 To 5  'System Selection
    Put #1, pointer, SystemSelection(i).Value
       pointer = pointer + 2
    Next i
    
   For i = 281 To 281 + 12  'compression starts from 335
    Put #1, pointer, intworkingbuf(i)
       pointer = pointer + 2
    Next i
    
Close #1
End Sub



Private Sub returnfiltertype(flttype As String)
On Error Resume Next
Dim filtertype
filtertype = Array("FO_ALLPASS", "SO_ALLPASS", "SO_EQ", _
                    "FO_BUTT_LOWPASS", "FO_BUTT_HIGPASS", _
                    "SO_BUTT_LOWPASS", "SO_BUTT_HIGPASS", _
                    "SO_LR_LOWPASS", "SO_LR_HIGPASS", _
                    "FO_SHELF_BASS", "FO_SHELF_TREB", _
                    "SO_SHELF_BASS", "SO_SHELF_TREB", _
                    "LOW_PLATEAU", "HIGH_PLATEAU", _
                    "LOW_VARIQ", "HIGH_VARIQ", "NOTCH", _
                    "BANDPASS", "SHELF", "BYPASS")
For i = 0 To 20
If filtertype(i) = flttype Then
    A(0) = i
    Exit Sub
    
End If
Next

End Sub


Private Sub Command2_Click()
' Create TF
' input data
Q = 1
f = 60
fs = 48000#
pi = 3.1415926
' intemediate results
w = 2 * pi * f
Ts = 1 / fs
Wc = w                 ' correction (pre-warped) frequency - selected by designer

'B = [1*w/Q 0]         ' gain = 1 => independent of frequency
'a = [1 w/Q w^2]

'SYS = TF(B, a)

'bode (SYS)
'HOLD

'SYSD = C2D(SYS,Ts,'prewarp', Wc)
'pause

'[num,den,Ts] = tfdata(SYSD, 'v')

'TAS5504 -> b2 b1 b0'
'num / den(3)

'TAS5504 -> a2 a1 a0'
'den / den(3)


'//             A*s^2+B*s+C
'//     H(s) = ---------------
'//             D*s^2+E*s+F
'// fs - sample frequency

'Bandpass Filter:
'*      A = 0,          B = K*w/Q,      C = 0
'*      D = 1,          E = w/Q,        F = w^2

        '// Biquad
fa = Wc                '// [Hz] - prewraping frequency - fc, f_center, etc....

wa = (2 * fs) * Tan(pi * fa / fs)
C_wa = (2 * pi * f / wa)               '// correction coeficient

a1 = 0 * C_wa
b1 = w / Q * C_wa
C1 = 0 * C_wa
D1 = 1 * C_wa
E1 = w / Q * C_wa
F1 = (w ^ 2) * C_wa

a21 = ((4 * fs ^ 2 * D1 - 2 * fs * E1 + F1) / (4 * fs ^ 2 * D1 + 2 * fs * E1 + F1))

a11 = ((2 * F1 - 8 * fs ^ 2 * D1) / (4 * fs ^ 2 * D1 + 2 * fs * E1 + F1))
b21 = ((4 * fs ^ 2 * a1 - 2 * fs * b1 + C1) / (4 * fs ^ 2 * D1 + 2 * fs * E1 + F1))

b11 = ((2 * C1 - 8 * fs ^ 2 * a1) / (4 * fs ^ 2 * D1 + 2 * fs * E1 + F1))

b01 = ((4 * fs ^ 2 * a1 + 2 * fs * b1 + C1) / (4 * fs ^ 2 * D1 + 2 * fs * E1 + F1))

Dim st As Long
st = Hex((b21 * 2 ^ 20) And &HFFFFFF)
Debug.Print "b2="; Hex(b21 * 2 ^ 20), "b1="; Hex(b11 * 2 ^ 20), _
"b0="; Hex(b01 * 2 ^ 20), "a2="; Hex(a21 * 2 ^ 20), "a1="; Hex(a11 * 2 ^ 20)
decTohex (b21 * 2 ^ 20)
decTohex (b21 * 2 ^ 20)
End Sub
Private Sub decTohex(d)
Debug.Print "0x"; Hex(d And &HFF0000); Chr$(44);
Debug.Print "0x"; Hex(d Mod &H10000); Chr$(44);
Debug.Print "0x"; Hex(d Mod &H100); Chr$(44);
End Sub

Private Sub Command3_Click()
Dim BQtype As Byte
Dim fc As Double

Dim fh As Double
Dim fs As Double
Dim width As Double
Dim gain As Double
Dim p(0 To 14) As Byte
'----------SO_EQ
'For fc = 30 To 90 Step 10
'For i = 1 To 10
'            fs = 48000
'
'         width = fc / 6: gain = -6 + (i - 1) * 1.5: BQtype = 2: fh = 1
'
'            B = CalcFilterCoeffsT(BQtype, fc, fh, fs, width, gain, p(0))
'
'     For l = 0 To 14: Debug.Print " 0x"; Hex(p(l)); Chr$(44);: Next
'     Debug.Print
'     If gain = 6 Then
'     Exit For
'     End If
'    Next i
'    Next fc

For i = 1 To 18
            fs = 48000
          fc = 50
         width = 1: gain = -6 + (i - 1): BQtype = 11: fh = 1
        
           If (gain <> 0) Then B = CalcFilterCoeffsT(BQtype, fc, fh, fs, width, gain, p(0))
        
     For l = 0 To 14: Debug.Print " 0x"; Hex(p(l)); Chr$(44);: Next
     Debug.Print
     If gain = 6 Then
     Stop
     End If
    Next i
    

End Sub

Private Sub compression_2ohm1_Click()
compressionform_2ohm.Show
End Sub

Private Sub Compression_Click()
compressionform.Show
End Sub

Private Sub compression1_Click()
compressionform_2ohm.Show
End Sub

Private Sub eqconfig_Click()
On Error Resume Next
If eqconfig.RowSel > 7 Then Exit Sub
If eqconfig.CellBackColor = &HE44500 Then Exit Sub

'Select Case eqconfig.RowSel
'    Case 7, 14, 21, 28
'       Exit Sub 'eqconfig.TextMatrix(eqconfig.RowSel, eqconfig.ColSel) = 2222
'    End Select

If eqconfig.MouseCol = 0 Or eqconfig.MouseRow = 0 Then
tempedit1.Visible = False
    Exit Sub
End If
If eqconfig.ColSel = 1 Then
tempedit1.Visible = False
filertype.Top = eqconfig.CellTop + eqconfig.Top ' + eqconfig.CellHeight
filertype.Left = eqconfig.Left + eqconfig.CellLeft + 100
filertype.Text = eqconfig.TextMatrix(eqconfig.RowSel, eqconfig.ColSel)
filertype.Visible = True
Exit Sub
End If
If eqconfig.ColSel = 6 Then
If eqconfig.TextMatrix(eqconfig.RowSel, eqconfig.ColSel) = "Y" Then
    eqconfig.TextMatrix(eqconfig.RowSel, eqconfig.ColSel) = "N"
Else
    eqconfig.TextMatrix(eqconfig.RowSel, eqconfig.ColSel) = "Y"
End If
Exit Sub
Else
tempedit1.Height = eqconfig.CellHeight
tempedit1.width = eqconfig.CellWidth
tempedit1.Top = eqconfig.CellTop + eqconfig.Top '+ 2 * eqconfig.CellHeight
tempedit1.Left = eqconfig.CellLeft '+ 100
tempedit1.Text = eqconfig.TextMatrix(eqconfig.RowSel, eqconfig.ColSel)
tempedit1.Visible = True
tempedit1.SetFocus

filertype.Visible = False
Exit Sub
End If

End Sub

Private Sub feedforward_Click()
On Error Resume Next
tempedit2.Height = feedforward.CellHeight
tempedit2.width = feedforward.CellWidth
tempedit2.Top = feedforward.CellTop + feedforward.Top '+ 2 * feedforward.CellHeight
tempedit2.Left = feedforward.CellLeft '+ 100
tempedit2.Text = feedforward.TextMatrix(feedforward.RowSel, feedforward.ColSel)
tempedit2.Visible = True
tempedit2.SetFocus
End Sub

Private Sub feedforward_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
If X > feedforward.CellWidth Then
    feedforward.ToolTipText = "Second butter worth LOW pass"
Else
    feedforward.ToolTipText = "Second butter worth HIGH pass"
End If
End Sub

Private Sub filertype_click()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -