Pages: [1]   Go Down
Author Topic: RDM880 connection problem  (Read 1132 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 1
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1278457441

Hi

I'm having a similar problem as the one addressed in the topic above. The clock is really ticking for me and I need a resolution FAST  smiley-confuse

Connection is as follows:

RFID  -> ARDUINO
===================
TX    -> TX (pin 4)
RX    -> RX (pin 3)
+5V   -> +5V
GND   -> GND
 and I've also tried:
RFID  -> ARDUINO
===================
TX    -> TX (pin 3)
RX    -> RX (pin 4)
+5V   -> +5V
GND   -> GND

I had some help from somebody who modified the code from cool componenets as below. This is the only output I'm getting.. (nothing happens when I place a card over the antenna)
The RFID test program has started
Header = AA
Station ID = 00
Data Length = 1
Command = 20
Checksum = 21
Footer = BB

Listening for response...
Header = AA
Station ID = 00
Data Length = 1
Command = 20
Checksum = 21
Footer = BB


CODE:

Code:
#include <NewSoftSerial.h>

/*

This program tests communication with the Seeeduino 13.56 RFID Reader by sending a request for the unit's serial number and getting a response.

www.coolcomponents.co.uk 2010

We need 4 pins connected from the RFID to the Arduino : These all come from connector J2

RFID  -> ARDUINO
===================
TX    -> TX (pin 4)
RX    -> RX (pin 3)
+5V   -> +5V
GND   -> GND

NOTES :

1.Debug info and received data will be sent through the Arduino to your serial monitor. You should have it open to see anything!

You should see something like this :

The RFID test program has started
Header = AA
Station ID = 00
Data Length = 1
Command = 83
Checksum = 82
Footer = BB
Listening for response...
I received: AA
I received: 0
I received: A
I received: 0
I received: 0
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: A
I received: BB

NOTES (Continued)
2.The reset pin on the RFID should be tied to GND, either on the RFID or the Arduino
3.Please note that this test program outputs debug data with no trailing zero : so for example '00' becomes '0' and '0A' becomes 'A'
4.If you're not seeing any response from the RFID unit, chances are that you have your RX and TX pins round the wrong way.
5.This code uses the 'NewSoftSerial' library to set up another serial port on pins 3+4 of your Arduino. You must download the library and 'include' it in your code (using Sketch:Import Library from the Menu bar). Library can be found at : arduiniana.org/libraries/newsoftserial/
6.The code used to send the data section of the packet has not been properly tested.

*/

NewSoftSerial rfid(4,3);
byte DATA[255] = {};

void send_command(int CMD, byte DATA[])
{
  int i;  //an index for the data send loop
  int checksum;
  int DATALENGTH;
  byte STX=0xAA;
  byte STATIONID = 0x00;
  
  Serial.print("Header = ");
  Serial.print(STX,HEX);           //STX command begin code
  Serial.println();
  rfid.print(STX,BYTE);
  
  Serial.print("Station ID = ");
  Serial.print("00");             //RFID reader address use zero for all readers to respond)
  Serial.println();
  rfid.print(STATIONID,BYTE);
  
  DATALENGTH = sizeof(DATA)/2;
  Serial.print("Data Length = ");
  Serial.print(DATALENGTH,HEX);   //send the length of the data section
  Serial.println();
  rfid.print(DATALENGTH,BYTE);
  
  Serial.print("Command = ");
  Serial.print(CMD,HEX);          //send the command word
  Serial.println();
  rfid.print(CMD,BYTE);
  
  checksum = (STATIONID ^ DATALENGTH ^ CMD);

  i=0;  
  
  while (DATA[i])
  {
    Serial.print("Data Word ");
    Serial.print(i);
    Serial.print(" = ");
    Serial.print(DATA[i],HEX);    //send each byte of the data
    Serial.println();
    
    rfid.print(DATA[i],BYTE);
    checksum = checksum ^ DATA[i];
    i++;
    
  }
  
  Serial.print("Checksum = ");
  Serial.print(checksum,HEX);      //
  Serial.println();
  rfid.print(checksum,BYTE);
  
  Serial.print("Footer = ");
  Serial.print(0xBB,HEX);          //ETX command end code
  Serial.println();
  rfid.print(0xBB,BYTE);
  
  Serial.println();
  
}

void read_response()
{
  byte incomingByte;
  
  Serial.println("Listening for response...");
  
while (rfid.available() > 0)
  {
  // read the incoming byte:
  incomingByte = rfid.read();

  // say what you got:
  Serial.print("I received: ");
  Serial.println(incomingByte, HEX);
  }
  
}

void setup()
{
  //start serial port at 9600 bps: This is for the debug info we send to your PC/Mac
  Serial.begin(9600);
  //start a NewSoftSerial serial port at 9600bps : This is to talk to the RFID.
  rfid.begin(9600);
  
  Serial.println("The RFID test program has started");
}

void loop()
{
  send_command(0x20, DATA);   //This command is requests the serial number of the RFID unit
  read_response();            //This just displays the raw data recieved
  delay(1000);
  //while(1) {}                 //loop forever
}


« Last Edit: March 07, 2011, 11:39:51 am by Kevin360 » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12480
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please use the # button if you post code ( just modify your post, select the programcode and press # button)

Quote
had some help from somebody who modified the code
What did he change?
What was the original code?
The post you refer to ended with working code. So can you describe in more detail what you expected the code todo.

Did a quick scan and only one line of code triggered me.
Use Serial.begin(115200) as this is the max baudrate useable for PC connectivity - 12 times as fast so more time for your app todo what it should do.

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Newbie
*
Karma: 1
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not 100% sure what he changed but it had been done initially using NewSoftSerial code (which wasn't responding).

Pardon my ignorance but I have absolutely no understanding of programming  smiley-roll-sweat

In the case of the code working in the post that I referred to at first, I pasted this into Arduino and it gave an error. Should it be pasted alone or along with the code that I included in my first post? And if so, where abouts should it be added in that code?
I know that user reffered to something called a Bus Pirate - does this mean extra hardware that I'd need to purchase or is it simply code?

Code:
#include <NewSoftSerial.h>

/*

This program tests communication with the Seeeduino 13.56 RFID Reader by sending a request for the unit's serial number and getting a response.

www.coolcomponents.co.uk 2010

We need 4 pins connected from the RFID to the Arduino : These all come from connector J2

RFID  -> ARDUINO
===================
TX    -> TX (pin 4)
RX    -> RX (pin 3)
+5V   -> +5V
GND   -> GND

NOTES :

1.Debug info and received data will be sent through the Arduino to your serial monitor. You should have it open to see anything!

You should see something like this :

The RFID test program has started
Header = AA
Station ID = 00
Data Length = 1
Command = 83
Checksum = 82
Footer = BB
Listening for response...
I received: AA
I received: 0
I received: A
I received: 0
I received: 0
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: A
I received: BB

NOTES (Continued)
2.The reset pin on the RFID should be tied to GND, either on the RFID or the Arduino
3.Please note that this test program outputs debug data with no trailing zero : so for example '00' becomes '0' and '0A' becomes 'A'
4.If you're not seeing any response from the RFID unit, chances are that you have your RX and TX pins round the wrong way.
5.This code uses the 'NewSoftSerial' library to set up another serial port on pins 3+4 of your Arduino. You must download the library and 'include' it in your code (using Sketch:Import Library from the Menu bar). Library can be found at : arduiniana.org/libraries/newsoftserial/
6.The code used to send the data section of the packet has not been properly tested.

*/

NewSoftSerial rfid(4,3);
byte DATA[255] = {};

void send_command(int CMD, byte DATA[])
{
  int i;  //an index for the data send loop
  int checksum;
  int DATALENGTH;
  byte STX=0xAA;
  byte STATIONID = 0x00;
 
  Serial.print("Header = ");
  Serial.print(STX,HEX);           //STX command begin code
  Serial.println();
  rfid.print(STX,BYTE);
 
  Serial.print("Station ID = ");
  Serial.print("00");             //RFID reader address use zero for all readers to respond)
  Serial.println();
  rfid.print(STATIONID,BYTE);
 
  DATALENGTH = sizeof(DATA)/2;
  Serial.print("Data Length = ");
  Serial.print(DATALENGTH,HEX);   //send the length of the data section
  Serial.println();
  rfid.print(DATALENGTH,BYTE);
 
  Serial.print("Command = ");
  Serial.print(CMD,HEX);          //send the command word
  Serial.println();
  rfid.print(CMD,BYTE);
 
  checksum = (STATIONID ^ DATALENGTH ^ CMD);

  i=0; 
   
  while (DATA[i])
  {
    Serial.print("Data Word ");
    Serial.print(i);
    Serial.print(" = ");
    Serial.print(DATA[i],HEX);    //send each byte of the data
    Serial.println();
   
    rfid.print(DATA[i],BYTE);
    checksum = checksum ^ DATA[i];
    i++;
   
  }
 
  Serial.print("Checksum = ");
  Serial.print(checksum,HEX);      //
  Serial.println();
  rfid.print(checksum,BYTE);
 
  Serial.print("Footer = ");
  Serial.print(0xBB,HEX);          //ETX command end code
  Serial.println();
  rfid.print(0xBB,BYTE);
 
  Serial.println();
 
}

void read_response()
{
  byte incomingByte;
 
  Serial.println("Listening for response...");
 
while (rfid.available() > 0)
  {
  // read the incoming byte:
  incomingByte = rfid.read();

  // say what you got:
  Serial.print("I received: ");
  Serial.println(incomingByte, HEX);
  }
 
}

void setup()
{
  //start serial port at 9600 bps: This is for the debug info we send to your PC/Mac
  Serial.begin(9600);
  //start a NewSoftSerial serial port at 9600bps : This is to talk to the RFID.
  rfid.begin(9600);
 
  Serial.println("The RFID test program has started");
}

void loop()
{
  send_command(0x83, DATA);   //This command is requests the serial number of the RFID unit
  read_response();            //This just displays the raw data recieved
 
  while(1) {}                 //loop forever
}

Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12480
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
RFID  -> ARDUINO
===================
TX    -> TX (pin 4)
RX    -> RX (pin 3)

Try

RFID  -> ARDUINO
===================
RX    -> TX (pin 4)
TX    -> RX (pin 3)

as serial pins need to be crossed
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Newbie
*
Karma: 1
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tried that - still no joy I'm afraid.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am having the same issue using the posted code. There are a few bugs in the code though, so this is what I changed:
  • The data length calculation must be done over both the CMD and the DATA array. sizeof(DATA) returns the number of bytes in the array, no need to divide it by 2 and you always have to add 1 for the CMD byte.
  • Somehow I had issues with sizeof() and the array passed as variable so I moved the CMD and DATA variables into the send_command method so they will be used locally only
  • I also changed the while loop condition to use the datalength variable (i don't think this was necessary in the end)
  • Added code to use the RESET pin to enable/disable the reader

When issuing the 0x83 command you don't need additional data in the array. This command will ask for the serial number of the reader itself (this should always give a result) if I understand this document http://neophob.com/files/rfid/PROTOCOL-821-880%20_2_.pdf correctly.

If you want to read the serial number of a Mifare RF card issue command 0x25 and put {0x26, 0x00} in the DATA array.

Anyway in both situations I don't get any response at all. I am using the Duemilanove (Atmega328) and have tried this cvode with both the NewsoftSerial and the SoftwareSerial without any luck.

I am wondering if there is a problem with the pin layout in the datasheet or command protocol. Can anyone please crack this puzzle  smiley-mad

Here is my code:
Code:
#include <NewSoftSerial.h>

/*

This program tests communication with the Seeeduino 13.56 RFID Reader by sending a request for the unit's serial number and getting a response.

www.coolcomponents.co.uk 2010

We need 4 pins connected from the RFID to the Arduino : These all come from connector J2

RFID  -> ARDUINO
===================
TX    -> RX (pin 3)
RX    -> TX (pin 4)
+5V   -> +5V
GND   -> GND
RESET -> RFID ENABLE (pin 2)

NOTES :

1.Debug info and received data will be sent through the Arduino to your serial monitor. You should have it open to see anything!

You should see something like this :

The RFID test program has started
Header = AA
Station ID = 00
Data Length = 1
Command = 83
Checksum = 82
Footer = BB
Listening for response...
I received: AA
I received: 0
I received: A
I received: 0
I received: 0
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: A
I received: BB

NOTES (Continued)
2.The reset pin on the RFID should be tied to GND, either on the RFID or the Arduino
3.Please note that this test program outputs debug data with no trailing zero : so for example '00' becomes '0' and '0A' becomes 'A'
4.If you're not seeing any response from the RFID unit, chances are that you have your RX and TX pins round the wrong way.
5.This code uses the 'NewSoftSerial' library to set up another serial port on pins 3+4 of your Arduino. You must download the library and 'include' it in your code (using Sketch:Import Library from the Menu bar). Library can be found at : arduiniana.org/libraries/newsoftserial/
6.The code used to send the data section of the packet has not been properly tested.

*/

int rfidEnable = 2;
int rxPin = 3;
int txPin = 4;


NewSoftSerial rfid(rxPin,txPin);

void setup()
{
  pinMode(rfidEnable, OUTPUT);
  //pinMode(rxPin, INPUT);
  //pinMode(txPin, OUTPUT);

  //start serial port at 9600 bps: This is for the debug info we send to your PC/Mac
  Serial.begin(9600);
 
  //start a NewSoftSerial serial port at 9600bps : This is to talk to the RFID.
  rfid.begin(9600);
 
  Serial.println("Initializing reader with reset cycle");
  //initialize reader with reset cycle
  digitalWrite(rfidEnable, LOW);
  delay(100);
  digitalWrite(rfidEnable, HIGH);
  delay(100);
  digitalWrite(rfidEnable, LOW);
  delay(100);
 
  Serial.println("The RFID test program has started");
}

void loop()
{
  digitalWrite(rfidEnable, LOW);
  delay(100);
  send_command();   //This command is requests the serial number of the RFID unit
  read_response();            //This just displays the raw data recieved
  digitalWrite(rfidEnable, HIGH);
  delay(100);
 
  while(1) {}                 //loop forever
}


void send_command()
{
  int i;  //an index for the data send loop
  int checksum;
  byte DATALENGTH;
  byte STX=0xAA;
  byte ETX=0xBB;
  byte STATIONID = 0x00;
  byte CMD = 0x83;
  byte DATA[] = {};
 
  Serial.print("Header = ");
  Serial.print(STX,HEX);           //STX command begin code
  Serial.println();
  rfid.print(STX,BYTE);
 
  Serial.print("Station ID = ");
  Serial.print("00");             //RFID reader address use zero for all readers to respond)
  Serial.println();
  rfid.print(STATIONID,BYTE);
 
  DATALENGTH = sizeof(DATA)+1;
  Serial.print("Data Length = ");
  Serial.println(DATALENGTH,DEC);   //send the length of the data section
  rfid.print(DATALENGTH,BYTE);
 
  Serial.print("Command = ");
  Serial.print(CMD,HEX);          //send the command word
  Serial.println();
  rfid.print(CMD,BYTE);
 
  checksum = (STATIONID ^ DATALENGTH ^ CMD);

  i=0; 
   
  while (i<(DATALENGTH-1))
  {
    Serial.print("Data Word ");
    Serial.print(i);
    Serial.print(" = ");
    Serial.print(DATA[i],HEX);    //send each byte of the data
    Serial.println();
   
    rfid.print(DATA[i],BYTE);
    checksum = checksum ^ DATA[i];
    i++;
   
  }
 
  Serial.print("Checksum = ");
  Serial.print(checksum,HEX);      //
  Serial.println();
  rfid.print(checksum,BYTE);
 
  Serial.print("Footer = ");
  Serial.print(ETX,HEX);          //ETX command end code
  Serial.println();
  rfid.print(ETX,BYTE);
 
  Serial.println();
 
}

void read_response()
{
  byte incomingByte;
 
  Serial.println("Listening for response...");
 
while (rfid.available() > 0)
  {
  // read the incoming byte:
  incomingByte = rfid.read();

  // say what you got:
  Serial.print("I received: ");
  Serial.println(incomingByte, HEX);
  }
 
  Serial.println("Not listening anymore");
 
}

Logged

Pages: [1]   Go Up
Jump to: