Capacitive Touch Button by using ADC channel (the CVD system)


Closed Thread
Results 1 to 40 of 43

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Posts
    34


    Did you find this post helpful? Yes | No

    Default Re: Capacitive Touch Button by using ADC channel (the CVD system)

    Max Power,

    I need to make a correction. 12F675 having 10 bit ADC channels but I was using them as 8 bit. Because in that job I do not need 10 bit conversation.

    I made a system which is working without any problem. But it was not so easy to do that. Because as I told on my first message the system does not work with stability. Let say if you touch the touch point it is not coming the same result all the time. There is like a loop and after that loop you obtain again the same result.
    For instance the ADC value is depend on what you use as touch point (cable , cupper plate etc) The capacity of that equipments are changing the ADC value.
    I was using one short (about 25 cm) thick cable (single line inside). With that cable I was getting $85 value without touching to the cable. If I touch the ADC value was going down as zero ("0") This was the trick for me to catch the touch moment. BUt as I told you it was not stabil. Finally I decided to use also one loop to eliminate the false signals. Finally my siystem is working very well without any problem. I made both TOGGLE system and also NON-TOGGLE system.
    Here is the codes for Toggle system;
    * : TOGGLE *
    '************************************************* ***************
    @ DEVICE pic12F675
    @ DEVICE pic12F675, WDT_ON
    @ DEVICE pic12F675, PWRT_ON
    @ DEVICE pic12F675, PROTECT_OFF
    @ DEVICE pic12F675, MCLR_off
    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT

    DEFINE OSCCAL_1K 1

    DEFINE OSC 4

    DEFINE ADC_BITS 8
    'DEFINE ADC_CLOCK 1
    DEFINE ADC_SAMPLEUS 10
    CMCON = 7
    RAW VAR byte 56
    TOP VAR WORD
    SINIR VAR BYTE
    I VAR BYTE
    BUYUK var byte
    KUCUK VAR BYTE
    poz var bit
    OPTION_REG=%01001111
    GPIO=0
    TRISIO=0
    ANSEL = %01011111
    ADCON0=%00001001
    WPU=0
    GPIO.2=1
    SINIR=132 'This is the sensibility value can reach up to 136 according to my touching cable and it can be changed for the different material.
    BUYUK=0
    KUCUK=255

    START:
    GOSUB TUSBAK
    '------------------------do not use these lines I was used them to see the ADC values-------------------------------
    IF RAW>BUYUK THEN BUYUK=RAW
    IF RAW>0 and RAW<KUCUK THEN KUCUK=RAW
    WRITE $10,BUYUK
    WRITE $11,KUCUK
    '-------------------------------------------------------------------------------------------------------------------
    IF RAW<SINIR and POZ=0 THEN 'this is the lines to eliminate the false loop
    TOGGLE GPIO.5
    I=0oz=1
    BIR: gosub tusbak
    IF RAW<SINIR then
    I=0
    GOTO BIR
    ELSE
    I=I+1
    IF I<SINIR then BIR
    ENDIF
    pause 50
    I=0
    goto start
    endif

    pause 10
    poz=0
    GOTO START
    TUSBAK: 'means check if there is a touch
    GPIO.2=0
    ANSEL.2=0
    HIGH GPIO.2
    ADCON0=%00001001 ' The direction of ADC channel is now GPIO.2 and C_hold is charging by the signal coming from AN2.
    ANSEL.0=0 'sensor pin is digital
    TRISIO.0=0 'sensor pin is now output pin
    GPIO.0=0 'sensor pin is LOW and it was discharged
    TRISIO.0=1 'Sensor pin is again input
    ANSEL.0=1 'sensor pin is analog input now
    ADCIN 0,RAW
    BAK:
    TRISIO.0=0
    ANSEL.0=0
    GPIO.0=0
    RETURN
    I hope everything is clear now.

    Ero

  2. #2
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Capacitive Touch Button by using ADC channel (the CVD system)

    I've made a touch controlled dimmer with touch up/touch down controls using this method. There is a lot of variability in the measurement, but empirically I determined a range of values that the result always falls within when touched. I then implemented a "tell me three times" loop to eliminate noise. I'm happy with the result and there are several complete units in use with no complaints.

    I can't post the code because I sold the rights to it, but the only tricks to making it work are in the paragraph before this one.

  3. #3
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Re: Capacitive Touch Button by using ADC channel (the CVD system)

    Mister_e had an elegant piece of code that worked flawlessly;

    http://www.picbasic.co.uk/forum/show...?t=2671&page=1

    Hope it works for you.

    Regards,

    Anand

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Capacitive Touch Button by using ADC channel (the CVD system)

    I remember struggling with a16f690 for a good while wrt cap touch (albeit a different method to the one being discussed here )...I then bought a £1.00 12f1822 & was up and running with cap touch within about 20 minutes!

    moral of the story (for me at least) - get the right pic for the task at hand!

  5. #5
    Join Date
    Jun 2008
    Location
    Milwaukee, WI
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Capacitive Touch Button by using ADC channel (the CVD system)

    Thanks everybody. I love this forum.
    Looks like I will get a 12F1822 for my low pin count micro, and a 16F1823 for my higher pin count micro. I was kind of put off by the lack of examples here.

    Hank, I'm so glad you chimed in. I've been reading your posts about your relaxation osc. and the 16F690 with great interest, and I watched your youtube video. the 690 seemed like an easy way to get multiple channels. I've done a few single channel, relaxation osc, cap sensors using a comparator and a timer in the 16F628A, but I was always limited to 1 channel. Then, I got the 16 channel mux and SOIC breakout board from sparkfun and I made a 16 key piano - thats probably my most fun project yet. I really should post the code, it could be so much better.

    You were up and running in 20 min?!? jeez, what am I waiting for! did you use PBP? 2.6 or 3? or... (shudder) C code? :-) what did you program it with? pickit2 pickit3? I might pick your brain a little more later.

    Thanks again.

  6. #6
    Join Date
    Feb 2011
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Capacitive Touch Button by using ADC channel (the CVD system)

    Max,

    If you like the 12f1822 then you will like the 16f1825 & 1829 -- via newark.com
    May I suggest the 16f1825 @14pins $1.61 and - and 16f1829 @20pins $1.84
    Code:
    PIC16F1825  1,4,20 - 14 dip - 32MHz-31kHz 8k 1kram 256ee 12I/O             $1.61
    PIC16F1829  1,4,20 - 20 dip - 32MHz-31kHz 8k 1kram 256ee 18I/O             $1.84
    The handy image is a cut and paste job from the data sheets
    Attached Images Attached Images  
    Last edited by ofuzzy1; - 8th September 2011 at 05:15. Reason: clarity

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


    Did you find this post helpful? Yes | No

    Default Re: Capacitive Touch Button by using ADC channel (the CVD system)

    Damn, it's ridiculous how cheap PIC are right now... geez...
    Steve

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

  8. #8
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Capacitive Touch Button by using ADC channel (the CVD system)

    Quote Originally Posted by Max Power View Post
    Hank, I'm so glad you chimed in. I've been reading your posts about your relaxation osc. and the 16F690 with great interest, and I watched your youtube video. the 690 seemed like an easy way to get multiple channels. I've done a few single channel, relaxation osc, cap sensors using a comparator and a timer in the 16F628A, but I was always limited to 1 channel. Then, I got the 16 channel mux and SOIC breakout board from sparkfun and I made a 16 key piano - thats probably my most fun project yet. I really should post the code, it could be so much better.

    You were up and running in 20 min?!? jeez, what am I waiting for! did you use PBP? 2.6 or 3? or... (shudder) C code? :-) what did you program it with? pickit2 pickit3? I might pick your brain a little more later.
    The 20 minutes on the 12f1822 was probably becuase I'd had to go through the ordeal of getting the 16f690 to work with capacitive touch (& for all even now I'm just one rung up from n00besque territory, back then I wasn't even that!)....and it's not the most beginner friendly! (perhaps it was a rite of passage, to 'grasp' the cap touch basics?!) Seriously, it's incredibly easy to get 4 channel cap touch working on a 12f1822, 16f1824,1827, 1829 etc, what I strongly recommend though is getting the PIC to send info to you PC so you can see the cap module output into TMR1 count

    To your other questions, I was using picbasic V2.6, pickit2 - I'll try & post something soon(ish) to get you started.

    As it goes i was searching the globe yesterday trying to track down a PIC16LF1829 (XLP variant) - nobody seems to stock them, 'microchip direct' do...but they charge about £15 delivery ($23!) - stuff that!
    Last edited by HankMcSpank; - 8th September 2011 at 20:25.

Members who have read this thread : 1

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