Arduino Duemilanove, 24 RFID Readers (wiegand26 type)

Hi

I want to be able to connect up to 24 rfid readers to Arduino, I have been able to connect up to 8 but there are no more free pins. What chip/component should I use so I can connect the other rfid readers?

Cheers

Please share the code as this might trigger new ideas!

Can you tell more about the project, what you want to accomplish, are the readers far from each other

As I suppose it should be possible to handle them "simultaniously" you just don't have enough pins. did you test simultanious access for 8?

Option 1: take 3 Arduino's (and network them) Option 2: take a MEGA Option 3: hardware buffering per RFID, and do a round Robin

If you use NewSoftSerial you can declare the transmit pin to be -1 for the TX pin: NSS RFID1(-1,3); NSS RFID2(-1,4); etc This will make more RFID's per Arduino possible (so only 2 are needed) especially as you can use the analog pins as digital pins too.

Hi

Option 1 and 2 are out of consideration unfortunately. But option 3 seems interesting, although I have never heard of it, could you please elaborate on it? A little bit more on my project:

  • I have developed a board that uses Arduino Duemilanove schematics, but have also included 2 MCP23017 IO expanders, which I use to control the RFIDs and relays. In the following please find the code I’m trying to use for the MCP23017, there are some println just for debugging.
  • I’m getting some response from the reader, but I can not catch the tag ID correctly since I’m only getting at most 9 interrupts (but 26 are required, since we are using wiegand26 type reader).
#include <MCP23017.h>
#include <Wire.h>

#define INFTFA   0x0E
#define INFTFB   0x0F

int pressed = 0;
MCP23017 mcp(4);

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("Hello");
 
  // enable all interruptsc
  mcp.digitalRead(0);
  mcp.digitalRead(1);

  expanderWriteBoth(GPINTEN, 0x03);
  expanderWriteBoth(DEFVAL, 0x03);
  expanderWriteBoth(INTCON, 0x03);
  expanderWriteBoth(IODIR, 0xff);
//  mcp.writeRegister(IOCON, (byte)0x00);
  
  
//  mcp.writeRegister(GPINTEN, (byte)0x03);
//  mcp.writeRegister(DEFVAL, (byte)0x03);
//  mcp.writeRegister(INTCON, (byte)0x03);
 
  attachInterrupt(0, keypress, FALLING);
  //mcp.digitalWrite(0, HIGH);
}

// for example, IO direction
void expanderWriteBoth (const byte reg, const byte data ) 
{
  Wire.beginTransmission ((0x40 >>1) | (4 & 0x07));
  Wire.send (reg);
  Wire.send (data);  // port A
  Wire.send (data);  // port B
  Wire.endTransmission ();
} // end of expanderWrite

// read a byte from the expander
unsigned int expanderRead (const byte reg) 
{
  Wire.beginTransmission ((0x40 >>1) | (4 & 0x07));
  Wire.send (reg);
  Wire.endTransmission ();
  Wire.requestFrom ((0x40 >>1) | (4 & 0x07), 1);
  return Wire.receive();
} // end of expanderRead

int count = 0;

void loop() {
  if(pressed > 0) {
    Serial.println("Handling");
    handleKeypress();
    
    Serial.print("COUTN: ");
    Serial.println(count);
  }
}

volatile long reader = 0;

void keypress() {
  pressed++;
  reader = reader << 1;
  count++;
}

volatile long readerA = 0;
volatile long readerB = 0;

//for now, I am just defining 4 RFID readers, which corresponds to one port

volatile unsigned long reader1 = 0;
volatile unsigned long reader2 = 0;
volatile unsigned long reader3 = 0;
volatile unsigned long reader4 = 0;

volatile unsigned int reader1bits = 0;
volatile unsigned int reader2bits = 0;
volatile unsigned int reader3bits = 0;
volatile unsigned int reader4bits = 0;

void handleKeypress ()
{
  unsigned int interruptBit = 0;
  pressed = 0;
  count = 0;
  
  // Read port values, as required. Note that this re-arms the interrupts.
  if (mcp.readRegister (INFTFA))
    interruptBit |= mcp.readRegister (INTCAPA) << 8;    // read value at time of interrupt
  if (mcp.readRegister (INFTFB))
    interruptBit |= mcp.readRegister (INTCAPB);        // port B is in low-order byte
  
  for(int i = 0; i < 101; i++) {
    Serial.println(mcp.readRegister (INTCAPB));
    Serial.println(mcp.readRegister (GPIO));
  }
  
  //idea is to shift register to the right to find out which caused the interrupt, then shift either a 1 or a zero onto the reader value
  //reader 1
  if (interruptBit & 1)
    { //bit 0, indicating a 0 on reader 1, so shift a zero onto reader 1 value
    reader1 << 1;
    reader1bits++;
    }
  if (interruptBit & 2)
    { //bit 1, indicating a 1 on reader 1, so shift a one onto reader 1 value
    reader1 << 1;
    reader1++;
    reader1bits++;
    }
  //reader 2  
  if (interruptBit & 4)
    { //bit 2, indicating a 0 on reader 2, so shift a zero onto reader 2 value
    reader2 << 1;
    reader2bits++;
    }
  if (interruptBit & 8)
    { //bit 3, indicating a 1 on reader 2, so shift a one onto reader 2 value
    reader2 << 1;
    reader2++;
    reader2bits++;
    }
  //reader 3  
  if (interruptBit & 16)
    { //bit 4, indicating a 0 on reader 3, so shift a zero onto reader 3 value
    reader3 << 1;
    reader3bits++;
    }
  if (interruptBit & 32)
    { //bit 5, indicating a 1 on reader 3, so shift a one onto reader 3 value
    reader3 << 1;
    reader3++;
    reader3bits++;
    }
   //reader 4  
  if (interruptBit & 64)
    { //bit 6, indicating a 0 on reader 4, so shift a zero onto reader 4 value
    reader4 << 1;
    reader4bits++;
    }
  if (interruptBit & 128)
    { //bit 7, indicating a 1 on reader 4, so shift a one onto reader 4 value
    reader4 << 1;
    reader4++;
    reader4bits++;
    }
  
  
  
  mcp.digitalRead(0);
  mcp.digitalRead(1);
  
}  // end of handleKeypress

Thanks in advance