Receiving with Serial Ports
' MSComm1 is the name of the Microsoft Comm component
Private Sub MSComm1_OnComm(Index As Integer)
Select Case MSComm1(Index).CommEvent
Case comEvSend
Case comEvEOF
Case comEvReceive
' Receive the data and write the result in the response text box
txtIn(Index).Text = txtIn(Index) & MSComm1(Index).Input
End Select
End Sub
Receiving with GPIB
' The GPIB control has no receive event, it must be queried for a response.
' timerGPIB counts down from 2 to 0, decrementing in the Timer1 function.
' Timer1 fires every 250 milliseconds This allows us to check for a response 4 times a second.
timerGPIB = 2
GPIBResult = "" 'tracks GPIB reply - see Timer1 function
' While loop will exit after receives a reply or times out - see Timer1 function
While timerGPIB > 0
DoEvents
Wend
' If we don't receive a reply in 1 second, time out
If GPIBResult = "" Then 'no reply
txtIn(Index).Text = "Timeout: " & TMWControl1.TimeOut/1000 & "seconds."
Else ' Write the reply to the response text box
txtIn(Index).Text = GPIBResult 'GPIB value
End If
'--- Timer1 function: fires every 250 ms ---
' Timer1 queries 4 times per second and jumps out of while loop once every 1 second
If timerGPIB > 0 Then
' Check for a response to the previous Send query
TMWControl1.Enter result$
' If we receive a result we break the previous Do Events loop
If result$ <> "" Then
Else
End If
End If
Receiving with TCP/IP
' tcpClient1 is the name of the Microsoft TCP Client component
Private Sub tcpClient1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
' Get data
tcpClient1.GetData strData
' Write the response in the response test box
txtIn(3).Text = Replace(strData, vbCrLf, "", 1, -1, vbBinaryCompare)
End Sub
Synergy Controller Technical Manual, Revision H
Visual Basic Code: Receiving
' SThreshold # of characters in transmit buffer.
' An EOF character was found in the input stream
' Received RThreshold # of chars
'Set global variable to response value
GPIBResult = result$
timerGPIB = 0
' Breaks out of previous While loop and records response
' Increment timerGPIB
timerGPIB = timerGPIB – 1
Page 284
Need help?
Do you have a question about the Synergy Series and is the answer not in the manual?
Questions and answers