Touch sensor weirdness...

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

I'm pulling my hair out over this one. I'm using a nucleo for testing, rather than an AVR, hence it's here in general electronics though it is generisable to any controller (but mods, please feel free to move it if I guessed wrong).

 

Many microcontrollers contain hardware to perform touch sensing, but the ones that don't are cheaper - and therefore alternate methods as worth investigating.

 

One way in which this sensing can be done is as follows, assuming a sensor with a guard ring around it to improve isolation from environmental effects. The sensor pad acts as a capacitor with a value of a few picofarads. When a conductive object such as a finger moves close to it, its capacitance increases, maximising when the sensor is touched. A collecting capacitor - 100n or so - can be connected to the sensor pad using a fet, and a similar capacitor for the guard ring.

 

1) start by emptying all the caps. i/o ports in push-pull and set to '0' do this. Thirty or forty microseconds will do this, depending on the output impedance of the port.

2) short deadband delay, to avoid interractions - all i/o ports set three state and the fet turned off.

3) charge the sensor pad and guard ring: a couple of microseconds on a push-pull output.

4) short deadband delay

5) turn on the fet to transfer charge from the sensor to the collection capacitor

6) measure the voltage on the collection capacitor; if it has not reached a trigger voltage then back to (3) and repeat until it does, or you time out.

 

The trigger voltage *can* be the i/o logic level, but that's a bit noisy; if you have a comparator against a standard voltage available, that's much better. You're counting the number of cycles required to reach the trigger voltage; decreasing numbers indicate a finger is getting closer and a big decrease indicates it's touching. As an example, using the i/o logic as the trigger, the noise between samples is around fifty counts; using an internal comparator and voltage reference, the noise is one or two counts. With this method, I can see a clear indication of a hand approaching the sensor through the thickness of a desk - a count change of perhaps ten or twelve.

 

