📄 scope.frm
字号:
Font_6 = 0
tickopts_6 = 2711
major_6 = 500
minor_6 = 250
Caption_6 = 11
ClassName_11 = "CCWDrawObj"
opts_11 = 62
C[0]_11 = -2147483640
Image_11 = 12
ClassName_12 = "CCWTextImage"
style_12 = 119260024
font_12 = 0
Animator_11 = 0
Blinker_11 = 0
Y_5 = 13
ClassName_13 = "CCWAxis"
opts_13 = 575
Name_13 = "YAxis-1"
Orientation_13 = 2067
format_13 = 14
ClassName_14 = "CCWFormat"
Format_14 = """mV"""
Scale_13 = 15
ClassName_15 = "CCWScale"
opts_15 = 122880
rMin_15 = 12
rMax_15 = 213
dMin_15 = -4000
dMax_15 = 4000
discInterval_15 = 1
Radial_13 = 0
Enum_13 = 16
ClassName_16 = "CCWEnum"
Editor_16 = 17
ClassName_17 = "CCWEnumArrayEditor"
Owner_17 = 13
Font_13 = 0
tickopts_13 = 2711
major_13 = 1000
minor_13 = 500
Caption_13 = 18
ClassName_18 = "CCWDrawObj"
opts_18 = 62
C[0]_18 = -2147483640
Image_18 = 19
ClassName_19 = "CCWTextImage"
font_19 = 0
Animator_18 = 0
Blinker_18 = 0
LineStyle_5 = 1
LineWidth_5 = 1
BasePlot_5 = 0
DefaultXInc_5 = 1
DefaultPlotPerRow_5= -1 'True
Axes_1 = 20
ClassName_20 = "CCWAxes"
Array_20 = 2
Editor_20 = 21
ClassName_21 = "CCWGFAxisArrayEditor"
Owner_21 = 1
Array[0]_20 = 6
Array[1]_20 = 13
DefaultPlot_1 = 22
ClassName_22 = "CCWDataPlot"
opts_22 = 4194367
Name_22 = "[Template]"
C[0]_22 = 65280
C[1]_22 = 255
C[2]_22 = 16711680
C[3]_22 = 16776960
Event_22 = 2
X_22 = 6
Y_22 = 13
LineStyle_22 = 1
LineWidth_22 = 1
BasePlot_22 = 0
DefaultXInc_22 = 1
DefaultPlotPerRow_22= -1 'True
Cursors_1 = 23
ClassName_23 = "CCWCursors"
Editor_23 = 24
ClassName_24 = "CCWGFCursorArrayEditor"
Owner_24 = 1
TrackMode_1 = 10
GraphFrameStyle_1= 1
GraphBackground_1= 0
GraphFrame_1 = 25
ClassName_25 = "CCWDrawObj"
opts_25 = 62
Image_25 = 26
ClassName_26 = "CCWPictImage"
opts_26 = 1280
Rows_26 = 1
Cols_26 = 1
Pict_26 = 450
F_26 = -2147483633
B_26 = -2147483633
ColorReplaceWith_26= 8421504
ColorReplace_26 = 8421504
Tolerance_26 = 2
Animator_25 = 0
Blinker_25 = 0
PlotFrame_1 = 27
ClassName_27 = "CCWDrawObj"
opts_27 = 62
C[1]_27 = 0
Image_27 = 28
ClassName_28 = "CCWPictImage"
opts_28 = 1280
Rows_28 = 1
Cols_28 = 1
Pict_28 = 1
F_28 = -2147483633
B_28 = 0
ColorReplaceWith_28= 8421504
ColorReplace_28 = 8421504
Tolerance_28 = 2
Animator_27 = 0
Blinker_27 = 0
Caption_1 = 29
ClassName_29 = "CCWDrawObj"
opts_29 = 62
C[0]_29 = -2147483640
Image_29 = 30
ClassName_30 = "CCWTextImage"
font_30 = 0
Animator_29 = 0
Blinker_29 = 0
DefaultXInc_1 = 1
DefaultPlotPerRow_1= -1 'True
Bindings_1 = 31
ClassName_31 = "CCWBindingHolderArray"
Editor_31 = 32
ClassName_32 = "CCWBindingHolderArrayEditor"
Owner_32 = 1
Annotations_1 = 33
ClassName_33 = "CCWAnnotations"
Editor_33 = 34
ClassName_34 = "CCWAnnotationArrayEditor"
Owner_34 = 1
AnnotationTemplate_1= 35
ClassName_35 = "CCWAnnotation"
opts_35 = 63
Name_35 = "[Template]"
Plot_35 = 36
ClassName_36 = "CCWDataPlot"
opts_36 = 4194367
Name_36 = "[Template]"
C[0]_36 = 65280
C[1]_36 = 255
C[2]_36 = 16711680
C[3]_36 = 16776960
Event_36 = 2
X_36 = 6
Y_36 = 13
LineStyle_36 = 1
LineWidth_36 = 1
BasePlot_36 = 0
DefaultXInc_36 = 1
DefaultPlotPerRow_36= -1 'True
Text_35 = "[Template]"
TextXPoint_35 = 6.7
TextYPoint_35 = 6.7
TextColor_35 = 16777215
TextFont_35 = 37
ClassName_37 = "CCWFont"
bFont_37 = -1 'True
BeginProperty Font_37 {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ShapeXPoints_35 = 38
ClassName_38 = "CDataBuffer"
Type_38 = 5
m_cDims;_38 = 1
m_cElts_38 = 1
Element[0]_38 = 3.3
ShapeYPoints_35 = 39
ClassName_39 = "CDataBuffer"
Type_39 = 5
m_cDims;_39 = 1
m_cElts_39 = 1
Element[0]_39 = 3.3
ShapeFillColor_35= 16777215
ShapeLineColor_35= 16777215
ShapeLineWidth_35= 1
ShapeLineStyle_35= 1
ShapePointStyle_35= 10
ShapeImage_35 = 40
ClassName_40 = "CCWDrawObj"
opts_40 = 62
Image_40 = 41
ClassName_41 = "CCWPictImage"
opts_41 = 1280
Rows_41 = 1
Cols_41 = 1
Pict_41 = 7
F_41 = -2147483633
B_41 = -2147483633
ColorReplaceWith_41= 8421504
ColorReplace_41 = 8421504
Tolerance_41 = 2
Animator_40 = 0
Blinker_40 = 0
ArrowVisible_35 = -1 'True
ArrowColor_35 = 16777215
ArrowWidth_35 = 1
ArrowLineStyle_35= 1
ArrowHeadStyle_35= 1
End
Begin VB.Label Label2
Caption = "采集信号"
Height = 375
Left = 120
TabIndex = 7
Top = 1320
Width = 735
End
Begin VB.Label Label1
Caption = "功率谱"
Height = 1335
Left = 120
TabIndex = 6
Top = 4680
Width = 615
End
End
Attribute VB_Name = "Scope"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub CWGraph2_Click()
End Sub
Private Sub Exit_Click()
Call StopAcq1_Click
End '退出程序
End Sub
Private Sub Form_Load()
Dim initCoefa(0 To 4) As Double '此处6的值来自myIIR中的na-1,共6个静态系数
Dim initCoefb(0 To 4) As Double '此处6的值来自myIIR中的nb-1,共6个静态系数
X1 = initCoefb '将数组转换为可变类型
Y1 = initCoefa
End Sub
Private Sub StartAcq1_Click()
Dim temp As Long
temp = StartFifo() '队列长度为32768.
If temp = 0 Then
MsgBox "请检查USB连接!"
Call Exit_Click
End If
Timer1.Enabled = True
End Sub
Private Sub StopAcq1_Click()
Dim i As Long
i = StopFifo()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim QueueSize As Long
Dim temp As Long
Dim AcqData(ReadLenth - 1) As Double '从二次fifo中读数。
Dim AdjData As Variant '软件校正后的数据
QueueSize = ReadBuff(ReadLenth, AcqData(0)) '读数据
AdjData = CWArray1.LinEvArray(AcqData, 1, 0) '软件校正零点
CWSlide1.Value = QueueSize '动态显示fifo的大小
'----------------滤波-------------------------------------------------
Dim y As Variant
y = myIIR(AdjData)
' y = AdjData
'---------------------------------------------------------------------
CWGraph1.ChartY (y) '显示
'-----------------以下是fft谱分析设计------------------------
Dim autospectrum As Variant
Dim dt, df As Variant 'df是输出频率间隔,即fft的分辨率
dt = 1 / SampleRate
CWDSP1.AutoPowerSpectrum y, dt, autospectrum, df
CWGraph2.Axes(1).Minimum = 0
CWGraph2.Axes(1).Maximum = SampleRate / 2
CWGraph2.PlotY autospectrum, 0, df
End Sub
'----------------------------------------------------------------------
'本函数通过改变IIR滤波器的参数a,b可以设计任意的数字滤波器
'---------------------------------------------------------------------
Private Function myIIR(x As Variant) As Variant
'Dim t1(0 To 6) As Double, t2(0 To 6) As Double
Dim filterType, Order, SampleFreq, CutoffFreqLow, CutoffFreqHigh, na, nb, a, b, y As Variant
filterType = 0 '低通
Order = 5 '5阶ButterWorth
SampleFreq = SampleRate
CutoffFreqLow = 5000 '截至频率为50Hz
na = 6 '系数长度
nb = 6 '系数长度
CWDSP1.BwCoef filterType, Order, SampleFreq, CutoffFreqLow, CutoffFreqHigh, na, nb, a, b
CWDSP1.IIRFiltering x, a, b, Y1, X1, myIIR '特别注意:此处的X1,Y1为全局静态变量,在form_load处定义
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -