Show Posts
Pages: 1 ... 71 72 [73] 74 75 ... 86
1081  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 21, 2010, 08:28:09 pm
I'd like to test that out for ya Mark, but I took the circuit apart a few days ago and right now my breadboards are a massive jumble of wires as I build the complete circuit.

Once I get that all put together though, I'll see about trying the capacitance thing.
1082  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 18, 2010, 11:22:51 am
Adding a delay seems to work!  May need to tweak the values.

I used a delay of 20ms.

With 100K resistance:
When not touching the leads the value stays pegged at 0 most of the itme, rising only as high as 1 when the other leads are touched.

A light touch with a dry finger gives between 4-20.
A hard press gives between 15-35.


With 3M resistance:
When not touching the leads, the value hovers around 0, oscillating a bit, up to as high as 6.

I get 40-200 when barely touching it with a dry finger,
100-300 when applying a normal amount of pressure,
500 when pressing hard,
and over 900 with a light touch and a wet finger.


Increasing the delay to 40ms had no effect on the 100K, but on the 3M:
I get less oscillation, but it still goes as high as 5 or 6 when just sitting there.  When touching the other switch the off state can go as hgh as 6.

With a light touch, I got a reading as low as 37,  but 99% of the readings are over 100 and as high as 300.

Double checking against the delay of 20, I don't really see a difference between the two.
Dropping the delay to 10, I see a marked increase in noise when the switches aren't being touched.  Though the values still don't rise above 6.  They just are above 0 a lot more often.
Double checking the noise I get with 20ms, I see I'm getting an oscillation back and forth between the two pins.   One stays at 0 while the other rises to 6 and drops again.  
Double chekcing 40ms, The oscillations go away, but are replaced by more random noise.  
Lastly, with 200K and 40ms, there's almost no noise when not touching the pads, and when touching the pads with dry fingers, there's a little noise on the one not being touched and I get values from like 30 to 50 on the pad being touched.


Don't have 500K or 1M resistors to test with, but I think the sweet spot will be around there.


So... this might just work.  I think I'll set up the code to behave like the schmitt trigger, turning on when I get a reading greater than a certain value, and off when I get a reading less than a certain value, so there's that buffer zone which will serve to debounce my input.  

Either that, or I'll average the input over time.  Or collect X number of inputs and take the median.  Averaging will probalby be sufficient and easier though.  

I gotta take a closer look at the input, I was only reading it once every half a second in these tests, so the ouytlying values might not happen often.


Thanks for the help! :-)
1083  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 18, 2010, 07:46:12 am
I'll give it a try!
1084  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 18, 2010, 07:13:06 am
Okay, I had some 100K resistors on hand, so I tested those out.  They seem to work better.  The values I'm getting are around 50 with dry skin, and 500 with wet skin, so I may be looking at using resistors which are 200K-1M.  

When not touching a contact, even if the other is being touched, the value pretty much stays pegged at zero.  I think it rose to 7 once when I was presisng down hard.

I'm not sure if the problems will return with the higher values, but I guess I'll find out once I test it.  

[edit]

Tested 200K.  Touching left switch had more effect on right switch reading tham before, and tocuhing it with a wet finger didn't cause the reading to jump to 1000 like I expected I would get by doubling the resistance.

Guess I'll have to grab some 1M resistors and see how those fare.
1085  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 18, 2010, 06:32:44 am
I just got done running some new tests using the serial monitor and the analog pins.

This time, I tried two touch switches, next to eachother, with one side attached to Vcc, and the other to analog pins 0 and 1, with the pins grounded via 10M ohm resistors.

While this setup seemed to work okay with one touch switch, giving me values of less than 47 when the switch wasn't being tocuhed, and with two switches it does the same, as soon as I touch either of the switches, their values jump up  to several hundred, and if I hold my finger on a switch, the two switches will seem to oscillate back and forth, with one dropping in value while the other increases, and vice versa.

