<< return to Pixycam.com

Pixy 2.1 in SPI mode to Arduino MKR ZERO

I am new to Pixy 2.1 and I am using it via SPI connections to the Arduino MKR ZERO, see picture below:

I had to make some custom jumper wires using Dupont connectors.

So far, I have only tested the example ccc_hello_world.ino, and I encountered a similar problem as previously reported here (Pixy2.1 alternates between no response error and actual data).

Fortunately, I have found a solution for it. Essentially, it looks like that the main loop needs to slow down a little bit as the MKR ZERO may be “faster” than the UNO: see the added line 55 in the picture below.

This small delay seemed to stabilize the data flow between the Pixy 2.1 and the MKR ZERO, so hopefully this will help future users.

However, I do have a question for Pixy Support: can I use 3.3 V (i.e. VCC) from the MKR ZERO to drive the Pixy 2.1? Or is that too low a Voltage Input for the Pixy 2.1 to work properly?

Thank you.

1 Like

Hello,
The thread you mentioned:

He had a conflict with the MISO and/or MOSI signals that was causing his communication to drop out. I’m not sure why you would need a delay.

Regarding powering Pixy via 3.3V, it’s too low. Your best bet would be to supply 5V via the I/O connector:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:port_pinouts

Edward

Thank you for the VIN update.

My setup was using only the SPI Port (no SS), see picture below.

Without the time delay, my setup showed correct data only for 1 or 2 minutes (randomly), then it showed the no response error message afterwards and got stuck there too, until the program got reloaded. However, during this “error” time, I could tell from the Front Color LED that the camera was still doing its job and recognized the correct color signatures though. Just glad to have found a “work-around” for now.

Hello,
It’s good that you found a workaround, but that’s really odd! When it gets into the no response state, are there other things that will bring things back? (Unplugging/plugging Pixy, power cycling Pixy.)

It could be a power issue:
https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:powering_pixy

Note the section on unregulated power – if the Arduino is powering Pixy, the Arduino regulator could be on the “edge” and the Pixy or Arduino could be “browning out”, which can put things in a defunct state. The delay could be power limiting (?)

Edward

Hello Edward,
I was intrigued by your raising the possible issue of power limitation when using the Arduino board to power Pixy2. So, I made a few more tests:

  1. I powered Pixy2 (5V regulated), but separately from the Arduino (USB Input) - but everything through the same household wall plug of course. Big surprise! Even without presenting learned targets to Pixy2, it was already sending over “no response error” messages, interpersed with “checksum” error. Definitely, some kind of grounding issue, it looks like.
  2. I went back to powering the Pixy2 via Arduino, and varying various delay times:
    • when the delay statement is commented out or “delay(0)” is used, then the program would get stuck into the “no response error” zone after 1-2 minutes of working properly.
    • the smallest delay I can use is “delay(1)” (i.e., 1 ms), and the detection data flow will be fast but stable as long as I needed to use Pixy2.

So, it will be interesting to see if another MAKER ZERO user would find the same issues in the future.

BTW, I used CMU-CAM2 many years back, it is great that you guys can keep up with its improvements.

Thank you very much for your comments.

Hello,
I suppose it’s working reasonably well, so that’s good. Thanks for sharing your test results. I’m sorta stumped… :slight_smile:

Edward

Hello Edward,

One last test. This time, I am using the official Pixy2 USB cable to power the camera and to use PixyMon at the same time, and my regular SPI setup on the MKR ZERO.

When I commented out my delay(1), the detection first worked fine:

Then the “no response” error happened.

But when I put back in my delay(1), everything worked “as advertised”!

UPDATE (10 hours later)
I just tested Pixy2 on another Arduino board. This one is a Variant called OpenCM-904, its controller is an M3, i.e., different from the SAMD21 on the MKR ZERO (https://emanual.robotis.com/docs/en/parts/controller/opencm904/#specifications).

But your example code worked fine, except now the delay has to be 2 ms for a stable dataflow. So, I don’t think that Pixy2 is the issue, it is just some Arduino boards need a slight delay in handling data flow from their SPI ports. :grinning: