<< return to Pixycam.com

Faster data transfer from Pixy to Arduino?

Hi, newbie here, hope I’m not asking a question that’s been answered a million times!

Anyway, I’m using my brand-new Pixy to track balls on on a billiards table (more or less). So far so good, and I’m getting decent results, but there seems to be a lower limit on the interval between data points of about 50 ms.

The setup is Pixy -> supplied cable -> Arduino Mega -> USB cable -> Processing on a PC. Thinking that my code was what was slowing things down, I started at the Processing end and worked my way up the chain, but every step of the way I kept seeing that 50ms. The limit really seems to be on the data rate between the Pixy and the Arduino.

It seems like I’ve seen chatter here about people needing to waste time so that their code doesn’t grab redundant data within the same 20ms frame interval, so I feel like I’m missing something. Any guidance would be appreciated.

Many thanks!

Hello,
Just so we are on the same page, which Pixy version are you using – Pixy1 or 2?

If you run the hello_world demo for Pixy on Arduino, it’s fairly straightforward to determine the framerate/update-rate (should be 50 hz for Pixy1 and 60 hz for Pixy2).

Are you printing anything to the console on your Arduino while it’s running? This can slow things down.

Edward

Thanks for the reply!

It’s a Pixy2.

Just running the straight hello_world I get a quite consistent 46-48 ms between readings. I even tried bypassing the Serial.print block except every hundredth time through loop() in case there was serial printing overhead, and still: 48 ms.

Odd…

There are a couple things that can be happening that result in less than 60 Hz update rate:

  1. Are you running Pixymon? Pixymon by default requires that Pixy send across the entire raw frame across USB and this takes time. You can set the “view” to send only blocks and the framerate should be fully 60 fps. This is what I’m guessing is happening. If not, there is a chance that —
  2. Pixy is tracking lots of objects. Pixy can, as a rule of thumb, track about 20 objects before the framerate can potentially suffer. But even then it depends on how many pixels in the frame are part of any of the 7 signatures. If more than 50% of the frames pixels are detected as any of the 7 signatures, the framerate can suffer. I’ve never seen it go down by more than 1/2 though (what you’re seeing).

Edward

1 Like

Ohhhhh!!! I’m certain #1 is it! I have been running Pixymon all this time.

Thanks so much! I might have eventually stumbled on that by random chance, but it probably would have taken a long time. Can’t wait to go turn off Pixymon and see the results!

That was it! That was it! That was it!

Thank you soooo much, Edward!

Absolutely, I’m glad you figured it out. :slight_smile: