QTouchADC Library for Arduino

From Hackteria Wiki
Jump to: navigation, search

QTouchADC on GitHub

https://github.com/dusjagr/QTouchADCTiny/

https://github.com/dusjagr/QTouchADC

QTouchADC finally getting it to work on the Attiny85

Documentation will follow veeeeery soon...


QTouchADC for the CocoMake7 based on Attiny84

JugaadCococoMakerBeach2.png

QTouch for Water Level Sensing

IMG 20150330 153711.jpgTest ringElectroide outside.png

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 :-)

QTouchADC example.png

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.


Compare to CapSense

  • no need of that huge resistor
  • fixed measurement time below 1ms
  • less (but still) troubles with grounding

http://playground.arduino.cc/Main/CapacitiveSensor

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?
  • make all measurements for the ref in the .init. but how to save it into a variable that can be used later again and is mapped to the right analog in?
  • define the reference pin in the QTouchADCduino.int(refPin) function, so the rest of the .sense is simpler?
  • add extra class for just "touch" reading, with a threshold calue. QTouchADCduino.touch(pin, threshold) that gives back a 1 or 0.
  • the range of urban's code is higher, but measurement slower... and still getting some massive outliers. could be optimized, fixing the variable definitions? maybe completely change to that one?

Example measurements and tests

QTouchADC plugged samples1.png QTouchADC unplugged samples1.png QTouchADC unplugged samples20.png QTouchADC unplugged samples20-outdoor.png

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

Urban's original code on SGMK wiki

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!!!

CapSensing touch library from Dave Mellis

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