QSlide Touch Slider IC Report

Initial preliminary report by Roy Vanegas, 22 May 2007. A thorough and definitive report will appear here during summer 2007, as I work more extensively with the QT411 and SPI.

The QT411-ISSG is a linear touch sensor in a 14-pin TSSOP (Thin-Shrink Small Outline Package) casing. It outputs data as a ``7-bit binary number (0...127) indicating angular position,'' per the datasheet. It can be used to replace items such as slider elements, faders, volume controls, and just about anything else that employs a potentiometer to control an electronic device.


Index


SPI Register Description of the Arduino

top


Serial Peripheral Interface (SPI)

The Serial Peripheral Interface (SPI) bus is a full duplex, synchronous, data communications link. According to Motorola, SPI's originators, the SPI bus is made of four signals: Master in/slave out (MISO), Master out/slave in (MOSI), Serial clock (SCK), and Slave select (SS), which appears in some datasheets with an overbar above both ``S'' characters, or with a forward slash before the first S. Both the Arduino Mini and the QT411 QSlide Touch Slider observe the SPI serial interface.

Alas, SPI is not standardized, in either hardware or protocol. Instead, a widely agreed upon definition is recognized. This leads to variation in the implementation and programming of SPI that requires special handling of each device.

top


QT411 SPI Commands

These are the commands that are sent from the Arduino Mini to the QT411. Except for the error status command, each returns to the Arduino Mini the Standard Response byte.

0x00: null
This command will trigger a new acquisition if /SS rises. Otherwise, nothing happens.
0x01: calibrate
As its title suggests, this command performs a basic calibration of the sensor via 10 acquisition bursts. The host microcontroller should wait for DRDY to rise again after the calibration has completed before shifting commands again.
0x03: drift compensate
This command performs an incremental compensation on drift. It should be sent to the QT411 about once every ten commands.
0x04: error status
This command does not return the Standard Response byte. Instead it returns to the Arduino Mini a byte with information such as touch status and sensor type. You may ignore all but bit 1, which reports 1 if a calibration error has been detected; 0 otherwise.
0x8T: set touch threshold
This is the command that is used to ``tune'' the sensor. Bits 5--0 are used to set the touch threshold. Each bit may be given a value between 0 and 63. Zero should never be used, however.

top


SPI-Related Acronyms

You'll encounter the following acronyms throughout the datasheets relating to SPI:

  • SCLK: Serial Clock
    • Generated by the master/host microcontroller, the serial clock, SCLK, synchronizes the MOSI and MISO serial data lines. Data is sampled, or read, by the QT411 on the rising edge of the clock, and it is sent by the QT411 on the falling edge of the clock.
  • SS: Slave Select
    • Same as Chip Select and triggered by the master, the slave select line chooses with which device to communicate. This line is taken low to allow for communication between the master and the slave. If many slaves are present, only the slave with which the master will communicate is taken low, while the SS lines of all the other slaves are taken high.
  • CS: Chip Select
    • same as Slave Select
  • SPIF: Serial Peripheral Interrupt Flag
    • This bit is set when a serial transfer is complete on the ATmega 8.
  • SPSR: Serial Peripheral Status Register
  • SPCR: Serial Peripheral Control Register
  • SPDR: Serial Peripheral Data Register
  • MCU: Microcontroller Unit
    • The Aruino Mini is the microcontroller unit for this example.
  • SDI: Serial Data Input
    • same as MOSI on the QT411
  • SDO: Serial Data Output
    • same as MISO on the QT411
  • CPOL: Clock Polarity
  • CPHA: Clock Phase
  • MOSI: Master Out, Slave In
  • MISO: Master In, Slave Out

top


The QT411


Dimensions

The dimensions of the QT411 are 4mm x 5mm, ~.15 x ~.20, respectively.

top


Sensing Element

The sensing element used for this example is a 22-gauge piece of wire. It was stripped of its insulation and soldered at the 33% and 66% points, per p2 of the QT411 datasheet marked ``RESISTIVE SLIDER ELEMENT.'' See the image below.

top


