Shop OBEX P1 Docs P2 Docs Learn Events
Resistive touch-buttons--how to use? — Parallax Forums

Resistive touch-buttons--how to use?

John AbshierJohn Abshier Posts: 1,116
edited 2011-06-24 17:29 in Propeller 1
How do these buttons work? I have code to light an LED and echo to PST screen when a button is touched. But the LEDs seldom light if I touch the button with my finger. I can get them to work, most of the time, if I touch the center stripe of the button with a jumper wire and the other end of the jumper wire is in the air.

John Abshier
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
  #1, HOME, #8, BKSP, TAB, LF, CLREOL, CLRLB, CR, #16, CLS      ' PST formmatting control  
OBJ
  Sio  : "FullDuplexSerialPlus"        

Pub Main | i
  Sio.start(31,30,0,115200)  ' Rx,Tx, Mode, Baud
  dira[16..23]~~
  dira[0..7]~
  repeat
    outa[16..23] := ina[0..7]
    sio.dec(ina[0..7])
    sio.tx(CR)
    waitcnt(clkfreq / 2 + cnt)

Comments

  • LeonLeon Posts: 7,620
    edited 2011-06-04 08:50
    Which buttons are those?
  • John AbshierJohn Abshier Posts: 1,116
    edited 2011-06-04 08:53
    The buttons connected to P0..P7 at the bottom of the board.

    John Abshier
  • LeonLeon Posts: 7,620
    edited 2011-06-04 08:59
    Which board?
  • jazzedjazzed Posts: 11,803
    edited 2011-06-04 09:56
    Leon wrote: »
    Which board?
    Surely not the QuickStart board :)
  • LeonLeon Posts: 7,620
    edited 2011-06-04 10:02
    I'm tending towards that conclusion. Resistive buttons at the bottom of the board and P0-P7 are the giveaway. :)
  • John AbshierJohn Abshier Posts: 1,116
    edited 2011-06-04 15:19
    It is the Quick Start board.

    John Abshier
  • jazzedjazzed Posts: 11,803
    edited 2011-06-04 19:49
    How do these buttons work?

    John, I'm sorry you haven't received a helpful reply so far.

    I saw someone playing with a QuickStart board at UPEW so I know code is out there somewhere. Maybe it will show up here. Meanwhile, I'll try to help.

    My touch button theory is a little dated, but here's what I think should happen:

    You should note in the schematic (Thanks Leon) that the touchpads make up part of a series RC network. Your finger will behave like a capacitor when it is on a touchpad. To read touchpad on P0 you will first have to apply a voltage to it. That is: use dira[0]~~ and outa[0]~~ to set P0 to output logic high. Then you should set P0 to an input with dira[0]~ and read the pin with "somevariable" := ina[0]. If somevariable remains high after becoming an input, then you can light the LED else turn it off. Skin capacitance can vary.
  • LeonLeon Posts: 7,620
    edited 2011-06-04 21:26
    I think that the skin actually behaves like a resistor in this case. Capacitive touch buttons are more common, and work a lot better:

    http://www.microchip.com/en_us/technology/mtouchbuttons/applications.html
  • AribaAriba Posts: 2,690
    edited 2011-06-04 22:23
    Yes it's the restance of the skin that is used here to pull the pin down if the finger is on the pad.
    I would say you need to output first a high pulse and then switch the pin 0..7 to input and read the state.
    If it is still high the button is not touched, if you read a low it is touched.

    Try these changes to your code:
    _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
      #1, HOME, #8, BKSP, TAB, LF, CLREOL, CLRLB, CR, #16, CLS      ' PST formmatting control  
    OBJ
      Sio  : "FullDuplexSerialPlus"        
    
    Pub Main | i
      Sio.start(31,30,0,115200)  ' Rx,Tx, Mode, Baud
      dira[16..23]~~
      dira[0..7]~
      outa[0..7]~~
      repeat
        dira[0..7]~~
        dira[0..7]~
        outa[16..23] := ina[0..7]
        sio.dec(ina[0..7])
        sio.tx(CR)
        waitcnt(clkfreq / 2 + cnt)
    
    Maybe you need a little delay after switching the pins to input, I can't try - my Quickstart has not arrived yet...

    Andy
  • jazzedjazzed Posts: 11,803
    edited 2011-06-04 22:40
    Well at least something useful came out of it all .... :)
  • John AbshierJohn Abshier Posts: 1,116
    edited 2011-06-05 08:14
    Thanks everybody. Andy, your code works. It seemed to be a little more responsive with a 100 uSecond wait after switching the pins to input.

    John Abshier
  • NikosGNikosG Posts: 705
    edited 2011-06-06 02:06
    Can we use these touch-buttons as an input device (like a mini keypad) to enter numeric data in our propeller program?
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-06 13:20
  • RaymanRayman Posts: 14,876
    edited 2011-06-09 08:17
    It's not clear to me that they couldn't be used as capacitive switches too...

    Looking at the code, it seems like it is looking for resistance to bleed off the pin's inherent capacitance.

    But, it seems you could also to RC-time on each pin to detect an increased capacitance there too...
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2011-06-09 09:58
    It definitely has to do with the skin on your finger tips. My fingers are inherintly dryer than most, so when David Carrier was showing me one of these boards at UPEW, I could not get it to work. He touched the buttons and it worked flawlessly. After moistening my finger on the side of my soda can and rubbing off the water drops, my fingers would make it work fine. I have the same issue at work with our ESD tester. If I don't put some ESD lotion on my fingers before I test, I can't pass. I am about as dry as my humor I guess........
  • veluxllcveluxllc Posts: 30
    edited 2011-06-12 10:33
    Using these demos, such as the led to button tracking one, it worked fine for the first day. A couple days later, I pick it up and nothing. wet my fingers and dry them, nothing.. BUT, if I run my finger across the pads with a single layer of a napkin, they will work but only if I'm moving. If I stop on one, they don't work. Also, random input from bumping or touching the mounting holes or simply getting to close to the two resister packs (or capacitor packs???) near P16 and P23 LEDs.....

    The one MAJOR flaw outside of this is a simple way to disconnect these. If you want to use external switches, you are still prone to problems from the pads. A jumper post should have been supplied to disable those inputs completely.. maybe one for the outputs as well.. at least a trace between vias so the user can cut it, install their own jumper posts or use it for other purposes.

    Okay, one more... a place to put our own connections for power to use the on board IC. Also seems the 5mhz clock is not removable on this unit, but not a real issue.

    Any recommendations for the buttons are greatly appreciated.

    Velux
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-06-12 10:53
    I've modified the demo code so it behaves better (at least on my board).

    The thread where I posted my code also has several links to other threads which discuss the button pads.

    I've also posted some pictures of a mezzanine board I'm working on.

    I hope you give my code a try and let me know if it works for you.

    Duane
  • Kevin McCulloughKevin McCullough Posts: 62
    edited 2011-06-24 17:29
    veluxllc wrote: »
    Okay, one more... a place to put our own connections for power to use the on board IC.
    Velux

    Hey Velux,
    Depending on how you want to power the board, there are a couple options:
    a) You can use VIN (pin 40) to provide an unregulated supply. You will probably want to include a diode in series with this input to prevent any possible back-flow when connected to USB power if your VIN voltage drops too low. This post has a little more info about this: http://forums.parallax.com/showthread.php?132117-Quick-Start-Board-Questions&p=1011691&viewfull=1#post1011691

    b) You could also power the 3.3V supply directly as long as you won't be plugging the device into USB power (or using VIN to provide power). The regulator should be able to tolerate being back driven when there is no input voltage; however you just wouldn't want to have an external 3.3v regulator trying to compete at the same time with the on-board 3.3v regulator.

    Hope this helps. :-)
Sign In or Register to comment.