QTouchADC Library for Arduino

From Hackteria Wiki
Revision as of 15:38, 18 February 2015 by Dusjagr (talk | contribs) (Created page with "= QTouchADC Library for Arduino = == forked from jgeisler0303 on Github == dusjagr converted the code from jgeisler0303 into a library "QTouchADCduino" and tested it again ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

QTouchADC Library for Arduino

forked from jgeisler0303 on Github

dusjagr converted the code from jgeisler0303 into a library "QTouchADCduino" and tested it again and again.

download here: https://github.com/dusjagr/QTouchADCArduino

It's the first time I tried to write a library, so please don't be too hard on me :-)

400px

Notes on the QTouchADC library

Overview and functionalities

  • up to 5 touch sensors can be attached to the AnalogIn pins, one is reserved as referencePin
  • allows averaging over many measurements
  • reading is very fast, ca 150µs for 1 reading. Averaging will increase to measurement time
  • baseline is stable, especially if it runs alone and on battery.
  • when the arduino is plugged into a laptop that is on the mains power, noise increases a lot and the measurement is very succeptible to how your body is connected to the room.

Still needs to be checked / optimized

  • playing around with the CHARGE_DELAY and TRANSFER_DELAY (in the library) impacts the noise. needs optimization
  • do the reference measurement in the .init? how to use that result in the other part of the library?

Example measurements and tests

400px 400px 400px 400px

Usage

QTouchADCduino.init();

// initializez the analog registers. put it in the void setup() of your code.

QTouchADCduino.sense("sensePin", "refPin", "samples");

//this will give you back the result comparing the ADC measurements from the reference pin and the sensepin, and it will take a number "samples" of measurement and averages them. The resulting difference might go from a negative number to positive, up to values of 600-700 when touched.

A single and averaged reference measurement during the void setup() can be later substracted from the measured values to create positive values only.

Code Example

find more examples on github

<syntaxhighlight lang="c">

  1. include <QTouchADCduino.h>

void setup() {

 Serial.begin(9600);
 QTouchADCduino.init();
 int ref1 = QTouchADCduino.sense(0, 1, 64);
 

}

void loop() {

 int value1 = (QTouchADCduino.sense(0, 1, 16) - ref1);
 Serial.println(value1);
 delay(10);

}

</syntaxhighlight>

Links

More on QTouchADC

discussion on mikrocontroller.net

QTouchADC application note

Atmel QTouch reference

How to make Buttons, Sliders and Wheels

Nice description and implementation on ATMega32u4

https://www.youtube.com/watch?v=Ncu2GZJbluI

QTouch on Attiny and Arduino

Very smoothly working implementation for Arduino ->> can someone translate it to the attiny register-ports? (dusjagr tried and failed...) or even make it into a library?

Library for Arduino for ADC Touch, noisy...

240px

TinyTouch library for attiny (I can't get this to run from the arduino IDE), looks very nice!!!

Programming the attiny85 with arduino IDE

Hardware Cores to program various Attiny 85/84 and others via arduino 1.0 & 1.6 and older, MIT High-Low tech

Hardware Cores to program various ATtiny84 (84/44/24), ATtiny85 (85/45/25), and ATtiny2313 (4313) and others via arduino