Show Posts
Pages: 1 [2] 3
16  Forum 2005-2010 (read only) / Syntax & Programs / Re: rfid compare tag code on: August 30, 2007, 12:18:01 pm
@John Ryan: In the past I've tried to modify the parallax rfid code for weeks in a row without any succes (see my other forum post: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1186246253/15).
After this I finally succeeded in printing the the tag codes to serial monitor by modifying some other code I found on the web. But with this last code (the code I posted at the beginning of this topic) I noticed that by changing the variable "serInString" from char to byte the output was always smaller and more equal in length rather than being always different from tag to tag. This is the output for 3 tags using a "char" variable:
00FFFFFFDDFFFFFF8EFFFFFF96E014FFFFFFE010FFFFFFC8
00FFFFFF989FFFFFF96E014FFFFFFE0FFFFFF857B
001B4EFFFFFFC1D014FFFFFFE0FFFFFFD57B
This is the output for the same 3 tags using a "byte" variable:
00DD8E96E014E010C8
0098996E014E0857B
001B4EC1D014E0D57B
These are all printed with the command "Serial.print((serInString[serOutIndx]), HEX );"
I mention all this because maybe the whole problem of comparing the tags to a list is related to this. I've also spotted in the basic stamp code that the tags are in this format
Code:
'Valid tags

Tag1         DATA     $00, $00, $7B, $7D, $90, $F2, $36, $07, $07, $F2, $03, $7D

Tag2         DATA     $00, $00, $7D, $7D, $1E, $1F, $E0, $E6, $EF, $6E, $04, $04
Thus being 12 hex numbers while I only have 9 in two tags and even one tag (0098996E014E0857B) with 17 character that  I even can't split into HEX (if you know what I mean)

@brianbr: I've tried the "strcmp" command but with no succes, the led flashes, but only when wrong tags a presented. Maybe it's related to the problems described above.

Does anyone see any light in this mess? :-/ Any help is really appreciated.

Kind Regards, Loic
17  Forum 2005-2010 (read only) / Syntax & Programs / Re: rfid compare tag code on: August 29, 2007, 09:10:58 am
Thank you kg4wsv,

I've been trying your suggestions for the last 24hours but with no success. The code that prints the tag code back to the serial monitor was modified from code I found on the web, I'm not such good coder to be able to rewrite it with a new approach to getting the tag codes reported. But as far as printing nice unique tag codes to the serial monitor this code works perfectly, so I'm not sure the "compare tag code to list" problem I'm having is to find in the way this original code works. But being a "C" noob I could be totally wrong.
Next thing I tried was using the <string.h> library, trying memcmp and strcmp. No succes  smiley-sad , but again could be my semi-noobness smiley

The last weeks I've been looking at this basic stamp code that does exactly what I want to do http://www.digitaldawgpound.org/wp-content/uploads/2007/03/rw210_rfid_reader.bse  (from this project http://www.digitaldawgpound.org/nick84/post=189) trying to understand the data types and sizes to work with (bytes vs chars etc).
Could someone who understands the basic stamp code please help me on the right way? I really appreciate your help.

Regards, Loïc
18  Forum 2005-2010 (read only) / Syntax & Programs / rfid compare tag code on: August 27, 2007, 12:46:16 pm
Hello everybody,

After weeks of intense testing I succeeded in reading tag codes from the 13.56Mhz APSX RW-210 rfid reader! This is the code: http://www.technicum.net/rfid/rfid_read.pde

It sends the read command via software serial to the rfid reader. Next it reads in the Tag code via hardware serial. Finally it prints a nice tag code to the computer!

Now the problematic part;
As a next step I wanted to compare the tag code to a list of known tags and then do a certain action (for example blink a led). I've been struggling with this for a week now so I decided to ask for some help. This is one of my numerous attempts  :-[
Code:
#include <SoftwareSerial.h>

#define rxPin 7
#define txPin 2

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
int serIn;             // var that will hold the bytes-in read from the serialBuffer
byte serInString[12]; // array that will hold the different bytes
int serInIndx  = 0;    // index of serInString[] in which to inser the next incoming byte
int serOutIndx = 0;    // index of the outgoing serInString[] array;
int ledPin = 13;                 // LED connected to digital pin 13
char Tag1[] = "001B4EC1D014E0D57B"; //known tag code, should become a list of 50+ tags

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  mySerial.begin(19200); // set the data rate for the SoftwareSerial port
  Serial.begin(19200);      // opens serial port, sets data rate to 19200 bps
}


