Shop OBEX P1 Docs P2 Docs Learn Events
Reading from three readers at the same time — Parallax Forums

Reading from three readers at the same time

coolbebecoolbebe Posts: 9
edited 2006-04-09 06:51 in General Discussion
I'm trying to read from three rfid readers at the·same time. I'm able to read from one reader but when i try to read from all of them i am able to read only from one or·from none of them.
In the following pieces of code, I only mention 2 readers, but I once I get this working, I want to scale it to 3 readers.


1)In this piece of code, when i enable multiple readers , it doesn't read from none of them


static int index = 0;
··· final static int rxPin1 = CPU.pin1; // Pin for serial from reader 1
··· static Uart rxUart1 = new Uart(Uart.dirReceive, rxPin1, Uart.dontInvert,
·································· Uart.speed2400, Uart.stop1);
··· final static int rxPin2 = CPU.pin3; // Pin for serial from reader 2
··· static Uart rxUart2 = new Uart(Uart.dirReceive, rxPin2, Uart.dontInvert,
·································· Uart.speed2400, Uart.stop1);
··· static char c;
··· static PrintStream ps = new PrintStream();
· public static void main() {

· CPU.writePin(CPU.pin0,false);//Enable Reader 1
· CPU.writePin(CPU.pin2,false);//Enable Reader 2
·· while(true) { //loop forever
····· //wait for '\n'
····· while(true)· {
················· if ( rxUart1.byteAvailable())
········ {
··········· c=(char)rxUart1.receiveByte();
··········· if (c=='\n') break;
········ }
····· }
····· //read 10 bytes and display
····· index=0;
····· while (index<10) {
······· if (rxUart1.byteAvailable()) {
·········· c = (char)rxUart1.receiveByte();
········· ps.print(c);
·········· index++;
········ }
····· }
····· ps.print('\n');

···· ·}


2)In this piece of code, when i·use loops for the·multiple readers ,·I can read form the first·reader ONLY one time, and nothing get read from the others.

static int index = 0;
··· final static int rxPin1 = CPU.pin1; // Pin for serial from reader 1
··· static Uart rxUart1 = new Uart(Uart.dirReceive, rxPin1, Uart.dontInvert,
·································· Uart.speed2400, Uart.stop1);
··· final static int rxPin2 = CPU.pin3; // Pin for serial from reader 2
··· static Uart rxUart2 = new Uart(Uart.dirReceive, rxPin2, Uart.dontInvert,
·································· Uart.speed2400, Uart.stop1);
··· static char c;
··· static PrintStream ps = new PrintStream();
· public static void main() {

·· while(true) { //loop forever
····· //wait for '\n'
····· while(true)· {
········ CPU.writePin(CPU.pin0,false);//Enable Reader 1
········ if ( rxUart1.byteAvailable())
········ {
··········· c=(char)rxUart1.receiveByte();
··········· if (c=='\n') break;
········ }
····· }
····· //read 10 bytes and display
····· index=0;
····· while (index<10) {
······· if (rxUart1.byteAvailable()) {
·········· c = (char)rxUart1.receiveByte();
········· ps.print(c);
·········· index++;
········ }
····· }
····· ps.print('\n');


····· //wait for '\n'
····· while(true)· {
········ CPU.writePin(CPU.pin2,false);//Enable Reader 2
········ if ( rxUart2.byteAvailable())
········ {
··········· c=(char)rxUart2.receiveByte();
··········· if (c=='\n') break;
········ }
····· }
····· //read 10 bytes and display
····· index=0;
····· while (index<10) {
······· if (rxUart2.byteAvailable()) {
·········· c = (char)rxUart2.receiveByte();
········· ps.print(c);
·········· index++;
········ }
····· }
····· ps.print('\n');
···· } //end loop forever
·· }
·}

Please let me know how i can fix this problem. Thank you.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-04-09 06:19
    You don't need to create an instance of printstream.
    Just use System.out.print() and System.out.println()
    Please try that and see if you then get output to the
    messenger window.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-04-09 06:51
    From the RFID reader manual (stock# 28140)

    The face of the RFID tag should be held parallel to the front or back face of the antenna (where the
    majority of RF energy is focused). If the tag is held sideways (perpendicular to the antenna) you'll either
    get no reading or a poor reading. Only one transponder tag should be held up to the antenna at any
    time. The use of multiple tags at one time will cause tag collisions and confuse the reader. The two tags
    available in the Parallax store have a read distance of approximately 3 inches. Actual distance may vary
    slightly depending on the size of the transponder tag and environmental conditions of the application.

    So you must have your readers at least 3 inch apart to read multiple tags at the
    same time using different readers. Otherwise a single tag will have effect on two
    or more readers and not only on the reader it is closest to.

    regards peter
Sign In or Register to comment.