8.8 Programmes d'échantillonnage
À préparer dans Visual Basic
Communications RS-232C _______________________________________
(Utilisation de MSComm de Microsoft Visual Basic
(1) Mesure de résistance simple
Importe des valeurs mesurées 10 fois et sauvegarde les mesures dans un fichier texte.
Private Sub MeasureSubRS()
Dim recvstr As String
Dim i As Integer
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True
Open App.Path & "\data.csv" For Output As #1
MSComm1.Output = ":TRIG:SOUR IMM" & vbCrLf
MSComm1.Output = ":INIT:CONT ON" & vbCrLf
For i = 1 To 10
MSComm1.Output = ":FETCH?" & vbCrLf
recvstr = ""
While Right(recvstr, 1) <> Chr(10)
recvstr = recvstr + MSComm1.Input
DoEvents
Wend
recvstr = Left(recvstr, Len(recvstr) - 2)
Print #1, Str(i) & "," & recvstr
Next
Close #1
MSComm1.PortOpen = False
End Sub
Ces programmes d'échantillonnage sont écrits dans Microsoft Visual Basic 5.0
et 6.0.
®
5.0/6.0
• Ce qui suit est utilisé pour la communication :
Pour la communication RS-232C : MSComm de Visual Basic
Pour la communication GP-IB : Carte GP-IB National Instruments, Pilote et
module pour Visual Basic
• Pendant les communications, le paramètre du terminateur est supposé être
comme suit :
RS-232C : CR+LF
GP-IB : LF
®
Professional)
HIOKI BT3562A960-05
8.8 Programmes d'échantillonnage
®
'Receiving char string
'Comm port setting
'Open a port
'Open a text file for saving
'Select internal triggering
'Continuous measurement ON
'Send ":FETCH?" to import the most recent
measurement
'From here on, continue receiving until an LF code
occurs
'Delete the terminator (CR+LF)
'Write to the file
165
®
Professional
8