Need a cheap touch sensor idea.. here it is


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default Need a cheap touch sensor idea.. here it is

    Hi all! Even if there's some built-in solution and dedicated IC to do the job, here's my few cents solution. Not that it is the only one and safest solution but it's working for me on few home-dedicated application.

    The touch sensor itself:
    almost everything you have on hand and conductive.

    The only thing you have to do is to touch the XYZ conductive material and TADA! No mechanical switch or push button... only one floating piece of conductive material.

    Maybe not suitable in harsh environement, but working great in home application.

    The schematic:
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=570&stc=1&d=1130515579 ">

    The code:
    Code:
    '   Few cents touch sensor
    '   ======================
    '   Using : PIC12F629
    '    
    '   Circuit is quite simple. One pin(GP4) is used as a signal generator.
    '   This pin send signal to all "virtual push button" (GPIO<2:0>)
    '   via 3 X 22K resistor. The touch sensor could be almost everything 
    '   conductive.  
    '
    '   Once a sensor is touched, the program will blink a LED as follow
    '                            GPIO.0 => 1 Blink
    '                            GPIO.1 => 2 Blink
    '                            GPIO.2 => 3 Blink
    
    
    '   PIC config and programming mode
    '   ===============================
        '
        @ DEVICE  PIC12F629,INTRC_OSC_NOCLKOUT ' internal RC osc
        @ DEVICE  PIC12F629,MCLR_OFF           ' Disable external MCLR
        @ DEVICE  PIC12F629,WDT_OFF            ' Disable WatchDog timer
        @ DEVICE  PIC12F629,PROTECT_OFF        ' Disable device protect
        @ DEVICE  PIC12F629,CPD_OFF            ' Disable Code-Protect
        @ DEVICE  PIC12F629,PWRT_ON            ' Enable Power-up timer
        @ DEVICE  PIC12F629,BOD_ON             ' Enable Brown-out detect
    
    '   I/O Alias definition
    '   ====================
        '
        LED        VAR GPIO.5
        Generator  var GPIO.4
        
    '   Hardware definition
    '   ===================
        '                           
        TRISIO = $0F ' GPIO<3:0> as input
                     ' GPIO<5:4> as output
                     '
        CMCON  = 7   ' Disable internal comparator
        
    '   Variable definition
    '   ===================
        '
        Sensor var byte
        Loop   var byte
    
    '   EEPROM assignement
    '   ==================
        '
        data @3,3,0,2,1 ' table to convert 'Sensor' variable result to according
                        ' LED blink. See Result list bellow
        
    '   Software/hardware initialisation
    '   ================================
        '
        led = 0
        generator = 0
        
                
    Start:
        ' /////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
        ' /                              Start                                    \ 
        ' /////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
        '
        ' Short explanation of the whole thing.
        '       1. Send a high level to all sensor input => GPIO<2:0>
        '       2. Read GPIO port 
        '       3. Send a low level to all sensor input
        '       4. Keep only GPIO<2:0> bits
        '       5. Test result
        '
        ' If no sensor has been touched, the result will be 7 => 0000 0111, case
        ' else, the body capacitance will introduce sufficient delay between
        ' step 1 and 2 wich will keep the according bit to 0.  
        '
        ' Results will be as follow
        '               NoSensor => 0000 0111 => 7
        '               GPIO.0   => 0000 0110 => 6
        '               GPIO.1   => 0000 0101 => 5
        '               GPIO.2   => 0000 0011 => 3
        '
        repeat
            Generator = 1       ' enable sensor power
            Sensor = GPIO       ' read sensor
            Generator = 0       ' disable sensor power
            Sensor = Sensor & 7 ' keep only Sensor bits
                                '        
            until Sensor != 7   ' redo the test untill one sensor is touch
        '
        ' Now we will flash an LED to confirm wich sensor has been touch
        '                      GPIO.0 => 1 Blink
        '                      GPIO.1 => 2 Blink
        '                      GPIO.2 => 3 Blink
        '
        read sensor,loop ' convert result to blink
        repeat
            LED = 1
            PAUSE 200
            lED = 0
            PAUSE 200
            loop = loop - 1
            until loop = 0
    
        goto start ' do it again...
    Have fun!
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by mister_e; - 28th October 2005 at 21:24.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    644


    Did you find this post helpful? Yes | No

    Default Any ideas???

    Hi all,
    Currently, I'm working on a project where it would be nice to have a cheap touch sensitive switch. So, I looked at mister_e's entry about a touch sensor. I think it's a very clever idea, but there is a problem I can't make it work. I'm using a pic16f84 at 4 MHz, the same frequency that uses mister_e's pic. I have tried different combinations of resistors and I have added some capacitors but still it doesn't work.
    When using an oscilloscope I can see the input signal at the input ports goes lower when touched by a finger but apparently not low enough to read a zero.
    Does anybody have any ideas on how to make this work? Probably adding an op-amp would do the job. Thanks.

    Robert.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hello Robert,
    Well we know it will not work without changing a few things for the 16F84, so post what you have and let's look and see. Open a new thread in PBP so as not to hijack this example thread.
    Last edited by Archangel; - 17th March 2009 at 06:13.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    Do NOT put extra capacitance at the inputs beside the sensor itself.

    Even the Osc. probe will load inputs.

    Maybe play with the 22k resistors. Also good idea would be to compare spcs of the two PIC's.

    Ioannis

    P.S. If necessary, admins move this message to keep thread clean. No problem.

  5. #5
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    What a great idea, is it working reliably - I have a device I need this sort of thing for, pref very cheap with little extra in the way of components, did rsocor01 ever get it running? He didnt mention it on his other thread. Just wondering. would higher value resistors and a longer charge period help with the sensitivity?

    I need this unit to be fairly reliable, is it likely to do this if set up right? Hopefully will be mass produced. Most commercial capacitive systems take a running average and are constantly resetting their zero point to allow for atmospheric conditions etc dont they?

  6. #6
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    644


    Did you find this post helpful? Yes | No

    Default

    George,

    No, I never got it to work the way it's explained in this threat. The way to go is with the series PIC16F72x. They work great. Refer to the threats started by byte_butcher about his project. That should help you.

    Robert

  7. #7
    Join Date
    Feb 2016
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: Need a cheap touch sensor idea.. here it is

    Hi, I want to use a 12F675 for this project. I replaced 12F629 with 12F675 in the code, since 675 chip is almost identical to 629 chip. It compiled without any errors. But the LED just keeps bilinking. doesn't respond to touch. Can someone tell me, what else do I have to change in the code to make it work. Thanks in advance...

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Need a cheap touch sensor idea.. here it is

    Start a new thread in General forum and post your code, all of it, easier for people to help you.

    Robert

Similar Threads

  1. Any Ideas for a cheap touch sensor??????
    By rsocor01 in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 19th October 2013, 00:33
  2. Touch screen 4-wire interface
    By Demon in forum General
    Replies: 6
    Last Post: - 31st December 2011, 18:02
  3. Relaxation oscillators (for capacititive touch sensing)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 6th December 2009, 22:03
  4. touch switch dimmer
    By helmut in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 18th August 2007, 11:25
  5. Touch Screen Wish List!!!
    By Amity in forum PBP Wish List
    Replies: 2
    Last Post: - 15th September 2005, 14:40

Members who have read this thread : 4

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts