Thursday, July 24, 2008

Microtouch Touchscreen configuration and calibration

Since i had to deal with a few touchscreens at work, i'd like to summarize my experiences with linux' touchscreen capabilities, or better yet Xorg's touchpad support.
The latest touchscreen i got my hands on was integrated into a terminal-pc of the company ict, which is a german company that is specialized on these kinds of terminals. All i could tell from the looking inside the machine's designer case was that it's touchscreen was connected vie RS232 on Com2 and that the touchscreen's manifacturer was propably Microtouch Systems, a company that (at least by now) belongs to 3M. Since the terminal came with Windows 2000 preinstalled and preconfigured, i was able to check further information on the touchscreen form its Windows driver. The Touchscreen was indeed a serially connected Microtouch device with firmware version 6.0. Another quite important fact was the serial port configutation for the touchscreen, namely the baudrate of 19200.

Now for the linux support: 3M provides a linux driver for its touchscreens on their website in rpm format. There are binaries available for various redhate and suse version and a so-called "source" package, which mosty contained a bunch of binaries and the source code of the Microtouch kernel module. But the Xorg/XFree86 driver seems to be closed source.
So i started looking for open-source options for Microtouch devices. Fortunatly, there are two xorg-maintained drivers for microtouch devices available: microtouch, for devices with firmware versions older than 2.0 and mutouch, for firmware versions 2.0 and later. Since i know that my device has firmware version 6.0, i used mutouch with its default settings. After adjusting xorg.conf and starting Xorg, sadly, the touchscreen wasn't working at all. Xorg.0.log didn't even state any info on correct detection of the device. Since the mutouch's manpage is only poorly filled, i had to look in the sourcecode of the xorg driver for available options. the mutouch driver by default configures a baud rate of 9600 for serial touchscreens, which was obviosly didn't work with my device. So i set the correct baud rate in xorg.conf, and voila, the mouse pointer was moving.
Now, only calibration was needed. A quick google query revealed that touchcal is the tool to use. Unfortunatly, touchcal doesn't work with this specific Mictrotouch device, not even after i adjusted touchcal's baud rate to 19200. It seems like there are some protocol differences between my microtouch device and the ones touchcal was developed and tested for. But another driver option of the mutouch driver came very much in handy at this point. In mutouch's InputDevice section i set the option "DebugLevel" to "9", and started X again. This way, a lot of info from the touchscreen is dumped to Xorg.0.log, including the touchscreen coordinates when the screen gets touched. So i touched the top left and the bottom right corner, which resulted in something like this in Xorg.0.log:
..... snip.....
Packet: 0x98 0x40 0x15 0x8 0x71
TouchScreen Finger: x(2600), y(14608), Release
..... snip.....
Packet: 0xD8 0x58 0x75 0x68 0x13
TouchScreen Finger: x(15064), y(2536), Stream
..... snip.....
All that was necessary then, was to set those values in mutouch' Inputdevice section, resulting to this:

Section "InputDevice"
Identifier "touchscreen"
Driver "mutouch"
Option "Device" "/dev/ttyS1"
Option "ScreenNo" "0"
Option "Type" "finger"
Option "ButtonNumber" "1"
Option "SendCoreEvents" "yes"
Option "BaudRate" "19200"
Option "MinX" "2600"
Option "MaxX" "15064"
Option "MinY" "2536"
Option "MaxY" "14608"
# Option "DebugLevel" "9"
EndSection
As you can see, in my case, i had to switch the values for miny and maxy, otherwise, my mouse was inverted.
After all that, my touchscreen works as expected.

2 comments:

davers said...

trying to get my microtouch usb to work and my x-axis is inverted. You said to swap the calibration values, but it had no effect. Incidentally I'm using evtouch which reportedly has successfully be tested on the microtouch usb touchscreen.

Anyway I noticed that in the code you posted the values for Miny and MaxY are not swapped (minY is still small, maxY is still big). Is that because you pasted this before you swapped the values, or am I missing something>

thx!

Anonymous said...

Thanks man. With the help of your post I figured out that the unidentified touch I was working with is an MicroTouch.