Mutiple parallax rfid 28440 modules

Hello everyone, I’m trying to interface with 2 RFID modules from parallax 28440 on my Arduino Due.

link: http://www.parallax.com/product/28440

It works if I only use one RFID reader on the arduino, but when I try to communicate with 2 RFID modules I run into a problem.

I know he get stuck at the while (rfidRead… but I just haven’t changed that because everything I try fails.

When I use the code for only 1 Module the RFID reader go from idle state (green led) to working state (red led). and constantly watch to read a card. But when I use 2 Modules they both go in idle state and do nothing… I have tried interrupts but when I write the command to read he constantly read so that doesn’t work, also i have tried multi threads but they also get stuck.

Also I have tried to do it with this code from the arduino website (the second part). It gives the same problem they both go in idle state
link: http://playground.arduino.cc/Learning/ParallaxRFIDreadwritemodule

I hope some one can help me with this so the 2 RFID readers can read constantly.

If you need any more info just ask!

Or if there is a thread where I can find the solution to my problem post it, I have looked everywhere for it but didn’t found any solutions…

Here is my code:

// rx Serial ingang (connecteer aan de RFID's SOUT pin)
// tx Serial uitgang (connecteer aan de RFID's SIN pin)

#define BUFSIZE    12  // Size of receive buffer (in bytes) for incoming data from the RFID R/W Module (this should be adjusted to be larger than the expected response)

// RFID R/W Module Commands
// Number of bytes returned in ()
#define RFID_Read         0x01	  // Read data from specified address, valid locations 1 to 33 (5)

// Memory map/address locations for EM4x50 tag
// Each address holds/returns a 32-bit (4 byte) value
#define ADDR_Password     0	  // Password (not readable)
#define ADDR_Protect	  1	  // Protection Word
#define ADDR_Control	  2	  // Control Word
// ADDR 3-31 are User EEPROM area
#define ADDR_Serial	  32	  // Device Serial Number
#define ADDR_DeviceID	  33	  // Device Identification

// Status/error return codes
#define ERR_OK		  0x01	  // No errors


void setup() {

  // Arduino serieële monitor instellen
  Serial.begin(9600);
  while (!Serial);   // Wachten tot hij klaar is
  Serial.println("Scan je kaart in 1 van de 2 RFID modules");
  
  // set the baud rate for the SoftwareSerial port

  Serial1.begin(9600);
  Serial2.begin(9600);
  
  Serial.flush();   // wait for all bytes to be transmitted to the Serial Monitor
  
}

void loop() {

  uint8_t rfidData[BUFSIZE];  // Buffer voor inkomende data
      
  Serial.print("RFID Binnen De badge zijn unieke badge nummer word gelezen...");
  while (rfidRead1(rfidData, ADDR_Serial) != 0);
  PrintHex(rfidData, 4);   // De rfidData string moet nu het serienummer van de tag bevatten, en geeft het weer op de seriêle monitor
  Serial.println();
  Serial.flush();  
    
  Serial.print("RFID Buiten De badge zijn unieke badge nummer word gelezen...");
  while (rfidRead2(rfidData, ADDR_Serial) != 0);
  PrintHex(rfidData, 4);   // De rfidData string moet nu het serienummer van de tag bevatten, en geeft het weer op de seriêle monitor
  Serial.println();
  Serial.flush();
    
    
}

//RFID BINNEN (1)

char rfidRead1(uint8_t *data, uint8_t address)
{
  char offset1;  // offset1 into buffer
  
  rfidFlush1();  // empties any buffered incoming serial data
  
  Serial1.print("!RW");       // header
  Serial1.write(RFID_Read);   // command
  Serial1.write(address);     // address
  
  while (Serial1.available() != 5);  // wait until data is received from RFID module
  
  if (Serial1.read() == ERR_OK)  // if our status byte is OK
  {
    for (offset1 = 0; offset1 < 4; offset1++)
      data[offset1] = Serial1.read();  // get the remaining data
       
    return 0; // return good
  }
  
  return -1; // return error
}



void rfidFlush1()  // Empties any buffered incoming serial data
{
    while (Serial1.available() > 0)
      Serial1.read();
}

//RFID BUITEN

char rfidRead2(uint8_t *data, uint8_t address)
{
  char offset2;  // offset2 into buffer
  
  rfidFlush2();  // empties any buffered incoming serial data
  
  Serial2.print("!RW");       // header
  Serial2.write(RFID_Read);   // command
  Serial2.write(address);     // address
    
  while (Serial2.available() != 5);  // wait until data is received from RFID module
  
  if (Serial2.read() == ERR_OK)  // if our status byte is OK
  {
    for (offset2 = 0; offset2 < 4; offset2++)
      data[offset2] = Serial2.read();  // get the remaining data
       
    return 0; // return good
  }
  
  return -1; // return error
}

void rfidFlush2()  // Empties any buffered incoming serial data
{
    while (Serial2.available() > 0)
      Serial2.read();
}


// prints 8-bit data in hex
void PrintHex(uint8_t *data, uint8_t length) 
{
  char tmp[length*2+1];
  byte first ;
  int j=0;
  for (uint8_t i=0; i<length; i++) 
  {
    first = (data[i] >> 4) | 48;
    if (first > 57) tmp[j] = first + (byte)39;
    else tmp[j] = first ;
    j++;

    first = (data[i] & 0x0F) | 48;
    if (first > 57) tmp[j] = first + (byte)39; 
    else tmp[j] = first;
    j++;
  }
  tmp[length*2] = 0;
  Serial.print(tmp);
}