This is where the head-scratching starts. With the system idling, I see a continuous sawtooth on the count signal; the period is about ninety-five seconds and the height is a relatively constant 70-72 counts. This is irrespective of how fast the signal is collected (i.e. pauses between sampling from instant to a couple of seconds) and whether the unit is attached to a computer (and therefore mains ground) or completely galvanically isolated using a batteries and fibre optics for communications... This sawtooth makes it impossible to filter the signal to get a clean reference for low level signals (I see a count of about 1700 normally, so the noise is about 2.5%, and I'm hoping to be able to trigger on changes of around five or ten counts - as the hardware controller can do. Actually touching the sensor gets the count down to six or seven hundred, so that bit's easy - but I want to be able to detect approach as well as actual contact.

 

My head is starting to hurt where I'm scratching it... any thoughts?

 

Neil

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

barnacle wrote:
One way in which this sensing can be done is ...
Capacitance Voltage Division (CVD)

barnacle wrote:
... if you have a comparator against a standard voltage available, that's much better.
Some comparators have one leg via a switch to a constant current source; an ideal CCS has infinite impedance.

barnacle wrote:
any thoughts?

... rather than an AVR, ...

PIC CTMU?

 


Waking up a capacitive touch-sensing device with an MCU peripheral | Embedded

Microsoft PowerPoint - CTMUWebinar_101408.ppt

 

edit :

PIC24 : mTouch Conducted Noise Immunity Techniques for the CTMU

all : AN1375, See What You Can Do with CTMU

 

edit2 :

I'm using a nucleo for testing, ...

PIC32MZ DA[K..S] have a CTMU that's clocked with the ADC and the comparators during power-down (CPU off)

ADC current during power-down is 3.5mA typ to 5mA max.

Power-down current is 8mA typ to 14mA max at 25C (so, 11.5mA typ to 19mA max)

Unfortunately, its development board is an order of magnitude more expensive than the least expensive Nucleo (arm Cortex-M0+)

DM320010 - PIC32MZ Embedded Graphics with Stacked DRAM (DA) Starter Kit via PIC32MZ2064DAK176 - 32-bit Microcontrollers

 

PIC32MX may be a better match (similar characteristics though less current, board is three times the price)

Curiosity PIC32MX470 Development Board via Development Tools - 32-bit Curiosity Boards

PIC32MX470F512H - Microcontrollers and Processors

 

edit3 :

Final Projects ECE 4760

...

 

Fall 2015    youtube PIC32MX250 microprocessor with MPLABX/GCC

...

5. Capacitive touch piano (videohackaday,

...

 

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

Last Edited: Sat. Jul 13, 2019 - 06:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

barnacle wrote:
any thoughts?

 

My first thought is to commend you on your ingenuity!

 

My knee jerk thought would be to say.."Why go through all the trouble, when for $0.60, you could use one of these:"

 

https://www.digikey.com/product-...

 

But knowing you, I am guessing your more into the challenge than the easy way out wink

 

 

They make multiple input models for a few pence more but at that point switching to a PSoC or an AVR might be a better option.

 

Jim

 

Sub note: I find using PSoC's for touch interfacing far easier than AVR's and Atmel SAMs but don't let the uppity ups know ok? Thanks

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

I'm intrigued by the circuit and algorithm you describe but I'm having trouble visualizing the circuit in my head.  Could you post a schematic?

Letting the smoke out since 1978

 

 

 

 

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

This is an attempt to reduce baseline cost on an ARM system. The STM32L073 and 071 are pin and code compatible, but the 073 contains a hardware touch sensor module. The 071 doesn't, and is twenty-odd cents cheaper :)

 

The ingenuity is by no means due to me, just the implementation: the mechanism I use is the same as the 073, but requires some external fet switches and hardware attention. The process is explained in the application note here: https://www.st.com/content/ccc/r...

 

The switches to vdd and vss are implemented in the i/o pin drivers, and the switch to the sampling capacitor is an external BSS84.

 

Neil

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

I take it there's nothing else happening with the firmware while you're testing this?

96 seconds is a long time, sound like some sort of interaction. If you move to the US, is it still 96 seconds?

Four legs good, two legs bad, three legs stable.

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

Dunno about moving to the US, but one of my colleagues has just implemented the same algorithm and timings, using internal timers and more fets (because the timers can wiggle pins but not change their modes) and that does *not* exhibit the effect. Very odd.

 

Neil

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

So, although its a not really related. Nordic had sometime ago implemented a capacitive touch sensing integrated inside the mcu. >>its not there anymore<< and no more supported.

 

while their approach is quite similar to the one described by you (here ST), after testing/evaluation and so on they decided to ditch the idea. the main concern here was that the touch sensing is in general requires some shielding and special algorithms which reuires in turn more parts (capacitors...fets..etc) -Noise..EMI...etc, not to mention that it can only be guranteed in room temperature. so why bother with all this added cost ? when in return you can use one of the capacitive sensors and then you can play around the software and you need very few parts associated with it to pass the EMI test.

 

while the approach described in the the appnote of ST works quite well in room temperature, it will fail over the time due to false detection, variation of room temperature, ESD, not to mention variation of current, etc...

 

PS: I used the same approach before, but at the end its better to get one of those 0.50 cents cap sensors....

 

Regards,

Moe

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

Please do let us all know if you get to the bottom of this.

 

Four legs good, two legs bad, three legs stable.

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

Have you tried conducting your tests elsewhere?  It will be interesting to find the source of the that 0.01 Hz signal...

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

By the way, is the typo in your location deliberate?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

No one who lives in Hemel Hempstead wants to truly admit it cheeky

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

We don't live here, we more sort of exist... Could be worse, could be Finchingfield, and then I'd have to put up with Cliff as a neighbour. :p

 

Tried in other locations, no change to the sawtooth in either period or size. But when implemented using the internal timers and interrupts and external switches to fill, empty, and transfer the charge, with the processor mostly asleep, no sign of the sawtooth. Using the internal hardware on the same processor shows a similar sawtooth but of much lower amplitude - perhaps four or five counts - and slightly faster, at 75 seconds.

 

We note that the entire process is highly dependent on a consistent charge going into the sensor capacitor, and that it will be sensitive to any Vcc noise. We speculate that internal thermal effects may be changing something around the (external) voltage regulator though it appears constant to two decimal places; we haven't yet hung it on a precision recording ammeter yet.

 

Moe, the whole point here is a cost reduction exercise; seven fets at around 3c each vs a processor with the hardware on board at 25c more expensive. To be fair we get a better deal on selecting capacitor distributors; I saved a buck and a quarter that way last week. Capacitor prices have gone stupid in the last couple of years. But even a couple of cents is worth it on a few hundred thousand units with a BOM cost I can't disclose, but isn't a lot.

 

Neil

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

barnacle wrote:

Dunno about moving to the US, but one of my colleagues has just implemented the same algorithm and timings, using internal timers and more fets (because the timers can wiggle pins but not change their modes) and that does *not* exhibit the effect. Very odd.

That would seem to implicate your algorithm somehow.

 

Can you go into greater detail about how you're measuring the passage of time?  How you accumulate 'counts'?

 

A sawtooth suggest to me some kind of numerical 'beating'.

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

It's a wonder that these circuits work at all with the fractional pico farad involved. I built a self-capacitance one with Atmel's Q-Touch on a bog-standard mega329 (very similar to mega328 but includes segment LCD driver). The fact it worked first time still surprises me.

 

Are you using a decent X7R or equivalent charge accumulation capacitor ?

 

Last Edited: Thu. Jul 18, 2019 - 09:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

re X7R, C0G and U2J for 2% and/or 5%.

 

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

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

N.Winterbottom wrote:
Are you using a decent X7R or equivalent charge accumulation capacitor ?
gchapman wrote:

re X7R, C0G and U2J for 2% and/or 5%.

Neither explains sawtooth noise at 0.01 Hz.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Not only X7R but adjacent caps from the same strip for the sensor and guard collection ring. So they ought to be matched.

 

A colleague changed some of the charge and transfer times with no change to the resulting sawtooth.

 

'Tis a puzzler...

 

Neil