Shop OBEX P1 Docs P2 Docs Learn Events
Resistance / Capacitance Touch switch or sensor -- by touching 1 or more electrodes? — Parallax Forums

Resistance / Capacitance Touch switch or sensor -- by touching 1 or more electrodes?

Winston TWinston T Posts: 6
edited 2012-12-27 18:14 in Accessories
Hi Guys,

I finished reading through the 'What's a Microcontroller Kit?' and am excited about the possibilities of what can be done with electronics! This stuff is amazing! I still, however, am a complete newbie and can barely interpret much of the technical jargon on this forum!

One of the first test activities that I am interested in doing with my Basic Stamp is creating what I believe to be called either a capacitance touch switch or a resistance touch switch.

The activities that I want to achieve are:

1st) to create a "touch switch" or "touch sensor" that is sensitive enough to detect my finger touching it (which, in turn, triggers an LED light to turn on or off).

2nd) create a touch switch that is so sensitive that it could detect even an ant crawling over it or a piece of hair falling on it (which would trigger an LED light to turn on or off, as well).

and then 3rd) to make a "smart" touch switch where I am capable of adjusting or calibrating how sensitive the switch is to touch so that its (on/off) response depends on what touches it.


Is this possible using the Basic Stamp 2?


I've read in Wikipedia that:

A capacitance switch needs only one electrode to function. The electrode can be placed behind a non-conductive panel such as wood, glass, or plastic. The switch works using body capacitance, a property of the human body that gives it great electrical characteristics.

A resistance switch needs two electrodes to be physically in contact with something electrically conductive (for example a finger) to operate. They work by lowering the resistance between two pieces of metal. It is thus much simpler in construction compared to the capacitance switch. Placing one or two fingers across the plates achieves a turn on or closed state. Removing the finger(s) from the metal pieces turns the device off.


My problem is that I'm having trouble translating this over to the goal of my activities (described above) using Basic Stamp 2!

How would you make a touch switch (on the Basic Stamp) that, for example, can make use of one or more wires (or one or more contact points, electrodes, surface, etc.) as a touch sensor?

And then how would it be programmed as an On/off switch?

I've spent a few days looking for this information and still haven't been able to find anything specific!


Winston

