CAP1188 sensitivity setting?

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
42df
 
Posts: 17
Joined: Fri Sep 09, 2011 5:35 pm

CAP1188 sensitivity setting?

Post by 42df »

Hi there -

I'm relatively new to I2C and very new to the CAP1188.
I've got it hooked up to an Arduino Micro, and the thing works like a champ... EXCEPT.... it's just far too sensitive. My touchplates are definitely in prox sensor mode.
I'm trying to work through the datasheet now and figure out how to dull this down a little. Section 5.5 Sensitivity Control Register (1Fh) looks like it should do what I'm after, but I'm trying to figure out exactly how to set the DELTA_SENSE bits. Any help would be appreciated!

I'm also wondering if I should be working with 5.18 Sensor Input Threshold Registers (30h-38h)?

Many thanks in advance-

User avatar
42df
 
Posts: 17
Joined: Fri Sep 09, 2011 5:35 pm

Re: CAP1188 sensitivity setting?

Post by 42df »

I also just found the GAIN[1:0] bits in the Main Control Register (00h).
Now, I'm slightly more confused :)

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: CAP1188 sensitivity setting?

Post by adafruit_support_mike »

What you're seeing are several knobs that all control the same basic process. Their effects are interrelated, which means you can ignore most of them and concentrate on a couple.

The sensitivity register (0x1f) is probably the best place to start. You have eight options, and lower numbers mean more sensitivity. The default setting is in the middle (sensitivity 32, register bit pattern 010) so try dropping it to the lowest setting (sensitivity 1, register bit pattern 111).

User avatar
42df
 
Posts: 17
Joined: Fri Sep 09, 2011 5:35 pm

Re: CAP1188 sensitivity setting?

Post by 42df »

Thanks, and got it!
I had to drop it down to level 2, but it works like a champ! Thanks.

User avatar
DisruptItYourself
 
Posts: 193
Joined: Mon Sep 23, 2013 6:58 pm

Re: CAP1188 sensitivity setting?

Post by DisruptItYourself »

How did you do this? My Cap1188 is pretty much useless. As soon as I connect a wire to one of the pins (on a breadboard) it continually registers until I pull it out.

User avatar
42df
 
Posts: 17
Joined: Fri Sep 09, 2011 5:35 pm

Re: CAP1188 sensitivity setting?

Post by 42df »

This is a quick Arduino sketch that I used to experiment with the settings until it felt right.
Just uncomment out the different lines until one works well.
Hope it helps!
Todd

Code: Select all

/*************************************************** 
  This is a library for the CAP1188 I2C/SPI 8-chan Capacitive Sensor

  Designed specifically to work with the CAP1188 sensor from Adafruit
  ----> https://www.adafruit.com/products/1602

  These sensors use I2C/SPI to communicate, 2+ pins are required to  
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/
 
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_CAP1188.h>

// Reset Pin is used for I2C or SPI
#define CAP1188_RESET  9

// CS pin is used for software or hardware SPI
//#define CAP1188_CS  10

// These are defined for software SPI, for hardware SPI, check your 
// board's SPI pins in the Arduino documentation
//#define CAP1188_MOSI  11
//#define CAP1188_MISO  12
//#define CAP1188_CLK  13

// For I2C, connect SDA to your Arduino's SDA pin, SCL to SCL pin
// On UNO/Duemilanove/etc, SDA == Analog 4, SCL == Analog 5
// On Leonardo/Micro, SDA == Digital 2, SCL == Digital 3
// On Mega/ADK/Due, SDA == Digital 20, SCL == Digital 21

// Use I2C, no reset pin!
Adafruit_CAP1188 cap = Adafruit_CAP1188();

// Or...Use I2C, with reset pin
//Adafruit_CAP1188 cap = Adafruit_CAP1188(CAP1188_RESET);

// Or... Hardware SPI, CS pin & reset pin 
// Adafruit_CAP1188 cap = Adafruit_CAP1188(CAP1188_CS, CAP1188_RESET);

// Or.. Software SPI: clock, miso, mosi, cs, reset
//Adafruit_CAP1188 cap = Adafruit_CAP1188(CAP1188_CLK, CAP1188_MISO, CAP1188_MOSI, CAP1188_CS, CAP1188_RESET);

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo/Micro only
  }
  Serial.println("CAP1188 test!");
  
  
  // Initialize the sensor, if using i2c you can pass in the i2c address
  // if (!cap.begin(0x28)) {
  if (!cap.begin()) {
    Serial.println("CAP1188 not found");
    while (1);
  }
  Serial.println("CAP1188 found!");
  //Decrease sensitivity a little - default is 0x2F (32x) per datasheet
  //cap.writeRegister(CAP1188_SENSITIVITY, 0x3F);  // 16x sensitivity
  //cap.writeRegister(CAP1188_SENSITIVITY, 0x4F);  // 8x  sensitivity
  //cap.writeRegister(CAP1188_SENSITIVITY, 0x5F);  // 4x  sensitivity
  cap.writeRegister(CAP1188_SENSITIVITY, 0x6F);  // 2x  sensitivity THIS SEEMS TO WORK THE BEST FOR 3.5" plate sensors
  //cap.writeRegister(CAP1188_SENSITIVITY, 0x7F);  // 1x  sensitivity
  //Serial.print("Sensitivity: 0x");
  //Serial.println(cap.readRegister(CAP1188_SENSITIVITY), HEX);
}

void loop() {
  uint8_t touched = cap.touched();
  if (touched == 0) {
    // No touch detected
    return;
  }
  
  for (uint8_t i=0; i<8; i++) {        // Check each bit, each bit represents 1 sensor
    if (touched & (1 << i)) {
      Serial.print("C"); Serial.print(i+1); Serial.print("\t");
    }
  }
  Serial.println();
  delay(50);
}

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: CAP1188 sensitivity setting?

Post by adafruit_support_mike »

Nice! Thanks for posting it. ;-)

User avatar
DisruptItYourself
 
Posts: 193
Joined: Mon Sep 23, 2013 6:58 pm

Re: CAP1188 sensitivity setting?

Post by DisruptItYourself »

God bless you Todd. Haha thanks

rivaluk
 
Posts: 7
Joined: Sun Jul 27, 2014 8:57 am

Re: CAP1188 sensitivity setting?

Post by rivaluk »

Hey this is great. You might need to add the line

Code: Select all

#define CAP1188_SENSITIVITY 0x1F
as well.

User avatar
miss_n
 
Posts: 70
Joined: Mon Dec 17, 2012 8:21 pm

Re: CAP1188 sensitivity setting?

Post by miss_n »

Thank you so much for posting an example. I was reading through threads and the data sheet but just wasn't getting how to adjust the sensitivity. This made it so much clearer!

User avatar
lshaffren
 
Posts: 2
Joined: Wed Jul 17, 2019 10:57 am

Re: CAP1188 sensitivity setting?

Post by lshaffren »

Thank you so much for this. I am having this exact issue and this thread offered the solution.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”