PixyCam SPI Output Inconsistent

We’ve recently been working on getting vision working with our PixyCam, and we’ve had a good amount of success with a few issues.

We started by using the analog output for tracking our target. It worked great and was very consistent. Then we realized it wouldn’t work for the gear peg targets because they were two separate objects, not one, so it would attempt to track either left or right. So we switched to SPI instead.

SPI seems to be working correctly, but the output for the center of the target is very inconsistent. Holding the object still results in a returned value that can jump around a very large range, almost ±50 pixels at a couple feet away. We aren’t sure why this happens or what to do about it, so any help with this would be greatly appreciated. Analog worked fine, but now SPI seems to be jumping all over the place with a trend of tracking the object (and it IS tracking, the number just jumps around far too much to be really useful).

So if anyone can help with this, I’d really appreciate it.