I've been experimenting more in the scope of the Cypress CY8CKIT-058 PSoC 5LP Prototyping Kit RoadTest. This time, I experimented with CapSense and created my own linear slider.

 

CapSense

 

There are two parts to the TopView:

  • a PWM signal directly connected to the onboard LED on P2_1
  • a CapSense component

 

The CapSense component can be used for different types of capacitive touch buttons. In this particular case, I opted for the linear slider.

The goal is to control the duty cycle of the PWM signal depending on where the linear slider was touched.

Screen Shot 2015-05-17 at 21.48.53.pngScreen Shot 2015-05-18 at 21.53.16.png

 

Screen Shot 2015-05-17 at 21.47.40.pngScreen Shot 2015-05-17 at 21.47.51.png

 

The code example was found here: PSoC 4 Pioneer Kit Community Project#02 - CapSense Slider

 

#include <project.h>

#define NO_SLIDE 0xFFFFu

int main()
{
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
    uint16 SliderPos = NO_SLIDE;
    uint16 LastPos = NO_SLIDE;

    CyGlobalIntEnable;

    CapSense_1_Start();
    CapSense_1_InitializeAllBaselines();

    Clock_1_Start();
    PWM_1_Start();

    for(;;)
    {
        /* Place your application code here. */
        CapSense_1_UpdateEnabledBaselines();
        CapSense_1_ScanEnabledWidgets();

        while(CapSense_1_IsBusy());

        SliderPos = CapSense_1_GetCentroidPos(CapSense_1_LINEARSLIDER0__LS);

        if(SliderPos != NO_SLIDE && SliderPos != LastPos) {
            PWM_1_WriteCompare(SliderPos);
        }
    }
}









 

Linear Slider

 

To create the linear slider, I used a piece of cardboard on which I created some shapes using copper tape. The shapes were then connected to alligator clips using conductive paint. Why paint and not just more copper tape ? Purely because I wanted to experiment with different conductive materials

 

Finally, the alligator clips were connected to the kit's pins assigned to the CapSense Linear Slider. The copper tape was covered with regular tape, making it easy to slide back and forth without ripping the copper tape.

 

photo 2.JPGScreen Shot 2015-05-18 at 21.48.41.png

 

It is possible to create a longer slider with up to ten electrodes using the same five pins, by configuring and wiring the slider in "diplexed" mode. This allows for a finer granularity of the measured values.

 

Demo


A demo of the PWM signal's duty cycle being changed based on the input of the linear slider: