<< return to Pixycam.com

Pixy not acting on Set commands sent by host

I modified the porting code
(http://cmucam.org/projects/cmucam5/wiki/Porting_Guide)

to match more closely the arduino 1.7 code which contains the flush fix (circular input buffer, etc).
(http://www.cmucam.org/projects/cmucam5/news)

But sending setLED (0, i++, 0) commands every 500ms in a loop, the Pixy Led doesn’t react to it… I’d expect it to go green with increasing intensity. The 1mhz sclk (Pin3) Mosi (Pin4), and Ground (Pin6) look good when I look at the spi bus.
(i.e. I see the command (0x5B, 0x00, 0x5B, 0xFD) followed by the data (0x5B, 0x00, 0x5B, 0xXX, 0x5B, 0x00) where 0xXX increments from 0x00-0xFF

Do I need to press the white button on the pixy to get into a slave mode? Does the default program/mode on power-on work with setLED SPI commands? Can the CS line be left open? Any issue if CS is tied high or low?

Because of the cable I’m using, the I2C SCL pin is tied low… is this a problem or does it expect it to be high (even though I’m using only the SPI interface?)

Here is the bus activity, any ideas why the Pixy isn’t changing the led color?

Hello Ben,
When Pixy’s “Data out port” parameter is set to 0 or 1 (both of which are SPI modes) Pixy is in slave mode. (Pixy doesn’t have a master mode for SPI or I2C.) Tying the I2C pins low shouldn’t be a problem, but it’s not a recommended to tie any potential output pins low. If you must, use a resistor 1K ohm or greater.

The data doesn’t seem right (0x5b, 0x00, 0x5b) To set the led, the data it needs to be 0x00, 0xfd, r, g, b (where r g and b are the 8-bit values for red green and blue). (see Tpixy.h) in the Arduino library.

Hope this helps!

Actually, in Tpixy.h, all data bytes have the PIXY_SYNC_BYTE_DATA (0x5B) sent before it… i.e. 0x5B, red, 0x5B, green, 0x5B, blue).

The problem was that I had a bug that was sending out the data WITHOUT any delay… apparently this was too fast and the led was changing colors randomly (including red and blue which I always sent 0 to!). It would be nice to the know the specs on how fast commands can be sent to the pixy, and how fast the master sclk can be. In any case, once I placed the delay before the ‘continue’ keyword, it worked fine (green intensity changing only).

Hello Ben,
Bear in mind that Pixy doesn’t expect to respond to more than a few commands for every frame (its receive queue is only 64 bytes). While Pixy is processing a frame of data, it doesn’t read the serial data, so data sent over serial piles up in the receive queue. So just wait 20ms between commands and you’ll be fine.

Edward

Hello,
I am having troubles setting the LED colour via SPI. Ben, in your case, sending 0x5B, 0x00, 0x5B, 0xFD, 0x5B, red, 0x5B, green, 0x5B, blue worked fine in the end?
I tried sending both like that and without the synch bytes, but without success…
I am working with a NI myRIO and I am coding in LabVIEW, and I can’t send hexadecimal numbers (I can only transform in hex strings but then the SPI block won’t accept it), though I have converted my array of data to unsigned bytes. Could decimal numbers be a problem for some reason?
Thanks!!!

Hello Ilaria,

Here are the bytes you need to send in order:

0x00
0xfd
r
g
b

where r g and b are the red green and blue values. The first 2 bytes (0x00 and 0xfd) are the sync bytes.

Hope this helps!

Edward