18M2 touch input temperature sensitivity

Has anyone else found that the touch imput levels vary massively with temperature?
Here are are the results of some tests today on input B.6

7.6 degrees C open 6642 touched 6784
13.5 degrees C open 6761 touched 6889
19.7 degreesC open 9444 touched 10200

That suggests that using absolute thresholds will be very unreliable

I now use the self tuning algorithm below, but it is still unreliable at temp extremes with the thresholds it uses of around 500 on and 300 off relative to the open reading.

These were done with a solar powered floating picaxe connected via the direct PC serial out port Com1. I have used AXE 027 cable too but its plug has gone intermittent so I have had to suspend that.

Note: in another application I am getting strange readings using the Pulsein command which also seem to be temperature dependent. Could it be that the resonator frequency is changing ? I doubt this becase the SERTXD seems to contuinue to work normally.


CAN ANYONE GIVE ME ANY ADVICE TO GET AROUND THIS PLEASE??

Here is the code I use. The rest of the code ( memory almost full) seems to continue to work as expected.

; ************************************
; Touch key control

; Autotune Touch sensors backgound task (don't do this for positive changes eg when a key preseed)
; these are sensitve to battery voltge temp etc so need Auto tune - say 128 smoothing to get average

:FIRST TEST ;DEFAULT touch16 [%10010010], touch_enter, ww1 ; scan touch sensors and save (Touch default values)
; @5.5 v 7949 and 8926 touched
; @2.5 v 8049 and 9125 touched
; so try set level at 8500


touchin: ;goto touchin10 ; TEMP JUMP OVER UNTIL DEBUGGED

let ww1 = looptimer & mask7 ; scan every 7 loops (appr 1 secs) (diff timeslot
if ww1 != 5 then goto touchin10 ; not time for a scan yet so jump on;l

if mode_notouch = 1 then goto touchin10



touch16 [%10010010], touch_enter, ww1 ; ; scan touch sensors and save

read touchenter_tunel, ww2l ; get the tuned level (this is preset on reboot to around 15,000
read touchenter_tuneh, ww2h
let ww3 = ww2 + touch_enterhigh

If ww1 > ww3 then goto touchin02 ; is this passed the key pressed threshold?


; no key pressed so add 1/128th of this reading to tuning level

touchin01: let ww3 = ww2 + touch_enterlow
If ww1 > ww3 then goto touchin10

let ww3 = ww1/128
let ww4 = ww2/128 ; reduce cumulative tune value by 16th
let ww2 = ww2 - ww4
let ww2 = ww2 + ww3 ; add 16th of latest reading

write touchenter_tunel, ww2l
write touchenter_tuneh, ww2h

let battery_pulse = 1 ;; set flag to pulse battery volts on next touch
let mode_comtest = 0 ; if touch released then clear comtest

goto touchin10


; process for a key touched to action it

touchin02:
If ww1 > ww3 then goto touchin03 ; is the key still pressed eg past threshold?

goto touchin10


; process for key first touched to pulse out battery voltage


touchin03: if battery_pulse = 0 then goto touchin04 ; if comtest already running jump over batt volts

peek battery0_volts, ww1l ; access battery volts
wb1 = ww1l / 10 ;Isolate the 10's
gosub pulseout
wb1 = ww1l // 10 ;Isolate the 1's
gosub pulseout

let battery_pulse = 0 ; battery volts pulsed so dont repeat it


; process to carry out comtest- bleeping when each station packet received when button held touched

touchin04: let mode_comtest = 1 ; set coms test flag to trigger recive


touchin10:goto scanloop ; all done so go back to scan loop


pulseout:
do until wb1 = 0
sound sounder,(70,100,0,100)
dec wb1
loop
nap 6
return '
 
Yes!

I found the same thing a while ago when I tried to use the touch input to measure the capacitance of a humidity sensor. The shift with temperature is absolutely massive, and was something I found I couldn't compensate out easily, as it varied from chip to chip.

It's a pity, as I thought that the touch capability might be an easy way to make a simple capacitance meter.
 
Derth of Knowledge

There is so little available for the TOUCH & TOUCH16 commands. I was really wanting to use TOUCH to create an intrinsically-safe switching menu, but I'm not so sure now.

Even Microchip has moved away from CSM (frequency based) towards CVD or CTMU (voltage based.) That's not to say that CSM is not workable, but there are acknowledged problems.

I found this application note (AN1334 "Techniques for Robust Touch Sensing Design") to be very useful.
 
Even Microchip has moved away from CSM (frequency based) towards CVD or CTMU (voltage based.) That's not to say that CSM is not workable, but there are acknowledged problems.

That's not true, some newer PIC chips have CSM and some older chips the CTMU. It's basically a design-time silicon cost decision (CTMU is more silicon, hence a more expensive silicon die in every chip), not a decision based on if one method has issues or not.

On M2 parts the touch command is CSM based, on X2 parts it is CTMU based.
However with all touch sensing systems some calibration routines are normally required.
 
Their own marketing doesn't even mention CSM ... http://www.microchip.com/pagehandler/en-us/technology/mtouchbuttons/technology/sensing-methods.html

Their "mTouch" modules have changed methods, too.

I'll be developing my own routines without much help from the manuals (except what I ask for here, of course!) There's no mention of any calibration required, but whatever is available from Microchip I will read diligently.

The goal would be to get the same switching functionality as a mechanical-styled switch. That will make TOUCH a nice addition to the line instead of just an item on a bulleted list.


That's not true, some newer PIC chips have CSM and some older chips the CTMU. It's basically a design-time silicon cost decision (CTMU is more silicon, hence a more expensive silicon die in every chip), not a decision based on if one method has issues or not.

On M2 parts the touch command is CSM based, on X2 parts it is CTMU based.
However with all touch sensing systems some calibration routines are normally required.
 
Last edited:
Thanks for the info folks. I quess I will need to look more closely at (AN1334 "Techniques for Robust Touch Sensing Design") perhaps to see if there is a way around that variation (eg series resistor to reduce noise) I wil also try turning the clock freq down to 4 for the touch command as the manual does not state the efffect of clock rate change. I was hoping that someone might have done more work around the [configuration] parameters to minimise this drift problem. My application is a very simple one - just wait around reguarly reading "no touch" and smoothing this into its tuning value, until someone touches the "test" button such that it exceeds this by a fixed threshold relative to the tuned no touch value, then run some diagnostics. The problem is that the thresholds I need to detect the (very infrequent)button touch at one temperature result in false touch triggering at lower temperatures... a pest as this is a 24/7 real time data gathering application.

Any more ideas will be appreciated please.
 
Peter, it looks like a touch sensor is going to need stored parameters to function reliably. Perhaps minimum, maximum and average touch numbers, and as you're finding out, a touch sensor may need to be keyed to a temperature adjustment table with all these parameters.

The gentleman "Dan aka Tarzan" from this link ( http://www.picaxeforum.co.uk/showthread.php?16566-AXE181-PICAXE-18M2-TOUCH-SENSOR-DEMO-BOARD-v1-0-0-Auto-Configuration-by-Tarzan&highlight=touch ) has done some work on it, but his code is spaghettized to the point that I'd have to sit down and work on it for awhile to figure it out.

The other link that Technical placed ( http://www.picaxeforum.co.uk/showthread.php?15993-PICAXE181-Selfcalibrate-touch-sensor-code&highlight=touch+calibration ) is some code snippets that hadn't been completed or debugged, but do offer some advice that seems important.

A couple of items is not much to work with, but it's better than I had.
 
There is also MPR121 that may suit. I have been playing with one from DFRobot, Sparkfun also have them.
My example for the AXE181 is nothing special only the selection for touch16 config is any good.
 
Limited experience but I found it worked reliably with a battery powered design, as soon as I added a 12 volts PSU and regulator, the switching thresholds were all over the place and it either cycled itself, or did not detect. Shame as it was for a touch controlled LED desk lamp project.
 
So many functions in the picaxe require a very stable voltage reference to get stable results, i dont buy the problem of the Vreg causing fluctuations in the readings, it more of a matter of your filtering on the Vreg / power supply was not adequate, i consistantly use a 5 volt reg on almost every circuit and dont have the problems many claims the Vreg causes.
Try adding a minimum of 330uf capacitor before the Vreg (1000uf would be better) and a 10uf cap after the reg, also a decoupling cap to the picaxe is important too.
 
"The gentleman "Dan aka Tarzan" from this link ... has done some work on it, but his code is spaghettized.."

I have never seen a better example of clear, linear, self-explanatory code than Tarzan's touch16
demo. Without a single goto it deserves a better description than spaghetti.
 
fgnash, you are absolutely right! Dan does have superb coding style. I referenced the wrong code in my comment above. I was studying a different program and mixed them up. My apologies to Dan!
 
touch16 [%00011001], 4, w2 'Read and store a background capacitance value on pin 4
Gives me a steady enough reading. Note the settings of various bits is well worth tinkering. I think this gives max 'power' or drive current to the charge / discharge ramp oscillator.
Yes temperature Does affect things but this can be reset a little with dual temperature and level measurement in most of our 'Abiotic' enviro / weather station type experiments that are now streaming nicely into a Pi.. Note underground HT electric fence cable gives almost mm H2O per count and the temperature probe becomes a 'good enough' -ve / ground capacitive reference.
Some photos...

DSC_4147.jpg
 

Attachments

  • IMG_4068.jpg
    IMG_4068.jpg
    76.9 KB · Views: 6
For general information. I have completed a range of tests on 08M2 hardware and found mainly:
* Using the higher power drive current option Using High Touch Sense Drive ~ %00011001 is best
* Voltage variations have little effect
* 10pF and 33pF dummy loads were added to the breadboard
The chip was placed in a temperature control state and ranged over 20 Deg C from 20 ~ 40 Deg C
1770599108828.png
Above shows 'Significant' count variation with temperature

1770599364434.png
The High High Power Touch Sense Drive ~ %00011001 seems a lot less sensitive to temperature and is the mode I use in Practical water level detection, monitoring etc. A practical and more accurate system could be set up using two parallel Cap Touch inputs and using one input for Measure and one for refference.
 

Attachments

  • 1770599293536.png
    1770599293536.png
    26.4 KB · Views: 0
I imagine the 08M2 / 18M2 internal circuitry wpould be similar enough but hope this adds to the general knowledge.
Voltage effect: Almost none on an 08M2 at least.

1770599911977.png

Default 08M2 on a Breadboard.
Note 'Grounded' adjacent row capacitance on a breadboard = a count change of up to 10 ~ 30 counts.
 
Back
Top