View previous topic :: View next topic |
Author |
Message |
theteaman
Joined: 04 Aug 2006 Posts: 98
|
Touchswitch |
Posted: Sun Nov 05, 2006 10:44 pm |
|
|
Hello I discovered this touchswitch that I've tried to implement:
http://www.bytecraft.com/touchsw.html
Apparently you take two pins (and input and an output) of a microcontroller and connect them to each other. You also connect a wire to the output pin (this is a finger sensor). Then, discharge the output pin and send a pulse high to the input pin. Wait x uS and sample the pin. If the pulse isn't detected then there was extra capacitance (for example from a finger touching a wire connected to the output pin) resulting in a delayed pulse.
I've tried to implement this, and it works in that it definately detects the presence of my finger. But it seems to pulse on and off. Ie. if I hold a finger on the wire connecting to the output pin, the switch turns on/off/on/off randomly.. I am wondering why this is, or if there's a way to stop it?
Thanks |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Mon Nov 06, 2006 3:46 am |
|
|
The circuit itself is an RC arrange so its behaviour should be cuasi-oscillating while
detecting a "capacitor" not in a random way but with a period proportional to RC.
You should know the response time and when the change had been detected,
your code would get the change -if so- validate the change and add a delay or
disable this function to stop the cycling effect.
Humberto |
|
|
theteaman
Joined: 04 Aug 2006 Posts: 98
|
|
Posted: Mon Nov 06, 2006 6:56 am |
|
|
Humberto wrote: | The circuit itself is an RC arrange so its behaviour should be cuasi-oscillating while
detecting a "capacitor" not in a random way but with a period proportional to RC.
You should know the response time and when the change had been detected,
your code would get the change -if so- validate the change and add a delay or
disable this function to stop the cycling effect.
Humberto |
But while the circuit itself is quasi-oscillating, that doesn't mean the code should, should it? After all, I am only testing the input pin at intervals that are synchronous to the RC (ie. I only test the input pin, after I've set the output pin)
I think I miss what your saying |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Mon Nov 06, 2006 11:04 am |
|
|
Quote: |
But while the circuit itself is quasi-oscillating, that doesn't mean the code should, should it?
|
The idea is that knowing the response-time of the "floating" input to get the
"lowest" level with the finger close to the sensor, you should validate the level,
toggling the switch action and quit testing such input, in such a way that next
touch should toggle again.
Humberto |
|
|
theteaman
Joined: 04 Aug 2006 Posts: 98
|
|
Posted: Mon Nov 06, 2006 6:24 pm |
|
|
Hmm, I *think* I understand what you mean, but then how would I know when to start testing for input again? |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Tue Nov 07, 2006 9:07 pm |
|
|
Quote: |
Hmm, I *think* I understand what you mean, but then how would I know
when to start testing for input again?
|
theteaman,
It is not only a matter of code, first of all you will try to get a stable and
reliable way to sense a finger touching a sensor.
The proposed model circuit seems very simple in a paper but this kind of
circuit are highly hardware influenceable:
- the whole parasitic capacitances
- the length of wires
- the sensor size/shape
- the sensor material
- the enviromental electromagnetic field
- etc
are variables that affect the behaviour in a real circuit.
Once you get a stable and predictable touch sensor, next step is a matter
of to analize the sampled signal and to define the right time to validate it.
I have an application using this approach, the sensor is a laminated PCB
(10x18mm) with a thin polycarbonate as insulator, the length of the wire
from the pin is 50mm, the R value is 820K, the delay used to sample the
sensor plate is 20us. When I detect the finger over the plate, I use a
toggle action to switch On/Off a LED and quit with 250ms time gap prior
to sample the plate again.
Humberto |
|
|
theteaman
Joined: 04 Aug 2006 Posts: 98
|
|
Posted: Wed Nov 08, 2006 12:18 am |
|
|
Humberto wrote: | Quote: |
Hmm, I *think* I understand what you mean, but then how would I know
when to start testing for input again?
|
theteaman,
It is not only a matter of code, first of all you will try to get a stable and
reliable way to sense a finger touching a sensor.
The proposed model circuit seems very simple in a paper but this kind of
circuit are highly hardware influenceable:
- the whole parasitic capacitances
- the length of wires
- the sensor size/shape
- the sensor material
- the enviromental electromagnetic field
- etc
are variables that affect the behaviour in a real circuit.
Once you get a stable and predictable touch sensor, next step is a matter
of to analize the sampled signal and to define the right time to validate it.
I have an application using this approach, the sensor is a laminated PCB
(10x18mm) with a thin polycarbonate as insulator, the length of the wire
from the pin is 50mm, the R value is 820K, the delay used to sample the
sensor plate is 20us. When I detect the finger over the plate, I use a
toggle action to switch On/Off a LED and quit with 250ms time gap prior
to sample the plate again.
Humberto |
Thanks Humberto. I understand what you're saying.. I do have the switch in a stable implementation. But the problem is that a 250ms delay is verrry long. I would be looking at 1ms delay max. Hence what I want to do is mimick the response of a SPST momentary switch. But by reading your message, I think I have actually figured out a way to do it, if the circuit oscillates at a defined period (as you say).
Thanks! |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Nov 08, 2006 6:32 am |
|
|
Quote: |
But the problem is that a 250ms delay is verrry long. I would be looking at 1ms delay max.
|
The steps are:
1) Turn HIGH Pa.0
2) Wait 5...30us // depends of your hardware and the analisis of the signal...
3) Test Pb.0 if H or L and validate the reading
Code: |
if( finger sensed ) // IF == TRUE
{ toggle = !toggle; } // change the switch STATUS
|
5) Turn LOW Pa.0
6) Make some action to "watch the change effect"
Code: |
if( toggle ) // IF == TRUE
{ output_high(PIN_B2); } // activate something
else
{ output_low(PIN_B2); } // deactivate
|
7) Wait >~250ms doing something more intersting....
This time is a gap between samples to get a clean snap action.
8) Start again...
At least this is the way I do it, I hope it will be usefull for you.
Humberto |
|
|
theteaman
Joined: 04 Aug 2006 Posts: 98
|
|
Posted: Wed Nov 08, 2006 7:15 am |
|
|
Thanks Humberto! I will work on it now |
|
|
|