I tried using delays of up to 20ms between taking the two analog readings, and 500 between readings of both switches, but this didn't seem to help.

I will now try using smaller resistors as you mentioned, and see if that helps, though based on the behavior the led in yesterday's tests, I suspect the smaller resistors may make things worse.

If this doesn't work, it looks like I'm going to have to figure out how to make a schmitt trigger or make room on the board for another DIP-16 IC.
1086  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 17, 2010, 01:01:48 pm
Hm... I was hoping if I couldn't get the resistive touch sensing working that I could go with capacitive, but I just found a thread about that where someone was asking how to implement it on a musical instrument, and apparently you can't place those sensors too close together.  And these ones need to be right next to eachother.

I'm fairly confident I can get these resistive switches working reliably with the analog inputs though.  I mean it's clear the input is noisy from the way the led was behaving, but when there was no finger on there it wasn't lit at all.  So there's a pretty big margin there.

As for whether this might introduce noise elsewhere in my circuit, I don't know.  But I'll be prototyping the whole thing on a breadboard and putting capacitors on there for reducing noise because I'm gonna have noisy servos in the circuit, so... I think I should be okay.

I guess the next step is figuring out how to output debug data over the serial connection so I can see exactly what values I'm getting off the analog port.
1087  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 17, 2010, 12:31:48 pm
I can't find a schmitt trigger in a smaller package, but I wonder... if the real issue here is just that the signal is noisy, can I just read the noisy signal an analog input and denoise it in software, either with a simple threshold, or some kind of averaging algorithm?
1088  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 17, 2010, 11:43:47 am
I just tried turning on the internal pullup and switching to ground both directly, and via a 51K resistor.  Didn't have any 30Ks on hand.  

LED remained solidly lit with both setups, presumably because finger resistance was greater than pullup resistance.

[edit]

Is there anything I can use besides a schmitt trigger?  They don't seem to be widely available... there's only one 4854 in a DIP-14 package on both Mouser and Digikey.  And I don't really have space on this board for yet another IC.

(Searching now to see if there's any other schmitt triggers in other packages.)
1089  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 17, 2010, 11:30:22 am
Quote
This is a digital input it is not designed for measuring high resistance values.

Would I have better luck using an analog input?


Quote
Well no not really. A 12M resistor is a stupidly high value to use

Every page I've found on the web which deals with resistive touch switch circuits uses values in the millions of ohms.  Admittedly, I don't think they deal with reading the state using a microcontroller.


Quote
the resistance from a fingerprint would be about the same value. If you use the internal pull up resistors then 30K (about) is going to dominate anything you can do with fingers and skin resistance.

So are you saying I should turn on the internal pullups, and swap my resistor out for a 30K one?  I guess I can try that.


Quote
That implies you are getting pickup and injecting noise into the system normally and the LED is flashing rapidly thus making it dim.
For this sort of application you want to be using something like a 4584 Hex schmitt trigger rather than going directly onto the input pins.

I have no idea what a schmitt trigger is, but I'll look into that.  Are you sure there's no way to do this reliably with, say the analog pins instead though?  Or is the reason this won't work the same reason using pots over 20K isn't recoomended?
1090  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 17, 2010, 10:00:47 am
Okay I just did some more tests.


When switching to ground, and pulling pin 2 high via the 12M resistor:

1) With pin 2's internal pullup turned off, a lot of pressure must be applied to the touch switches to make the led turn off.  

2) With pin 2's internal pullup turned on, no amount of pressure will make the led turn off.

This seems to imply that there is too much resistance across the touch pads, or that there is too little resistance on the pullup.  (I assume that turning on the internal pullup reduces the pullup resistance from around 12M ohms to around 20K.)

When switching to Vcc, and pulling pin 2 low via the 12M resistor:

1) With pin 2's internal pullup off, the barest touch of the touch pad lights the LED fairly bright, but it lights even more brightly if I press hard.  

