Go Down

Topic: Priority 1 Design Rfid (Read 3376 times) previous topic - next topic

crumpy10

Hi All,
I have a problem with a little success using a rfid from Priority 1 Design in Melbourne.

http://www.priority1design.com.au/shopfront/index.php?main_page=product_info&cPath=1&products_id=18

Please excuse my lack of knowledge I am a very green learner in the Arduino world but I am willing to learn.

I have managed to read a 134khz tag successfully (I think!) but I am getting added numbers in the serial monitor as well as my rfid code.

My tag number is -:982123468623775

and my serial monitor is displaying -: 39 38 32 5F 31 32 33 34 36 38 36 32 33 37 37 35 0D

Now I am guessing the 5F is an underscore and the 0D is a carriage return.  What I am looking to do is just display the tag number in the same format as the top one!
Has anyone had any experience with this module or any ideas please?

Below is my code, yes its cut and paste and may contain newbie errors, please be gentle!

Code: [Select]

#include <SoftwareSerial.h>
SoftwareSerial RFID(2, 3); // RX and TX

int i;

void setup()
{
  RFID.begin(9600);    // start serial to RFID reader
  Serial.begin(9600);  // start serial to PC
}

void loop()
{
  if (RFID.available() > 0)
  {
     i = RFID.read();
     Serial.print(i, HEX); //Display the Serial Number in HEX
     Serial.print(" ");
  }
}


Thanks for your time everyone.

barbaz

#1
Sep 22, 2014, 07:02 pm Last Edit: Sep 22, 2014, 07:17 pm by barbaz Reason: 1
Hey! I'm looking forward to play with one of these rfid modules too, as soon as I get a hold of one.

So here's what the datasheet says:

Quote
The output format for a read of an FDX-B protocol transponder is a simple string of decimal characters
indicating the 3 digit country code, and 12 digit National ID followed by the ASCII code $0D (carriage
return) as a string end marker.

When a FDX-B programmed transponder enters the field of the reader it will be scanned and a string as
shown in the example below is transmitted:

999_000000001008<crn>, where <crn> is serial ASCII code $0D, and "_" is a data separator

In this example 999 is the country code defined inside the transponder, while 000000001008 is the unique
12 digit decimal code used to identify an animal.

FDX-B protocol transponders may contain additional data which can be accessed using specific commands.
See RAT and WAT commands as shown in Table 3. Active Tag Commands Summary further on.


What you need here is a way of discarding the underscore,  dealing with the cr, and printing the characters as actual characters and not integers in hexadecimal format.

Here is how I would do it (not tested of course, and I'm an arduino newbie myself so take this with a grain of salt):

Code: [Select]

#include <SoftwareSerial.h>
SoftwareSerial RFID(2, 3); // RX and TX

// no need to use an integer, it's characters we are dealing with
char c;

void setup()
{
 RFID.begin(9600);    // start serial to RFID reader
 Serial.begin(9600);  // start serial to PC
}

void loop()
{
 if (RFID.available() > 0)
 {
    c = RFID.read();
   
    // underscore? ignore it and jump to the next character
    if (c == '_') return;
   
    // send the character
    Serial.write(c);

    // if it was a carriage return send a linefeed character, too
    if (c == '\r')  Serial.write('\n');
 }
}

crumpy10

Hello,
Heres the final code I came up with that works with an LCD display for the number.  Give it a go and play around with it.  The guys that sell this reader in Oz are pretty good at dispatch.  It seems like a nice little module so far.

Code: [Select]
// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define WHITE 0x7 //set the backlight colour
SoftwareSerial RFID(2, 3); //pin2 Rx, pin3 Tx

int CMD[64];
int comlen = 0;
int out_flag = 0;

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2); // set up the LCD's number of columns and rows:
  RFID.listen();
  Serial.println("Tag number will be displayed here if detected by the module:\n");
  lcd.print("Your tag No is:");
  lcd.setCursor(0, 1); //place cursor on 2nd row for tag number
 
  RFID.begin(9600); // set the data rate for the RFID reader
  delay(10);

}
void loop()

{

  while (Serial.available())
  {
    int a = SerialReadHexDigit();
    if (a >= 0) {
      CMD[comlen] = a;
      comlen++;
    }
    delay(10);
  }

  for (int i = 0; i < comlen; i += 2) {
    int c = RFID.write( CMD[i] * 16 + CMD[i + 1]);
  }
  comlen = 0;

  while (RFID.available()) {
    byte C = RFID.read();
    //if (C<16) Serial.print("0"); //Future use for tags with less numbers
    Serial.write(C);  //Display tag number on serial bus in human form
       
    lcd.write(C);     //Display tag number on LCD
   
    //Serial.print(" "); //Puts space between each digit on Serial Monitor
    out_flag = 1;
  }
  if (out_flag > 0) {
    Serial.println();
    out_flag = 0;
    lcd.setCursor(0, 1);
  }
}
int SerialReadHexDigit()
{
  byte c = (byte) Serial.read();
  if (c >= '0' && c <= '9') {
    return c - '0';
  } else if (c >= 'a' && c <= 'f') {
    return c - 'a' + 10;
  } else if (c >= 'A' && c <= 'F') {
    return c - 'A' + 10;
  } else {
    return -1;   // getting here is bad: it means the character was invalid
  }
}

barbaz

Ah I see, that writes the rfid tag, too! Why not input the digits in decimal format:

Code: [Select]

int SerialReadDecDigit()
{
  byte c = (byte) Serial.read();
  if (c >= '0' && c <= '9') {
    return c - '0';
  } else {
    return -1;   // getting here is bad: it means the character was invalid
  }
}


I'm thinking of writng some code to manage the other kinds of rfid tags as well, maybe I'll post it here when I've got something. Cheers!

Seedler

Crumpy10 thanks for posting your code. I have the TTL version of Priority one's reader, and your code is getting me an output. I am trying to read cattle tags. From the format of your number I'm guessing you are reading the same.

The code displayed though is not the same as the code printed on the tag. Is this what happens, or am I doing something wrong?

Cheers,

Damien

clemenlg

Crumpy10 thanks for posting your code. I have the TTL version of Priority one's reader, and your code is getting me an output. I am trying to read cattle tags. From the format of your number I'm guessing you are reading the same.

The code displayed though is not the same as the code printed on the tag. Is this what happens, or am I doing something wrong?

Cheers,

Damien
Crumpy10 thanks for posting your code. I have the TTL version of Priority one's reader, and your code is getting me an output. I am trying to read cattle tags. From the format of your number I'm guessing you are reading the same.

The code displayed though is not the same as the code printed on the tag. Is this what happens, or am I doing something wrong?

Cheers,

Damien
Do you have any progress?
Can you explain/show your connections?
Regards

Go Up