PDA

View Full Version : parallax rfid reader module interface with PC



jonil22
- 31st January 2008, 00:45
Hi,

I am doing an interface with the PC and the parallax RFID reader module through PIC 16F877A. The program interface in the PC is Visual Basic 6(VB6) . I think there is something wrong with my Visual Basic codings. When i scan the RFID tag , the VB6 will capture the data from the PIC. Then it will search the database for the matching ID. IF found , the label box will put Found It. The porblem is that when i scanned the matching RFID ID tag , the VB6 program will put Not Found in the label box and the program will hang. When the MSComm1.output = Chr$(255) & Chr$(modenumber) command line is deleted, when the RFID tag is scanned , the program can find the matching data in the database. Is there any problem with my codings ? Below is the vb6 program code.

Private Sub Form_Load()

MSComm1.CommPort = 1
MSComm1.Settings = "2400,N,8,1"
MSComm1.RThreshold = 10
MSComm1.SThreshold = 1
MSComm1.InputLen = 0
MSComm1.PortOpen = True
MSComm1.DTREnable = False
MSComm1.RTSEnable = False

End Sub


Private Sub MSComm1_OnComm()
Dim buffer As String, Criteria As String
Dim IDFound As Boolean
Dim modenumber As Integer

If (MSComm1.CommEvent = comEvReceive) Then
buffer = MSComm1.Input
picBox.Print buffer & " " & Time() & " " & Date
End If

IDFound = False
modenumber = 0
Criteria = "ID =" & "'" & buffer & "'"
datIDTAG.Recordset.FindFirst Criteria
MSComm1.OutBufferCount = 0

Do While datIDTAG.Recordset.NoMatch = False
modenumber = 1
lblNum.Caption = "Found It. " & modenumber
IDFound = True
datIDTAG.Recordset.FindNext Criteria
Loop
If IDFound = False Then
lblNum.Caption = "Not Found. " & modenumber
End If

MSComm1.Output = Chr$(255) & Chr$(modenumber)

End Sub

Plz help me to solve this problem.Thanks.

cooksydesign
- 31st January 2008, 19:27
Jonil22,
Try adding MSCOMM1.InBufferCount = 0 at the end of the OnCom event.
You may want to close the port as soon as you have your data.

B

jonil22
- 3rd February 2008, 06:54
dear cooksydesign,

i have tried what you recommend me to do but the program still cannot run whenever i put the MSComm1.ouput line. So sorry for the late reply.