📄 frmcockpit.frm
字号:
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 2
Left = 120
TabIndex = 18
Top = 1800
Width = 975
End
Begin VB.Label lblOut
Alignment = 1 'Right Justify
Caption = "dB / dt"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 1
Left = 120
TabIndex = 17
Top = 1080
Width = 975
End
Begin VB.Label lblOut
Alignment = 1 'Right Justify
Caption = "dA / dt"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 0
Left = 120
TabIndex = 16
Top = 360
Width = 975
End
End
Begin MSComDlg.CommonDialog CommonDialog
Left = 1080
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton ButtonExit
Caption = "Exit"
Height = 375
Left = 8520
TabIndex = 2
Top = 2760
Width = 1215
End
Begin VB.CommandButton ButtonStop
Caption = "Stop"
Height = 375
Left = 240
TabIndex = 1
Top = 2760
Width = 1215
End
Begin VB.CommandButton ButtonStart
Caption = "Start"
Height = 375
Left = 240
TabIndex = 0
Top = 2160
Width = 1215
End
Begin VB.Menu mnuConfig
Caption = "Config"
Begin VB.Menu mnuSampling
Caption = "Sampling"
End
End
End
Attribute VB_Name = "frmCockpit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' Vektorstruktur, 6 Freiheitsgrade. 3 translatorische, 3 rotatorische
' wird fuer Parameteruebergabe an die f_*() Funktionen verwendet
' ACHTUNG: alpha, beta und gamma sind EULERWINKEL, also nicht einfach Rotationen
' um die jeweiligen Achsen. Mehr dazu siehe Transformationen
Private Type VectorType
xtrans As Double ' x - Richtung
ytrans As Double ' y - Richtung
ztrans As Double ' z - Richtung
arot As Double ' Alpha = "Bank" = Rot um (Laengsachse = y - Achse)
brot As Double ' Beta = "Pitch" = Rot um (Querachse = x - Achse)
crot As Double ' Gamma = "Direction" = Rot um (Hochachse = z - Achse)
End Type
Private Sub ButtonExit_Click()
' Programm beenden
End
End Sub
Private Sub ButtonStart_Click()
' Diese Routine aquiriert kontinuierlich Daten vom AD und uebergibt
' sie dem Artificial Horizont & Virtual Compass
' Wie koennen mit dem Aufsetzen des Samplings beginnen:
Dim iStatus As Integer
Dim iRetval As Integer
Dim iDevice As Integer
Dim iDBmodeON As Integer
Dim iDBmodeOFF As Integer
Dim ulCount As Long
Dim iLoopCount As Integer
Dim iHalfBufsToRead As Integer
Dim iUnits As Integer
Dim iSampTB As Integer
Dim piBuffer() As Integer
Dim piHalfBuffer() As Integer
Dim iHalfReady As Integer
Dim iDAQstopped As Integer
Dim ulPtsTfr As Long
Dim iIgnoreWarning As Integer
Dim lTimeout As Long
Dim iYieldON As Integer
Dim SampleCounter As Long ' Zaehler fuer die Anzahl Einzelsampels
Dim inRecord As Integer ' Welcher Wert innerhalb des Records?
Dim iterate As Integer ' Schlaufenvariable
Dim realTimebase As Double ' S_timeBase ist nur ein index 1 - 5
Dim correctBufferSize As Integer
Dim tempdouble As Double
Dim whichDispUpdate As Boolean ' welches Display soll upgedated werden?
' Initialisierung
iDevice% = 1 ' DAQ-Card 1200 immer Device 1
iDBmodeON% = 1 ' DoubleBufferedMode
correctBufferSize = S_bufferSize - (S_bufferSize Mod S_NrCh)
If (correctBufferSize Mod 2) <> 0 Then
correctBufferSize = correctBufferSize - S_NrCh
End If
ReDim piBuffer(correctBufferSize) ' S_bufferSize muss Vielfaches sein!
ReDim piHalfBuffer(S_bufferSize) ' Sicher groesser ...
iUnits% = 0 ' immer "Samples pro Sekunde"
ulCount = correctBufferSize
iHalfBufsToRead% = 20
lTimeout& = 180
iYieldON% = 1
PosCounter = 0
Ibank = 0
Ipitch = 0
' Abbuchbedingung setzen
GoOnAquire = True
' Disable Buttons
ButtonExit.Enabled = False
ButtonStart.Enabled = False
ButtonStop.Enabled = True
' Timeout Setzen
iStatus% = Timeout_Config(iDevice%, lTimeout&)
iRetval% = NIDAQErrorHandler(iStatus%, "Timeout_Config", iIgnoreWarning%)
' Timebase, SampleInterval und ScanInterval berechnen
' iStatus% = DAQ_Rate(S_Freq, iUnits%, S_sampTimebase, S_sampInterval)
' bestimmen der echten Timebase:
' Bedingungen:
' - ZeitproMessung >= 10us (bei Gain < 10) = S_sampInterval/realTimebase
' - realTimebase sampTimebase
' 100 Hz 5
' 1k Hz 4
' 10 kHz 3
' 100kHz 2
' 1MHz 1
' - scanInterval < 65535, > 2 und > NrCh / realTimebase + 5 us
' - SampleRate (Hz) = realTimebase / scanInterval
Select Case S_Freq
Case 1
' 1 Hz
S_sampTimebase = 3
S_sampInterval = 2
realTimebase = 10000
S_scanInterval = 10000
Case 10
' 10 Hz
S_sampTimebase = 2
S_sampInterval = 2
realTimebase = 100000
S_scanInterval = 10000
Case 50
' 50 Hz
S_sampTimebase = 2
S_sampInterval = 2
realTimebase = 100000
S_scanInterval = 2000
Case 150
' 150 Hz
S_sampTimebase = 1
S_sampInterval = 10
realTimebase = 1000000
S_scanInterval = 6667
Case 300
' 300 Hz
S_sampTimebase = 1
S_sampInterval = 10
realTimebase = 1000000
S_scanInterval = 3333
Case 500
' 500 Hz
S_sampTimebase = 1
S_sampInterval = 10
realTimebase = 1000000
S_scanInterval = 2000
Case 2000
' 2000 Hz
S_sampTimebase = 1
S_sampInterval = 10
realTimebase = 1000000
S_scanInterval = 500
End Select
If S_Freq <> 0 Then
S_scanInterval = CInt((1 / S_Freq) * realTimebase)
Else
' Division by zero, kommt nie vor, hoffentlich ;-)
End If
' Single ended unipolar input mode setzen
iStatus% = AI_Configure(iDevice%, -1, 1, 0, 1, 0)
' Double Buffered Mode
iStatus% = DAQ_DB_Config(iDevice%, iDBmodeON%)
iRetval% = NIDAQErrorHandler(iStatus%, "DAQ_DB_Config", iIgnoreWarning%)
' Dithering einschalten
iStatus% = MIO_Config(iDevice%, 1, 0)
' Starte Scan Aquisition
iStatus% = Lab_ISCAN_Start(iDevice%, S_NrCh, S_gain, piBuffer%(0), ulCount, S_sampTimebase, S_sampInterval, S_scanInterval)
iRetval% = NIDAQErrorHandler(iStatus%, "Lab_ISCAN_Start", iIgnoreWarning%)
RecordCounter = 0
SampleCounter = 0
' Loopen und lesen
While ((iLoopCount% < iHalfBufsToRead%) And (iStatus% = 0) And (GoOnAquire))
iLoopCount% = 0 ' Ewig
iStatus% = DAQ_DB_HalfReady(iDevice%, iHalfReady%, iDAQstopped%)
' Ist wieder ein halber Buffer lesebereit?
If ((iHalfReady% = 1) And (iStatus% = 0)) Then
' Ja, lesebereit
iStatus% = DAQ_DB_Transfer(iDevice%, piHalfBuffer%(0), ulPtsTfr&, iDAQstopped%)
iRetval% = NIDAQErrorHandler(iStatus%, "DAQ_DB_Transfer", 0)
' Abfuellen in MessArr - Struktur
For iterate = 0 To (ulPtsTfr& - 1)
inRecord = S_NrCh - (SampleCounter Mod (S_NrCh)) - 1
MessArr(RecordCounter, inRecord) = piHalfBuffer%(iterate)
If inRecord = 0 Then
Call calculateOrientation
RecordCounter = RecordCounter + 1
End If
SampleCounter = SampleCounter + 1 ' Anzahl Samples
Next iterate
' Messung Anzeigen
If RecordCounter > 0 Then
For iterate = 0 To 2
TextAnalog(iterate).Text = MessArr(RecordCounter - 2, iterate + 3)
Next iterate
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -