RDM6300 Advice

Evening all,

I'm a new Arduino'er and coder, having only started a few days ago! I've been trying to build a device which reads 125 khz RFID tags, displays the 8 digit token on an LCD screen and saves it to an SD card, after which point I would like to scan another RFID tag and again, display it on screen and onto the card. My hardware is a Uno R3, LinkSprite 16x2 and Deek-Robot SD shield, linked to an RDM6300 reader.

Essentially, the program works as per the original coding found within GitHub by ManiacBug, and to be honest - works exactly how I want it too except for the following two bugs:

  1. When I present the same card again. It just gives me a 0 and CHECKSUM ERROR in Serial. I don't have any other cards to test it with.

  2. When I boot with the SD card inserted, the program won't run. I have to boot then pop the card in.

I've searched the buggery out of the forum and the internets, and struggled - and so any assistance would be greatly appreciated. Tomorrow is day 3 learning to code so hoping for more luck! I've attatched a copy of the code.

Thanks,

S

Draft_2_6_Logger_Working.ino (7.08 KB)

My hardware is a Uno R3, LinkSprite 16x2 and Deek-Robot SD shield, linked to an RDM6300 reader.

Links, not vague descriptions.

      // Write message to confirm Arduino running.
      Serial.println(F("Arduino Serial Running OK\n"));
      
      // Print messages for Serial Output:
      Serial.println("125 kHz Recorder - Draft Version 2.3 Logger \n");
      
      Serial.println("Created on 22:52 28/12/15 \n");

The F() macro should be used everywhere.

      lcd.print("loserscott");
                      
            {
                  // Courtesy Message in Serial for SD Startup.
                  Serial.print("Initializing SD card...");

Why is there a curly brace there?

                  //Pin Allocation for SD Card.                  
                  pinMode(10, OUTPUT);
                  
                  // Pin Forced to High to overcome some issues with SD.
                  digitalWrite(10, HIGH);

That is NOT why pin 10 needs to be set high.

          // Experimental 1: If SD Card found at Pin 10.
          if (!SD.begin(10))             
                                                
          {

You initialized the reader in setup(). Do NOT do it again.

Your process for reading from the RFID device is fatally flawed. rfid_read is an interrupt service routine. When it is called, interrupts are disabled. The rfid object is an instance of SoftwareSerial, which relies on pin change interrupts to get data. They do not happen while the ISR is running, so only buffered data can be read.

You need to JUST set a flag in the ISR to indicate that there is data to be read, and then read ALL of the data in loop(), after the ISR ends.

Hello! Thank you very much for taking the time to download and read the code. I appreciate the feedback - it's all very new to me so lots of learning required I'm sure. I'm going to attempt to make the changes as you've suggested and report back. I'm unsure how to set the code for the rfid_read but I shall certainly have a go!

I'm unsure how to set the code for the rfid_read but I shall certainly have a go!

It's the same code as in the function, just executed from a different place.

Best would be to create a new function, rfid_ready() that is passed to attachInterrupt().

In rfid_ready(), simple set the ready flag.

Remove the setting of the ready flag from rfid_read(), and call rfid_read() from loop(), when the ready flag is set.

Paul,

Thanks for your support. I have made the majority of the changes you have suggested but I'm struggling with the last changes, mostly around the attachInterrupt command. Would you be able to take one last look for me and see if you can spot how many times I've gone wrong!

Advice is appreciated,

Scott

Draft_2_8_Logger.ino (5.95 KB)

uint8_t* buffer_end = buffer + sizeof(buffer);

The address of the buffer plus the size of the buffer points to the first memory address past the buffer, not to the end of the buffer.

uint8_t* buffer_at;

Why does this not point to anything?

The rfid_read() function is still doing too much. The call to rfid_ready() is unconditional. You have the roles of rfid_ready() and rfid_read() reversed. rfid_ready() should be triggered by the interrupt. rfid_read() should be called if ready is true.