Capacitive touchpad and ST Nucleo

Capacitive touchpad and ST Nucleo

1 A touchpad detector IC: the TTP229

The TTP229 is an integrated circuit for capacitive sensing designed specifically for touch pad controls. It provides stable sensing method covering different conditions.

1.1 Description and versions

The chip is a TSSOP-28 deigned to work with 8 or 16 key. It provide a direct interface if we use it in 8 key mode providing an output for pin for every key (So 8 direct output). When we want to use it in 16 key mode, the TSP229 provides a serial interface.
We can find two different version of the TTP229: BSF and LSF. Main difference is in serial communication: TTP229BSF uses a 2 wire serial, TTP229LSF uses a standard I2C.

1.2 Documentation

We will provide a demonstration of uses with a 16 key capacitive touch pad. Our device uses a TTP229-BSF and these are related datasheet and schematics.

TTP229BSF Schematic TTP229BSF Datasheet

2 Features

Capacitive touchpad pins
Fig.1 – A capacitive touchpad based on TTP229BSF and its header connector with labels.

2.1 Design and connections

The TTP229 can work with a voltage between 2.4~5.5V, it provides some configuration and auto calibration for environment changing. Typical current consumption are in order of 2.0~2.5uA.

2.2 Pin description

Our touchpad provides direct output for direct connection (using key from 1 to 8 only) or the two wires serial interface (using all the 16 keys). Let’s we describe pin (Please refer to figure 1):

  1. VCC, power supply 2.4~5.5V DC
  2. GND, connection to ground
  3. SCL, serial clock
  4. SDO, serial data out
  5. OUT1, direct output for key 1
  6. OUT2, direct output for key 2
  7. OUT3, direct output for key 3
  8. OUT4, direct output for key 4
  9. OUT5, direct output for key 5
  10. OUT6, direct output for key 6
  11. OUT7, direct output for key 7
  12. OUT8, direct output for key 8

2.3 Choose the settings through the jumper

Configuration header
Fig.2 – Configuration headers on 16 key touchpad.

The TTP229 could be configured connecting some pin to GND using an high impedance resistor. These pin are pin TP0~TP7 corresponding to the same pin used as input for key1~key8.

Looking at schematic we can see that our PCB is already provided of 1MΩ resistors: we need just to make connections using jumpers. We have two header (see figure 2) named P1 (in red) and P2 (in green). Note that every header in enumerated from 1 to 8 (as example header 3 is in yellow). Connecting two contiguous header using a jumper we are actually connecting a pin of the TTP229 to GND though the 1MΩ resistor (R2 or R1). So we have different configuration connecting or not impedances to our chip using jumpers.

Let’s go to describe how we can choose TTP229 functionalities using headers. First of all consider that the enumeration assert where the header is connected: the header identified by number 1 is connected to TP0, 2 to TP1 and so on.


Let’s discuss all the available configuration:

  1. CMOS or Open Drain selector. Select direct output gate: OD with jumper, CMOS otherwise;
  2. Active High or Active Low selector. This pin manages more than a think. If CMOS output is selected, output is AL with jumper, AH otherwise. If OD output is selected, output is OD pull down with jumper, OD pull up otherwise. Furthermore this pin decides sampling edge for serial communication: rising edge with jumper, falling otherwise;
  3. 8 or 16 key selector. Selects number of keys: 16 keys with jumper, 8 otherwise;
  4. Multi-key single key selector 1. Decides if keys 1~8 could be pressed simultaneously. Multi-key with jumper;
  5. Multi-key single key selector 2. As above for keys 9~16;
  6. Sampling rate in sleep mode selector. When device enter in sleep mode it wakes up checking pad periodically. This selects sampling rate when device is in sleep mode: sampling rate 64 Hz with jumper 8Hz otherwise;
  7. Sampling period in sleep selector. Decides how long is sampling time, in sleep mode: 2ms with jumper 4ms otherwise;
  8. Maximum key-on time. If a key is pressed for a long time most likely this is caused by charge accumulation. This option prevent malfunction resetting chip if a button is pressed for to much time: 80s with jumper, infinite otherwise.

In our case we just need to activate 16 keys mode adding a jumper on header number 3. continue reading…

How to use an HD44780 based Liquid Crystal Display

How to use an HD44780 based Liquid Crystal Display

1 A 16×2 LCD based on HD44780

1.1 HD44780

The HD44780 is a controller for display developed by Hitachi commonly used to manage alphanumeric dot matrix LCD. This controller is a standard de-facto for this kind of display. It is often used in industrial test equipment, networking equipment, vending machine and in embedded projects.

Compatible LCD screens are manufactured in several standard configurations. Common sizes are one row of eight characters (1×8), as well as 16×2, 20×2 and 20×4 formats. Larger custom sizes are made with 32, 40 and 80 characters and with 1, 2, 4 or 8 lines. The most commonly manufactured larger configuration is 40×4 characters, which requires two individually addressable HD44780 controllers with expansion chips as a single HD44780 chip can only address up to 80 characters. A common smaller size is 16×2, and this size is readily available as surplus stock for makers and prototyping work.

1.2 Controller documentation

We want to provide a full library for HD44780 compatible with ChibiOS/HAL 3.0 ad a demo explaining gradually how software has been designed. This task requires a preliminary read of HD44780 datasheet.

HD44780 datasheet

1.3 Hardware PIN-map

HD44780 pinmap
Fig.1 – A 16×2 LCDII based on HD44780 with pinmap.

In this article we are going to use a 16×2 LCD driven by HD44780. This display usually comes with a monochromatic backlight and a 16 PIN header connector.

There are also some kits equipped with a 8-bit I/O expander for I2C bus which simplify connections and code but are costly. We will discuss this solution in another article.

The header PIN is organised as follows:

  1. VSS, connection to GND;
  2. VDD, power supply 2.7~5.5V DC;
  3. V0 or VE, contrast pad that should be connected to a potentiometer;
  4. RS, or Register Selector pad;
  5. RW, or Read Write selector pad;
  6. E, or Enable pad;
  7. D0, LSb parallel data pin;
  8. D1, data pin 1;
  9. D2, data pin 2;
  10. D3, data pin 3;
  11. D4, data pin 4;
  12. D5, data pin 5;
  13. D6, data pin 6;
  14. D7, MSb parallel data pin;
  15. A, backlight anode pin
  16. K, backlight cathode pin continue reading…