How to make 2 Phidget 1024 work on same computer?

Supporting Visual Studio on Windows
Dwynn@scaquarium.org
Fresh meat
Posts: 2
Joined: Fri Oct 21, 2016 2:30 pm
Contact:

How to make 2 Phidget 1024 work on same computer?

Postby Dwynn@scaquarium.org » Mon Oct 24, 2016 7:51 am

I've modified some example code to create 2 objects, controlling 2 RFID 1024 readers on a Windows 10 computer. When each reader is independently connect, both readers work perfectly. However, when both are connected to the same computer, neither device reads. My code is below. Can someone please offer some insight on how to connect two 1024 RFID readers and make them scan tags simultaneously?

More Info:
- 3919_0 Tags are being used - (T5577)
- Test text has been loaded on each tag using the RFID-Full program
- Phidget control panel sees both readers but, when RFID-Full is launched for each reader, neither device will scan; when one device is connected, each reader will scan.
- Firmware was updated on 10/21/2016 for both devices. Was unable to simultaneously use both devices before and after the firmware update.
- Written Text: test1 Protocol: Phidgets to Tag 1
- Written Text: tes Protocol: Phidgets to Tag 2

Code: Select all

namespace PhidgetsExample
{
    class Program
    {
        public static void Main()
        {
            //int array that holds serial numbers for both RFID readers.  Used to open both devices below
            int[] serialNumArray = { 440799, 440591};


            try
            {
                //Declare RFID reader1 object
                RFID rfid = new RFID();

                //initialize RFID1 reader and attach events
                rfid.Attach += new AttachEventHandler(RFIDExample.rfid_Attach);
                rfid.Detach += new DetachEventHandler(RFIDExample.rfid_Detach);
                rfid.Error += new ErrorEventHandler(RFIDExample.rfid_Error);
                rfid.Tag += new TagEventHandler(RFIDExample.rfid_Tag);
                rfid.TagLost += new TagEventHandler(RFIDExample.rfid_TagLost);

                //open reader 1
                rfid.open(serialNumArray[0]);


                //Wait for a Phidget RFID to be attached before doing anything with
                //the object
                Console.WriteLine("waiting for attachment...");
                rfid.waitForAttachment();



                //Declare RFID reader2 object
                RFID rfid1 = new RFID();
                //initialize RFID2 reader and attach events
                rfid1.Attach += new AttachEventHandler(RFIDExample.rfid_Attach);
                rfid1.Detach += new DetachEventHandler(RFIDExample.rfid_Detach);
                rfid1.Error += new ErrorEventHandler(RFIDExample.rfid_Error);
                rfid1.Tag += new TagEventHandler(RFIDExample.rfid_Tag);
                rfid1.TagLost += new TagEventHandler(RFIDExample.rfid_TagLost);
                //open reader2
                rfid1.open(serialNumArray[1]);
                rfid1.waitForAttachment();


                //turn on the antenna and the led to show everything is working for both readers
                rfid.Antenna = true;
                rfid1.Antenna = true;

                rfid.outputs[0] = false;
                rfid.outputs[1] = false;

                rfid1.outputs[0] = false;
                rfid1.outputs[1] = false;

                //standard example text
                Console.WriteLine("Press any key to end...");
                Console.Read();

                //turn off the led
                rfid.LED = false;
                rfid.outputs[0] = false;
                rfid.outputs[1] = false;

                //close both readers and dispose of objects
                rfid.close();
                rfid = null;

                rfid1.close();
                rfid1 = null;

                Console.WriteLine("ok");
            }
            catch (PhidgetException ex)
            {
                Console.WriteLine(ex.Description);
            }
     }
   }
}


/* - RFID simple -
****************************************************************************************
* This program simply displays the data that is generated by an RFID phidget in a very
* simple case and outputs it to the console. This simple example covers the basics of
* connecting and using an RFID phidget. For a more detailed example, see RFID-full.
*
* Please note that this example was designed to work with only one Phidget RFID
* connected.
* For an example showing how to use two Phidgets of the same time concurrently, please see the
* Servo-multi example in the Servo Examples.
*
* Copyright 2007 Phidgets Inc.
* This work is licensed under the Creative Commons Attribution 2.5 Canada License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/ca/
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using Phidgets; //Needed for the RFID class and the PhidgetException class
using Phidgets.Events; //Needed for the phidget event handling classes

namespace RFID_simple
{
    public class RFIDExample
    {

        //attach event handler...display the serial number of the attached RFID phidget
        public static void rfid_Attach(object sender, AttachEventArgs e)
        {
            Console.WriteLine("RFIDReader {0} attached!", e.Device.SerialNumber.ToString());
        }

        //detach event handler...display the serial number of the detached RFID phidget
        public static void rfid_Detach(object sender, DetachEventArgs e)
        {
            Console.WriteLine("RFID reader {0} detached!", e.Device.SerialNumber.ToString());
        }

        //Error event handler...display the error description string
        public static void rfid_Error(object sender, ErrorEventArgs e)
        {
            Console.WriteLine(e.Description);
        }

        //Print the tag code of the scanned tag
        public static void rfid_Tag(object sender, TagEventArgs e)
        {
            Console.WriteLine("Tag {0} scanned", e.Tag);

            RFID rfid = (RFID)sender; //Used for rfid in event
        }

        //print the tag code for the tag that was just lost
        public static void rfid_TagLost(object sender, TagEventArgs e)
        {
            Console.WriteLine("Tag {0} lost", e.Tag);
        }
    }
}



User avatar
mparadis
Site Admin
Posts: 609
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: How to make 2 Phidget 1024 work on same computer?

Postby mparadis » Mon Oct 24, 2016 10:44 am

How close together are the readers, physically? If both antennas are enabled at the same time and they are too close together, they will interfere with one another. You can get around this limitation by moving them further apart or by rapidly enabling and disabling them in sequence, as described in this blog article.

Dwynn@scaquarium.org
Fresh meat
Posts: 2
Joined: Fri Oct 21, 2016 2:30 pm
Contact:

Re: How to make 2 Phidget 1024 work on same computer?

Postby Dwynn@scaquarium.org » Mon Oct 24, 2016 11:53 am

wow....... that was my problem! Both readers were 6" apart. After I move them to 15" apart, both can read tags simultaneously. So where to I mail the bottle of champagne?

Thanks for the help!


Return to “C#.NET”

Who is online

Users browsing this forum: No registered users and 1 guest