lordcape 0 Posted May 17, 2014 Share Posted May 17, 2014 Hi. I'm using the capacitive touch library for my project of a touch-lamp. The code is very very simple. The idea is scan if the capacitive pad is touched and then activate a relee to drive the lamp. If you touch the pad again, the relee goes off. It works very well at beggining but after one day more or less the relee starts to oscillate. The lamp goes on and off until I reset the MCU. I think that is related with the mode that the library measures capacitance but I don't know. Here is the code: #include <CapTouch.h> #define BOTON P2_0 // Capacitive Sensor in a PCB. #define RELEE P1_0 uint8_t state = false; uint8_t k = 0; CapTouch PRESS = CapTouch(BOTON, TOUCH_BUTTON); void setup() { pinMode(RELEE, OUTPUT); digitalWrite(RELEE, 0); } void loop() { while(k < 10) { if(PRESS.isTouched()) { k++; } else { k = 0; } } if(k = 10) { state = !state; digitalWrite(RELEE, state); delay(1000); k = 0; } } Another question. Can I measure time intervals with millis() using functions of this CapTouch library? Because I want to use millis() and send the number with Serial but it only works if I pulse the sensor. I hope you can guide me. Thanks lordcape Quote Link to post Share on other sites
p2baron 11 Posted May 19, 2014 Share Posted May 19, 2014 I'm having similiar issue. Never managed to resolve this. I suspect this has something to do with the size of the object that is being used as the touchpad. Also the power supply seems to make a difference. With some cheap usb-charger the MCU constantly registered touches that weren't there. Quote Link to post Share on other sites
p2baron 11 Posted May 20, 2014 Share Posted May 20, 2014 Robert is the Captouch-master. @@energia do you know a way to debug this? Quote Link to post Share on other sites
energia 485 Posted May 21, 2014 Share Posted May 21, 2014 Couple questions: 1: What are you using as the sensing pad? 2: What are you using as the power supply for the MSP430? 3: Is this a LaunchPad or is the MSP430 standalone (e.g. soldered onto a breadboard)? When I last tested it, it was up for 2 weeks without any of the issues described above. This was with the official CapTouch BoosterPack on a LaunchPad that was powered from an iPhone USB adapter. If you can provide me with the information below then I will restart the experiment and see if I can reproduce it this time around. Robert Quote Link to post Share on other sites
coyotek 0 Posted June 10, 2014 Share Posted June 10, 2014 Hi! Can you use Cap Touch library together with millis() -function? If not what would be the best way to measure time while using CapTouch? I'm using G2553 so it has two timers. CapTouch uses timer0_A but I'm not sure about millis() if it can be set up to use timer1_A. Thanks Coyotek Quote Link to post Share on other sites
zormino 1 Posted June 12, 2014 Share Posted June 12, 2014 The millis() thing should still work, but it wont report time in milliseconds anymore. I timed it, and for each second in real time, millis() had incremented by 25. If you were waiting for half a second banking on millis() incrementing by 500, it will actually take 20 seconds. Im assuming the CapTouch library changes the clock frequency for whatever clock millis() was using. I too had the issues with the oscillation, but it would start almost as soon as I had touched the sensor (im using the capacitive sliders on the 430BOOST-SHARP96 as buttons, with a G2553). I think this was partly because the isTouched function would eventually start reporting inverted values. (if it was touched it would send a 0, not a 1). The way I got around this was to go into CapTouch.cpp, and comment out from line 93 to line 95, (the if (delta < 0) stuff), and comment out the base--; on line 98. Then in the code I'm writing I set the threshold to 1000. I havn't tested this to see if it works over extended periods though. I was also wondering if there was a plan to port the CapTouch library over to working on the fr5969? p2baron 1 Quote Link to post Share on other sites
p2baron 11 Posted July 1, 2014 Share Posted July 1, 2014 @@zormino Thanks, that solved the problem for me!! @@energia Robert, sorry for the late reply. Here are my answers: 1: What are you using as the sensing pad? A piece of breadboard wire 2: What are you using as the power supply for the MSP430? Just a plain USB charger (LG, 5v, 800mA) 3: Is this a LaunchPad or is the MSP430 standalone (e.g. soldered onto a breadboard)? I used the launchpad Zormino's solution fixed the problem for me. I am unsure why I am having this problem but you don't. 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.