Lake Shore Model 625 Superconducting MPS User’s Manual
Computer Interface Operation
5-29
Table 5-9. Visual Basic Serial Interface Program
Public gSend As Boolean 'Global used for Send button state
Private Sub cmdSend_Click() 'Routine to handle Send button press
gSend = True 'Set Flag to True
End Sub
Private Sub Form_Load() 'Main code section
Dim strReturn As String 'Used to return response
Dim strHold As String 'Temporary character space
Dim Term As String 'Terminators
Dim ZeroCount As Integer 'Counter used for Timing out
Dim strCommand As String 'Data string sent to instrument
frmSerial.Show 'Show main window
Term = Chr(13) & Chr(10) 'Terminators are <CR><LF>
ZeroCount = 0 'Initialize counter
strReturn = "" 'Clear return string
strHold = "" 'Clear holding string
If frmSerial.MSComm1.PortOpen = True Then 'Close serial port to change settings
frmSerial.MSComm1.PortOpen = False
End If
frmSerial.MSComm1.CommPort = 1 'Example of Comm 1
frmSerial.MSComm1.Settings = "9600,o,7,1" 'Example of 9600 Baud,Parity,Data,Stop
frmSerial.MSComm1.InputLen = 1 'Read one character at a time
frmSerial.MSComm1.PortOpen = True 'Open port
Do
Do 'Wait loop
DoEvents 'Give up processor to other events
Loop Until gSend = True 'Loop until Send button pressed
gSend = False 'Set Flag as false
strCommand = frmSerial.txtCommand.Text 'Get Command
strReturn = "" 'Clear response display
strCommand = UCase(strCommand) 'Set all characters to upper case
If strCommand = "EXIT" Then 'Get out on EXIT
End
End If
frmSerial.MSComm1.Output = strCommand & Term 'Send command to instrument
If InStr(strCommand, "?") <> 0 Then 'Check to see if query
While (ZeroCount < 20) And (strHold <> Chr$(10)) 'Wait for response
If frmSerial.MSComm1.InBufferCount = 0 Then 'Add 1 to timeout if no character
frmSerial.Timer1.Enabled = True
Do
DoEvents 'Wait for 10 millisecond timer
Loop Until frmSerial.Timer1.Enabled = False
ZeroCount = Zer 1 'Timeout at 2 seconds
Else
ZeroCount = 0 'Reset timeout for each character
strHold = frmSerial.MSComm1.Input 'Read in one character
strReturn = str strHold 'Add next character to string
End If
Wend 'Get characters until terminators
If strReturn <> "" Then 'Check if string empty
strReturn = Mid(strReturn, 1, InStr(strReturn, Term) – 1) 'Strip terminators
Else
strReturn = "No Response" 'Send No Response
End If
frmSerial.txtResponse.Text = strReturn 'Put response in textbox on main form
strHold = "" 'Reset holding string
ZeroCount = 0 'Reset timeout counter
End If
Loop
End Sub
Private Sub Timer1_Timer() 'Routine to handle Timer interrupt
frmSerial.Timer1.Enabled = False 'Turn off timer
End Sub
Содержание 625
Страница 2: ...Lake Shore Model 625 Superconducting MPS User s Manual A ...
Страница 5: ...Lake Shore Model 625 Superconducting MPS User s Manual D ...
Страница 6: ...Lake Shore Model 625 Superconducting MPS User s Manual C ...
Страница 8: ...Lake Shore Model 625 Superconducting MPS User s Manual E ...
Страница 20: ...Lake Shore Model 625 Superconducting MPS User s Manual 1 8 Introduction This Page Intentionally Left Blank ...
Страница 36: ...Lake Shore Model 625 Superconducting MPS User s Manual 3 10 Installation This Page Intentionally Left Blank ...
Страница 100: ...Lake Shore Model 625 Superconducting MPS User s Manual 6 2 Options and Accessories ...
Страница 101: ...Lake Shore Model 625 Superconducting MPS User s Manual Options and Accessories 6 3 This Page Intentionally Left Blank ...
Страница 102: ......