I am going to try to describe exactly what I'm seeing and hearing to try and make this as clear as possible.
We have a camera that snaps a picture of a part we mold as the robot takes it out of the press. The camera compares 6 areas of the part for contrast. If the contrast is right a 1 is returned, if wrong we get a 0. This camera is hooked up to a control box and the control box connects to a laptop via serial port (com1). We want to capture this data and time stamp it for customer reference.
When I start hyper terminal using 115200,8,N,1 and hit the button, the control box goes click-click. Data is received by hyper terminal. The data is in this format xxx,1,1,1,1,1,1 where xxx is a sequencial number for each camera shot. No problem so far.
Well I figured it would not be hard to write a quick vb app to capture this data with a timestamp and log to a text file. I was wrong.
I am using the MSCOMM32.ocx for my communication. I can not get anything to receive though. One thing that I have been able to produce is what keeps driving me, I think it's close. If I open the port with my app I then click the button 15 times. after the fifteenth click-click all I get is one click. If I then hit the receive button on my app I get one character. The first character of the sequencial number. But the camera will not click-click any more. So now I close my app and open hyper terminal. Once terminal is open the camera gives me another click and the next sequencial number comes up. No other data, just the number. Then the camera operates correcly (click-click).
I don't know what to do. Please help. More information is below.
Here is the code.
Private Sub cmdClose_Click()
cmdClose.Enabled = False
cmdOpen.Enabled = True
Comm1.PortOpen = False
Write #1, Now() & "- Port Closed"
Close #1
lblStatus.Caption = "Port Closed"
End Sub
Private Sub cmdOpen_Click()
cmdClose.Enabled = True
cmdOpen.Enabled = False
Open "c:\commlog.txt" For Output As #1
With Comm1
.CommPort = 1
.Settings = "115200,N,8,1"
.Handshaking = comXOnXoff
.InputLen = 0
End With
Comm1.PortOpen = True
Write #1, Now() & "- Port Open"
lblStatus.Caption = "Port Open" & vbCrLf & "Waiting..."
MsgBox Comm1.CommID
End Sub
Private Sub Form_Click()
Dim strCommData As String
strCommData = Comm1.Input
lblStatus.Caption = Now() & vbCrLf & "Received " & " - " & strCommData
Write #1, Now() & strCommData
End Sub
Here are my MSCOMM32 settings
Settings = "115200,8,N,1"
CommPort = 1
DTREnable = False
EOFEnable = False
Handshaking = comXOnXoff
InBufferSize = 1024
InputLen = 0
InputMode = comInputModeText
RThreshold = 100
RTSEnable = False
Chris
IS Manager
We have a camera that snaps a picture of a part we mold as the robot takes it out of the press. The camera compares 6 areas of the part for contrast. If the contrast is right a 1 is returned, if wrong we get a 0. This camera is hooked up to a control box and the control box connects to a laptop via serial port (com1). We want to capture this data and time stamp it for customer reference.
When I start hyper terminal using 115200,8,N,1 and hit the button, the control box goes click-click. Data is received by hyper terminal. The data is in this format xxx,1,1,1,1,1,1 where xxx is a sequencial number for each camera shot. No problem so far.
Well I figured it would not be hard to write a quick vb app to capture this data with a timestamp and log to a text file. I was wrong.
I am using the MSCOMM32.ocx for my communication. I can not get anything to receive though. One thing that I have been able to produce is what keeps driving me, I think it's close. If I open the port with my app I then click the button 15 times. after the fifteenth click-click all I get is one click. If I then hit the receive button on my app I get one character. The first character of the sequencial number. But the camera will not click-click any more. So now I close my app and open hyper terminal. Once terminal is open the camera gives me another click and the next sequencial number comes up. No other data, just the number. Then the camera operates correcly (click-click).
I don't know what to do. Please help. More information is below.
Here is the code.
Private Sub cmdClose_Click()
cmdClose.Enabled = False
cmdOpen.Enabled = True
Comm1.PortOpen = False
Write #1, Now() & "- Port Closed"
Close #1
lblStatus.Caption = "Port Closed"
End Sub
Private Sub cmdOpen_Click()
cmdClose.Enabled = True
cmdOpen.Enabled = False
Open "c:\commlog.txt" For Output As #1
With Comm1
.CommPort = 1
.Settings = "115200,N,8,1"
.Handshaking = comXOnXoff
.InputLen = 0
End With
Comm1.PortOpen = True
Write #1, Now() & "- Port Open"
lblStatus.Caption = "Port Open" & vbCrLf & "Waiting..."
MsgBox Comm1.CommID
End Sub
Private Sub Form_Click()
Dim strCommData As String
strCommData = Comm1.Input
lblStatus.Caption = Now() & vbCrLf & "Received " & " - " & strCommData
Write #1, Now() & strCommData
End Sub
Here are my MSCOMM32 settings
Settings = "115200,8,N,1"
CommPort = 1
DTREnable = False
EOFEnable = False
Handshaking = comXOnXoff
InBufferSize = 1024
InputLen = 0
InputMode = comInputModeText
RThreshold = 100
RTSEnable = False
Chris
IS Manager