<< return to Pixycam.com

SPI Issue

First off, the Pixy is amazing!

One thing I am trying to work out now is that when using SPI between the Pixy and a PICF2550 the Pixy is only sending (or I am only receiving) object blocks of data for whatever the lowest number signature that’s currently in the frame. All data I am receiving (checksum, x, y, etc.) is correct however. For example, when I have 3 signatures (1=blue, 2=red, 3=yellow) in frame I only get blocks for blue. When blue goes out of frame I start getting blocks just for red. If just yellow is in frame I get blocks for yellow.

My Pixy is connected to my Mac across USB and Pixymon is running Default Program 0. My Pic circuit is connected to the Pixy using 4 pins (SCK->SCL, SDI->SPI MISO, SDO->SPI MOSI, Vss->GND) and my Pic circuit is connected to my Mac across USB in order to work with the data in Max/MSP.

I’ve tried multiple approaches like:
a) streaming the bytes the Pic receives to the Mac where I look for the proper 4 sync bytes and then parse and start to look for the 4 sync bytes again…
b) waiting for the proper 4 sync bytes in a row in my Pic and then writing the next 12 bytes into an array there and then sending those 12 to the Mac and continuing from there…

Only data for the lowest signature currently in frame comes across no matter what I try however. The stream looks correct and I don’t appear to be missing any bytes or operating out of sync so this is confusing.

Anybody experiencing anything similar or have any suggestions? Thanks!

Is your connection between PIC and Pixy correct? I’m still confuse about the SPI connection. I search in the internet that the SDI pin is similar to MISO and SDO pin similar to MOSI…

SDI–>MOSI
SDO–>MISO
SCK–>SCK/SCL

I did look into that and it is connected properly. I’ve got SPI Data Out(SDO) on the Master connected to Slave In(MOSI) on the Pixy and SPI Data In(SDI) on the Master connected to Slave Out(MISO) on the Pixy. The other way around just gives me FF for every byte.

Everything is coming across nicely as expected but unfortunately the stream from the Pixy is only for whatever is the lowest numbered signature currently in frame and I need data for ALL the signatures in frame.

Hi Vince, can you share with me coding for communicating Pixy with PIC18F2550. I am stuck with the SPI write and read. I only manage to program using I2C for communicate between Pixy and Pic Microcontroller…
Thanks

My system is working properly using SPI between the Pixy and the PIC18F2550. I have the 18F2550 set up with the following SPI parameters:

SSPCON1.0 = 0
SSPCON1.1 = 0
SSPCON1.2 = 0
SSPCON1.3 = 0
SSPCON1.4 = 0
SSPCON1.5 = 1

SSPSTAT.6 = 0
SSPSTAT.7 = 0

SSPSTAT.0 (BF) is the buffer full status bit. In a loop I poll the Pixy by setting SSPBUF = 1 then when BF = 1 it means the buffer is full with a byte from the Pixy and I send that byte across USB from the PIC to my Mac. The byte stream that reaches the Mac is then successfully parsed.

How about sending sync byte and sync byte data to the pixy to synchronize communication? How do you do that?I am still confuse about these sync data

Syncing is taken care of already by way of SPI SCK. You have to poll the Pixy by putting some value in SSPBUF. Then Pixy offers a byte. Sync bytes and data bytes are the types of bytes you’ll be getting from the Pixy.

Did you have any luck with this? Would you be willing to share how you got data into Max? I am a pretty experienced Max user, but I have no idea about how to get the data from the Pixy into Max.

I would suggest looking for the 4 sync bytes and then just collecting the next 100 bytes into an array. (Or just collecting about 200 bytes without looking for the sync bytes.) Then analyze the array building the data words just to see what you get.

When I was starting to use the UT interface, I did this and found that the number of blocks of data I could get per frame depended both on the baud I was using and on how much time was being taken collecting and manipulating the data.

If you are taking the data in 12 byte chunks (plus the sync bytes) you might be running out of time and only getting 1 block. Now once I get the Frame start, I keep collecting data into a 2 dimensional array, testing for a block sync to increment the first index.

Best wishes, let us know what works.
Tom