<< return to Pixycam.com

Using multiple Pixys via USB

I am currently working on using two pixy cameras simultaneously via USB in linux. I haven’t been able to find anything about how to do this in the documentation and was wondering what the best way to go about this would be.

Thanks
Darren

Hello Darren,
PixyMon supports multiple Pixys, but I don’t believe libpixyusb support multiple Pixys. We should add this to our list for the next version. It just entails taking the device enumeration code in pixymon:

(The part where is calls libusb_get_device_list(), and bringing it over to libpixyusb:

I’m surprised that no one has asked about this earlier!

Edward

Hi Edward

Thanks for the reply. I have modified the code as you suggested, it all seems to compile and run ok. To test it I have just been running 2 instances of the hello_pixy code however the second instance returns a USB busy error from pixy_init (I tested it this way based on running 2 instances of pixymon to see both cameras). Is this the correct way to test this, or do I need to modify the pixy_init function?

Thanks

Darren

Hi Darren,
If you modify USBLink::open() in usblink.cpp to open the first available Pixy (as it does in int USBLink::openDevice() in the pixymon code), it should work. Can you do some debugging and see what USBLink::open() is doing?

Edward

Hi Edward,

I am also working on getting two pixy’s on a Laptop working I am using
the code from https://github.com/JhottMaster/PixyUSBdotNET

It is working for one pixy cam and I have changed usblink.cpp but nothing happens.
Every pixy cam has the same PIXY_VID and PIXY_PID where can I change the code so that it will detect the second pixy cam
On the Second USB Port.

Dick

Hello,
Is this code calling libusb_get_device_list() as it does below?

Edward

Hi,

There is a fork of the code that has been used to work with multiple Pixy cameras over USB here:

It’s a few commits behind but I believe it should still be compatible. Here is a sample source file:

Hopefully this is helpful.

Thanks,
Tigist

Question regarding the use of multiple Pixy’s over USB: Is there a way to identify each Pixy when multiple cameras are used? We have a way to recognize and handle the multiple devices, we haven’t yet figured out how to identify one vs the other. The thought was to use the serial number, but it appears that the firmware reports up the same number for all devices. Is there a way to configure some sort of identity within the Pixy?

Hello Ken,
There is something called “GetUID”. It’s a chirp command that you can send over libpixyusb, or you can type it into the command window on PixyMon after you hit the stop button.

Here’s how you might do it over libpixyusb in C:

int32_t uid;
pixy_command(“getUID”, END_OUT_ARGS, &uid, END_IN_ARGS);

This should get the UID which is a 32-bit unique number that is unique for each Pixy.

Hope this helps!

Edward

Thank you for the reply, Edward. We will give that a try.

Ken

I’m also looking at using multiple pixies with the raspberry pi, but am having difficulty identifying them.
I cloned the hello_pixies example from NURobotics, which works great with the two pixies I have hooked up.

To identify each pixy, I tried the command you recommended Edward, but it is not working. The uid value is not
being set by pixy_command(“getUID”,END_OUT_ARGS, &uid, END_IN_ARGS), which is returning -154. Are END_OUT/IN_ARGS
supposed to be replaced with something else? Also, right now I put the pixy_command in the main loop of the hello_pixies.cpp
example by NURobotics. Is that the right spot?

Edit: I’ve just decided to have the two pixies identify different signatures, and identify the pixies based off of which
signatures they use (i.e. Pixy 1 uses signatures (0-3) and Pixy 2 uses signatures (4-6).

Hmm, it looks like you are doing it correctly. Just to make sure, are you running that latest firmware version?

http://cmucam.org/projects/cmucam5/wiki/Latest_release

Edward