This implies that the resistance across the touch switches is still too great relative to the resistance to ground.  So perhaps I should use a a resistor even greater than 12M, though every example of a touch switch I've found reccomends a resistor around that value.  I've read human skin can have resistances up to 50M though, so perhaps that would be a better value to use.  I am not sure how high I can go though before effectively I cut off the ground signal and the pin floats and does weird things, like act as a capacitance switch.

2) Enabling pin 2's internal pullup causes the led to light, and once again the touch switch stops working.  This makes sense because I've got 12M between the pin and ground, and 20K between the pin and Vcc.  So it should go on and stay on.  And touching the switch would of course do nothing since that would only serve to pull it even higher.


So... based on all that:

It would seem that if I want the switch to pull down, 12M will work, but it's probably turning on and off rapidly, and  50M would likely be better.  

As for pulling up... I don't know why, but it seems that even 50M would not be nearly enough to make it work well, given it barely works as 12M.


[edit]

Another test reveals that with the pull down setup that works the best, a damp finger works even better, which was expected.  The LED lights very brightly with a light touch of a damp finger.
1091  Forum 2005-2010 (read only) / Interfacing / Re: Touch switch on: June 17, 2010, 09:28:39 am
This chip?  Do you mean the chip in that other thread?  I'm not using that here.  I was just referencing what you said about how switches should be used.

Does that chip have 50K pullups then?  I haven't looked into that.


My switch here is connected to pin 2 on the Arduino Pro Mini.  

And according to this page the pull ups on that are 20K:
http://www.arduino.cc/en/Tutorial/DigitalPins


So I was wrong about them being 10K, but that's neither here nor there, because as far as I know, they're not enabled.


Does that help make it any clearer what might be going on?
1092  Forum 2005-2010 (read only) / Interfacing / Touch switch on: June 17, 2010, 07:14:15 am
Hey guys,

I've got a resistive touch switch working in my project, but I've got a question....

Why doesn't it work as well with a pull up resistor, as with a pull down?

I've been told that the usual method of connecting switches to the Arduino is to use a pull up resistor, and that using a pull down wastes electricity, is less immune to noise, and has more potential for damage if mistakes in the wiring are made:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1276283661/10#10

Because of this, I decided to try reversing the wiring on my resisitve touch switch.  But doing so doesn't work!

Here's how I've got it wired up now:

Pin -> Touch Wire 1 -> 12M Resistor -> Gnd
Touch Wire 2 > 5v

Placing my finger across touch wires 1 and 2 completes the connection to +5v, and the led on pin 13 lights up.


If I try the reverse however:

Pin -> Touch Wire 1 -> 12M Resistor -> +5v
Touch Wire 2 > Gnd

The led stays lit, as it should because the pin is being pulled high, but placing my finger across the touch wires does nothing, unless I press really hard, then the led dims very slightly.

It should be noted that for testing here, I am using the button example.  I believe that the 10K pullup on pin 2 is therefore not enabled.  The code doesn't explicity enable or disable it anyway, and I think pins are low by default, so it should be off when the pin is set to input mode.
1093  Forum 2005-2010 (read only) / Interfacing / Re: Shiftin - 8 pulldowns? on: June 12, 2010, 10:27:09 am
Quote
Correct on all points, but why are they relevant? Is there some important reason to use shift registers that you haven't mentioned?

I was just saying... he was suggesting a different circuit with another kind of multiplexer, but he was using shift register terminology.

The only reason I was considering shift registers in the first place was becuase I may need more dip switches than I have pins available on the Arduino.  And the only reason I'm still considering them is that one extra pin I'd save using them over the multiplexer.  If I don't need to save one pin somewhere though, I'm gonna go with the multiplexer.

Quote
The suggested analog multiplexer works in either direction. Your Arduino code handles what to do with each bit of input.

