touch input

rob nash

Senior Member
hi,
i,ve been plodding along with this idea for to long, am trying to add serial touch input using 14m2 too a little bot am making
again using brass "drawing pins":p.I do need a better touch sensor was thinking off using coper stripes rev ed sells 3mm coper stripes i was thinking off slightly overlay a strip till i made an inch square solder dap each strip then cut into a circle does anyone see a problem making a sensor this way.
anyway the problem am having am using is after i calibrate the sensors they was'nt relaible reacting to my touch "hit and miss" to say but when i touch the download socket DSCF0012.JPG " which is in the center of the buttons please see pic" and the sensors they worked every time. I dont know why, but i thought i may roll with it as a feature again'st accendental touch or unwanted little fingers. i.ve had an off the wall idea of adding an 22uf cap on the serial out pin of download socket to ground. but because i not got the project on a breadboard i thought i ask here if adding the cap a good idea or not. so that what i observed and am going to look at some auto calibration routines.
rob,
 

eclectic

Moderator
Two points.

1. The copper strip idea. Just try it and see.
It won't cost a fortune.

2. What's your circuit and code?

e
 

rob nash

Senior Member
hi ecletric,
here a crude circuit diagramimg002.jpg " must learn to use diptrace". the caps are 100nf/uf not decided which pins am going use for a simple serial to the master prcessor which is 28x2.my code is even cruder than the pic but here it is
Code:
#picaxe14m2
#com3



symbol toMP   = c.4						' serout line to master processor
symbol fromMP = c.3

symbol bone  = b.5
symbol btwo  = b.4
symbol bthree= b.3
symbol bfour = b.2
symbol bfive = b.1


symbol led = c.2

symbol cmd = b14
symbol junk= w10

main:do

touch16[%11101000], bone,w0                                      ; read value into w0
if w0 > 464 then
high led                                             
pause 100
let cmd = 20
pause 10
gosub senddata
else
low led                                                 
endif

touch16 [%11101000],btwo,w1                                          ; read value into w0
if w1 > 480 then
high led                                                    ;
pause 100
let cmd = 30
gosub senddata
else
low led 
endif

touch16[%11101000], bthree,w2                                       ; read value into w0
if w2 > 472 then
high led 
pause 100
let cmd = 40
gosub senddata
else
low led 
endif

touch16[%11101000], bfour,w3                                     ; read value into w0
if w3 > 481then
high led 
pause 100
let cmd = 50
gosub senddata
else
low led ;
endif

touch16[%11101000], bfive,w4                               ; read value into w0
if w4 > 505 then
high led                                      
pause 100
let cmd = 60 
gosub senddata
low led
else
endif
loop


senddata:
pause 10
  sertxd("cmd=",#cmd,13,10)
   pause 100
  '	high toMP										' tell MP that data is available
'	pulsin fromMP,1, junk				                         ' junk is junk; we're just waiting
'	low toMP										' prepare to send data
	
'	serout toMP,N2400_4,(cmd) 
'	pause 10

  let cmd =0
 return
the send data sub routine is so rough :rolleyes: that once i get the touch working reliable i'll i,ll get it sorted
am still struglling to visalize what the code will look like on the 28x2 too receive the button press but still ploding.my firsrt idea is creative an interrupt routine using b.1 on the 28 but am no where near getting that sorted.
rob
 

techElder

Well-known member
This line has a problem with spacing syntax.

Code:
if w3 > 481then

I would try to put all of the TOUCH statements inside a tighter loop that doesn't exit unless one (or more) of the values is above a threshold.

Then test the "w.." values for branching and sending.

You should get better response.
 

rob nash

Senior Member
hello, I never did find a clear reason for the failure of the touch button but seems to work fine at the mo. i did have my test circiut close to my dodgie phone on the desk that did seem too interfere ie i hold the phone in the lft hand touched the pads nothing happened i let go of the phone the touch buttons work so kept the breadboard away from the phone and all is well, placing the following code here for safe keeping they work for am always changing the original code
Code:
'progrm runs on the 28x2 master processor.
'data from touch pad module

'===directives=====
#com 3
#picaxe 28x2
#no_data
#no_table

'====constant====== 
symbol fromtp = c.1
symbol totp   = c.4

'===variables======

symbol cmd = b0
symbol tpflag = pinc.1

'========== Begin main Program ===================
main:do
   pause 100
   if tpflag = 1 then
     gosub getdata
     
     select case cmd
     
      case 20
       gosub one
       
      case 30
       gosub two
      
      case 30
       gosub three
       
      case 40
       gosub four
       
      case 50
       gosub five
       
      case 60
       gosub six
      
      end select
       end if 
        
      loop  
      
      
 '=====End Main Program - Subroutines follow=====
 
 getdata:
     pulsout totp,10
     serin fromtp,n2400_8,cmd
      sertxd (#cmd,cr,lf)
     return   
     
     
     
 one:
 high b.0
 pause 200
 low b.0
 pause 30
  return
 
 two:
  high b.1
 pause 200
 low b.1
 pause 30
  return
  
 three:
     high b.2
 pause 200
 low b.2
 pause 30
    return
    
 four:
  high b.3
 pause 200
 low b.3
 pause 30
    return
    
 five:
     high b.4
 pause 200
 low b.4
 pause 30
  return
  
  six: high b.5
 pause 200
 low b.5
 pause 30
  return
the following code works on the 14m2 this sends the data to the master.
Code:
#picaxe14m2

symbol toMP   = c.4						' serout line to master processor
symbol fromMP = c.0

symbol bone  = b.5
symbol btwo  = b.4
symbol bthree= b.3
symbol bfour = b.2
symbol bfive = b.1


symbol led = c.2

symbol cmd = b14
symbol junk= w10

main:do

touch16 bone,w0                                      ; read value into w0
if w0 > 3740 then
let cmd = 20
gosub senddata                                                
endif

touch16 btwo,w1                                          ; read value into w0
if w1 > 3930 then
let cmd = 30
gosub senddata
 endif

touch16 bthree,w2                                       ; read value into w0
if w2 > 3857 then
let cmd = 40
gosub senddata
endif

touch16 bfour,w3                                     ; read value into w3
  if w3 > 4140 then
    let cmd = 50
    gosub senddata
endif

touch16 bfive,w4                               ; read value into w4
if w4 > 4430 then
 let cmd = 60 
gosub senddata
endif

loop


senddata:
 pause 10
 high led
 sertxd (#cmd,cr,lf)
 high toMP										' tell MP that data is available
 pulsin fromMP,1, junk				                         ' junk is junk; we're just waiting
  low toMP										' prepare to send data
   serout toMP,N2400_4,(cmd) 
  let cmd = 0
 low led
 pause 30  	
 return
 
Top