Linux in-wall Automation Control Touch Screen Project
by Gerry Duprey (gerry@cdp1802.org)
I've been building and upgrading my home-brew HA system for over a decade. A few years back, I installed my first in-wall touch screen for the house. This was a black and white 10" unit with I/R touch sensing and running Windows95. The display is about shoulder level in the wall and the actual motherboard/disk/power supply is between the joists in the floor below.
It's worked well. We have started a serious renovation of the house and as I planned to install additional touch screens, I wanted to get away from any dependence on Windows. I also wanted to get rid of a local hard disk (maintenance item) and, if possible, any fans. I wanted to upgrade to color and preferably a little larger than the old screen. Finally, I wanted the entire unit to fit in the wall as a single assembly - display, cpu, power supply, etc - for serviceability.
With that in mind, I decided to use a embedded single board computer, a 12.1" TFT color LCD and touch screen and linux for an O/S. Here's some of the details.
Pictures - everyone likes Pictures! Click on them for a larger view.
The Hardware
The CPU board is an Advantech PCM9550F. I had started this project with another board (the PCM-5268), but that has been discontinued. This board literally has everything on it. It has a built-in Realtek 8139 NIC, a C&T 69000 XGA chip with enough RAM for 1024x768 @16bpp. It has full audio support (mic in, line in, line out), VGA connector, a direct LCD panel interface, keyboard, PS/2 mouse, 4 serial ports, IrDA port, USB ports, parallel port, floppy disk port, IDE port, 1 DIMM to support up to 256Mb, a embedded 266Mhz fan-less CPU and can run on a single 5VDC power supply. It's sister model (the PCM9550FM) adds video in and out. All this on a board a bit over 5" wide and 8" deep (can almost fit in a 5.25" drive bay). I installed a 128Mb DIMM into the unit (cost $40 - how can you go wrong).
The LCD screen was originally to be a NEC unit that I had directly attached to the PCM9550F's LCD panel connector. The problem was that the connector on the LCD panel and wiring are extremely fragile - I kept having to build new connectors. This to me seemed to be a maintenance issue. While I was pondering this, Earth Computer came out with a 12.1" TFT LCD with integrated VGA/XGA controller. It supports 1024x768 resolutions at 16million colors. This unit just plugs into a a VGA connector and is very easy to use. it does get a little warm after being on for a while, but that is mostly the backlights and I figured out a way to shut them down when not in use. The unit is their SK-2005R unit which sells for about $350. Excellent choice.
On top of the LCD is a Dynapro (3M) 12.1" touch screen and SC3 controller. I purchased these from Earth computer as well. The controller plugs into a serial port (the PCM-9550F has 4, so no problem). The Touch panel is a glass plate with a plastic "touch sensitive" coating. You can mount it right to the LCD display using double sided tape. However, as I found out, this won't work if the unit is mounted on a vertical plane (i.e. in a wall) as the heat from the LCD causes the tape to release. If you could find a high temperature double sided tape or don't need the unit mounted in a vertical plane, this technique will work. Whatever you do, do not drill into the metal case around the LCD and forget any idea of soldering anything to it. You may be able to weld a holder to it, but I'm not sure what temperatures might destroy it. Note: you never want to handle the LCD using by its sides while it's running. Partly because you can easily be shocked by the high voltage used to run the backlights, but mostly because I did it, got shocked and in the process, must have coupled the high voltage into the LCD unit, destroying it. Major bummer.
In the end, I had a wood frame that was mounted over the display. I routed a 1/16" insert into the back of the frame and sat the panel in it. I fashioned some metal clips to hold it (just sheet metal, bent and screwed in) and it works just great. The renovation and house are in the Arts & Crafts style - meaning lots of woodwork. We managed to integrate it right into that woodwork rather smartly.
The power supply is a modified ATX power supply. To be honest, a 250watt power supply is overkill. However, I did this as I wanted the power supply to run as cool as possible and one way is to get a large P.S. and let it loaf. Modifications were mostly to bend the heat sinks and cut some of them back to fit into the wall cavity. There is also an audio amplifier (20 watts/channel) on board as well to drive in-wall speakers (streaming radio, MP3, telephone messages, etc).
All this is mounted to a 14 gauge 12"x11" steel plate. On the front is the LCD and space for 4 mounting holes. On the back is the CPU board, the touch screen controller, the audio amp and the power supply. The whole thing is about 3" thick. It has 5 wires (A/C power, 100mbit cat-5 network, left and right speaker and a microphone attached to the wood frame). 4 bolts protrude from a mounting board at the back of the wall cavity. The assembly screws on to that and the touch panel/wood frame attaches over that using Velcro.
The Software
I had a nicely configured Linux server in the basement and wanted to use that to boot the in-wall workstation. I went to the Linux Terminal Server Project (LTSP.org) and downloaded their kit. Fortunately, Linux supports all the hardware on the PCM9550F pretty well, though the sound card took a little finagling. The LTSP web site has both a core install to setup a server to support diskless clients as well as lots of documentation on how to make this all work.
In short order, I had a floppy disk drive attached to the CPU board and had written a simple boot loader from the Etherboot project to a floppy. I attached the network and after some configuration details on my server, my CPU board loaded the boot code from the floppy and then proceeded to download and boot Linux from the server (the floppy is used for just a moment to load the network loader) . I did have to play around with the XF86Config file a bit to make it work for the video chipset. In fact, what I eventually did was loaded Linux on a spare IDE disk and booted the CPU off of that so I could have enough of a system to run the XConfigurator. When that was done, I copied the configuration file back to the server, disconnected the IDE drive and rebooted over the network (via the floppy boot image). Worked great! The LCD unit has controls to allow shifting and resizing the image. I created a simple graphic that was a few rectangles 1 pixel wide at the outskirts of 1024x768 and displayed that to make sure I had all pixel visible. Once the LCD panel is configured, it'll retain those settings indefinitely.
Next up was getting the touch screen working. This proved to be quite an adventure. XFree86 supports the Dynapro SC3 controller well enough via the xf86Dyna.so loadable module (included with XFree86 3 and later) and it only takes a few minutes of editing the XF86Config file to enable it. The real bear is trying to calibrate it.
After I had enabled the touch screen, I touched the panel and sure enough, the X cursor moved. Of course, it didn't go anywhere near my finger, but at least the driver and hardware were working. There are some values you can change in the XF86Config file to help calibrate it, but it's an immensely slow, frustrating and imprecise process. After nearly hurling the whole thing through a window, I decided to put down the calibration for a bit and move on to booting.
The unit would already boot from the network after loading an image from a floppy. That part worked perfectly. But I didn't want a floppy drive tether on the unit. Some network cards support a network boot ROM. You can burn a simple boot loader into this ROM, install it into the network card, enable network booting in your BIOS and completely eliminate any floppy or hard disk drive needs.
Burning ROMs (well, really PROMs) is fine if you have the equipment and your NIC has an empty socket, but it can be a bit tricky. As it turns out the PCM9550F has a flashable BIOS. In addition to being able to flash a replacement BIOS, you can also install a bootable ROM image into the BIOS. Once installed, it acts like a real boot ROM. You can get the necessary image (for a floppy disk or PROM) either by building it using directions on the Etherboot page or by going to the Rom-o-matic web site. This is a web page that lets you specify your particulars (type of network card, floppy or ROM, etc) and generates an image file to download. Makes it's really easy.
I created a RTL8139 (the PCM9550F's NIC) boot image for ROM. Then used the award flash utility to read my current BIOS out to a disk file. I then used the cbrom utility to alter that BIOS image by including my RTL8139 ROM image and then reflashed the BIOS from this altered disk image. A few seconds in the BIOS setup to enable network booting and it worked! Now I had a completely diskless setup that loaded everything from my server.
I did alter the LTSP default setup (the /etc/rc.local file) a bit. Normally, the LTSP configuration finishes up the boot by starting a XDM (or GDM/KDM) login session. Since this is an embedded touch screen app, I didn't want a login box - I just wanted to immediately start running the X based app on successful boot. This wasn't too hard.
I also wanted to enable the PCM9550F sound module. It's not as "standard" as the rest of the board and required the Maestro3 sound driver - something available only in later versions of the kernel. LTSP had a 2.2.14 kernel, so I downloaded and built a 2.2.19 kernel (which has the Maestro3 support). A little bit of playing around (mostly to create the kernel module dependencies - hint: mount the workstations root read/write so you can use depmod -a, then alter so it's mounted read-only after that) and viola! it worked!
At that point, I had virtually everything working the way I wanted, so it was time to revisit the calibration issue. Right off, I knew I wanted a tool that would let me recalibrate the unit anytime I needed to (vs tweaking numbers in a config, rebooting, etc). Because the unit was mounted in the wall and the touch screen itself was mounted in the removable wood frame, everytime I open it up (very easy to do as I used Velcro), I'd have to recalibrate.
I spent a lot of time trying to write a calibration tool for the current xf86Dyna driver, but in the end, could not pass the necessary info from the client to the Xserver. I received some help from Dynapro in the form of the source code they use for their DOS based calibration tools. I finally bit the bullet and substantially rewrote the xf86Dyna driver to support dynamic calibration and a dynacal program to actually interact with the user. This tool communicates with my new xf86Dyna driver, allowing immediate calibration and storing those results to a file that is automatically reloaded when the X server restarted next. Perfect!
The next issue I wanted to address was the heat and light that the LCD backlights through off. The lights are great/necessary when using the touch screen, but when you're not, that add a lot of heat to an otherwise unvented wall cavity and at night, cast an erie glow over the whole room (forget trying to put one in a bedroom). Even with the screen blanked, the backlights still put out a lot of light/heat. Eventually, I found out that the LCD unit supported DPMS power management. By setting the X server up with an xset command like "xset +dpms dpms 0 0 900", the X server would turn off the display AND backlight after 15 minutes of inactivity. That drastically cut down on the ambient temperature in the wall and increased the life of the LCD panels by years (often, when the backlight dies, you have to replace the panel as you can't get the lamps out).
Next up was enabling local applications. In other words, instead of running applications on the server and displaying them on the workstation, I wanted to both run and display them on the wall panel. When I first looked into enabling this with LTSP, it looked daunting as they recommended enabling NIS. I hate NIS :-) It's one of those things that if you set it up wrong, it cripples your system (name resolutions fails, logins can fail, etc). I get what they are trying to do with it, but either I'm thick or it's overly complex (probably a little of both). Fortunately, you do not need NIS. You do need to modify the supplied /etc/rc.local to disable any NIS stuff. Then add a "portmap" invocation before all the NFS mounts. Enable local apps in the lts.conf file. And enable and export all the appropriate file systems on your linux server (and restart NFS). I added a /etc/passwd file with a root and user level login. Again, rebooted and it worked great. Not only can I run applications on the workstation, but I can telnet into it to administer/reboot it.
With locals apps enabled, I needed a way for each touch screen to have it's own "private" space. For things like calibration files, preferences for that station. I simply have all the workstations mount a common directory. Under that main directory is a sub-directory for each workstation with a name that matches the node name of the station. In the workstations /etc/profile, I setup an environment variable that points to the root of that stations "private" space and anything that needs this (again, touch screen calibration data, seti files, customized button panels) uses this as a root.
At this point, all the basic stuff is working. I have a simple interim tool that launches a streaming connection to my local NPR station, a button that launches xmms to play my MP3s, a button that launches netscape (configured with a number of "toolbar" bookmarks of useful stuff) and a button that launches the calibration tool. Since the wall station has a 266MHz processor and 128Mb or RAM and is sitting there doing virtually nothing most of the time, I loaded and enabled seti to run on it (using nice so it never gets in the way). So now, my walls are helping search for aliens (cool in concept :-).
I still need to write a replacement interface to the HA system. My original interface (still running in the kitchen until I build a replacement) is a Windows95 (Delphi) module talks to a Delphi server module in the basement that is hooked up to my HA equipment. This has started, but will take a while (especially since I want to build in a bunch of new features).
The Future
I have the hardware to complete 3 more touch screen units. They will be installed in strategic places throughout the house, including replacing the old Windows based one in the Kitchen. In addition to allowing me control over lights, scene based lighting, HVAC, environment/weather and security, I'm going to integrate the streaming audio and MP3 playing features I' playing with now in. I'm also going to add support for playing and recording phone messages, reviewing the list of folks who have called and allow leaving voice messages for family members. I'm going to try to also implement a digital "intercom" system. Finally, I want to add grocery lists, to do lists, calendering/date management (alert me to moms birthday) and generally turn these panels into more than just control centers but household information centers. The multi-media and color options are going to drive new development as well - it's already had a pretty reasonable impact on the first draft of the replacement HA control screens. So much fun, so little time....
The cost
I've received a number of requests for how much something like this might cost. Some of the info is above, but I've consolidated it all here. Note: because of the low volume I'm buying these things at, almost all costs are retail/list prices. Building these in quantity would probably take at least 1/3 to 1/2 off the material cost. Costs are approximate and do change over time.
| Item/Part | Cost |
| Advantech PCM-9550F SBC w/cable kit | $610.00 |
| 128Mb DIMM for above SBC | $40.00 |
| 12.1" TFT LCD Display unit from EarthLCD.com (note: price reduced to $299 since I purchased) |
$349.00 |
| 3M Dynapro 12.1" Touch screen with SC3 controller (note: you can now use the SC3 or SC4 controller) |
$250.00 |
| ATX 250 Watt power supply | $50.00 |
| 20Watt audio amp | $25.00 |
| screws, metal panel, connectors | $50.00 |
| TOTAL | $1,374.00 |
The Drivers
In order to support dynamic "on the fly" calibration, I had to re-write the XFree86 Dynapro driver and create a new calibration utility. I'm currently working with 3M to add support for other touch controllers (started with their SC3 controller and have added support for the SC4 as well). If you need the drivers, please email me and we can make arrangements. Eventually, I expect to have the drivers submitted back to the XFree86 project and 3M may list them on their touch screen web sites.
Last update July 9, 2001