void loop () {
  
  
  mySerial.print(0xfa, BYTE); // request tag code
  
  // only if there are bytes in the serial buffer execute the following code
  if(serialAvailable()) {    
    
    //keep reading from serial untill there are bytes in the serial buffer
     while (serialAvailable()){        
        serIn = serialRead();              //read Serial        
        serInString[serInIndx] = serIn; //insert the byte you just read into the array at the specified index
        serInIndx++;                    //update the new index
     }
    
     //feedback that something was received
     Serial.println ("Processing Tag");
  }
  
  //do somenthing else perhaps wait for other data.
  Serial.println ("NO TAG ");
  
  //print out later in the loop the sentence only if it has actually been collected;
  if( serInIndx > 0) {
      Serial.print("Tag ID=");      
      
      //loop through all bytes in the array and print them out
      for(serOutIndx=0; serOutIndx < serInIndx; serOutIndx++) {
          Serial.print((serInString[serOutIndx]), HEX );    //print out the byte at the specified index
            if((serInString[12], HEX) == Tag1[19]) { //compare received tag code to known tag code
            digitalWrite(ledPin, HIGH); // if true blink led
            delay(500);
            digitalWrite(ledPin, LOW);
            delay(500);
            digitalWrite(ledPin, HIGH);
            delay(500);
            digitalWrite(ledPin, LOW);
            delay(500);
          }
          //serInString[serOutIndx] = "";            //optional: flush out the content
      }
        
      //reset all the functions to be able to fill the string back with content
      Serial.flush(); //flush serial buffer
      serOutIndx = 0;
      serInIndx = 0;
  }
    
  //slows down the visualization in the terminal
  Serial.println();
  delay(200);
}

The tag code "001B4EC1D014E0D57B" is the code that I have copied from serial monitor after reading a tag. All my attempts won't make the led blink smiley-sad Can someone please help me, I would like to put 50+ tags in the memory that trigger a certain action.

Kind Regards,
Loïc
19  Forum 2005-2010 (read only) / Development / avr_libc 1.4.6? on: September 10, 2007, 06:14:11 pm
Hello,

The past months I've been very busy trying to get the APSX RW-210 rfid reader to work with Arduino. I can now say it has been a total success!

The last piece of the puzzle was trying to compare tags to an array of tags living in PROGMEM. To do this I had to use the command "memcmp_P" which  was only added to avr_libc version 1.4.6. I was able to replace parts of the Arduino avr lib by the new lib. It works perfectly and has enabled me to compare rfid tags to a list of more than 75 tags in flash memory! See my post for code and details: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1188236776/15

I was wondering if there are plans to add avr_libc 1.4.6 to Arduino 010 ?

Regards, Loïc
20  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: October 22, 2007, 12:46:29 pm
Sorry but I don't really understand your question, in what case would you want to disconnect power to the ftdi?
21  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: October 22, 2007, 10:54:40 am
This is actually the reason why I use Software Serial on an other port for sending the "request tag code" command. I'm not having a single problem with this setup, the code and the hardware work perfectly...

Regards, Loïc
22  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: September 07, 2007, 04:22:46 pm
Everything works, including checking the tag to an array of known tags (see: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1188236776/0).
A Playground tutorial will follow soon.
23  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: September 02, 2007, 12:45:46 pm
I've moved the discussion to the software department of the forum because it's not a hardware issue any more, the communication is established between the rfid reader and arduino. My next try is to compare the Tag code to a list of known codes. Continue reading here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1188236776/0
24  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: August 22, 2007, 07:23:15 am
Big progress!!! The following code reads the Tag and prints it back to the computer:

Code:
#include <SoftwareSerial.h>

#define rxPin 7
#define txPin 2

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
byte incomingByte;      // for incoming serial data
int serIn;             // var that will hold the bytes-in read from the serialBuffer
char serInString[12]; // array that will hold the different bytes  100=100characters;
                       // -> you must state how long the array will be else it won't work.
int serInIndx  = 0;    // index of serInString[] in which to inser the next incoming byte
int serOutIndx = 0;    // index of the outgoing serInString[] array;


void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  mySerial.begin(19200); // set the data rate for the SoftwareSerial port
  Serial.begin(19200);      // opens serial port, sets data rate to 19200 bps
}


void loop () {
  //simple feedback from Arduino
  mySerial.print(0xfa, BYTE);
  
  // only if there are bytes in the serial buffer execute the following code
  if(serialAvailable()) {    
    
    //keep reading from serial untill there are bytes in the serial buffer
     while (serialAvailable()){        
        serIn = serialRead();              //read Serial        
        serInString[serInIndx] = serIn; //insert the byte you just read into the array at the specified index
        serInIndx++;                    //update the new index
     }
    
     //feedback that something was received
     Serial.println ("Processing Tag");
  }
  
  //do somenthing else perhaps wait for other data.
  Serial.println ("NO TAG ");
  
  //print out later in the loop the sentence only if it has actually been collected;
  if( serInIndx > 0) {
      Serial.print("Tag ID= ");      
      
      //loop through all bytes in the array and print them out
      for(serOutIndx=0; serOutIndx < serInIndx; serOutIndx++) {
          Serial.print( (serInString[serOutIndx]), HEX );    //print out the byte at the specified index
          //serInString[serOutIndx] = "";            //optional: flush out the content
      }
        
      //reset all the functions to be able to fill the string back with content
      serOutIndx = 0;
      serInIndx = 0;
  }
    
  //slows down the visualization in the terminal
  Serial.println();
  delay(200);
}

