Pixy Camera with Teensy 3.5 and SPI

Added by Rand Vibe 24 days ago

A couple of years ago I transitioned from the Arduino-Due to Teensy, specifically Teensy 3.2 and recently 3.5 & 3.6. I'm opting for SPI for speed and signal robustness and I have had good success with the ILI9341 display and a Sparkfun IMU on the Teensy. The Pixy SPI library was written for Arduino, and peeking into it, I don't see how it will work with Teensy. Has the Pixy organization written an SPI library (with SS select) for the Teensy 3.2, 3.5 or 3.6? This would be extremely useful for the community. Thank you.


Replies (10)

RE: Pixy Camera with Teensy 3.5 and SPI - Added by Edward Getz 24 days ago

Hello Rand,
We do have SPI with SS supported. :)

http://cmucam.org/projects/cmucam5/wiki/Interface_Pane

Edward

RE: Pixy Camera with Teensy 3.5 and SPI - Added by Rand Vibe 23 days ago

Yes, I was able to configure my Pixy board through the PixyMon app. When I choose SPI with SS, it does not allow me to select the SPI clock speed. Is it possible to do so? Is the default speed 1 Mhz? How can I change this to say, 10 Mhz?

Regarding libraries, is there a dedicated Teensy 3.5 or 3.6 SPI library? I found the Arduino version in your Wiki page, but I don't see how it can work with the Teensy 3.5 or 3.6, which uses a completely different MCU chip (Freescale MK66FX1M) compared to the Arduino SAM3X8E.

RE: Pixy Camera with Teensy 3.5 and SPI - Added by Jesse French 18 days ago

Hi Rand,
When Pixy talks over SPI, it does so as a "slave", which means that it takes the clock rate from the master (the Teensy in your case), which is why you can't configure the clock rate for SPI. The clock rate is configured on the master.

We don't have a native Teensy library, but it should be possible to convert the existing Arduino library over. Is the API the same? (I haven't used Teensy)

Jesse

RE: Pixy Camera with Teensy 3.5 and SPI - Added by Rand Vibe 16 days ago

Hello Jesse, I understand the Pixy is the slave, but there should be a maximum clock rate it can handle. Is it 1 Mhz, 10 Mhz, 20? I have not experimented beyond 1 Mhz to avoid any chance of "bricking" my Pixy.

I went ahead a developed simple but robust functions to read Pixy data with SPI for the Teensy 3.5 and 3.6. The code is designed for use with other SPI devices/slaves with a single Teensy SPI connection. You select the CS port for the Pixy. I tested it with a Teensy 3.5 and it works properly. All I need is object pixel information. It helps that the Pixy streams out a checksum value - I make use of that to ensure a proper data stream. Complete example code here:

[[https://forum.pjrc.com/threads/46107-Pixy-Camera-with-Teensy-3-5-and-SPI?p=152844&viewfull=1#post152844]]

RE: Pixy Camera with Teensy 3.5 and SPI - Added by Edward Getz 16 days ago

Hello Rand,
I believe you don't want to exceed 1.5Mhz for a cable less than 1 ft in length.

Congratulations on getting your Teensy working with Pixy! and thanks for the link!

Edward

RE: Pixy Camera with Teensy 3.5 and SPI - Added by Rand Vibe 11 days ago

The aforementioned Pixy functions for SPI communication with the Teensy 3.5 are working well. Now I want to try the setup on my Teensy 3.6, which has a faster microcontroller chip over the 3.5, however it's not 5V tolerant. What's the recommended approach for level shifting Pixy SPI signals at 1 Mhz for a 3.3V device?

RE: Pixy Camera with Teensy 3.5 and SPI - Added by Edward Getz 11 days ago

Hello Rand,
The SPI signals are 0 to 3.3V. Pixy runs off of 5V, but none of its signals are 0 to 5V except for I2C SDA, which has a weak pullup (75K) to 5V. In other words, you won't need to do any level shifting to communicate with a device that accepts/expects 3.3V.

Hope this helps!

Edward

RE: Pixy Camera with Teensy 3.5 and SPI - Added by Rand Vibe 10 days ago

Edward Getz wrote:

Hello Rand,
The SPI signals are 0 to 3.3V. Pixy runs off of 5V, but none of its signals are 0 to 5V except for I2C SDA, which has a weak pullup (75K) to 5V. In other words, you won't need to do any level shifting to communicate with a device that accepts/expects 3.3V.

That's very helpful - thanks. It is almost too good to be true. Aside from comments in the wiki about 3.3V levels, I'm having trouble finding a complete Pixy diagram of all the pins and their voltage levels. I just want to make sure I don't destroy my Pixy board and Teensy board.

RE: Pixy Camera with Teensy 3.5 and SPI - Added by Jesse French 10 days ago

Hmm, good point - we don't list voltage levels on the pinout. Maybe I can make that happen...

Here's the diagram, for reference: http://cmucam.org/projects/cmucam5/wiki/Port_Pinouts

And our complete porting guide: http://cmucam.org/projects/cmucam5/wiki/Porting_Guide

Hope this helps!

Best,
Jesse

RE: Pixy Camera with Teensy 3.5 and SPI - Added by Rand Vibe 10 days ago

Here's a diagram found by @tarzan from the Teensy forum. It verifies the SPI 3.3V pins. This is good news. No need for high speed level shifting (which can be problematic) with the Teensy 3.6.

[[http://cmucam.org/attachments/915/cmucam5_1_2.pdf]]

(1-10/10)