<< return to Pixycam.com

Pixy2 -> Rbp4 interference issues

Hi All,

Brief description of our set-up: we are using the Pixy2 in color-components mode in which it has been trained to recognize a green line. The Pixy2 communicates to the Rbp4 via USB. The Pixy2 lives about 20cm above a hallway chamber, with metallic rods that span the entire hallway horizontally and the green line at the middle of the hallway (which the pixy recognizes nicely). These rods are in turn connected to a shock generator which delivers a 0.3mA ‘shock’ through the rods in particular experimental conditions (active avoidance with rodents). The shocks get delivered when there is a ‘break’ in the detection of the given signature by the pixy2.

The issue: when the shock happens, the pixy2 gets disconnected and i get the ‘error: no response’ communication issue. I am forced to power off the pixy2/rbp4 and restart it to restore communication. I need to have detection intact during this period.

What I’ve tried: shielding tape all around the pixy2 cable + ferrite beads all over the place. If there is no shock, no interruption happens, everything works perfectly. I am guessing the shock causes so much electromagnetic interference that it disrupts data transfer over USB. I’ve tried longer shielded cables and playing around with cable location but the same issue happens.

I was wondering if anyone had any advice. We have a similar set-up that is with arduino and the pixy communicates via the provided SPI cable and that works fine. Do you think trying to swap from USB to SPI using jumper wires to the rbp4 SPI is worth an effort? I also read on the wiki about the pixy2’s analog/digital output which i think could potentially work (custom wires from the pixy2 to the rbp4 GPIO). I really do not know much about these things, but perhaps one means of communication would be less vulnerable to EMI than USB?

Apologies for the wall of text, any advice would be much appreciated.
Thank you in advance!

Hello,
This sounds like an interesting project! :slight_smile:

I’m wondering if it could be a power issue – for example if the shock is somehow stealing power from the Pixy. I’m guessing it’s unlikely, but how are you powering your shock generator?

If it’s truly an EMI issue that’s causing the Pixy USB connection to get into a weird state, there are some potential ways to reset the USB connection:

https://forums.raspberrypi.com/viewtopic.php?t=343341

There’s also “usbreset” utility that you can install:

Let me know what you find.

Edward

Hi Edward,

Thank you for the speedy response!

The shock generator has its own power source. We do have a servo getting powered by the raspberry pi but I already spent some time looking into that and making sure that there was no interference caused by that (which I am pretty sure there isn’t). To make that a little more concrete, if I have a mock shock everything works just fine.

Thank you for suggesting the usbreset tool, I was not familiar with that but will give it a shot today and report back. Just for full transparency, I do not have much experience with microcontrollers so my intuition with these things is not at its best.

I did spend some time trying to get SPI communication going yesterday. I made 6 jumper cables (approximately 2 meters in length, which I realize now may not be ideal) to connect pins 1,2,3,4,6,7 from the Pixy to the appropriate pins on the raspberry pi and swapped the data out port configuration for the Pixy from Pixymon to SPI with SS. SPI communication within the raspberry pi itself was functional, communication between the pi and the Pixy was somewhat functional but the responses received from the Pixy to the pi were weird and not what was expected. I tried various SPI modes and timings but could not get it to work fully. Any suggestions for getting that going would also be very much appreciated.

I’ll mess around with things a little more today and test the usbreset tool and report back!

Thank you!

Hello,
Getting SPI working on the Pi is similar to porting to a new platform. You might try sending a version request and see what you get back.

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide#the-serial-protocol

This page also has some good technical details.

Edward