speeding up the touch sensors

womai

Senior Member
I just built up the touch sensor demo board and played around a bit. I noticed that the sensing takes quite some time when using the default touch sensor configuration. This can be an issue when scanning several sensors in a row - short key presses won't get reliably recognized. Luckily the touch16 command allows changing of the confguration. A config byte of %11101000 turned out to work very well - the price is reduced resolution because the maximum count is smaller, but it still works very reliably and fast for me - I get now over 100 scans per second, so if one scans e.g. 8 buttons that would mean an overall scan rate of better than 10 Hz.

symbol TOUCHCONFIG = %11101000
touch16 [TOUCHCONFIG], C.0, w0

Wolfgang
 

mega

New Member
I thought the response was a little slow too, so I had a play with the listing from the manual supplied with the AXE181, I've found these settings work well with my board.

I'm running full speed, I'll have a bit more of a play to see how fast it can read the touch inputs sometime.

I'm really warming to the 18M2, a great little chip, nice one Rev-Ed.


Code:
'Normally the default configuration is recommended, so the optional config byte
'is not required within the touch16 command. However the optional ‘config’ byte
'can be used to fine tune the touch command operation if desired.
'Config:
'bit7, 6, 5	 = Counter preload value (bits 7-5), e.g.
		'= 000 Oscillation count required = 256
		'= 010 Oscillation count required = 192
		'= 100 Oscillation count required = 128
		'= 110 Oscillation count required = 64
		'= 111 Oscillation count required = 32
		
'bit4,3 = 00 Touch sensor oscillator is off
		'= 01 Low range (0.1uA)
		'= 10 Medium range (1.2uA)
		'= 11 High Range (18uA)
		
'bit 2,1,0 = Counter Prescalar (divide by 2 up to 256) e.g.
		'= 001 Prescalar divide by 4
		
'The default value is %000 01 001
	'(Count to 256, low range, prescalar set to divide by 4)
'

#picaxe 18M2

setfreq m32
symbol TOUCHCONFIG = %11101000

main: 

touch16 [TOUCHCONFIG], C.0, w0 ; read sensor C.0 into word variable w0
if w0 > 3000 then
	high B.4 ; LED on
else
	low B.4 ; LED off
end if

touch16 [TOUCHCONFIG], C.1, w1 ; read sensor C.1 into word variable w1
if w1 >3000 then
	high B.5 ; LED on
else
	low B.5 ; LED off
end if

touch16 [TOUCHCONFIG], C.2, w2 ; read sensor C.2 into word variable w2
if w2 > 3500 then
	high B.6 ; LED on
else
	low B.6 ; LED off
end if

touch16 [TOUCHCONFIG], B.3, w3 ; read sensor B.3 into word variable w3
if w3 > 3000 then
	high B.7 ; LED on
else
	low B.7 ; LED off
end if

; debug ; optional display the variable values

goto main ; loop
 
Top