B4R Question RDM6300 RFID Card Reader

Mostez

Well-Known Member
Licensed User
Longtime User
Hi,
I'm making an RFID reader using RDM6300 UART RFID reader. This module has no real trigger out signal, it has LED output signal following card number stream. I had to use this signal to trigger Arduino to read serial stream. the time between LED signal and next serial stream is 50ms. so I had to ignore first read and wait for the next for 50ms. after all of that I got no data at all, serial buffer is zero length. any ideas? PS. according to datasheet, TTL timing diagram shows CP signal leading serial stream!! this pin is not found!

Thanks

B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Private RFID As SoftwareSerial
    Private RFIDbuffer(14) As Byte
    Private RFIDena As Pin
    Private Ba As Byte
End Sub

Private Sub AppStart
    RFIDena.Initialize(4,RFIDena.MODE_INPUT_PULLUP)
    RFIDena.AddListener ("RFIDchanged")
    RFID.Initialize(9600,2,3)
    Serial1.Initialize(115200)
    Log("AppStart")
End Sub

private Sub RFIDchanged(State As Boolean)
    If State = False Then
        CallSubPlus ("ReadRFID",50,0)
    End If
End Sub

private Sub ReadRFID(tag As Byte)
   
    Ba = RFID.Stream.BytesAvailable
    Log(Ba)
    'If Ba >=1 Then
        RFID.Stream.ReadBytes(RFIDbuffer,0,14)
        Log(RFIDbuffer)
    'End If
End Sub
 

Attachments

  • rfid_timing.png
    rfid_timing.png
    100.2 KB · Views: 404
  • rfid_log.png
    rfid_log.png
    1.8 KB · Views: 406

Mostez

Well-Known Member
Licensed User
Longtime User
I changed the board from Leonardo to Uno, it worked OK, I also tried this code as suggested, it worked well too. but I wonder why it did not work with Leonardo, all I need is to read RFID card and send it to PC as keyboard output :(

B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Private RFID As SoftwareSerial
    Private Astream As AsyncStreams
    Private LED As Pin
End Sub

Private Sub AppStart
    RFID.Initialize(9600,2,3)
    Astream.Initialize(RFID.Stream ,"ReadRFID","RFIDerr")
    Serial1.Initialize(115200)
    LED.Initialize(13, LED.MODE_OUTPUT)
    LED.DigitalWrite(False)
    Log("AppStart")
End Sub

private Sub ReadRFID(Buffer() As Byte)
     LED.DigitalWrite(True)
     Log (Buffer.Length)
     Log(Buffer)
End Sub

private Sub RFIDerr()
    Log("Error")
End Sub
 
Upvote 0

Mostez

Well-Known Member
Licensed User
Longtime User
Hello,
sorry for not starting a new thread, but I wanted to share this solution under same page. I read that leonardo D0 D1 serial pins are not the same like those on UNO, the article says:

There is now a second serial port. The primary port is built into the USB interface and the Tx/Rx LEDs are attached to it. The secondary port is located at pins D0 & D1. This port does not have any LEDs attached.
To use the primary serial port, use the class Serial as usual. For the secondary port, a new serial class called Serial1 has been created. You use it the same way as the Serial class.

so if you want to use D0 D1 on leonardo board they should be treated like additional serial ports on Mega (Serial1), see this example by Erel, full article here
after adding inline C code, the code worked as expected.

Thanks
 
Upvote 0
Top