<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Taking control of the capacitive touch library</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/22522/taking-control-of-the-capacitive-touch-library</link><description>Hi.
I am trying to get a capacitive sensor library using a button ( 2 plates, one to ground, one to the AIN, separated). 
 It&amp;#39;s going crazy, sometimes it just get tones of callbacks, sometimes not. The docs algorithm diagram is not clear regarding the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 06 Jun 2017 12:55:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/22522/taking-control-of-the-capacitive-touch-library" /><item><title>RE: Taking control of the capacitive touch library</title><link>https://devzone.nordicsemi.com/thread/88596?ContentTypeID=1</link><pubDate>Tue, 06 Jun 2017 12:55:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f8aef1b-69cb-43f7-8205-afe059d318bd</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Lola&lt;/p&gt;
&lt;p&gt;It&amp;#39;s good to hear you found a working solution.&lt;br /&gt;
If you need some inspiration for the filtering algorithm you can take a look at the old &lt;a href="https://github.com/NordicSemiconductor/nrf51-capsense-example"&gt;capsense example for the nRF51&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It works just like you described, by using a 1M resistor to charge the sensor through a separate GPIO.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Taking control of the capacitive touch library</title><link>https://devzone.nordicsemi.com/thread/88595?ContentTypeID=1</link><pubDate>Fri, 02 Jun 2017 18:04:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8e0c88b-4861-4573-9659-3d19b6540dbf</guid><dc:creator>Lola</dc:creator><description>&lt;p&gt;I found out that working with the driver directly will provide a more intimate relationship with the sensor , so I used the driver directly, and I can measure values and &lt;em&gt;run my own dsp&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;This code will measure every 150 ticks the values, but I must say the values are strange at the moment, I will update when I get it right !&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE !&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This works REALLY good, with a resistor of 1M, where you touch directly the pad. I have to mention to anyone who reads this, this will not use the COMP since it&amp;#39;s unstable, so you need 2 pins, a digital out with a resistor into the AIN, and from the analog , exposed pad.&lt;/p&gt;
&lt;p&gt;From here, any cool DSP can be implemented !&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/* Pin used to measure capacitor charging time. */
#if USE_COMP == 0
#ifdef ADC_PRESENT
#define OUTPUT_PIN 30
#elif defined(SAADC_PRESENT)
#define OUTPUT_PIN 26
#endif
#endif

/* Time between RTC interrupts. */
 #define APP_TIMER_TICKS_TIMEOUT APP_TIMER_TICKS(150)
 #define AIN_1                   1
 #define AIN_2                   2
 #define AIN_7                   7
 #define PAD_1_MASK              (1UL &amp;lt;&amp;lt; AIN_1)
 #define PAD_2_MASK              (1UL &amp;lt;&amp;lt; AIN_7)
 #define PAD_ID_0                0
 #define PAD_ID_1                1



static ret_code_t clock_config(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_clock_init();
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    nrf_drv_clock_lfclk_request(NULL);

    return NRF_SUCCESS;
}


 static void csense_timeout_handler(void * p_context)
{
    ret_code_t err_code;

    err_code = nrf_drv_csense_sample();
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_INFO(&amp;quot;Busy.\r\n&amp;quot;);
        return;
    }
}

  void start_app_timer(void)
{
    ret_code_t err_code;

    /* APP_TIMER definition for csense example. */
    APP_TIMER_DEF(timer_0);

    err_code = app_timer_create(&amp;amp;timer_0, APP_TIMER_MODE_REPEATED, csense_timeout_handler);
    APP_ERROR_CHECK(err_code);

    err_code = app_timer_start(timer_0, APP_TIMER_TICKS_TIMEOUT, NULL);
    APP_ERROR_CHECK(err_code);
}




void csense_handler(nrf_drv_csense_evt_t * p_event_struct)
{
    switch (p_event_struct-&amp;gt;analog_channel)
    {
        case AIN_1:
        case AIN_2:
                 NRF_LOG_INFO(&amp;quot;t:%d\r\n&amp;quot;,p_event_struct-&amp;gt;read_value);
                 break;
        case AIN_7:

                 NRF_LOG_INFO(&amp;quot;t:%d\r\n&amp;quot;,p_event_struct-&amp;gt;read_value);
                 break;
 
        default:
            break;
    }
}


void csense_initialize(void)
{
    ret_code_t err_code;

    nrf_drv_csense_config_t csense_config = { 0 };

#if USE_COMP == 0
    csense_config.output_pin = OUTPUT_PIN;
#endif

    err_code = nrf_drv_csense_init(&amp;amp;csense_config, csense_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_csense_channels_enable(PAD_1_MASK | PAD_2_MASK);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>