Yes, I'm aware of that.  I was trying to undertsand why he mentioned needing a different type of multiplexer that can output.  I thought maybe it was a langugae barrier and he didn't know the chip in question functioned as both.  But perhaps he meant to say shift register after all.


Quote
It appears that they are suggesting using an output shift-register as a "programmable" pull-down. Each switch is pulled down (by the 0 in the shift register data) in turn and you look at the common outputs of all the switches to determine if that switch is open (stays high because of the Arduino built-in pull-up) or goes low (because the switch is conducting the zero from the shift register.  Rather clever, IMHO. Smiley  Only downside is that it requires an OUTPUT shift register, vs. an INPUT shift register (as the one you are trying to use).

Well if that's true, then what I described... what I thought he was trying to describe...  was kind of the same thing but  using the multiplexer instead.  

Except I don't know if what I suggested would work... because rather than set them all high but one, I set one low and left the others hanging, expecting that the pull up resistor on the arduino would do the rest.


Quote
Of course, when resistors are so small that they can be put between the pins of the switch, one wonders what is the obsession with avoiding them?

Are you talking about surface mount?  I'm soldering all these boards by hand with through-hole components. :-)  

I haven't yet ventured down the road of paying the board manufacturer to put all the surface mount stuff on there for me, and I don't really want to get into soldering SMT stuff myself.
1094  Forum 2005-2010 (read only) / Interfacing / Re: Shiftin - 8 pulldowns? on: June 12, 2010, 08:31:58 am
Quote
In order to work without any external resistor the circuit should be a different one

Okay, but before we get into that... why do I need an external resistor for the other setup?

I was told to attach each of the switches to ground, and to the mutliplexer, and the common output from the multiplexer to the input on the arduino, then add a pull up resistor to that input pin.  Switching a switch on would then pull it down when I have selected that switch with the three select pins.

But if that will work, then why the need for the pull up resistor, if the the input pin has a pull up resistor built into it?


Quote
Step 1) Do not use a shift in but a shift out. Yes, an output multiplexer.

I don't understand.  There's no shifting at all with a multiplexer, is there?  There's no clock on a multiplexer.  You don't use the shiftin or shiftout commands...

Also... an output multiplexer?  Do you mean a demultiplexer?


Quote
Step 2) Connect all switches to the different outputs and one common AVR input

AVR input?  I don't know that term.  Are you saying attach one end of the switched to one pin of the Arduino and the other end to the individual outputs of the demultiplexer?


Quote
Step 3) Enable pullup for this input

So... pull the switches high...


Quote
Step 4) Load the shiftout with all 1 but 0 zero

Um...  Set all three inputs on the demultiplexer high, and none of them low?  


Quote
Step 5) Read the input in order to determine if the corresponding switch is pushed

Hm... maybe what you were trying to say is step through each of the outputs one at a time?

No... that doesn't make sense.  Unless maybe you want me to connect the input pin in the demultiplexer to ground?

In which case...  when a switch ISN'T selected... the pin it is attached to on the demultiplexer would be connected to nothing, so even if that switch were in the on position it wouldn't pull the input pin to ground.  So an unselected pin could not affect the state of the Arduino's input pin.

On the other hand, if a switch IS selected... it would be connected to ground.  And thus, if it is on, it will pull the input pin low.  And we'll know it was that switch which did it because the unselected switches can have no effect on the input pin, because as mentioned previously, they would be connected to nothing.

I think that's what you were getting at anyway?
1095  Forum 2005-2010 (read only) / Interfacing / Re: Shiftin - 8 pulldowns? on: June 12, 2010, 07:09:51 am
You mean like a DAC?  But in reverse?  

Mmm.... Neat idea, but too risky.  Each switch added would be more likely to give you faulty readings.  Then there's the issue of noise which could affect the readings which I'm by no means an expert( or even an intermediate) at mitigating.
Pages: 1 ... 71 72 [73] 74 75 ... 86