Next thing I want to achieve is to compare the Tag to a list (maybe an array) of known Tags and then do something (blink a led for example). Does someone have an idea how to achieve this?


Kind Regards, Loïc
25  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: August 09, 2007, 06:35:18 pm
I was also wondering if it was rated for 19200 but sending the commands works, so I can't see why reading shouldn't work. But it's always possible. An other way of doing things could be by just using software serial for sending the commands and reading back with the standard hardware serial rx. This way the Serial.available command could be used wich isn't possible with software serial. I've tried this by modifying the P*r*lax rfid code, but I it's other hardware so I probably made some errors:
Code:
//
#include <SoftwareSerial.h>

#define rxPin 7
#define txPin 6

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin); //Only tx is used
byte  val = 0;
char code[12];
int bytesread = 0;

void setup() {

Serial.begin(19200); // RFID reader SOUT pin connected to Serial RX pin at 19200
pinMode(rxPin, INPUT); //Only tx is used, the standard hardware rx pin is used for receiving the tag code
pinMode(txPin, OUTPUT);
mySerial.begin(19200);

}  void loop() {
  mySerial.print(0xfa, BYTE); //request tag code with the FA command
  if(Serial.available() > 0) {          // if data available from reader
    if((val = Serial.read()) == 12) {   // check for header
      bytesread = 0;
      while(bytesread<10) {              // read 12 digit code
        if( Serial.available() > 0) {
          val = Serial.read();
          if((val == 12)||(val == 15)) { // if header or stop bytes before the 12 digit reading
            break;                       // stop reading
          }
          code[bytesread] = val;         // add the digit          
          bytesread++;                   // ready to read next digit  
        }
      }
      if(bytesread == 12) {              // if 12 digit read is complete
        Serial.print("TAG code is: ");   // possibly a good TAG
        Serial.println(code);            // print the TAG code
      }
      bytesread = 0;
           delay(500);                       // wait for a second
    }
  }
}

Could someone give me a hand with getting the output wright? Mayby by getting some inspiration from the working Basic Stamp code at DigitalDawgpound http://www.digitaldawgpound.org/wp-content/uploads/2007/03/rw210_rfid_reader.bse
I really appreciate your help.
Regards, Loïc
26  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: August 09, 2007, 07:42:00 am
Hi everybody,

I've made some good progress:

If I want to print tag codes to my computer I knew that I needed to use the SoftwareSerial lib to communicate to the Rfid reader. I've succeeded in this:
Code:
#include <SoftwareSerial.h>

#define rxPin 9
#define txPin 8

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(19200);
}

void loop() {
  
  mySerial.print(0xfd, BYTE);
  delay(500);
  mySerial.print(0xfc, BYTE);
  delay(500);
}

To test the tag reading functionality I connected the the tx pin of the reader to the tx of the arduino instead of pin 9. This way when I send 0xfa via softwareSerial I got perfect rfid tag readouts in the SerialMonitor  ;D. So now I wanted to do it the clean way, by sending the command via SoftwareSerial, receiving it back via SoftwareSerial and printing it to the computer via traditional Serial.print.
This is what I got so far:
Code:
#include <SoftwareSerial.h>

#define rxPin 7
#define txPin 6

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
byte incomingByte = 0;      // for incoming serial data

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  mySerial.begin(19200); // set the data rate for the SoftwareSerial port
  Serial.begin(19200);      // opens serial port, sets data rate to 19200 bps
}

void loop() {
  mySerial.print(0xfa, BYTE);
  incomingByte = mySerial.read();
  Serial.print(incomingByte, BYTE);
  delay(500);
}

In the serial monitor I get a "?" as long as I hold a tag above the reader. Can someone help me a bit further?
27  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: August 06, 2007, 04:48:31 pm
I'll be glad to do that.  smiley-wink
28  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: August 06, 2007, 11:58:03 am
SUCCES! SUCCES! SUCCES!   ;D
Thank you sooo much kg4wsv. After uploading this
Code:
void setup() {
  Serial.begin(19200);
}

void loop() {
Serial.print(0xfd, BYTE);
delay(50);
Serial.print(0xfc, BYTE);
delay(50);
}
 
the red led flashes real fast so at last communication has been established. Now I'll try to read the rfid tags. I'll post every progress.

Euforic regards, Loïc
29  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: August 06, 2007, 09:21:43 am
I'm on OS X, I tryed the test application under Parallels, but I can't get the serial port to work in parallels (but that's an other issue). The fact that I got sort of a reply in Zterm makes me believe that there's no hardware error.

Thanx anyway Daniel  smiley

Grtz, Loïc
30  Forum 2005-2010 (read only) / Interfacing / Re: RW-210 13.56Mhz Rfid Reader/Writer on: August 06, 2007, 08:44:41 am

I soldered the pins on the board.
In case of arduino to rfid: RC rfid to TX arduino, TX rfid to RX arduino
In case of Zterm to rfid: RC rfid to RX "arduino", TX rfid to TX "arduino"
But I doubt that it's a hardware issue..

Loïc
Pages: 1 [2] 3