Monday, April 22, 2013

Connecting an iPad retina LCD to a PC

This project was born at the Warsaw Hackerspace, it was funded by my friend Spin, who wanted to use the display in a project of his.

In short, I've managed to drive the iPad retina display at maximum resolution from a regular PC with DisplayPort, no additional electronics required!

This is just a prototype, I'm working on a professional PCB with a DP connector so no wire splicing will be required in the future. :)


The screen

The "retina" LCD panel is LP097QX1-SPA1 manufactured by LG.
It's a 9.7" panel with a resolution of 2048x1536!
It's not exclusive to Apple, it can already be found in a couple of Chinese tablets.


What is great about this panel (except its resolution) is that it has an eDisplayPort interface (which is supposed to replace LVDS in the near future), and as this hack proves it is compatible  with traditional DisplayPort outputs found on all modern video cards.

The panel is also surprisingly cheap - I got mine on ebay for $55, shipped from China.

Hoping that eDisplayPort is compatible with regular DisplayPort (I couldn't find conclusive proof of this), I went on to interface the panel with a DP cable.

The interface board






The FPC of the panel has 51 really tiny pins, and requires a special connector to mate with a PCB. You can find it online just by looking for "ipad3 lcd connector", but I've figured out that it's a Molex 502250-5191 connector. The cheapest I could find was $14 for two of them at aliexpress.


Creating the PCB was fairly straightforward, I just had to route all the FPC connector pins out to pads where I would solder DP cable wires. It was possible on a single-sided home-made board.
I tried to make the traces for DP lanes to be of the same length (that's very important for high speed differential signals), and as it turns out, either my PCB design is pretty good, or DisplayPort is very forgiving. :)

Soldering everything was a little difficult, the FPC connector has tiny pins, but they stick out a little bit, so it's doable with a regular soldering iron.
After the PCB was done, I cut open a DP cable and soldered all the wires in their places.
Unfortunately there is no standard for wire colors, so I had to open up the DP plug to trace them to the correct pins.

You can find the schematics and PCB layout on github.

Power and backlight

The panel itself can be powered from the DP connector, as it should provide 3.3V at 500mA, which is enough for the logic. Although that power is meant for an active cable, so I had to solder an additional wire to a regular "dumb" cable I was using.

The backlight requires some external power source, as it can consume up to 4.4W.
The datasheet is very misleading about driving the backlight, it only mentions something about "12V driver voltage", which is not the proper voltage (fortunately it's too low).
After finding iPad3 schematics, I've found out that the backlight actually requires 20V for operation, as it consists of 12 LED strings, with 6 white LEDs in series, each.

For the prototype, I didn't bother with a proper LED driver, just attached 68R resistors to each cathode, which resulted in a current draw of about 17mA per string.
The 20V was generated from a 5V using a TPS61175 step-up converter.

Results

It works! No glitches at full resolution.
The whole thing cost about $70 in parts.
Here are some pictures for your enjoyment. Believe me, the display looks much better when viewed in person.




Thursday, March 28, 2013

Adding Bluetooth remote control to computer speakers






 Introduction

Some time ago, I had to replace the volume pot/power switch in my Creative computer speakers.
Unfortunately, they use a non-standard pot with a switch, and I didn't bother finding a proper replacement, just did a quick fix with a generic pot and switch.
It worked well, but looked bad. So now I decided to repair it properly and put everything back together, while I'm working on it, might as well mod it a bit...


The volume control PCB and my quick fix

At first I just wanted to add a rotary encoder instead of the volume pot, but if I'm going to put a microcontroller inside I might as well add some more features, so I grabbed an LED and a Bluetooth module and got to work...


Hardware

Here's a list of hardware used in this project:
  • Creative 5.1 speakers
  • TPL0202 digital potentiometer
  • Rotary encoder with switch
  • ATmega8A
  • RGB SMD LED
  • BTM-5 Bluetooth SPP module
 And here's a basic diagram of the whole thing:

Basic diagram of the project

Speaker PCB

The original volume/power/bass control PCB is very simple, just two pots, two jack sockets, some resistors, cable connector and an LED.
The main speaker unit supplies 5V to this board, and the speakers are turned on when this 5V is applied to one of the pins.
Unfortunately I have overestimated the power of of that 5V source and so my modification requires an external 5V power supply, but that's no problem.
There is not much I had to do to the PCB, just removed the pot, removed the green power led, changed some resistors (because the original pot was 50k and the digital one is 10k) and cut out some more room for the rotary encoder.

Digital potentiometer

I'm using a TPL0202 digital potentiometer from Texas Instruments. It has two outputs, 256-position resolution and is controlled via SPI.
The chip is QFN16, but I have somehow managed to solder it (after a couple of tries :P) onto a home-made PCB using hot air.

Rotary encoder

It's just a 20-step encoder with a button. The button is used for a couple of functions. Firstly, it is used as a power switch. Secondly, when the button is pressed while turning the knob, the volume is changed in more precise steps. And lastly, when pressed during power-up, it causes the chip to enter the bootloader (yes! wireless software update!).
The shaft of the encoder sticks out higher than the original knob, but instead of shortening it, I've decided to make the knob a little taller (with a piece of PVC), so there is no gaping hole and it is easier to manipulate.

The microcontroller

The ATmega8A is the best chip ever, costs less than $1 and has so much to offer.
Here's the schematic:
Schematic of the microcontroller part

I've uploaded a serial bootloader to the chip, which allows me (thanks to the Bluetooth SPP module) to update the firmware wirelessly (trust me, I'm not opening that case ever again ;P).

RGB LED

Every project needs blinkenlights! I used a cheap SMD RGB LED, controlled with software PWM by the uC. It lights up when the speakers are turned on and shows the current volume in color (pink means 'ear damage imminent').

Bluetooth module

The module I'm using is a BTM-5 SPP module. It acts as a UART-Bluetooth bridge and works automatically and transparently. It's the easiest way to add wireless connectivity to your project.
You can get one of those off ebay for less than $10.

The communication protocol is just a couple of short commands sent over UART to the chip, for example: 'on', 'off', 'get' (get the current volume), 'v099' (set volume to 99).


Software

I wrote the uC firmware in C, compiled using avr-gcc of course, and a simple GUI application in PyQt.
Head over to GitHub for the sources:
https://github.com/Emeryth/avrdigipot


Putting it together

Here's some crazy kynar soldering action. I've managed to squeeze everything back into the original case, although I didn't tighten the screws all the way in. :P



All the components in place
At this point I though the soldering was over... (spoilers: it wasn't)
Now that I think of it, it might have been easier to redo the original PCB...

Conclusions

It works!
I can finally control my speakers without getting out of bed.
The clicking action of the rotary encoder is very nice, at last I can set the volume precisely, without fiddling with the pot.

It was a simple project in theory, but getting it done proved much more difficult.
I'm glad it works and that I've managed to make it look presentable (unlike some of my other projects).


Thursday, January 17, 2013

U-blox PCI-5S - a cheap GPS module for your projects


 [Update] I have found the timepulse output!

The U-blox PCI-5S is the cheapest GPS module on eBay right now (although you have to buy an additional antenna).
At first glance it seems useless for microcontroller projects because it's a mini PCIe card, but as it turns out it has an easily accessible UART port that can be connected to a microcontroller.

Here's the pinout:
The USB device is a standard CDC ACM serial port.

RX/TX pins are a second (independent of USB) UART port running at 9600bps by default.

You can use u-center to modify the module's configuration, for example set the update frequency to 4Hz.

Happy hacking!

Friday, December 7, 2012

USB mass storage bootloader for the Stellaris Launchpad


Edit: prebuilt binaries now available at github!

I wrote a a bootloader for the Stellaris Launchpad (and other Stellaris boards/chips) that acts as a USB mass storage device.
It's inspired by the bootloader found on some NXP LPC microcontrollers.


Just plug in your board while holding SW2, it shows up as a tiny external drive, copy your firmware.bin to it and *bam!* your board has new firmware!
You can also download the current firmware from the drive.

It takes up 16kB of flash memory.
Please test it and report any issues!
Usage instructions at github.

Source code and prebuilt binaries: https://github.com/Emeryth/Stellaris-mass-storage-bootloader