Thursday, December 31, 2015

FPV for the 21st century

Saw a couple (of dozens...) of youtube videos with people mounting FPV to various RC things. The videos from cameras themselves looked fantastic, but to transmit the video feed to the pilot, an analog link is traditionally used. While the transmitters and receivers are small, relatively cheap and yet use fancy modern stuff like digitally controlled PLL tuning, it's still analog video, even at perfect conditions you have 576 visible lines at most, a far cry from 720p or 1080p we are used to in digital video that has been around for almost a decade now.
There are a few working attempts at transmitting amateur video over DVB-T, but the problem is that the cheapest variant (to this day) requires a modulator that costs $170-$230, not very cheap. Does not include the cost of any other vital part (camera, RasPi...)
Others that I saw use software radio, this particular one a BladeRF ($420), and I would guess that it should be possible to use HackRF (~$300, depending where you buy it from) or the HackRF Blue ($215, or $150 for a "factory second" version), which is a cost-optimised version of the HackRF. One more that I remeber used an URSP 1 (>$700, the newer versions cost even more).
All of the software radio versions however require a fair bit of floating-point maths to be done, way more then a measly Raspberry Pi could do, so they are not practical as FPV transmitters.

So, not being happy with the analog quality and the pricy-ness of the digital solutions, I've been putting FPV off for over 2 years now.
Recently I noticed Wifibroadcast, which simply put uses "monitor mode" to force certain wifi chipsets (only some can do this!) to completely change the way the protocol works, which allows not only to receive mangled packets (under normal operation wifi discards packets whose CRC does not match), but to also transmit modified packets. One other important feature of Wifibroadcast is that it's one way, meaning that the transmitter does not need to receive any conformation from the receiver (again, under normal wifi operation, the transmitter keeps re-transmitting a packet until it gets an ACK from the receiver or times out and quits trying). The combination of one-way transmitting and ability to receive mangled packets means that with degrading conditions (like the transmitter getting too far) the link fails "gracefully", not instantly like normal wifi would.

So, (my) shopping list:

1x Raspberry Pi Model A+ with Coupé Royale Pibow (£20.83 GBP (~$29.5) from pimoroni.com )
1x Raspberry Pi Zero + Adaptors (£6.67 GBP (~$9.4) from pimoroni.com)
1x OV5647 Sensor camera ($15 from Ebay) *
2x TP-Link TL-WN722N ($14.5 each from Ebay)
2x microSD cards, 4GB at minimum ($3 each? from Ebay)

total: $88.9 USD

