SkinH_Attach 未定义,大神赐教。
Private Sub Command1_Click()Dim timer_clk As Double
Dim Ts As Double
Dim f_out As Double
Dim ModulationDepth As Double
Const PI = 3.141592654
Const PARA = 0.866025403
Dim TBCCR0 As Integer
Dim Dimension As Integer
Dim SVcounter As Integer
Dim SV_T1 As Double
Dim SV_T2 As Double
Dim SV_T0 As Double
TBCCR0 = 0
Dimension = 0
SVcounter = 0
SV_T1 = 0
SV_T2 = 0
SV_T0 = 0
timer_clk = Val(Text1.Text)
Ts = Val(Text2.Text)
f_out = Val(Text3.Text)
ModulationDepth = Val(Text4.Text)
Text5.Text = ""
'计算TBCCR0
TBCCR0 = 0.5 * 1000 * timer_clk / Ts
'计算数组长度
Dimension = 1000 * Ts / f_out
'显示参数资信
Text5.FontBold = False
Text5.FontSize = 10
Text5.Text = "The results are :" & vbCrLf
Text5.Text = Text5.Text + " TBCCR0 = " & Str(TBCCR0) & vbCrLf
Text5.Text = Text5.Text + " the length of array = " & Str(Dimension) & vbCrLf & vbCrLf
Text5.Text = Text5.Text + "With following conditions: " & vbCrLf
Text5.Text = Text5.Text + " Timer clock = " & Str(timer_clk) & " MHz;" & vbCrLf
Text5.Text = Text5.Text + " the frequency of each pulse circle = " & Str(Ts) & " kHz" & vbCrLf
Text5.Text = Text5.Text + " the frequency of output = " & Str(f_out) & " Hz" & vbCrLf
Text5.Text = Text5.Text + " the modulation depth = " & Format(Str(ModulationDepth), "0.000") & vbCrLf & vbCrLf
Text5.Text = Text5.Text + "The arrays are :" & vbCrLf
Dim SV_cmp1() As Double
Dim SV_cmp2() As Double
Dim SV_cmp3() As Double
Dim SV_PHA() As Integer
Dim SV_PHB() As Integer
Dim SV_PHC() As Integer
ReDim SV_cmp1(Dimension)
ReDim SV_cmp2(Dimension)
ReDim SV_cmp3(Dimension)
ReDim SV_PHA(Dimension)
ReDim SV_PHB(Dimension)
ReDim SV_PHC(Dimension)
For SVcounter = 0 To Dimension - 1 Step 1
'第一扇区
If SVcounter <= (Dimension * 1 / 6 - 1) And SVcounter >= 0 Then
SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 1 / 6)
SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 9 / 6)
SV_T0 = (1 - SV_T1 - SV_T2) / 2
SV_cmp1(SVcounter) = SV_T1 + SV_T2 + SV_T0
SV_cmp2(SVcounter) = SV_T2 + SV_T0
SV_cmp3(SVcounter) = SV_T0
SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
End If
'第二扇区
If SVcounter <= (Dimension * 2 / 6 - 1) And SVcounter >= (Dimension * 1 / 6) Then
SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 11 / 6)
SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 7 / 6)
SV_T0 = (1 - SV_T1 - SV_T2) / 2
SV_cmp1(SVcounter) = SV_T1 + SV_T0
SV_cmp2(SVcounter) = SV_T1 + SV_T2 + SV_T0
SV_cmp3(SVcounter) = SV_T0
SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
End If
'第三扇区
If SVcounter <= (Dimension * 3 / 6 - 1) And SVcounter >= (Dimension * 2 / 6) Then
SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 9 / 6)
SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 5 / 6)
SV_T0 = (1 - SV_T1 - SV_T2) / 2
SV_cmp1(SVcounter) = SV_T0
SV_cmp2(SVcounter) = SV_T1 + SV_T2 + SV_T0
SV_cmp3(SVcounter) = SV_T2 + SV_T0
SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
End If
'第四扇区
If SVcounter <= (Dimension * 4 / 6 - 1) And SVcounter >= (Dimension * 3 / 6) Then
SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 7 / 6)
SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 3 / 6)
SV_T0 = (1 - SV_T1 - SV_T2) / 2
SV_cmp1(SVcounter) = SV_T0
SV_cmp2(SVcounter) = SV_T1 + SV_T0
SV_cmp3(SVcounter) = SV_T1 + SV_T2 + SV_T0
SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
End If
'第五扇区
If SVcounter <= (Dimension * 5 / 6 - 1) And SVcounter >= (Dimension * 4 / 6) Then
SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 5 / 6)
SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 1 / 6)
SV_T0 = (1 - SV_T1 - SV_T2) / 2
SV_cmp1(SVcounter) = SV_T2 + SV_T0
SV_cmp2(SVcounter) = SV_T0
SV_cmp3(SVcounter) = SV_T1 + SV_T2 + SV_T0
SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
End If
'第六扇区
If SVcounter <= (Dimension * 6 / 6 - 1) And SVcounter >= (Dimension * 5 / 6) Then
SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 3 / 6)
SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 11 / 6)
SV_T0 = (1 - SV_T1 - SV_T2) / 2
SV_cmp1(SVcounter) = SV_T1 + SV_T2 + SV_T0
SV_cmp2(SVcounter) = SV_T0
SV_cmp3(SVcounter) = SV_T1 + SV_T0
SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
End If
Next SVcounter
Text5.Text = Text5.Text & "unsigned int TB_CCR_A[" & Str(Dimension) & " ] ={" & vbCrLf
For SVcounter = 0 To Dimension - 1 Step 1
Text5.Text = Text5.Text & Str(SV_PHA(SVcounter)) & ","
If SVcounter Mod 10 = 9 Then
Text5.Text = Text5.Text & vbCrLf
End If
Next SVcounter
Text5.Text = Text5.Text & "};" & vbCrLf
Text5.Text = Text5.Text & "unsigned int TB_CCR_B[" & Str(Dimension) & " ] ={" & vbCrLf
For SVcounter = 0 To Dimension - 1 Step 1
Text5.Text = Text5.Text & Str(SV_PHB(SVcounter)) & ","
If SVcounter Mod 10 = 9 Then
Text5.Text = Text5.Text & vbCrLf
End If
Next SVcounter
Text5.Text = Text5.Text & "};" & vbCrLf
Text5.Text = Text5.Text & "unsigned int TB_CCR_C[" & Str(Dimension) & " ] ={" & vbCrLf
For SVcounter = 0 To Dimension - 1 Step 1
Text5.Text = Text5.Text & Str(SV_PHC(SVcounter)) & ","
If SVcounter Mod 10 = 9 Then
Text5.Text = Text5.Text & vbCrLf
End If
Next SVcounter
Text5.Text = Text5.Text & "};" & vbCrLf
End Sub
Private Sub Command2_Click()
Open "SVresult.txt" For Output As #1
Print #1, Text5.Text
Close #1
End Sub
Private Sub Text1_Change()
End Sub
Private Sub Timer1_Timer()
Cls
Label9.Caption = Now
End Sub
Private Sub Form_Load()
SkinH_Attach
Timer1.Interval = 500
Timer1.Enabled = True
Label9.Caption = Now
End Sub