Pinouts

   PIN  NAME   TYPE    DESCRIPTION
   1    VDD    Power   Positive power pin (+2.5 .. + 5V)
   2    MISO   Output  Serial data output
   3    /SS    Input   Slave Select pin.  This is an active low input 
                       that enables serial communications
   4    SCLK   Input   Serial clock input.  Clock idles high
   5    SNS3B  I/O     Sense pin; connects to both slider ends, each 
                       via separate additional resistors
   6    SNS3A  I/O     Sense pin
   7    SNS2B  I/O     Sense pin; connects to 66% point (from left) of
                       slider
   8    SNS2A  I/O     Sense pin
   9    SNS1B  I/O     Sense pin; connects to 33% point (from left) of
                       slider   
   10   SNS1A  I/O     Sense pin
   11   MOSI   Input   Serial data input
   12   DETECT Output  Active high touch detected.  May be left 
                       unconnected.  (Pin floats ~400us after wake 
                       from Sleep mode.)
   13   DRDY   Output  Data ready output.  Goes high to indicate it 
                       is possible to communicate with the QT411.  
                       (Pin floats ~400us after wake from Sleep mode.)
   14   VSS    Ground  Negative power pin.

top


Arduino Connections

Page 2 of the QT411's datasheet contains a layout of how the QT411 should be connected to a microcontroller. I used an Arduino Mini microcontroller and copied the pin configurations exactly as stated on the datasheet. I wired the DETECT line and the SPI bus of the QT411 to the SPI bus of the Arduino Mini, as follows. (See page 161 of the Atmel ATmega 8 datasheet, in the ``Links'' section, for more.)

          QT411         Arduino Mini
-------------------------------
(DRDY)       13   -->   8
(DETECT)     12   -->   9
(/SS)         3   -->   10
(SDI/MOSI)   11   -->   11
(SDO/MISO)    2   -->   12
(SCLK)        4   -->   13

Note that the pin mappings above aren't all direct. For example, /SS is connected via a 1k resistor. See the image below. (SDI is not shown in image.)

top


Breakout Board

The breakout board fits inline with the Arduino Mini. Its pins are spaced at a 2.5mm (~0.01'') pitch, and its dimensions are about 20mm x 20mm, ~0.78 x ~0.78, respectively.

Since the QT411 is a tiny SMD chip (see the Dimensions section), I had to build a breakout board so I could mount the QT411 onto a breadboard. To build the breakout board, I had to draw up an EAGLE design. I zipped that design file along with its PS and PDF equivalents into one tgz file: QT411_Board_Files.tgz. To uncompress the tgz file, simply double-click on it in your GUI (Windows, Mac, Linux), or extract it via the terminal (in UNIX or any of its variants, including Macintosh):

tar xvzf QT411_Board_Files.tgz

top

top


Code


Sample Code

Working sample code is forthcoming.

top


Debugging Code

To help me to understand the Arduino Mini's SPI bus, I wrote a few small programs to view the behavior of each in big endian format (MSB --> LSB). Each program displays information in three second intervals.

The Arduino pins:


The SPSR (Serial Peripheral Status Register) register:


#define BAUD_RATE 9600
#define SECONDS   3000

void setup()
{
   Serial.begin( BAUD_RATE );
}

void loop()
{
   static int i;
   static int step = 0;

   Serial.print( "SPSR: " );

   for( i = 7; i >= 0; i-- )
   {
      Serial.print( (SPSR & (128 >> step)), DEC );
      Serial.print( " " );
      step++;
   }

   step = 0;

   Serial.println( "\n" );

   delay( SECONDS );

   return;
}

The SPCR (Serial Peripheral Control Register) register:


#define BAUD_RATE 9600
#define SECONDS   3000

void setup()
{
   Serial.begin( BAUD_RATE );
}

void loop()
{
   static int i;
   static int step = 0;

   Serial.print( "SPCR: " );

   for( i = 7; i >= 0; i-- )
   {
      Serial.print( (SPCR & (128 >> step)), DEC );
      Serial.print( " " );
      step++;
   }

   step = 0;

   Serial.println( "\n" );

   delay( SECONDS );

   return;
}

The SPDR (Serial Peripheral Data Register) register:

#define BAUD_RATE 9600
#define SECONDS   3000

void setup()
{
   Serial.begin( BAUD_RATE );
}

void loop()
{
   static int i;
   static int step = 0;

   Serial.print( "SPDR: " );

   for( i = 7; i >= 0; i-- )
   {
      Serial.print( (SPDR & (128 >> step)), DEC );
      Serial.print( " " );
      step++;
   }

   step = 0;

   Serial.println( "\n" );

   delay( SECONDS );

   return;
}

All three of the above registers in one program:


top


Links (datasheets, SPI references, etc.)

I purchased the QT411 in the spring of 2007 for $3.45 from Saelig, sans shipping. DigiKey sold it for about $3.51, while Farnell in Europe sold it for a whopping $9.30 (after rate conversion from British Pounds).

top


Roy Vanegas