energia 484 Posted January 4, 2013 Share Posted January 4, 2013 [Edit: New library attached with a bug fix for CapTouch on port 1 in combination with Serial] Attached CapTouch.zip is a capacitive touch library for the MSP430. All examples are written for the capacitive touch boosterpack (http://www.ti.com/tool/430boost-sense1). If you do not have one of these then it's fairly simple to create a capacitive sensor from a bare piece of PCB. Just solder a wire to it and hook it up to one of the pins. The library is based on the relaxing oscillator method. Each of the MSP430 pins can be connected to the internal relaxing oscillator peripheral called PinOsc. The PinOsc is a comparator based relaxing oscillator that changes frequency based on a change in capacitance. The idea is to "measure" the capacitance by counting the number of relaxing oscillator cycles during a fixed amount of time. The time during which we measure is called the gate time. So we need a counter to count the number of cycles and a timer to set the gate time during which we count. In this case the watchdog timer in interval mode is used as the gate timer and the capture compare feature of Timer0 is used as the counter. To trigger a measurement, the watchdog timer is set to a certain gate time, the counter start running and the MSP430 is put into LPM3. When the watchdog triggers, the MSP430 wakes up and triggers the capture of the Timer0 counter. There is a lot more to it than this though such as baseline tracking, threshold, etc. If you would like to get to the details then I recommend reading the following literature: http://en.wikipedia.org/wiki/Relaxation_oscillator http://www.ti.com/tool/430boost-sense1#technicaldocuments There are 4 examples included in the library to show how to use the API's. To install the library, unzip the attached and copy it to a folder called libraries in you Energia Sketch folder. API: Include CapTouch.h in your Sketch. CapTouch(uint8_t pin, uint8_t sensorType); Description: Creates a CapTouch instance and calculates the baseline. Parameters: pin: The pin to use as a capacitive touch or proximity pin. sensorType: This is either TOUCH_PROXIMITY for a proximity sensor or TOUCH_BUTTON for a button. void setThreshold(uint16_t threshold); Description: Sets the threshold that needs to be exceeded for the button to be considered as touched. See isTouched() for more details. uint16_t getBaseline(); Description: Returns the the current baseline value of the last measurement of the untouched sensor. Note that a call to this library does not trigger a measurment. uint16_t getMeasured(); Description: Returns the measured value of the last measurement of the sensor. Not that a call to this library does not trigger a measurment. int16_t getDelta(); Description: Returns the difference between the baseline value and the las measured value. Note that a call to this function does not trigger a measurement. uint8_t isTouched(); Description: If the the difference between the baseline (untouched sensor) and the measured value exceeds the threshold then the button is considered to be touched. A call to this function triggers a measurement of the sensor. Returns 1 if the sensor is touched otherwise 0. 1HzCoder, pine, Raul and 6 others 9 Quote Link to post Share on other sites
energia 484 Posted January 4, 2013 Author Share Posted January 4, 2013 As a make shift sensor, a wire and tin foil does wonders as a proximity sensor ;-) sirri 1 Quote Link to post Share on other sites
VirtualEnder 3 Posted January 24, 2013 Share Posted January 24, 2013 Awesome thanks so much for this! Will this be included in the next Energia release? Been waiting for this for a while! Quote Link to post Share on other sites
energia 484 Posted January 29, 2013 Author Share Posted January 29, 2013 We have not yet decided what the distribution mechanism will be going forward but whatever it will be, we will include as many libraries as possible. Quote Link to post Share on other sites
dany_mar24 2 Posted March 9, 2013 Share Posted March 9, 2013 hi, i have just downloaded Energia, and i have to say it is amazing, and i downloaded this library but i cant get it to work with the msp430g2231, i just change the options in the example to the pin 1.7 and 1.4, but it only keeps the red led on, can u help me with this or upload an example for 2231? Quote Link to post Share on other sites
chunterosa 0 Posted March 20, 2013 Share Posted March 20, 2013 how difficult do you think it's going to be for me to learn how to turn this into a serial mouse??? it's the goal i set out for myself, i had some experience with the arduino before i killed it last year, and now i'm refreshing again, but still extreme noob in terms of trying to understand whats going on with the cap sense stuff. Quote Link to post Share on other sites
Raul 0 Posted July 26, 2013 Share Posted July 26, 2013 I can not make use of the center sensor connected to P2_5 Quote Link to post Share on other sites
mikikg 0 Posted October 15, 2013 Share Posted October 15, 2013 Hi to all, just few questions, is it possible to use this library with Stellaris or LM4F120 based LaunchPads? Is there any other HW or SW requirements to get this working on Stellaris + 430BOOST-SENSE1? Quote Link to post Share on other sites
fretless 0 Posted December 29, 2013 Share Posted December 29, 2013 Does anyone have the problem of serial not working when using this library? The example works fine, but as soon as you change anything it starts outputting weird messages. To replicate try changing CapTouchRaw example's #define PROXIMITY_SENSOR P2_0 to #define PROXIMITY_SENSOR P1_3 Quote Link to post Share on other sites
yosh 121 Posted March 28, 2014 Share Posted March 28, 2014 @@energia thanks for posting this lib. I got CapTouch working for Pins 2.x without problems, but not for Pins 1.x (e.g. 1.0, 1.3, 1.4, 1.5, 1.6 and 1.7 - I need 1.1 and 1.2 for serial). I'm using a Rev. 1.5 LP with G2553 and Energia 0101E0012. Of course I removed the jumpers for 1.0 and 1.6. Serial output: Delta on P1.0: 32766 //never changes Delta on P2.1: 264 //working, here: not touched Delta on P2.4: 8340 //working, here: touched Delta on P2.6: -3 //working, here: not touched Am I missing something? Best wishes yosh Quote Link to post Share on other sites
rustw 0 Posted April 3, 2014 Share Posted April 3, 2014 @@energia thanks for posting this lib. I got CapTouch working for Pins 2.x without problems, but not for Pins 1.x (e.g. 1.0, 1.3, 1.4, 1.5, 1.6 and 1.7 - I need 1.1 and 1.2 for serial). I'm using a Rev. 1.5 LP with G2553 and Energia 0101E0012. Of course I removed the jumpers for 1.0 and 1.6. Serial output: Delta on P1.0: 32766 //never changes Delta on P2.1: 264 //working, here: not touched Delta on P2.4: 8340 //working, here: touched Delta on P2.6: -3 //working, here: not touched Am I missing something? Best wishes yosh All of the pins on Port 2 do not have analog functionality. Refer to the Cap Touch Booster pack docs at www.ti.com/lit/ug/slau337b/slau337b.pdf? where there is a very little note about this in section 3.2 that mentions something about this. You may only need to add resistors to make it work properly. I have not tried this (only used Port 2 pins), so I would like to know if this solves your problem. Wayne Quote Link to post Share on other sites
yosh 121 Posted April 4, 2014 Share Posted April 4, 2014 Hi @@rustw, @@energia found the bug, see here. Kind regards yosh Quote Link to post Share on other sites
chicken 630 Posted May 30, 2014 Share Posted May 30, 2014 Just found this short article demonstrating the use of the CapTouch library together with conductive paint. http://macetech.com/blog/node/124 http://www.youtube.com/watch?feature=player_embedded&v=EiU7ac-qi3Q Rei Vilo 1 Quote Link to post Share on other sites
zenki 0 Posted February 21, 2015 Share Posted February 21, 2015 I have found the example code is not working well. The LED light will directly turn on after programming. It doesn't need to sense. So what is the problem here? If anyone has met this before, please tell me how to solve it. Thank you very much. Quote Link to post Share on other sites
benbergman 1 Posted April 1, 2015 Share Posted April 1, 2015 Will this library + examples work with the new MSP432 launchpad when coupled with the 430BOOST-SENSE1 boosterpack? It seems the 432 has cap sensing on all GPIO. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.