Teensy 3.0 Video streaming - is it possible?

Status
Not open for further replies.

semi

Member
Hi all,

I've ordered a couple of Teensy 3.0 for a project where I'm putting various things in an R/C car. I've got an NRF24L01+ module in it and a camera so I can do FPV.

It hit me that the teensy might be powerful enough to transmit a lo-res video stream over the NRF24L01+ module that's comparable to the (crappy) PAL signal I currently get.

I was thinking something like the OV2640 module in a low-res mode with JPEG compression enabled and then transmit it to a PC via another Teensy.

It seems that in order to get data from an OV2640 or similar module, it's necessary to clock it and then receive data on a parallel 8-bit bus. I was wondering if any of the features of the chip could help with this or if I have to do pure bit banging.

The NRF24L01+ supports up to 2Mbit and has an SPI interface. any ideas of high high a data rate I could sustain? I see that it's possible to use DMA for SPI transfers, so it seems to me that the limiting factor is the digital sample rate of the Teensy - anyone who knows how fast that is?


Thanks in advance.
 
Could you post a link to specs on the OV2640 module, and thoughts on how you'll interface it? I'll take a look.

My general opinion, without review any tech specs yet, is maybe? Certainly 2 Mbit/sec speeds are pretty achievable. But details matter....
 
RF modulation rates will limit you... IEEE 802.15.4 radios (Xbee, Anaren, etc) modulate at 250Kbps, OQPSK, and the net yield due to small packet size (100 bytes) is about 40Kbps with ideal signals.
This is in 2.4GHz, with the IEEE standard 2MHz occupied bandwidth of the RF signal (direct sequence spread spectrum).
The proprietary (non-IEEE standard) nRF radios often use GMSK (2 bits/symbol) or perhaps QPSK (4 bits per symbol) and are often less than 250Kbps as above (no matter the SPI rate).

It begins with RF channel bandwidth: I think you need at least 200Kbps to send a few frames per second, at a reduced frame size of say, 200 x 180 pixels or so. Or a few seconds per frame for 640-x480 monchrome.
MPEG compression video ... too much for less than a megabit RF link.

Short range, point to point- *analog* video in 2.4GHz is cheapest/easiest (like baby sitter cams, or X10 cams).

Or use a low cost 802.11 radio module and an IP cam.
 
I only just started looking at it, but the OV2640 comes from a series of camera modules from Omnivision. I've found a page detailing communicating with a lower-res version called the OV7670 (which I might as well use) here

I can see that the JPEG compression it offers is YUV subsampling when sending the bitmap, so no quantization or run-length encoding.

The way it works is that you setup its registers on a seperate SCCB bus. Then you read out the data by driving its VSYNC pin and then send a clock signal to read out the data in parallel on 8 pins (10 in 10-bit mode).

It seems that it needs to be clocked at a speed between 6 and 24MHz (I don't know if a lower clock rate will work).

The question is then how fast the Teensy can read and store the bits byte by byte. The naive way I would implement the reading is by manually changing the clock pin and then reading the input bits pin by pin and putting them together into a byte by using bitmasks. But maybe it's possible to read an entire pin register of the Teensy in one go to get faster reads (I think it should be possible at least) - it would be awesome if it was possible to shift the bytes directly into a buffer by somehow clocking both the OV module and reading with DMA at the same time I think.

I'll keep digging and see what possibilities there are.
 
Last edited:
in addition to speed (SPI limited?), the other part is storage media size and rates (SD card write-rates).

If your use case can stand it, analog video/cheap, is so much simpler than digital. On the receiving end, display NTSC/PAL directly, or digitize it with a USB gizmo into a PC or NAS.
 
in addition to speed (SPI limited?), the other part is storage media size and rates (SD card write-rates).

If your use case can stand it, analog video/cheap, is so much simpler than digital. On the receiving end, display NTSC/PAL directly, or digitize it with a USB gizmo into a PC or NAS.

I think SPI speed shouldn't be the limiting factor; it's very fast, and the Teensy can use DMA when talking with it.
The NRF24L01+ module supports speeds up to 2Mbit. I don't expect great (or even 'good') quality - I'd just like to see if it's possible at all.

I already have a camera that can send an analog PAL stream wirelessly, so if I can't get this to work in a satisfactory manner I have this to fall back on.

I have a device that can convert a PAL signal into a digital video stream and send it to my pc, but the latency is far too high for FPV purposes - about 1 second. So, latency is also an issue (as if it isn't complicated enough already :) ).
 
For anybody who's interested I found an application note and accompanying code on the Freescale website on how to capture frames from an OV7675 module to the SRAM on a K60 MCU.

The name of the application note is AN4627, and the example that is used is capturing QQVGA resolution frames (160x120) in YUV 4:2:2 mode, which results in 38.4kB per frame, which the Teensy's 128kB SRAM can easily handle.

The method is using an internal clock to generate a 3MHz clock signal that triggers both the readout of the CMOS sensor and the DMA transfer from 8 sequential GPIO pins.

The result of testing shows that both 30fps and 60fps capturing is possible, and in the conclusion it's speculated that JPEG compression of the images before transfer is possible by using the builtin DSP hardware.

Note that the OV camera modules that I've mentioned so far are functionally similar and differ mostly in resolution.

So yes, it seems that it's possible to some degree. It's probably not exactly trivial to implement, but at least the documentation is not lacking :)
 
MPEG would ease the low bandwidth RF link issue. Unless you use one of the $30 WiFi modules rather than low rate such as Nordic or 802.15.4. In these links, look first at the RF channel width they use. Laws of physics prevail. To get 2Mbps of NET YIELD, sustained, with all the wireless overhead, the RF channels needs to be 5 or 10MHz, to use modulation with constant amplitude data symbol/bits, such as GFSK or QPSK. QAM modulation, as used in WiFi, gets more net bits/Hz/Sec, but it's more expensive, takes more power.
With $5-20 radios, I'd plan on 100Kbps or less net yield. So the new WiFi modules are best - but they often have a UART interface and thus are slow. Maybe one with SPI can do. WizNet has various ones,as does Lantronics.
An 802.15.4 module like Xbee S1, in 2.4GHz, will yield 50Kbps or so net, for its defined 250Kbps raw bit rate on the channel (without Zigbee). Don't be deceived by the RF raw bit rate of a radio!

The wireless link is why it's so much better do do short range video via simple analog means; a la babysitter cam or X10 cam - these are NTSC 640x480x30fps, color.
 
Last edited:
A quick note: the Teensy only has 16kB of SRAM, not 128 as I wrote. That means that the only possible way of getting a frame off the camera module would be by subsampling the picture several times (the OV modules have a cropping function), but then it becomes absurd imho.
 
I'm still in favor of analog, but there are block compressors that start with a few lines (samples) and start generating blocks. MPEG does that. ADPCM does that - but the math for the DCT is needs good floating point speed.
lossless Run-length encoders (like WinZip) can work, but video doesn't have as much redundancy in it for these to work well.

Too much for a humble microprocessor.
 
Status
Not open for further replies.
Back
Top