Capacitive touch - success anyone?

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


I know there are "QTouch" libraries from Atmel/Microchip for selected AVR but as far as I can see from code such as:

 

https://gist.github.com/luisfcor...

 

it should be possible to do it on the pins of any AVR. The typical operation sequence always tends to be along the lines of:

uint8_t capsensePORTD(uint8_t mask) {
   PORTD = 0; //Ground the PCB surface
   DDRD  = 0xFF;
   asm("nop"); 
   cli();
   DDRD &= ~(mask); //Turn selected pin to input
   PORTD |= mask;   //With pullup
   uint8_t cycles = 0;
   if      (PIND & mask) { cycles =  0;}
   else if (PIND & mask) { cycles =  1;}
   else if (PIND & mask) { cycles =  2;}
   else if (PIND & mask) { cycles =  3;}
   else if (PIND & mask) { cycles =  4;}
   else if (PIND & mask) { cycles =  5;}
   else if (PIND & mask) { cycles =  6;}
   else if (PIND & mask) { cycles =  7;}
   else if (PIND & mask) { cycles =  8;}
   else if (PIND & mask) { cycles =  9;}
   else if (PIND & mask) { cycles = 10;}
   else if (PIND & mask) { cycles = 11;}
   else if (PIND & mask) { cycles = 12;}
   else if (PIND & mask) { cycles = 13;}
   else if (PIND & mask) { cycles = 14;}
   else if (PIND & mask) { cycles = 15;}
   else if (PIND & mask) { cycles = 16;}
   sei();
   PORTD = 0; //Ground the PCB surface
   return cycles; //Return measured cycles
}

So you drive low, then switch to pulled up input and effectively measure (with closely spaced PIN reads) when the observed bit goes high.

 

As far as I can tell this approach may have first started here:

 

https://support.bantamtools.com/...

 

(and the capacitive.ino there) 

 

So is anyone doing it in this simplistic way? How successful/effective is it exactly?

 

I'm just wondering how feasible it would be to do something like:

 

 

I know touch keyboards can be successful because of:

 

 

which is on possibly the most successful small synth of the current era. But I'm just wondering how feasible this is as DIY ?

 

PS and yes, I did look at the Capacitive Touch community here but I was almost knocked down by the large tumbleweeds that went rolling past !! (anyway, that's al about the "potted" QTouch solution anyway).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
So is anyone doing it in this simplistic way?
From the PIC side of the house is Capacitive Voltage Division (CVD, analog instead of digital)

Some AVR have a Peripheral Touch Controller (PTC)

 

https://microchipdeveloper.com/search:site?q=CVD&mini=true

AVR MCUs | Microchip Technology

[top of right column]

View our Quick Reference Guide to get a quick overview of Microchip's 8-bit AVR portfolio, peripheral integration, and migration options.

edit : ASF3

https://asf.microchip.com/docs/latest/search.html?search=QTouch

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Fri. Nov 27, 2020 - 05:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

>As far as I can tell this approach may have first started here:

 

Was doing 'touch' with the early pic's, so has been around a long time and I'm sure I read it in some book or a thick mchp pic datasheet/appnotes book before internet.

 

This may be helpful-

googl -> piano with rtos

(date on that is 2009)

 

Would make for a nice fun toy for kids (parents may not be so happy, but there are always headphones). I should make one of those, converted to use avr of course.

Last Edited: Fri. Nov 27, 2020 - 07:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


curtvm wrote:
Would make for a nice fun toy for kids
This kid sure enjoyed:

 

Back when I first got mine about 40+ years ago. There's surprisingly very few things like this available these days (which is why I'm trying to build a modern day one for nothing more than the nostalgia)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
There's surprisingly very few things like this available these days

There's lots of little (and not so little!) keyboards these days - but mostly just as input devices to a computer/laptop running some virtual synth ...

 

eg, https://www.native-instruments.com/

 

But Behringer do seem to be trying to re-create a load of bygone analogue synths ...

 

https://www.geextreme.com/music/...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
So is anyone doing it in this simplistic way? How successful/effective is it exactly?

I only did the Atmel "Charge Transfer" method using a "self-capacitance" type fingertip sized touch pad. It worked very well, had excellent resistance to noise, but did have noticeable latency. The simple method may result in less latency but could be very/extremely susceptible to noise.

 

clawson wrote:
I know touch keyboards can be successful because of {photo}...:

That surprises me: As an ex-pianist (I learnt in my youth and have since lost much of the ability} I would find that keyboard infuriating because I couldn't rest my fingers on the keys as I was taught. I would need real weighted switches with "feel".

 

Also that keyboard tracking suggests it uses the "mutual-capacitance" method as opposed to the "self-capacitance" method. That may improve latency but it's ability to reject triggering of adjacent keys is very likely why it is used here.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Watch some of the Arturia Microfreak reviews on YouTube to get various opinions about the keyboard. It does seem to be something of a Marmite item. Guess I'll know if/when Santa brings one. cheeky

 

awneil wrote:
- but mostly just as input devices to a computer/laptop
Umm, yeah. I currently own

 

and also

 

 

I use one or other of these as the UI for my synth until I have the display, encoders and hopefully some kind of keyboard wired up.

 

Actually a lot of the time, while testing, I also use

 

 

as the interface. It's a panel I designed using ctrlr.org

 

But ultimately I want the synth to be stand alone and not reliant on a MIDI Controller or a PC program to drive it (but because all these things currently DO operate it using MIDI then it will be fully driveable over either 5pin DIN or USB MIDI too).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got the best results by turning on the pullup for only one cycle at a time.  The code you posted probably results in a resolution of three or four cycles.  I did my testing with a metal 2.5" hard drive tray covered with a plastic insulator.

https://github.com/nerdralph/ner...

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Ralph that looks really interesting. I think I need to try some experiments myself.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Thanks Ralph that looks really interesting. I think I need to try some experiments myself.

 

With a little bit of extra code I was able to get a pretty good auto-calibration.  I hadn't got it quite perfect before other priorities got my attention.

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not sure I was clear in the previous post-

 

This may be helpful-

googl -> piano with rtos

(date on that is 2009)

 

The result-

http://www.pic24.ru/doku.php/en/...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As an ex-pianist (I learnt in my youth and have since lost much of the ability}

AAAARRRGGGGHHHH you should have sold some of the "ability" to me , I'm trying to learn to play.surprise

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

curtvm wrote:

The result-

http://www.pic24.ru/doku.php/en/...

Oh, nice link! Thanks.