Jump to content
energia

[Energia Library] Capacitive Touch library

Recommended Posts

With energia16 and launchpad msp430g2 p1 jumpers removed m430g2553 chip the proximity sensor returns too many false positives to be useful on all demo examples.

I tried setting the threshhold to 250 and 300 but still have the same problem.
Any suggestions?
 
 proximity.setThreshold(150);
  
  Serial.begin(9600);
}


void loop() {
  scanButtons();
  scanProximitySensor();
  ledSequence();
}


void scanProximitySensor() {
    digitalWrite(MIDDLE_LED, HIGH);
    while(!proximity.isTouched());
    Serial.print("proximity touched: ");
    Serial.println(proximity.getBaseline());
    digitalWrite(MIDDLE_LED, LOW);    
}


proximity touched: 50874
proximity touched: 50874
proximity touched: 50874
proximity touched: 50874
proximity touched: 50932
proximity touched: 50932
proximity touched: 50932


raw
State: 0 Base: 55684 Measured: 55661 Delta: 24
State: 0 Base: 55683 Measured: 55657 Delta: 27
State: 1 Base: 55683 Measured: 54950 Delta: 733
State: 0 Base: 55682 Measured: 55663 Delta: 20
State: 0 Base: 55681 Measured: 55674 Delta: 8
State: 1 Base: 55681 Measured: 55004 Delta: 677
State: 1 Base: 55681 Measured: 54946 Delta: 735
State: 0 Base: 55680 Measured: 55642 Delta: 39
State: 1 Base: 55680 Measured: 54958 Delta: 722
State: 1 Base: 55680 Measured: 54930 Delta: 750
State: 0 Base: 55679 Measured: 55659 Delta: 21
State: 1 Base: 55679 Measured: 54959 Delta: 720
State: 1 Base: 55679 Measured: 54929 Delta: 750
State: 0 Base: 55683 Measured: 55690 Delta: -11
State: 1 Base: 55683 Measured: 54955 Delta: 728
State: 1 Base: 55683 Measured: 54948 Delta: 735
State: 0 Base: 55682 Measured: 55651 Delta: 32
State: 0 Base: 55687 Measured: 55694 Delta: -12
State: 1 Base: 55687 Measured: 54961 Delta: 726
State: 0 Base: 55686 Measured: 55656 Delta: 31
State: 0 Base: 55685 Measured: 55668 Delta: 18
State: 1 Base: 55685 Measured: 54950 Delta: 735
State: 0 Base: 55684 Measured: 55639 Delta: 46
State: 0 Base: 55683 Measured: 55659 Delta: 25
State: 1 Base: 55683 Measured: 54956 Delta: 727
State: 1 Base: 55683 Measured: 54956 Delta: 727
State: 0 Base: 55682 Measured: 55647 Delta: 36
State: 1 Base: 55682 Measured: 54955 Delta: 727
State: 1 Base: 55682 Measured: 54958 Delta: 724
State: 0 Base: 55691 Measured: 55702 Delta: -20
State: 1 Base: 55691 Measured: 54963 Delta: 728
State: 1 Base: 55691 Measured: 54967 Delta: 724

Share this post


Link to post
Share on other sites

I'm trying to use the cap sense library to work with my own sensors on an FR5959 Launchpad - currently I have the sharp booster pack fitted. When i compile the CapTouch library I get the following errors:

/Users/colin/Documents/Energia/libraries/CapTouch/CapTouch.cpp: In member function 'uint16_t CapTouch::measure()':/Users/colin/Documents/Energia/libraries/CapTouch/CapTouch.cpp:124:16: error: 'BCSCTL3' was not declared in this scope
/Users/colin/Documents/Energia/libraries/CapTouch/CapTouch.cpp:143:2: error: 'IE1' was not declared in this scope
/Users/colin/Documents/Energia/libraries/CapTouch/CapTouch.cpp:147:13: error: 'LFXT1S_2' was not declared in this scope
/Users/colin/Documents/Energia/libraries/CapTouch/CapTouch.cpp:151:3: error: 'BCSCTL1' was not declared in this scope
/Users/colin/Documents/Energia/libraries/CapTouch/CapTouch.cpp:163:4: error: 'BCSCTL1' was not declared in this scope
 
Is there another library I need to add?
 
Thanks

Share this post


Link to post
Share on other sites

Just a note for those of you interested in using this code to create a touch slider in order to control the brightness of an LED using PWM. When used with the TOUCH_BUTTON option which tends to give the most accurate response, the MSP430 is put into Low Power mode 3 (LPM3_bits) which turns of SMCLK and ACLK, if you happen to be using these to clock TimerA1as your PWM then this will stop working every time you call isTouched. The simplest solution is to replace LPM3_bits on line 165 of the CapTouch.cpp file with LPM0_bits.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×