Adafruit Capacitive Touch Sensor Breakouts Created by Bill Earl Last updated on 2014-12-11 11:45:16 AM EST
Guide Contents Guide Contents 2 Overview 4 Momentary 5 Toggle 6 5-Pad Momentary 6 Assembly and Wiring 8 Installing the Headers: 8 Position the header strips 8 Position the breakout 8 And Solder 9 Wiring for Toggle and Momentary 10 Toggle Operation 11 Momentary Operation 12 Other Options: 12 LED Control 13 Speed vs. Power (Momentary Only) 13 Timer (Toggle Only) 14 Connecting to your Circuit.
Install the Panel 27 And Test 28 Connect to your Circuit 29 Downloads © Adafruit Industries https://learn.adafruit.
Overview These breakout boards are a simple way to add capacitive touch to your project. Just power with 1.8 to 5.5VDC and touch the pad to activate the sensor. These touch switches interface easily to any project - with or without a microcontroller. When a capacitive load (such as a human hand) is in close proximity to the sense-pad, the sensor detects the change in capacitance and activates the switch.
Momentary This sensor has a built-in sense-pad and is active for as long as the sensor area is touched. The sense-pad can be extended with wire and almost any conductive material. © Adafruit Industries https://learn.adafruit.
Toggle This sensor also has a built-in sense-pad. It becomes active when touched and remains active until it is touched again. As with the momentary sensor, the sense-pad can be extended with wire and almost any conductive material. 5-Pad Momentary This version combines 5 momentary switches into one breakout. There are 5 pins for attaching wires to up to 5 external sensor pads. © Adafruit Industries https://learn.adafruit.
We also have a new 12-Key version with it's own tutorial over here! (http://adafru.it/dKH) © Adafruit Industries https://learn.adafruit.
Assembly and Wiring These breakouts come fully assembled. For use in a breadboard, you may want to take a couple minutes to install the included header strips: Installing the Headers: Install the headers by following these 3 easy steps. The photographs below show one of each sensor type. Position the header strips Plug them long-pins down into a breadboard to stabilize them for soldering. Position the breakout Place the breakout board over the header pins. © Adafruit Industries https://learn.adafruit.
And Solder Solder each pin for solid electrical contact. © Adafruit Industries https://learn.adafruit.
Wiring for Toggle and Momentary These two breakouts are very similar and can be powered by anything from 1.8V to 5.5V DC. Simply connect Ground to GND and the positive voltage to VDD. The standalone sensors are fully functional without further connections. © Adafruit Industries https://learn.adafruit.
Toggle Operation The Toggle version of the sensor turns on when you touch it once, then turns off when you touch it again. The on-board LED indicates the state of the switch. © Adafruit Industries https://learn.adafruit.
Momentary Operation The momentary touch sensor works just like a momentary switch. It is on when you touch it and off when you move away. The on-board LED indicates the state of the switch. Other Options: These sensors have several jumper configurable operating modes as described below: © Adafruit Industries https://learn.adafruit.
LED Control The led indicators can be disabled for ultra-low power applications. To disable the LED, simply cut the jumper between the pads where indicated on the back of the breakout board. With the jumper cut, the LED can be controlled externally via the LED pin on the header. Speed vs. Power (Momentary Only) The Momentary version can be configured for "Fast" mode (default) or low-power mode. Fast mode requires 0.5mA. Low Power mode requires just 50uA.
Timer (Toggle Only) By default, the toggle sensor is configured for infinte time-out. it will stay on until you touch the sensor to turn it off. It also supports a configurable time-out to turn off the output automatically after a delay. To select this mode, cut the 'TIMER' jumper and connect a resistor & capacitor to the TIME pin. For a circuit diagram and resistor/capacitor calculations, see page 13 of the datasheet (http://adafru.it/cgW).
Simple Motor Control You can use it just like a pushbutton or logic signal with a transistor or MOSFET to drive highcurrent loads like a DC motor. © Adafruit Industries https://learn.adafruit.
Wiring for 5-pad Momentary The 5-pin momentary breakout can be powered with anything from 1.8V to 5.5VDC. Just connect ground to GND and the positive voltage to VDD. This sensor does not have built-in touch pads, but you can create your own pads in any size or shape from wire, foil or any other conductive material. Simply connect your touch-pads to each of the 5 sense pins. When you touch the pad, the corresponding LED on the other side will light up.
© Adafruit Industries https://learn.adafruit.
Adding Custom Touch Pads Custom touch pads are easy to make. You can use almost any conductive material: © Adafruit Industries https://learn.adafruit.
Wire, Thread, Foil, Fabric, Paint If it will conduct electricity, it will work as a touch sensor! © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Connections: The Toggle and Momentary boards have a solder hole located just below the sensor pad for attaching a wire to an external sensor. The 5-pad breakout has pins numbered 0-4 on the left side of the board. © Adafruit Industries https://learn.adafruit.
Sensor Pads Attach the connecting wire to any conductive object or surface. That surface will become touch sensitive. Larger surfaces tend to be more sensitive. You will be able to sense through fabric, plastic glass and many other non-conductive materials. Note that the wire will be touch sensitive too! Be sure to route any connecting wires away from areas where they might create an accidental touch input. © Adafruit Industries https://learn.adafruit.
Build a Touch Control Panel Capacitive touch sensors are a great way to add external controls to a waterproof enclosure. There is no need to drill holes or worry about gaskets and O-rings. These sensors will detect your touch right through the plastic case! Design your panel You can draw it by hand, or with your favorite drawing tool and print it on some heavy cardstock. © Adafruit Industries https://learn.adafruit.
Cut the touch-pads Cut pads from copper tape. About 1/2" square is a good size for buttons on a touch-pad. Attach the touch-pads Peel the release paper from the back of the copper tape and stick the touch-pads to be back of the panel so that they align with the buttons on the front. © Adafruit Industries https://learn.adafruit.
Attach the Wires Solder wires to the copper touch-pads. For this example, I used a 6-conductor 0.1" socket cable (http://adafru.it/206) with one end cut off to simplify connections to the breakout. © Adafruit Industries https://learn.adafruit.
Adjust the Wires Bend the wires away from the panel. The wires will be touch-sensitive too. To prevent accidental false touches, we want to keep them away from the panel surface. © Adafruit Industries https://learn.adafruit.
Install the Panel Tape the panel to the inside of the polycarbonate cover using clear packing tape. © Adafruit Industries https://learn.adafruit.
And Test Connect the cable to the breakout. Power it up and test your control panel. Touching each button should cause a different LED to light up. © Adafruit Industries https://learn.adafruit.
Connect to your Circuit The output signals are 'active low', so they can replace any pushbutton that shorts to ground such as the buttons on the RGB LCD shield. You can leave off the buttons and solder directly to the circled pads, or (if your shield is already built), just 'tack-solder' the wires to the legs of the buttons. When you put it all together, you will have a completely sealed, touch sensitive control panel! © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Downloads Schematics for '1010 and '1012 breakouts (click to enlarge) © Adafruit Industries https://learn.adafruit.
© Adafruit Industries Last Updated: 2014-12-11 11:45:20 AM EST Page 32 of 32
Document Number: MPR121 Rev. 4, 02/2013 Freescale Semiconductor Data Sheet: Technical Data An Energy Efficient Solution by Freescale Proximity Capacitive Touch Sensor Controller MPR121 The MPR121 is the second generation sensor controller following the initial release of the MPR03x series of devices. The MPR121 features an increased internal intelligence plus Freescale’s second generation capacitance detection engine.
1 Pin Descriptions Table 1. Pin Descriptions Pin No. Pin Name Description 1 IRQ Open Collector Interrupt Output Pin, active low 2 SCL I2C Clock 3 SDA I2C Data 4 ADDR I2C Address Select Input Pin. Connect the ADDR pin to the VSS, VDD, SDA or SCL line, the resulting I2C addresses are 0x5A, 0x5B, 0x5C and 0x5D respectively 5 VREG Internal Regulator Node – Connect a 0.
2 Schematic Drawings and Implementation VDD 1.71V to 2.75V 0.1 μF 20 6 5 1 2 3 4 7 VDD ELE11/LED7 VSS ELE10/LED6 VREG ELE9/LED5 IRQ ELE8/LED4 SCL ELE7/LED3 SDA ELE6/LED2 ADDR ELE5/LED1 REXT ELE4/LED0 ELE3 ELE2 75 kΩ 1% ELE1 GND ELE0 GND 19 18 17 16 15 14 13 12 11 10 9 8 MPR121Q TOUCH SENSOR Figure 1. Power Configuration 1: MPR121 runs from a 1.71V to 2.75V supply. VDD 2.0V to 3.6V 0.1 μF 20 6 5 1 2 3 4 7 0.
3 Device Operation Overview Power Supply The VDD pin is the main power supply input to the MPR121 and is always decoupled with a 0.1 μF ceramic capacitor to the VSS. Excessive noise on the VDD should be avoided. The VDD pin has an operational voltage range specification between 1.71V to 3.6V. The internal voltage regulator, which generates current to internal circuitry, operates with an input range from 2.0V to 3.6V. To work with a power supply below 2.
Table 2.
Table 2.
Table 2.
4 Electrical Characteristics 4.1 Absolute Maximum Ratings Absolute maximum ratings are stress ratings only and functional operation at the maxima is not guaranteed. Stress beyond the limits specified in Table 3 may affect device reliability or cause permanent damage to the device. For functional operating conditions, refer to the remaining tables in this section.
4.3 DC Characteristics This section includes information about power supply requirements and I/O pin characteristics. Table 5. DC Characteristics (Typical Operating Circuit, VDD and VREG = 1.8V, TA = 25°C, unless otherwise noted.) Parameter Symbol High Supply Voltage VDD Low Supply Voltage VREG Average Supply Current(1) Conditions Typ Max Units 2.0 3.3 3.6 V 1.8 2.75 1.
4.5 I2C AC Characteristics Table 7. I2C AC Characteristics (Typical Operating Circuit, VDD and VREG = 1.8V, TA = 25°C, unless otherwise noted.) Parameter Symbol Conditions Min Typ Max Units 400 kHz Serial Clock Frequency fSCL Bus Free Time Between a STOP and a START Condition tBUF 1.3 μs Hold Time, (Repeated) START Condition tHD, STA 0.6 μs Repeated START Condition Setup Time tSU, STA 0.6 μs STOP Condition Setup Time tSU, STO 0.
5 Register Operation Descriptions 5.1 Register Read/Write Operations and Measurement Run/Stop Mode After power on reset (POR) or soft reset by command, all registers are in reset default initial value (see Table 2). All the registers, except registers 0x5C (default 0x10) and 0x5D (default 0x24), are cleared. Registers 0x2B ~ 0x7F are control and configuration registers which need to be correctly configured before any capacitance measurement and touch detection.
5.3 Electrode Filtered Data Register (0x04~0x1D) Electrode Filtered Data Low Byte (0x04,0x06,...,0x1C) Bit D7 D6 D5 D4 D3 D2 D1 D0 Read Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Write — — — — — — — — Electrode Filtered Data High Byte (0x05,0x07,...,0x1D) Bit D7 D6 D5 D4 D3 D2 D1 D0 Read — — — — — — Bit 9 Bit 8 Write — — — — — — — — The MPR121 provides filtered electrode output data for all 13 channels.
Noise Count Limit (NCL): Determines the number of samples consecutively greater than the Max Half Delta value. This is necessary to determine that it is not noise. The range of the effective value is 0~255. Filter Delay Count Limit (FDL): Determines the operation rate of the filter. A larger count limit means the filter delay is operating more slowly. The range of the effective value is 0~255. The setting of the filter is depended on the actual application.
5.8 Filter and Global CDC CDT Configuration (0x5C, 0x5D) Filter/Global CDC Configuration Register (0x5C) Bit D7 D6 D5 D4 D3 D2 D1 D0 D2 D1 D0 Read FFI CDC Write Filter/Global CDT Configuration Register (0x5D) Bit D7 D6 D5 D4 D3 Read CDT SFI ESI Write Table 8. Bit Descriptions Field Description First Filter Iterations - The first filter iterations field selects the number of samples taken as input to the first level of filtering.
These two registers set the global AFE settings. This includes global electrode charge/discharge current CDC, global charge/ discharge time CDT, as well as a common filtering setting (FFI, SFI, ESI) for all 13 channels, including the 13th Eleprox channel. The register 0x5C holds the global CDC and the first level filter configuration for all 13 channels.
5.11 Electrode Configuration Register (ECR, 0x5E) Electrode Configuration Register (0x5E) Bit D7 D6 D5 D4 D3 D2 D1 D0 Read CL ELEPROX_EN ELE_EN Write Table 9.
baseline value starts from zero, it will require a very long time for the baseline to ramp up. This results in a short period of no response to touch after the MPR121 is first set to Run Mode. Setting the CL = 2b10 will command the MPR121 to load the initial baseline value at the beginning of the Run Mode. This shortens the initial baseline ramp-up time so that user will not notice any delay on touch detection. The MPR121 uses the five high bits of the first measured 10 bit electrode data.
SCTS: Skip Charge Time Search. 1: Skip CDTx search and update when autoconfiguration or autoreconfiguration, and current global CDT or CDTx are used for respective channels. CDT or CDTx needs to be specified by the designer manually before operation. Setting the SCTS to “1” results in a shorter time to complete autoconfiguration. This is useful for when the designer has obtained the correct CDTx / CDT, and is confident that the current CDT and CDTx settings work in all conditions.
With above mentioned, one possible example setting is given out below using equation 1~3, with the assumption that setting TL at 90% of USL, and LSL at 65% of USL would cover most of the application case. It may need further adjustment in some cases but will be a very good start. USL = (VDD - 0.7)/VDD x 256 Eqn. 1 TL = USL x 0.9 = (VDD - 0.7)/VDD x 256 x 0.9 Eqn. 2 LSL = USL x 0.65 = (VDD-0.7) / VDD x 256 x 0.65 Eqn. 3 Cin = I x T / V = CDC x CDT / (ADC counts x VDD/1024) Eqn.
GPIO Registers (0x73~0x7A) Direction Register(0x76) DIR_E11 DIR_E10 DIR_E9 DIR_E8 DIR_E7 DIR_E6 DIR_E5 DIR_E4 Enable Register(0x77) EN_E11 EN_E10 EN_E9 EN_E8 EN_E7 EN_E6 EN_E5 EN_E4 Data Set Register(0x78) SET_E11 SET_E10 SET_E9 SET_E8 SET_E7 SET_E6 SET_E5 SET_E4 Data Clear Register(0x79) CLR_E11 CLR_E10 CLR_E9 CLR_E8 CLR_E7 CLR_E6 CLR_E5 CLR_E4 Data Toggle Register(0x7A) TOG_E11 TOG_E10 TOG_E11 TOG_E8 TOG_E7 TOG_E6 TOG_E5 TOG_E4 These registers control GPIO and
6 MPR121 Serial Communication 6.1 I2C Serial Communications The MPR121 uses an I2C Serial Interface.The MPR121 operates as a slave that sends and receives data through an I2C twowire interface. The interface uses a Serial Data Line (SDA) and a Serial Clock Line (SCL) to achieve bidirectional communication between master(s) and slave(s). A master (typically a microcontroller) initiates all data transfers to and from the MPR121, and it generates the SCL clock that synchronizes the data transfer.
6.
PACKAGE DIMENSIONS PAGE 1 OF 3 MPR121 Sensors Freescale Semiconductor, Inc.
PAGE 2 OF 3 MPR121 24 Sensors Freescale Semiconductor, Inc.
PAGE 3 OF 3 MPR121 Sensors Freescale Semiconductor, Inc.
Table 11.
How to Reach Us: Information in this document is provided solely to enable system and software Home Page: freescale.com implementers to use Freescale products. There are no express or implied copyright Web Support: freescale.com/support information in this document. licenses granted hereunder to design or fabricate any integrated circuits based on the Freescale reserves the right to make changes without further notice to any products herein.
Adafruit MPR121 12-Key Capacitive Touch Sensor Breakout Tutorial Created by lady ada Last updated on 2014-07-25 02:45:09 PM EDT
Guide Contents Guide Contents 2 Overview 3 Pinouts 6 Power Pins 6 I2C Pins 7 IRQ and ADDR Pins 7 Assembly 8 Prepare the header strip: 8 Add the breakout board: 9 And Solder! 9 Wiring 11 Download Adafruit_MPR121 12 Load Demo 12 Library Reference 16 Touch detection 17 Raw Data 17 Electrodes 18 Downloads 19 Datasheets 19 Breakout Board Schematic 19 Fabrication Print 19 © Adafruit Industries https://learn.adafruit.
Overview Add lots of touch sensors to your next microcontroller project with this easy-to-use 12channel capacitive touch sensor breakout board, starring the MPR121. This chip can handle up to 12 individual touch pads. © Adafruit Industries https://learn.adafruit.
The MPR121 has support for only I2C, which can be implemented with nearly any microcontroller. You can select one of 4 addresses with the ADDR pin, for a total of 48 capacitive touch pads on one I2C 2-wire bus. Using this chip is a lot easier than doing the capacitive sensing with analog inputs: it handles all the filtering for you and can be configured for more/less sensitivity. © Adafruit Industries https://learn.adafruit.
This sensor comes as a tiny hard-to-solder chip so we put it onto a breakout board for you. Since it's a 3V-only chip, we added a 3V regulator and I2C level shifting so its safe to use with any 3V or 5V microcontroller/processor like Arduino. We even added an LED onto the IRQ line so it will blink when touches are detected, making debugging by sight a bit easier on you. Comes with a fully assembled board, and a stick of 0.1" header so you can plug it into a breadboard.
Pinouts The little chip in the middle of the PCB is the actual MPR121 sensor that does all the capacitive sensing and filtering. We add all the extra components you need to get started, and 'break out' all the other pins you may want to connect to onto the PCB. For more details you can check out the schematics in the Downloads page. Power Pins The sensor on the breakout requires 3V power. Since many customers have 5V microcontrollers like Arduino, we tossed a 3.3V regulator on the board.
I2C Pins SCL - I2C clock pin, connect to your microcontrollers I2C clock line. SDA - I2C data pin, connect to your microcontrollers I2C data line. IRQ and ADDR Pins ADDR is the I2C address select pin. By default this is pulled down to ground with a 100K resistor, for an I2C address of 0x5A. You can also connect it to the 3Vo pin for an address of 0x5B, the SDA pin for 0x5C or SCL for address 0x5D IRQ is the Interrupt Request signal pin. It is pulled up to 3.
Assembly Prepare the header strip: Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - lo ng pins do wn © Adafruit Industries https://learn.adafruit.
Add the breakout board: Place the breakout board over the pins so that the short pins poke through the breakout pads And Solder! Be sure to solder all pins for reliable electrical contact. (For tips on soldering, be sure to check out our Guide to Excellent Soldering (http://adafru.it/aTk)). You're done! Check your solder joints visually and continue onto the next steps © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Wiring You can easily wire this breakout to any microcontroller, we'll be using an Arduino. For another kind of microcontroller, just make sure it has I2C, then port the code - its pretty simple stuff! Connect Vin to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V Connect GND to common power/data ground Connect the SCL pin to the I2C clock SCL pin on your Arduino.
ADDR tied to 3V: 0x5B ADDR tied to SDA: 0x5C ADDR tied to SCL: 0x5D We suggest sticking with the default for the test demo, you can always change it later. Download Adafruit_MPR121 To begin reading sensor data, you will need to download Adafruit_MPR121_Library from our github repository (http://adafru.it/dKE). You can do that by visiting the github repo and manually downloading or, easier, just click this button to download the zip Download Adafruit_MPR121 http://adafru.
Thats it! Now open up the serial terminal window at 9600 speed to begin the test. Make sure you see the "MPR121 found!" text which lets you know that the sensor is wired © Adafruit Industries https://learn.adafruit.
correctly. Now touch the 12 pads with your fingertip to activate the touch-detection © Adafruit Industries https://learn.adafruit.
For most people, that's all you'll need! Our code keeps track of the 12 'bits' for each touch and has logic to let you know when a contect is touched or released. If you're feeling more advanced, you can see the 'raw' data from the chip. Basically, what it does it keep track of the capacitance it sees with "counts". There's some baseline count number that depends on the temperature, humidity, PCB, wire length etc.
// comment out this line for detailed data from the sensor! return; Then reupload. Open up the serial console again - you'll see way more text Each reading has 12 columns. One for each sensor, #0 to #11. There's two rows, one for the 'baseline' and one for the current filtered data reading. When the current reading is within about 12 counts of the baseline, that's considered untouched. When the reading is more than 12 counts smaller than the baseline, the chip reports a touch.
0x5D cap.begin(0x5A) begin() returns true if the sensor was found on the I2C bus, and false if not. Touch detection 99% of users will be perfectly happy just querying what sensors are currentlt touched. You can read all at once with cap.touched() Which returns a 16 bit value. Each of the bottom 12 bits refers to one sensor. So if you want to test if the #4 is touched, you can use if (cap.to uched() & (1 << 4)) { do so mething } You can check its not touched with: if (! (cap.
Electrodes Once you have the MPR121 breakout working you'll want to construct electrodes. These are large conductive piece of copper, foil, paint, etc that will act as the "thing you touch" Remember that electrodes must be electrically conductive! We suggest copper foil tape, conductive fabrics, ITO, pyralux flex PCB, etc. We have tons of great conductive materials in our Materials category. Some can be soldered to, others can be clipped to with alligator chips. (http://adafru.
Downloads Datasheets MPR121 Datasheet (http://adafru.it/dKG) Breakout Board Schematic Fabrication Print Dimensions in Inches © Adafruit Industries https://learn.adafruit.
© Adafruit Industries Last Updated: 2014-07-25 02:45:10 PM EDT Page 20 of 20