Connecting a LCD Panel to a Raspberry Pi

After finalizing the LCD panel project I asked myself what to use it for. As I’m doing a lot stuff with Raspis these days it was a good target.

When I connect the device to the Raspi I could verify its basic functionality by visiting the kernel log (e.g. by issuing a dmesg). Everything works as expected as the log shows

[    3.355900] usb 1-1.2: New USB device found, idVendor=04d8, idProduct=fa97
[    3.364488] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    3.374741] usb 1-1.2: Product: LCD BACK PACK
[    3.380586] usb 1-1.2: Manufacturer: Dangerous Prototypes
[    3.387491] usb 1-1.2: SerialNumber: 00000001
[    5.617100] cdc_acm 1-1.2:1.0: This device cannot do calls on its own. It is not a modem.
[    5.687628] Registered led device: led0
[    6.042156] cdc_acm 1-1.2:1.0: ttyACM0: USB ACM device

The device is somehow detected and communicating with the machine. In the above case the device showed up with the VID 0x04D8 and PID 0x FA97. It identifies itself as product “LCD BACK PACK” from “Dangerous Prototypes”. At this point Linux recognized the device as communication device and created a new device ttyACM0 for it.

At this point I configured lcdproc to use this panel by adjusting some settings in the configuration file at /etc/LCDd.conf. The following lines needed to be adjusted:

in section [server]

in section [MtxOrb]

After restarting the lcdproc daemon the display lit up and running lcdproc brought life to it.LCD-Panel 1LCD-Panel 2 LCD-Panel 3

I soon realized that plugging in the panel to the other USB port or even unplugging and plugging back in results in different device files. Mainly switching between ttyACM0 and ttyACM1. This should be more deterministic. To achieve this the UDEV system needed to be configured appropriately. I needed to tell UDEV what it should do once the device is connected. In folder /etc/udev/rules.d I created a file (the name for this file will be 95-LCD-Backpack.rules for this example) with the following content:

# Rule for hotplugging LCD Backpack
SUBSYSTEM=="tty", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="fa97", SYMLINK+="LCD", RUN="/etc/init.d/LCDd restart"

This instructs the UDEV system to run “/etc/init.d/LCDd restart” and create an additional device /dev/LCD (which is a symbolic link to the real device) upon insertion of the LCD panel which identifies itself by VID 0x04D8 and PID 0xFA97.

One problem remains (for now). In the above pictures the panel has its backlight turned off. I had to configure it that way because turning it on let it flicker. My first thought was that this flickering is related to lcdproc but further investigations led me to the firmware of the back pack. It’s using some sort of PWM simulation to regulate the backlight brightness (persistence of vision). The routine uses a delay which is based on NOP operations assuming that the controller is operating at 32 MHz. Mine is operating at 16 MHz.

Fixing this is a different story…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s