I've had the wifi adapters and SD cards for less, since I work at a computer store (employee discount :D).
*The camera has fairly crap optics, which is not very surprising since it cost less then 1/2 of what the ones with better optics do. It also is not wide-angle enough, so it's unsuitable for me (kept snagging the car on obstacles, because I couldn't see them), will probably be changing that. But it works for a proof-of-concept. There are several options for the camera, for example with and without the IR filter, the rest is all about the lens.
Since not everything arrived before Christmas (like it was supposed to...I'm looking at you Czech Post), I didn't have all the essential parts until now.
So, after a couple of zip-ties, about 50cm of kapton tape and one hour of hacking, most of which was spent troubleshooting the 5V switchmode regulator (amazing how much flustration can a forgotten resistor do...), I had this:

No officer, this totally is not a bomb, honest!
The green LED flashes when transmitting...seriously though, some might see this as a bomb :D
Pictures were shot with a crappy cell phone camera with clearly not enough light. Sorry about that.

The box from laser-cut acrylic contains the Pi A+, below it is a 3S2P lithium pack scavenged from a laptop battery (was 4S, but one pair was dead). The mess of wires on the right with the inductor and grossly oversized heatsink is an LM2575T-ADJ buck regulator providing 5V for the RasPi. Junk from a disasembled old project. I could have made it output 3.3V and feed the Pi directly (it has an internal 5V to 3.3V regulator), but I do not trust the thing enough to do that. If it goes apeshit and starts feeding more then it's supposed to, the Pi will let out the magic smoke. The 5V input on the other hand is quite idiot tolerant, as it survived 9V. (forgot to remove an original resistor from the board as I installed a new voltage divider into the feedback loop, it happened to be in the "lower" part of the divider causing it give out much more voltage).
The bare board (with the antenna) dangerously sticking out is the TL-WN722N. As mentioned in the picture caption, the thing does flash when it starts to transmit, which draws unnecessary attention and eats power (albeit not very much). The board on the copper wire with the flat-flex leading to it is the camera module. The black part is 8.5x8.5mm, really small. Might also try to change the flat-flex to normal wires to make it more flexible.

Plug&play:
Getting it to work is stupidly simple, download both the precompiled TX and RX images from the Wifibroadcast GitHub, load the images onto the SD cards (Adafruit has a nice tutorial), plug the cards into respective Pi's, connect the camera, wifi dongles, power, monitor and off you go. If you did it right, it will be plug-and-play, don't be scared by the commandline dump on the receiver screen, you just have to wait until everything loads and starts.

The tiny thing on the drum with the cables is the Zero. Receiving wifi is on the stool down left.
Picture quality (and latency!) will depend on both the camera and monitor. Currently I'm using an LG smart TV, but that will change once the damn display finally gets here...
The picture does not do justice to the quality, even with the shitty optics the $15 camera module has, it's quite reasonable. Low light performance however is atrocious (not surprising given the size of the lens), best to this outside in daylight.
Latency is well perceptable, estimated guess is somewhere on the 500ms mark. A lot like a good IP security camera with direct cable connection. The main suspect is here the TV itself, not Wifibroadcast.
Sadly I can't record the HDMI output directly, the TV will not allow it (cause hurr durr pirates...fuck you DMCA, fuck you with a cactus) and I have nothing else that can record HDMI. Will have to see if the receiver has enough gnomes free to record the output somewhere...

Power:
When booting, the current was jumping around 100mA, once the camera kicks in (h264 encoding) and wifi starts transmitting, it jumped to 260mA (couldn't use low range, so I just round up the last decimal).
during boot, jumps between 60-150mA

transmitting
Volts
Current times voltage equals power, in this case 3 watts. Considering that's with the sub-optimal regulator design (fairly low frequency and grossly oversized inductor), not too bad. I will be doing more measurements with a better regulator providing 3.3V directly.
Sadly, the Zero does not have the camera port or the connections to it on the board, which is a shame, so you have to use an A+ for the transmitter. Using the more powerful Pi versions for the transmitter is counterproductive, as the greater heard of horses also eats more (and generates more waste heat).

Obvious thing to do at 6 o'clock in the evening...

Yes, that's a zip-tie

I was kinda in a hurry to get it moving...

All it's missing is the kitchen sink...
Did just a few quick indoor tests, big surprise, a 1:10 RC car is too big for driving around a flat without wrecking it. Since it's dark, freezing and now snowing outside (and the 100cm TV is kinda hard to carry around), so I have to wait for better weather and a small display.

To come:
this (Zero has the same header, so it should work)
- some miniaturization (remove USB connectors and hardwire the wifi, use a more modern buck converter)
- weatherproofing
- lowering the power-hungriness
- dealing with the slight EMI issues (RC car and the wifi interfere with each other in various ways)
- different camera module (huge lens, maybe no IR filter for better low-light performance)

edit:

So I measured the 5V side, and the consumption is when transmitting is 2,15W, which is pretty much dead on 70% of the regulator input, so, quite a shitty buck regulator. A properly designed one should be capable of at least 85%, over 90% if done really well.
However keep in mind that these measurements do not include the absolute deviation, I'm too lazy to look it up and count it, if you're bored, I used a UT61 multimeter, current was on the 10A range.
Also there's the problem of switchmode PSUs, which notoriously confuse the fuck out of multimeters by the high frequency ripple, the UT61 is a true-RMS meter, but a cheap one, so...

No comments:

Post a Comment