Comments

  • Winston TWinston T Posts: 6
    edited 2012-07-03 21:56
    I still haven't been able to solve this but have found several videos on YouTube that demonstrate on a general breadboard(?) exactly what I am trying to figure how to do on my Basic Stamp. The schematics are listed in the YouTube video but I'm still unable to figure out how to apply it to the Basic Stamp.

    How the Capacitance touch sensor (button-switch) works
    http://www.youtube.com/watch?v=0GmIkyEzHnk

    How the Resistance and the AC Hum touch sensor (button-switch) works
    http://www.youtube.com/watch?v=QpY5wcX0B-g

    I really do feel that there should have been a full chapter devoted to this topic in one of the Basic Stamp educational kits! While typing this, I just found in the "Similar Threads" links below a thread by Andy Lindsay which seems to cover the matter in some way. But I really wish someone knowledgeable on this topic could chime in with advice! A full word search through the awesome book "What's in a Microcontroller?", for example, doesn't even show up as having the words "touch sensor" in it so I'm at a bit of a loss!

    I seriously feel that the topic of touch sensors should be given equal weight as push buttons. Can anybody help out on this? : )

    The link to Andy's post that seems to cover the topic is below. I just found it a few minutes ago and haven't yet been able to determine if it covers what is shown in the YouTube videos. Any help would be appreciated!

  • IroneIrone Posts: 116
    edited 2012-07-04 02:20
    Winston,
    Here is a resistance touch switch using a CMOS IC. The VDD is your 5 volts. The E must be also tied to 5 volts, and your ground is your VSS. You can then take your output and connect it to a pin of your choice. ( I would use a 220 ohm resistor even though the 4000 series puts out a small amount of mA just to get you used to it) You can then take this information and pause it or toggle it or do whatever you need to do.

    Standard Touch Switch JPEG.jpg



    Also remember there are 4 nand gates per IC so inputs you do not use have to be all grounded or connected to 5 volts
    990 x 615 - 29K
  • Winston TWinston T Posts: 6
    edited 2012-07-05 08:38
    Hi, Irone! And thanks a bunch for responding!

    This is very frustrating for me! I'm still unable to solve this problem! Also, please remember that I'm a genuine newbie and so far have only gone through the "What's in a Microcontroller?" kit. I'm actually unable to determine, for example, exactly what the CMOS IC is that you're referring to and where it can be found! Is there a specific part available to be purchased on this site? For a second, I assumed the CMOS IC was the digital potentiometer (AD5220) included in the microcontroller kit! But I am still unsure?!

    Making both a resistance or capacitance touch sensor using Basic Stamp is very, very important to me! Most importantly, to be specific, is a capacitance touch sensor. It is only a matter of time before Parallax gets about $500 out of me as I plan to go through almost all of the educational kits to learn as much about electronics as possible! This stuff is that fascinating to me!

    But I prefer to get to capacitance (as well as resistance) touch sensing almost immediately.

    The website article:
    http://www.eetimes.com/design/analog-design/4009869/Building-a-reliable-capacitive-sensor-interface

    ...appears to state in the article (as well as in the schematics) that a "555 counter/timer" as well as something else called a "comparator" is needed to make a basic capacitance touch sensor. The link in the YouTube video above (in my second post) demonstrating the capacitive touch sensor also mentions that it is using a "555 timer" in the example. On the Parallax website the "555 Timer IC CMOS" is available. The "555 Timer" is also a part of the Parallax - Basic Analog and Digital (Student Guide) Kit.

    The other part of the equation is this issue of a "comparator". I'm having trouble finding specific information on it -- on what it is? How it can be set up and programmed to make a capacitance sensor, etc.?

    I did, however, find listed on the Parallax website that in one of the activities in the Basic Analog and Digital Kit is "Building a comparator". My plan is to order this kit and then go through the information trying to find out what I can to eventually piece together a capacitive touch sensor.

    But if there is anyone that knows very well how to go about setting up a capacitance touch sensor on their Basic Stamp, I could seriously use some schooling on it! Please help!@ !

    I'm trying to put together a resistance touch sensor as well (but the capacitance one is also a priority)!
  • IroneIrone Posts: 116
    edited 2012-07-06 10:07
    Winston,

    The 555 timer has been in business for more than 30 years. It is hard to believe how many things you can do with it. There is a book on sale at Radio Shack by Forrest M. Mimms That explains about some things you can do with the timer without much math. Here is a website that explains it without too much more math http://www.sentex.ca/~mec1995/gadgets/555/555.html

    The 4011 is a logic gate. An AND gate is like having two switches wired up in series so they both have to be on to put power to a light. The 4011 is a NAND gate which has an inverter at the end which gives you the opposite of what you have which is needed for this circuit.

    I have done some searching on the Basic Stamp 2 and have found out there is a frequency counter in the Stamps Works Manual.PDF on page 101. It needs a 555 timer, some resistors and a variable pot. All these can be picked up at your Radio Shack. Perhaps we can use this with another one that is powered by a 555 to stretch the pulse and do some addition for separating the correct answer.
  • IroneIrone Posts: 116
    edited 2012-07-06 20:49
    Winston,

    It was so hot in central PA today I thought that downed tree in my backyard could stay there a couple of days and I would play at the table with my BS2. I altered the program from the Stamp Works Manual, made a homemade capacitor from a single sided copper plated not drilled circuit board cut into two one inch squares separated by scotch tape (it measured 220 picofarads), changed the original capacitor to one marked 20J (189 picofarads I believe my meter is kinda cheap) and added a 470 ohm resistor from pin 14 thru a LED to ground.

    Code:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' -----[ Program Description ]---------------------------------------------
    '
    ' This program counts the number of events in 100 mill1seconds on my homemade
    ' capacitor and calculates a number from it. Then when you put your finger
    ' on the capacitor the frequency increases which gives you a larger number.
    ' Then this number can be compared to a number over your first reading and
    ' a number lower than the second reading with higher capacitance to make a
    ' high for your LED.
    
    ' -----[ I/O Definitions ]-------------------------------------------------
    FreqIn PIN 15                       ' frequency input pin
    ' -----[ Constants ]-------------------------------------------------------
    OneSec CON 100                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ' capture window = 1 sec
    ' -----[ Variables ]-------------------------------------------------------
    cycles VAR Word                     ' counted cycles
    ' -----[ Program Code ]----------------------------------------------------
    
    Main:
    DO
    COUNT FreqIn, OneSec, cycles        ' count for 100 milliseconds
    DEBUG HOME,
    "Frequency: ", DEC cycles, " Hz "   ' display frequency
    
        IF (cycles > 2080) THEN
          HIGH 14
          PAUSE 50
          ELSE
          LOW 14
          PAUSE 50
        ENDIF
    
    LOOP
    

    When you make your own homemade capacitor you may have to check it and change the greater than number.

    If you need help setting up (my lack of instructions) please ask.
  • IroneIrone Posts: 116
    edited 2012-07-06 20:58
    This did not work out properly, It was supposed to be a reply to Winston!!! I need more practice setting things up.
  • IroneIrone Posts: 116
    edited 2012-07-06 21:20
    Winston,

    I got a code and part setup that works, but I am too stupid to get it here!!! I will try again tomorrow after reading some more instructions.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2012-07-07 00:41
    When I caught the duplicate title in the forums, my "spammy sense was tingling". After realizing the cause, I merged the threads to keep the original thread discussion intact. Happy coding!
  • Winston TWinston T Posts: 6
    edited 2012-07-07 15:57
    Hi Irone,

    I really appreciate what you are doing! I must admit that, being very new to electronics, I am about seven steps behind on pretty much every explanation that I come across (pertaining to electronics design and programming). I got the "What's a Microcontroller?" kit almost two months ago. In the past several weeks, however, I have been trying to learn as much as possible on electronics (usually reading, working through the Basic Stamp activities, etc. for about five hours a day)! I'm almost falling in love with it! I would have gotten into it at least a decade ago had I known it would be so fulfilling! It's only a matter of weeks before I begin attempting to prototype invention ideas and such!

    For the first time (just this morning), I put together a working motion detection using the phototransistor as well as using a "helping hand" device to hold a flashlight toward the light sensor, etc. This was very uplifting for me as a working motion detector was one of my original goals when I purchased the "What's a Microcontroller?" kit! Additionally, this should also reveal my status as a complete beginner!

    So, to be honest, I probably do need to have my hand held (just like a child) and guided to making a capacitance sensor using Basic Stamp! I'm a bit frustrated that the kits don't seem to have clear instructional photos, etc. along side schematics that clearly spell out different ways in which one can put together these sort of sensors (i.e., custom capacitance and resistance touch switches)!

    The Parallax - Basic Analog and Digital student kit... showed up in the mail just today so I have all of the parts that are in that particular kit now (the 555 timer IC being one). I'm not sure how to use it yet -- but that's not to say that I'm not spending all of my energy into learning about Basic Stamp and electronics, etc. It's getting my all!

    I'm going to need at least a day to try to interpret what you've posted! My brain is fried from already having spent quite a few hours today working through the Basic Stamp kit(s)! Any additional details (on the parts, for example) would also be greatly appreciated!

    In fact, even the simplest touch sensor (circuit) would prove to be a milestone for me! I'd prefer to have several variations in my beginner's arsenal!

    Thanks a bunch, Irone!

    Winston
  • Winston TWinston T Posts: 6
    edited 2012-07-11 21:20
    Four days later... I am halfway there!

    I was able to make a simple resistive touch switch by following the schematic in the first example of this website:

    http://www.talkingelectronics.com/projects/TouchSwitch/TouchSwitch-1.html

    I had to go to Radioshack to buy more NPN transistors (for $3) to build the circuit as the "What's in a Microcontroller?" kit only includes one NPN transistor. Two months after having purchased the kit, I would not have been able to understand not even the simple schematic (the one called "super-Alpha pair") up until just a few days ago! I'm truly a beginner! Learning this stuff is not easy! My next goal for a resistive sensor will be to make some sort of smart resistive touch switch that responds differently depending on varying changes in voltage, resistance, etc. between two electrodes. The schematic that I followed on the linked website (above) achieves my initial goal of just making any ol' resistive switch but the circuit doesn't use any programming or intelligent sensing -- which is what I am ultimately after! I'm assuming that the answer to creating a smart resistive sensor may lie somewhere in using an Analog to DC integrated chip?... Or perhaps in conjunction with using Basic Stamp as a voltmeter (as described in the Parallax - Basic Analog and Digital kit) which could then be programmed to respond to a specific change in voltage? It's just a guess.

    And, by the way (or to whom it may concern),...... there is simply no way that a complete beginner could understand all of this without having first gone through both books (i.e., What's in a Microcontroller?, and Basic Analog and Digital, etc.). The What's in a Microcontroller? book by itself does NOT teach all of the basics of electronics, I don't think. You've been warned! One would have to go through all of the Basic Stamp kits to truly understand the basics, in my opinion. I haven't. And that is why I am struggling. It also doesn't help that none of the Parallax books seem to include not a single chapter on custom touch switches (either resistive nor capacitive). The two books (from the kits) that I have read don't mention capacitance switches,etc. at all throughout the entire text (not even in the index). It's an AWOL topic. : )

    With respect to a capacitance touch switch... I'm still working on it. On page 109 of Basic Analog and Digital, there is a schematic for measuring frequency (using the 555 timer) that is very similar to the schematic on page 101 of the StampWorks Manual. And then both of them are similar to the 2nd schematic of the actual capacitance touch sensor listed in the talkingelectronics.com link above. I'm still in the process of piecing the puzzle together!

    I still haven't been able to put together a homemade capacitor as well but will work on it tomorrow. I'm also still a bit confused about which capacitor is swapped out to form a capacitance switch? Some of the video examples on YouTube seem to use wires as the physical touch switch as opposed to a homemade capacitor (or cut PCB). I'm interested in learning both methods!

    Thanks a bunch, Irone!

    Winston
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-07-13 11:34
    Winston,

    Have you tried simply attaching a plate capacitor to a stamp pin, nothing else, and then run the following simple program:
    DO
      DEBUG BIN1 in0   ' set up for pin p0
    LOOP
    

    The debug display will show a mix of 0's and 1's and that will change when you touch the plate. Especially if there is a lot of 60Hz energy from electrical wiring. One thing that would stabilize that circuit would be a diode or LED, connected with its cathode to p0 and its anode to ground. If it is an LED, cover it to keep it in the dark.
  • Winston TWinston T Posts: 6
    edited 2012-07-16 13:52
    Hi Tracy,

    So far, I've made the most progress in creating resistive touch switches. The capacitive touch switch is a bit elusive -- this could be because I haven't been able to put together a homemade capacitor!

    For a beginner... learning about electronics is almost comparable to swimming in a muddy swamp, taking a shower in cold water, and then eating warm alphabet soup : ) It's like learning a language almost. I love learning about electronics but the truth is that it has taken me hours a day for several weeks just to be able to begin to understand most of informational resources available on the internet!

    I think I need to recover! Once I'm rejuvenated, I'm sure my next efforts to build a homemade capacitor will be closer to a success.

    I don't know what a plate capacitor is, for example! And searches in Google, YouTube, google images, etc. bring up rather strange looking devices! : ) Searching for a "plate capacitor" on Amazon.com, for example (in search of some sort of product to buy and test out), even confuses the search engine at Amazon!

    I'm not alone in being so confused, Tracy!

    P.S. I'm only poking fun at how technical it is to learn this stuff!
  • ceolwynnceolwynn Posts: 2
    edited 2012-12-27 18:14
    Hi !

    are you still seeking answers to the capacitive switching obstacles ?
    if so I would share what I have discovered ...

    I made several circuits that worked but when I found out about the dedicated ICs
    their ease of use and accuracy made me put aside building custom sensing circuits.
    although I learned col things but grandma missed her favorite LED lamp NOW !!!!

    The first one I used was the QT102. a little 6 pin IC which only does capacitive
    sensing and does so very well, it even self calibrates ! I used the QT102 eval
    board $ 26 to fix my grandmoms favorite IKEA LED lamp. the power supply that
    IKEA uses is lower than turd quality LOL. and they don't sell them separately.

    I replaced the constant current 600ma 2.5 -to- 3.5 volt junk dc IKEA supply.
    with a china bought, 700ma 3 -to- 7 volts constant current supply.

    now the floor level- foot switch which grandma stumbled to reach between her
    chair and wall every now and then... dumb right ?
    http://www.ebay.com/itm/IKEA-Modern-Designer-LED-Floor-Lamp-NEW-Energy-Saving-Tived-/140835562805
    http://www.alibaba.com/product-gs/498424881/Lamp_or_light_use_switch_power.html

    we all agreed that a floor foot switch for a reading lamp next to a comfy fluffy chair
    was a really really stupid idea for the elderly , who might discover that balancing on
    one foot while searching with the other for a floor foot switch that might not stay in the
    exact same place all the time... my grandmas lamp is between her fluffy reading
    chair and a wall. then there is the annoying challenge of runnig the power wire for
    your reading lamp to some place in front of or beside your chair !!!! dumb.... so they
    gave me the broken lamp

    what I needed was an on / off toggling touch circuit. one-touch-on / one touch off, and
    a replacement for the trashy 2.5 -to- 3.5v 600 ma constant current ikea power supply,

    I discovered the Dedicated touch switch ICs late last year when I made a touch switch
    for an electric keyboard for a friend.

    The two most known are the Qtouch QT100 and QT102 etc by texas instruments,
    http://www.atmel.com/products/TouchSolutions/bsw/qtouch.aspx
    Pre made eval boards are between $ 9 -to- $ 28

    and the Mtouch http://www.smsc.com/Products/Capacitive_Touch_Sensors/CAP1133
    pre made eval boards are also avail so we don't have to build our board for a one-of
    project :-)

    there are others also that I have used a couple of times like the MPR032EPR2 by
    Freescale semi. it is 81 cents but a surface mount only which is why I like the eval boards
    http://www.newark.com/jsp/search/productdetail.jsp?SKU=14R8936&CMP=KNC-GPLA&mckv=|pcrid|12534598701|plid|

    and also the COM-07902 a bit pricey at $ 8 - $ 9 and also surface mount only
    https://www.sparkfun.com/products/7902 but don't fear the surface mount stuff
    too much cause there are many options to deal with ... like the following $ 4 board
    https://www.sparkfun.com/products/499?

    here is one nice list of easy to use capacitive IC chips to consider :-)
    http://www.mouser.com/Semiconductors/Sensor-ICs-MEMS/Capacitance-Touch-Sensor-ICs/_/N-6srgz

    moving on...
    The LED in grandmas lamp has a volts max of 3.5v. and my new power supply
    has an output that can go as high as 7v... way too much so... I made an over voltage
    protection circuit using a basic OpAmp Comparitor. and it uses a 3.3 v Zener diode
    as a voltage reference so,. if she dials the voltage over 3.3v the output of the OpAmp
    protection circuit breaks the circuit to the LED.

    Oh, forgot to mention, I got a rheostat from radio shack to make it dimmable ...
    http://www.radioshack.com/product/index.jsp?productId=2062299

    this has a peg for
    a knob which I got from the scrap parts box. the entire thing goes into a project box
    which I bolted to the top of the weighted base. when she sits in her chair she can
    reach down to the project box dial to adjust the light output. if she turns it too high
    it simply goes out,,, to protect the LED Chip.

    one thing I didnt think of was her touching the metal of the lamp while reaching for
    the dimmer dial and cutting it off while trying to set the light output... what I should
    have done was to add a circuit that would sense her hand on the dimmer dial with
    one of the other capacitive sense circuits so that while her hand is at the dimmer
    dial, and for say, 30 seconds after ( time for aiming it ) the off switch would be
    inactive. if she goes on vacation I'll ad that to the project.

    feel free to ask me questions about any of this. and best regards and good luck

    Tom W Dallas texas
    ceolwynn@hotmail.com




    Winston T wrote: »
    Hi, Irone! And thanks a bunch for responding!

    This is very frustrating for me! I'm still unable to solve this problem! Also, please remember that I'm a genuine newbie and so far have only gone through the "What's in a Microcontroller?" kit. I'm actually unable to determine, for example, exactly what the CMOS IC is that you're referring to and where it can be found! Is there a specific part available to be purchased on this site? For a second, I assumed the CMOS IC was the digital potentiometer (AD5220) included in the microcontroller kit! But I am still unsure?!

    Making both a resistance or capacitance touch sensor using Basic Stamp is very, very important to me! Most importantly, to be specific, is a capacitance touch sensor. It is only a matter of time before Parallax gets about $500 out of me as I plan to go through almost all of the educational kits to learn as much about electronics as possible! This stuff is that fascinating to me!

    But I prefer to get to capacitance (as well as resistance) touch sensing almost immediately.

    The website article:
    http://www.eetimes.com/design/analog-design/4009869/Building-a-reliable-capacitive-sensor-interface

    ...appears to state in the article (as well as in the schematics) that a "555 counter/timer" as well as something else called a "comparator" is needed to make a basic capacitance touch sensor. The link in the YouTube video above (in my second post) demonstrating the capacitive touch sensor also mentions that it is using a "555 timer" in the example. On the Parallax website the "555 Timer IC CMOS" is available. The "555 Timer" is also a part of the Parallax - Basic Analog and Digital (Student Guide) Kit.

    The other part of the equation is this issue of a "comparator". I'm having trouble finding specific information on it -- on what it is? How it can be set up and programmed to make a capacitance sensor, etc.?

    I did, however, find listed on the Parallax website that in one of the activities in the Basic Analog and Digital Kit is "Building a comparator". My plan is to order this kit and then go through the information trying to find out what I can to eventually piece together a capacitive touch sensor.

    But if there is anyone that knows very well how to go about setting up a capacitance touch sensor on their Basic Stamp, I could seriously use some schooling on it! Please help!@ !

    I'm trying to put together a resistance touch sensor as well (but the capacitance one is also a priority)!
Sign In or Register to comment.