Adafruit 12 key touchpad
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011
    Location
    Portland, Oregon
    Posts
    207

    Default Adafruit 12 key touchpad

    I'm trying to get an Adafruit 12 key capacitive touchpad (https://www.adafruit.com/product/1982) going. I don't think I'm too far off, but the multiple registers, Arduino-centric tutorial, and my own lack of experience leave me struggling. On a 16F88, I get inconsistent readings and cannot tell if it's the Adafruit part, some problem with my understanding of I2C statements, or general lunkheadedness. The link contains all in unique information I can find...

    I'm hoping someone has a minute to comment...

    Code:
    #CONFIG
       __config _CONFIG1, _INTRC_IO & _WDT_OFF & _PWRTE_OFF & _MCLR_ON & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _WRT_PROTECT_OFF & _DEBUG_OFF 
       __config _CONFIG2, _FCMEN_OFF & _IESO_OFF  
    #ENDCONFIG
    
    DEFINE OSC 8
    
    '-----DEBUG (SERIAL) SETUP----------------------------------------
    DEFINE DEBUG_REG PORTB
    DEFINE DEBUG_BIT 3
    DEFINE DEBUG_BAUD 2400
    DEFINE DEBUG_MODE 0
    
    OPTION_REG = %00001111                                              ' PULL-UPS ON, FALLING EDGE
    TRISA = %00000000                                                   ' Set PORTA output
    TRISB = %00000000                                                      
    OSCCON = %01110000
    ANSEL = %00000000 
    
    T_ADDR VAR BYTE
    T_ADDW VAR BYTE
    T_REG VAR BYTE
    KEYS VAR BYTE[2]
    
    '-----PORT SET-UP-------------------------------------------------   
    SDA  VAR PORTB.1
    SCL  VAR PORTB.0 
    T_ADDW = %10110100
    T_ADDR = %10110101
    T_REG = $0
    
    i2cwrite SDA, SCL, T_ADDW, $5E, [%00111100] , I2CERR
    i2cwrite SDA, SCL, T_ADDW, $0, [%11111111]   , I2CERR
    
    
    MAIN:
      PORTA = 0
      PAUSE 2000
      PORTA = 255
      PAUSE 50
      GOSUB READKEYS
    GOTO MAIN
    
    
    READKEYS:
      I2CRead SDA, SCL, T_ADDR, T_REG, [KEYS[0], KEYS[1]], I2CERR
      DEBUG "   ?--P110000000000", 13
      DEBUG "   ?--P109876543210", 13
      DEBUG "k: ", BIN8 KEYS[1], BIN8 KEYS[0], 13
    RETURN
    
    I2CERR:
    DEBUG "PROBLEM "
    RETURN

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,583

    Default Re: Adafruit 12 key touchpad

    its not a chip i have used but i can say

    T_ADDW = %10110100
    T_ADDR = %10110101
    is incorrect pbp uses the same address regardless of i2c read or write
    if you have the addr pin grounded the address is $b4 for that module




    i2cwrite SDA, SCL, T_ADDW, $5E, [%00111100] , I2CERR
    most demos do not enable proximity detection [%00111100]
    they use [%00001100] ($0c) to enable capsense on all 12 electrodes

    i2cwrite SDA, SCL, T_ADDW, $0, [%11111111] , I2CERR
    reg 0 Touch Status Register is read only


    most demos setup all the threshold regs

    eg

    Code:
    void mpr121QuickConfig(void)
    {
    	// Section A
    	// This group controls filtering when data is > baseline.
    	mpr121Write(MHD_R, 0x01);
    	mpr121Write(NHD_R, 0x01);
    	mpr121Write(NCL_R, 0x00);
    	mpr121Write(FDL_R, 0x00);
    	
    	// Section B
    	// This group controls filtering when data is < baseline.
    	mpr121Write(MHD_F, 0x01);
    	mpr121Write(NHD_F, 0x01);
    	mpr121Write(NCL_F, 0xFF);
    	mpr121Write(FDL_F, 0x02);
    	
    	// Section C
    	// This group sets touch and release thresholds for each electrode
    	mpr121Write(ELE0_T, TOU_THRESH);
    	mpr121Write(ELE0_R, REL_THRESH);
    	mpr121Write(ELE1_T, TOU_THRESH);
    	mpr121Write(ELE1_R, REL_THRESH);
    	mpr121Write(ELE2_T, TOU_THRESH);
    	mpr121Write(ELE2_R, REL_THRESH);
    	mpr121Write(ELE3_T, TOU_THRESH);
    	mpr121Write(ELE3_R, REL_THRESH);
    	mpr121Write(ELE4_T, TOU_THRESH);
    	mpr121Write(ELE4_R, REL_THRESH);
    	mpr121Write(ELE5_T, TOU_THRESH);
    	mpr121Write(ELE5_R, REL_THRESH);
    	/*mpr121Write(ELE6_T, TOU_THRESH);
    	mpr121Write(ELE6_R, REL_THRESH);
    	mpr121Write(ELE7_T, TOU_THRESH);
    	mpr121Write(ELE7_R, REL_THRESH);
    	mpr121Write(ELE8_T, TOU_THRESH);
    	mpr121Write(ELE8_R, REL_THRESH);
    	mpr121Write(ELE9_T, TOU_THRESH);
    	mpr121Write(ELE9_R, REL_THRESH);
    	mpr121Write(ELE10_T, TOU_THRESH);
    	mpr121Write(ELE10_R, REL_THRESH);
    	mpr121Write(ELE11_T, TOU_THRESH);
    	mpr121Write(ELE11_R, REL_THRESH);*/
    	
    	// Section D
    	// Set the Filter Configuration
    	// Set ESI2
    	mpr121Write(FIL_CFG, 0x04);
    	
    	// Section E
    	// Electrode Configuration
    	// Enable 6 Electrodes and set to run mode
    	// Set ELE_CFG to 0x00 to return to standby mode
    	// mpr121Write(ELE_CFG, 0x0C);	// Enables all 12 Electrodes
    	mpr121Write(ELE_CFG, 0x06);		// Enable first 6 electrodes
    	
    	// Section F
    	// Enable Auto Config and auto Reconfig
    	/*mpr121Write(ATO_CFG0, 0x0B);
    	mpr121Write(ATO_CFGU, 0xC9);	// USL = (Vdd-0.7)/vdd*256 = 0xC9 @3.3V
    	mpr121Write(ATO_CFGL, 0x82);	// LSL = 0.65*USL = 0x82 @3.3V
    	mpr121Write(ATO_CFGT, 0xB5);*/	// Target = 0.9*USL = 0xB5 @3.3V
    }
    Last edited by richard; - 28th January 2019 at 00:57.
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Apr 2011
    Location
    Portland, Oregon
    Posts
    207

    Default Re: Adafruit 12 key touchpad

    Looks like it will have to wait for now... For some reason the thing has quit responding altogether.

Similar Threads

  1. Key fifo
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 30th March 2014, 02:21
  2. USB key not found
    By shrtrtrt in forum General
    Replies: 3
    Last Post: - 20th April 2011, 15:12
  3. Key Pad Project
    By AMay in forum Schematics
    Replies: 5
    Last Post: - 3rd April 2007, 21:14
  4. Key Pad Matrix
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st December 2004, 00:50
  5. Electronic Key
    By Carl0701 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th February 2004, 11:01

Members who have read this thread : 19

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts