Relaxation oscillators (for capacititive touch sensing)


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Going back to your first post...

    There is a difference... pin 18 is C12IN0- and pin 15 is C12IN1-

    This is taken from my Datasheet DS41262E (yours might be an extinct version).

    You asked about RC4. Whether you consider a Comparator OUTPUT as analog I suppose is up to you. I consider Comparators INPUT as ANALOG but technically their OUTPUT is DIGITAL since it can only be a High or a Low. RC4 is the OUTPUT for Comparator 2. If you are using Comparator 2, you DON'T want to set that pin to ANALOG (because ANALOG refers really only to INPUTS), but you want DIGITAL OUTPUT.

    Look at figures 8.2 & 8.3 in the Comparator Section. They show you the Comparator INPUT arrangement. For your convenience CxVin- has four possible sources.

    The 16F690 does NOT have a CSM Module.

    This means that if you want to play with capacitive sensing you have to configure the Comparators as an Oscillator yourself, the frequency of Oscillation will change when you place your Dabs on the Sensing Terminal. It is up to you to detect the change in frequency. So really any PIC with Comparators can do that. It's nice that the 16F690 has a quad input to each Comparator, which means that each Comparator can potentially service up to four capacitive buttons (NOT like your schematic in the first post which cannot differentiate which Button is being touched). That's the easy part.

    The Hard part comes when you discover that the frequency will SIGNIFICANTLY DRIFT with ambient TEMPERATURE and HUMIDITY. This means you have to continually sample and reset your base reference. Then some snotty kid comes along and presses your button with damp hands 'cos he's just been picking his nose, and your base reference swings wildly into the unknown. Enjoy...

    (that said, I'm surprised that there aren't many many more people chomping at the bit to get funky proximity touch sensor switches working on there PICs)
    Some of us have a life... *smiles*... (quite apart from the fact that a tactile PCB switch costs about 5 cents and is reliable. Mount it behind a flexible overlay and all you need is a pull-up Resistor and ONE LINE of code to see if anybody's pressed it or not. It doesn't care if the overlay is dry or wet or somewhere in between, and it doesn't care about the flavour of Ben & Jerry's you want to slap on it!).

  2. #2
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    I have implemented capacitive touch sensing using a PIC in a handheld terminal project. I needed the ability to sense up to 32 touch pads (and control a 128x64 pixel graphic LCD) and went with a different approach that did not require a PIC with a CSM module or comparators. I used an external oscillator (a CMOS version of the 555 operating at 2MHz) - this approach allows it to be implemented with any PIC (or other processor such as Atmel, MSP, etc. - I used a 44-pin PIC18F44K20 which controls everything). Works real well. Front and rear pics of the prototype below.


  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Hello Melanie,

    firstly, thank you as ever for the comprehensive reply (& avoiding an overpowering temptation to pour scorn!)

    Quote Originally Posted by Melanie View Post
    Going back to your first post...

    There is a difference... pin 18 is C12IN0- and pin 15 is C12IN1-

    This is taken from my Datasheet DS41262E (yours might be an extinct version).
    Yes, I had an old datasheet, hey ho!

    Quote Originally Posted by Melanie View Post
    Going back to your first post...

    You asked about RC4. Whether you consider a Comparator OUTPUT as analog I suppose is up to you. I consider Comparators INPUT as ANALOG but technically their OUTPUT is DIGITAL since it can only be a High or a Low. RC4 is the OUTPUT for Comparator 2. If you are using Comparator 2, you DON'T want to set that pin to ANALOG (because ANALOG refers really only to INPUTS), but you want DIGITAL OUTPUT.
    I have to say, this confuses me - as an old analoguey dinosaur (desperately trying to find his feet in the whacky world of digital), a comparator is analogue, but thinking about it more, an SR latch is digital. But that said, I've tried several permutations with digital and analogue pins! I'll revisit this in the light of your reply.

    Quote Originally Posted by Melanie View Post
    Look at figures 8.2 & 8.3 in the Comparator Section. They show you the Comparator INPUT arrangement. For your convenience CxVin- has four possible sources.

    The 16F690 does NOT have a CSM Module.
    Yes, this is one bit I understood...but nevertheless it does have a Comparator SR latch relaxation oscillator possibility ...which ought to work!

    Quote Originally Posted by Melanie View Post
    This means that if you want to play with capacitive sensing you have to configure the Comparators as an Oscillator yourself, the frequency of Oscillation will change when you place your Dabs on the Sensing Terminal. It is up to you to detect the change in frequency. So really any PIC with Comparators can do that. It's nice that the 16F690 has a quad input to each Comparator, which means that each Comparator can potentially service up to four capacitive buttons (NOT like your schematic in the first post which cannot differentiate which Button is being touched). That's the easy part.
    yes that part of the schematic was wrong (and was pretty much lifted from Microchip's application note .... http://ww1.microchip.com/downloads/e...tes/01101a.pdf Appendix B - it's wrong!)

    Quote Originally Posted by Melanie View Post
    The Hard part comes when you discover that the frequency will SIGNIFICANTLY DRIFT with ambient TEMPERATURE and HUMIDITY. This means you have to continually sample and reset your base reference. Then some snotty kid comes along and presses your button with damp hands 'cos he's just been picking his nose, and your base reference swings wildly into the unknown. Enjoy...
    yes I know about the drift....but if you believe the hype on the microchip site, it can be accounted for in code (I should have something ready for this aspect in a few years)

    Quote Originally Posted by Melanie View Post
    Some of us have a life... *smiles*... (quite apart from the fact that a tactile PCB switch costs about 5 cents and is reliable. Mount it behind a flexible overlay and all you need is a pull-up Resistor and ONE LINE of code to see if anybody's pressed it or not. It doesn't care if the overlay is dry or wet or somewhere in between, and it doesn't care about the flavour of Ben & Jerry's you want to slap on it!).
    ......and some of us have guitars, the real estate of which is more sacrosanct than the Turin shroud! :-) believe me, if I could justify a h/w switch I would just use that ...but taking a drill to my vintage guitar would be like violation. (far better to have a capacitive touch sensor located somewhere under the scratchplate)

    Thanks for your help though ...it really is appreciated . :-)
    Last edited by HankMcSpank; - 22nd November 2009 at 17:21.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    If your Guitar is so sacrosanct, then why even consider sticking stuff to it? Leave it the way the manufacturer intended it to sound and why not simply build a bigger custom wah-wah pedal box with a heap more buttons and functions for controlling your effects?

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Ah... I see what I wrote with regard to DIGITAL OUTPUT... what I meant was that the COMPARATOR gives you the Digital Output. You NEED to select C1OE and C1ON (C2OE & C2ON) bits to 1 so the Comparator gives you a physical Hardware Output (rather than just setting a bit in a Register internally within the PIC), and you set the TRIS for that pin to 0 (treat it as DIGITAL OUTPUT - which is what it is).

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    If your Guitar is so sacrosanct, then why even consider sticking stuff to it? Leave it the way the manufacturer intended it to sound and why not simply build a bigger custom wah-wah pedal box with a heap more buttons and functions for controlling your effects?
    Because the end goal here is, is a guitar sustainer, ie infinite sustain (the holy grail for most guitarists) ...there isn't an effect pedal in existence that yields an equal effect (yes, there are guitar sustain pedals, but they're nothing more than glorified compressors/limiters...as the guitar note dies, the compressor pedal merely cranks up the gain to try and counteract, leaving you with a woeful signal to noise ratio & a still dying guitar note)....a proper guitar sustainer, uses an electromagnetic driver to keep the string moving - and that needs to go physically go on the guitar (as it goes this driver will literally be stuck onto the guitar - to save the unpaletteable thought of having to drill the guitar to mount it)

    For those that hold an interest, I made a short video clip where you can hear the end result (it's at a very rough & ready stage here though!) - complete with a breadboarded circuit hosting a 16F690 to one side of the frame (which presently has 5p momentary switches too - those are the puppies I'd like to replace with capacitive sensing switches - I can then use the screws on the scratchplate as on/off switches!)...

    (btw, that ain't no vintage guitar, but my test guitar...no worries if it gets scratched while I mess about mounting/removing driver coils to establish the best one)


    Quote Originally Posted by Melanie View Post
    Ah... I see what I wrote with regard to DIGITAL OUTPUT... what I meant was that the COMPARATOR gives you the Digital Output. You NEED to select C1OE and C1ON (C2OE & C2ON) bits to 1 so the Comparator gives you a physical Hardware Output (rather than just setting a bit in a Register internally within the PIC), and you set the TRIS for that pin to 0 (treat it as DIGITAL OUTPUT - which is what it is).
    I need to sit down in a quiet darkened room & digest that paragraph....but I will!

    rmteo ...thank you for your input, your chosen path - whilst brilliant - is excessive for my meagre switching needs! (I only need three switches & have an unhealthy obsession with keeping the component count low!)
    Last edited by HankMcSpank; - 22nd November 2009 at 19:16.

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    Ah... I see what I wrote with regard to DIGITAL OUTPUT... what I meant was that the COMPARATOR gives you the Digital Output. You NEED to select C1OE and C1ON (C2OE & C2ON) bits to 1 so the Comparator gives you a physical Hardware Output (rather than just setting a bit in a Register internally within the PIC), and you set the TRIS for that pin to 0 (treat it as DIGITAL OUTPUT - which is what it is).
    Ok, I think I understand, that's pretty much what their Application Note said (albeit for the 16f877, but doing some x correlation, it seems that most register settings on the 16F690 are very similar)...


    Edit: Bingo! it works now!(phew)

    The problem?

    The darned Pickit2 programmer pin 2 (which goes to pin 18 - ICSPCLK -on the 16F690), was seemingly dragging the whole cct down and stopping it from oscillating - when I removed that leg from my Pickit2 & I get the following...



    (which alters in frequency nicely when I touch my fingers across the 250nf cap I have in place in lieu of the C3 sensor pad/cap in the schematic above)

    For the capactive touch record, here are my register settings...

    Code:
    CM1CON0= %10010100    'from the Microchip AN1011a application note.
    CM2CON0= %10100000    'from the Microchip AN1011a application note.
    CM2CON1= %00110010    'from the Microchip AN1011a application note.
    SRCON  = %11110000    'from the Microchip AN1011a application note.
    VRCON  = %10000111    'from the Microchip AN1011a application note.
    
    ANSEL  = %00001010    'AN1 & AN4 analogue, the rest Digital.
    
    TRISA  = %11111011     'RA1 (C12IN0-) as input, RA2 (C1Out ) output - but not sure if it's in scope here!
    TRISC  = %00000011     'RC0 (VCC/4) as input, RC1 Input (not sure if it's in scope either), RC4 output (C2OUT)
    Thanks for chiming in, your input made me revisit this one last time (I was flagging!) ....that's the simple bit over with (which has taken me two nights!), now the hard stuff - getting this all to work!
    Last edited by HankMcSpank; - 22nd November 2009 at 21:26.

Similar Threads

  1. Need a cheap touch sensor idea.. here it is
    By mister_e in forum Code Examples
    Replies: 20
    Last Post: - 16th April 2016, 23:42

Members who have read this thread : 0

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