CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Design question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wintermute



Joined: 10 Sep 2005
Posts: 3

View user's profile Send private message Send e-mail

Design question
PostPosted: Wed Sep 14, 2005 5:03 pm     Reply with quote

I'm using a modified circuit for a capacitive switch for my pic. I've created the switch in firmware the usual way
(i.e.
port_b_pullups(TRUE);
if(!input(BUTTON) {
//do something
} )
on a port B pin. Basically, connect pin to ground to operate the switch. This particular circuit will constantly send +5-volts to the pin until a finger touches metal contacts which will bring the b-port pin to ground potential.

My question is: will constantly sending 5 volts to the pin except for button presses damage the circuit; and will the firmware still detect a button press?

Thanks for reading,
--wintermute
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Sep 14, 2005 7:03 pm     Reply with quote

We need to know a lot more about this "capacitive switch" to help you? Is this a commercially built module?
_________________
The search for better is endless. Instead simply find very good and get the job done.
wintermute



Joined: 10 Sep 2005
Posts: 3

View user's profile Send private message Send e-mail

schematic
PostPosted: Wed Sep 14, 2005 7:45 pm     Reply with quote

It's a pretty simple circuit, here is a schematic: (sorry for the blurriness)
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Sep 15, 2005 7:38 am     Reply with quote

To answer your original question, No running 5V to the PIC pin all the time is no problem as long as that is the same 5V supply that runs the PIC. Putting 5V on a pin while the PIC is not powered can cause problems. You should be able to remove the 1 meg resistor and just let the port B pullups do the job safely.

I do see two other problems with your circuit:
1) If someone on a dry day shuffels across a carpet and reaches out with their finger charged with static electricity to 10,000V and touches the sense electrode first, your FET is going to be destroyed in an instant. You should put a Zener diode from the gate to ground to clamp the positive voltage to a safe value. The Zener will foreward conduct to clamp negative voltages.
2) If someone toughes the +5V electrode with something grounded they could crash the 5V supply. I would split the 47K resistor into two 22K resistors and put one on each button. On the other hand now you may have a problem if the finger is too well grounded (the person may be dripping wet) and the finger grounds the sense button instead of pulling it high. Depending on the application maybe a 5K resistor in the +5V electrode is better. You may have to experiment.

As a safety note it is good to limit worst case current through the human body to 1mA or less.
Also there is nothing capacitive about this switch. I would not refer to it by that name.
_________________
The search for better is endless. Instead simply find very good and get the job done.
wintermute



Joined: 10 Sep 2005
Posts: 3

View user's profile Send private message Send e-mail

Well answered.
PostPosted: Thu Sep 15, 2005 11:40 am     Reply with quote

Extremely informative, thank you very much for your help, SherpaDoug. My apologies for using the wrong term, would just, touch-switch be more accurate?

I don't want to get to far off-topic of CCS or pics, but while I have the attention of a knowledgeable person... I've heard that for what I think is called a single-contact, capacitive switch, you must have earth ground. Is that accurate?

Thanks again,
--wintermute
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Sep 15, 2005 12:10 pm     Reply with quote

You might also look at an MC33794 from Freescale. It is an Electric Field Sensing IC that would work nicely for you.
yerpa



Joined: 19 Feb 2004
Posts: 58
Location: Wisconsin

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 15, 2005 2:31 pm     Reply with quote

You can make a touch switch based on capacitive principles using the PIC as follows: Generate a square wave with the PIC (i used a 555 timer - more current to do many switches) - send this square wave thru diode and resistor divider to touch bolts (single-ended, like an antenna). Then, readback the touch bolts and count how long the falling edge is delayed compared to the falling edge directly from the square wave generator. When a finger adds capacitance to the circuit (parasitic), it takes longer for the falling edge of the waveform to reach logic 0. Works very nice as long as the wires to the touch bolts are less than about 24 inches. I could send a schematic if you are interested. I built a bunch of these boards for a customer in 1994, haven't used them since then. Each board had five PICs and read 40 touch bolts.
newguy



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Thu Sep 15, 2005 2:39 pm     Reply with quote

Quantum Research Group makes a whole line of capacitive touch sensor ICs. http://ca.digikey.com/scripts/DkSearch/dksus.dll?Criteria?Ref=278384&Site=CA&Cat=33227895

I've used them in the past - they work well and they're not expensive.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Sep 15, 2005 2:48 pm     Reply with quote

For a one contact capacitive sensor you would need at least a capacitive connection to ground, but that is not hard to get. Think of the electric lamps that turn on by touching them. On the other hand they aren't too reliable at working on the first touch. A lot depends on your application.

One approach would be to build a RC oscillator from a couple of inverters that used a small cap, say 100pF. Connect the "hot" side of the oscillator cap through a bigger cap , say 0.01uF, to the sense electrode. Then have the PIC monitor the frequency of the oscillator. The frequency should drop noticably when you touch the sense electrode.

You could model the oscillator from the description of the RC oscillator mode on the PIC datasheet, though such things are also used zillions of other places. Make sure to take care of static electricity protection as I mentioned earlier.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group