element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Safe and Sound
  • Challenges & Projects
  • Design Challenges
  • Safe and Sound
  • More
  • Cancel
Safe and Sound
Blog Safe & Sound -Flood early-warning Alarm Pack #7: Capacity Touch Sensor
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fyaocn
  • Date Created: 27 Jun 2017 8:06 AM Date Created
  • Views 679 views
  • Likes 4 likes
  • Comments 1 comment
Related
Recommended

Safe & Sound -Flood early-warning Alarm Pack #7: Capacity Touch Sensor

fyaocn
fyaocn
27 Jun 2017

1. There have been efforts trying to make the whole Design work, baffled by capacity sensor.

According to my research, MSP432P401 has offered great resource for capacity sensor for touching, motion with  capTouch libraries. Since I mean to make design in Energia, which function of timer is confined a lot. In the end, I try customized Tick Count and make results in the end.

2. The fundamental element required in the capacitive touch sensing application described is the variable capacitor itself. This capacitor should be easy to construct as well as sensitive to human touch in order to enable this as an alternative to mechanical buttons and switches. Such a touch sensitive sensor element can be constructed by “opening up” a capacitor structure so that the electric field can be interfered with by a conductive foreign object, in this case, a finger. The figure below shows the touch sensor.

image

It would be same if the capacitive water level sensors since water pose larger dielectric constant of 78.36F/m , in that

image

 

image

 

 

There are two methods of capacity sensor, Oscillator-Based Capacitive Measurement or Resistor-Based Capacitive Measurement, I use the later,

image

using an external resistor to charge or discharge the given capacitive sensor. Using the port pins of the MSP430 to charge or discharge the sensor cap, the internal Timer_A can be used to measure the corresponding charge or discharge time. Given a fixed external resistance to provide the charge/discharge path, the capacitance of the sensor can be measured.  With reference design on MSP430,

image

In fact, for MSP401r, capTouch is one of bottom function in MCU, simplified with one pin without external component, which can be studied later.image

 

3. Capacity sensor with program logic as follows,

image

 

4. The Energia Sketch as follows,

at first, I have tried tickTime= millis() for acurate time span, but it return 0. The timer still can not catch the transient state or RC circuit, so  I have to use capCount as tick counts for on and off of hand touch.

// Core library for code-sense - IDE-based
#   include "Energia.h"


// Include application, user and local libraries
//#include "rtosGlobals.h"
#include "Timer.h"


// Prototypes
#define   MYCAPSENSOR   2  // Pin 2 for capSensor;
#define   MYCAPSENSOR_POWER   3  // Pin 3 for capSensorn applying power;
#define   THRESHOLDHIGH  1.5  // ---
#define   THRESHOLDLOW   0.3  // ---


// Define variables and constants
uint8_t status = 1;
const uint8_t myLED = BLUE_LED;


const uint8_t myCapSensor = MYCAPSENSOR;
const uint8_t myCapSensor_Power = MYCAPSENSOR_POWER;


uint8_t eTag = 1;
float capVoltage;
uint32_t rcTime;
uint32_t capCount;


///
/// @brief 1st timer
///
Timer myTimer;


///
/// @brief Function for 1st timer
/// @note   Both void and ti_sysbios_interfaces_ITimer_FuncPtr work
/// @bug    Serial.print doesn't work
///
void timerFunction()
{
    
    eTag = 1; 
    capCount=0;
    
    while (eTag){
      digitalWrite(myCapSensor_Power, HIGH);
      delay(100);
      capVoltage = analogRead(myCapSensor)*3.3/1024;
      //Serial.print(capVoltage,DEC);
      //Serial.print("- -\n");
     
      if ( capVoltage > THRESHOLDHIGH ) {
              digitalWrite(myCapSensor_Power, LOW);
              while ( capVoltage > THRESHOLDLOW ) {
                capVoltage=analogRead(myCapSensor)*3.3/1024;    
                capCount++;       
                }    
               Serial.print("capCount= ");
               Serial.print(capCount,DEC);
               Serial.print("\n ");
        }
      eTag = 0;
    }




       
}


/*
 ///
 /// @brief 2nd timer
 /// @bug    Doesn't work. Only one timer allowed
 ///
 Timer myTimer2;

 ///
 /// @brief Function for 2nd timer
 /// @bug    Serial.print doesn't work
 ///
 void timerFunction2()
 {
 Serial.print("1 s\t");
 }
 */


// Add setup code
void setup()
{

    Serial.begin(115200);
    pinMode(myLED, OUTPUT);
    pinMode(myCapSensor_Power, OUTPUT);
        
   
    Serial.print("myTimer.begin... ");
    myTimer.begin(timerFunction, 2000);
    Serial.println("done");
    
/*
     Serial.print("myTimer2.begin... ");
     myTimer2.begin(timerFunction2, 1000);
     Serial.println("done");
 */
    
    Serial.print("myTimer.start... ");
    myTimer.start();
    Serial.println("done");


/*
     Serial.print("myTimer2.start... ");
     myTimer2.start();
     Serial.println("done");
 */
}


// Add loop code
void loop() 
{
    
}

 

with the result in serial console,

capCount number 2 show the touch of hand to input Pin and 1 for not.

image

The result is not idea and the parameter are not selected well, larger resistor and capacitor shall be used for this test. But at least ,it works and it is a good start to go.

With water level sensor, the capacitor is much larger than hand proximate, it will work well ,but thoroughly math calculation is needed.

  • Sign in to reply

Top Comments

  • DAB
    DAB over 8 years ago +1
    Nice tutorial on capacitive sensing, but I was really hoping to see more detail on how you are going to use it for your water detection issue. DAB
  • DAB
    DAB over 8 years ago

    Nice tutorial on capacitive sensing, but I was really hoping to see more detail on how you are going to use it for your water detection issue.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube