Go Down

Topic: Cap sense advice please! (Read 5399 times) previous topic - next topic

TonyWilk

Getting a third contact in would give a direction...either 123123 or 321321...but I haven't figured out how to wire that yet, so I've jury rigged it. As long as the total number of "teeth" is even (from pad one AND pad two combined), then in one direction I always hit pad one first, in the other, pad two.
Ah, so you'll count your way up the pole... neat.
With just inputs to the A-D's you are relying on picking up mains 'hum' I think, so it may stop working when it's portable.

Quote
The "total1 =  cs_4_2.capacitiveSensor(30);" line. This "adds up" readings from the pin I assume. Is the figure in brackets a period of milliseconds or a number of readings? I assume either way that a higher number would be a slower response?
Sorry... what code is that from ?

Yours,
 TonyWilk

GreyArea

It's the example from the capacative sense library by Peter Badger...

GreyArea

Yours is superior of course as it allows a change in direction...my way you have to keep going left if you started left...once the lights are added with my method you'd be able to keep lighting them by going back and forth between contacts...your way it should sense a change of direction.

One advantage to my method though may be aesthetics if it's visible...instead of two toothed contact plates, imagine two sinusoidal "snakes", back to back...as long as the snakes are wide enough that there's no loss of contact "under" the same snake, the effect should be the same...

I do need it to work when "mobile" though...the grounding issue may become a pain...


allanhurst

If you tightly ran a a length of very thin ( ie high resistivity) nichrome wire along your pole, spaced off from a fixed contact plate by a few mm ,   and supplied +/- 5v to the nichrome wire, you'd get a voltage on the fixed contact proportional to where you pressed it to the fixed contact.....

I'd add a capacitor to cut out mains pickup.



Allan

TonyWilk

If you tightly ran a a length of very thin ( ie high resistivity) nichrome wire.... *snip*
Ah, yes... that could be very accurate.

You also just reminded me that these are a thing: SoftPot Membrane Potentiometer

Yours,
  TonyWilk

GreyArea

The nichrome idea and the softpot require actual pressure I guess? ie it would not be possible to put them in the tube?

TonyWilk

The nichrome idea and the softpot require actual pressure I guess? ie it would not be possible to put them in the tube?
Yes, they'd have to be on the outside - tho' you could paint the softpot and maybe use a painted strip of Aquadag (or other conductive paint) as the contact strip for the wire to touch.

For the softpot you'd have to get a finger on it - it's just a thin membrane thing like old resistive touchscreens.

Yours,
 TonyWilk

GreyArea

Hmm, prefer hidden if possible, or decorative if not. Not sure the wire or soft pot delivers on either.

I figured out a way of getting a third contact, without using a third contact! Again cos the pole curves, it's possible to change my original contact layout to include one where the hand touches both...thus giving me my directional order...either 12b12b12b or b21b21b21...(b = both). Seems reliable, just fighting with the code to interpret it and activate the LEDs at the moment.

Got slug tape, but only serrated edge. Grrr. Will give your long triangles a go too, but a question...

You have the triangles...and other strips. What are the other strips for and how are they connected?

I'll post my code once it's reliably turning LEDs on and off. Right now it's a nightmarish hodge podge of the ghosts of variables past...

Thanks for all the help everyone!

TonyWilk

#23
Dec 19, 2017, 03:50 am Last Edit: Dec 19, 2017, 04:08 am by TonyWilk
You have the triangles...and other strips. What are the other strips for and how are they connected?
See attached picture.


The original sensor made use of two things:
1) the high impedance analog inputs are left 'floating'
2) the surroundings have electrical noise

So when you move near a strip, noise couples into the analog input, with the strips being tapered and the finger being in the middle, more noise gets injected where there is more tape. The comparison of the two AtoD readings gives the position.

Problems with that are: a) touching floating inputs can easily damage a chip and b) it only works if there's electrical noise.

What the 'drive band' does is make "loud" noise (the line is driven HIGH just before a readAnalog ) very close to the strip so we can afford to add the 1Mohm pull-down resistors which make it less sensitive to anything else around and makes it more repeatable.

Yours,
 TonyWilk

GreyArea

Thanks for that Tony. Really appreciate the time you've spent on this!

I persisted with my design and have it lighting up the LEDs - sometimes! The code has ended up being horrendously complex because I've written my own calibration routine.

The reason it only works "sometimes" I think is actually physical rather than anything else...my contacts aren't cut accurately enough and the spacing between them is on the borderline of being narrower than my finger (see pics) meaning I'm often hitting contact one and two together, which the code reads as "contact three".

I might persist in tidying it up. If I can find wider copper tape, I have a plotter/cutter that I believe could cut the contacts more accurately, consistently and efficiently (wasting less material) - and make them more aesthetically pleasing (my snake idea)...

TonyWilk

#25
Dec 20, 2017, 11:07 am Last Edit: Dec 20, 2017, 11:08 am by TonyWilk
From what you said earlier and seeing your picture there just made me think...

The long-capacitive-thing tries to measure you hand position wherever you put it, with your variation you 'count' your way up and down the pole.

You could do the same 'counting' thing with resistive sensors - just a couple of studs at each position that pulls up the input. With 3 inputs you'd count 1,2,3,1,2,3 or 3,2,1,3,2,1 etc.

You might even be able to use what you already have to use as a test

real hasty diagram:



Yours,
  TonyWilk

GreyArea

Hasty diagram? Still looks complicated.

Thought I'd hit on a much better way to achieve result today...but the programming is not working as expected;

There's four possible "conditions" for two cap sensors A and B in the way I use them;
C1: both no signal
C2: A full signal, B no signal (in practice B picks up a bit, but the ratio is still easily ten to one)
C3: both half signal (I assum cos it's my capacitance, when I touch both, it's shared between them)
C4: B full signal, A no signal (or same as above, a tiny bit)

I've rejigged my sensor pattern to take advantage of this pattern and my fat fingers (see image); as it's set up I thought it would be very responsive; because the two tongues are close together, it's not possible to straight from C2 to C4; the sliding finger has to pass through C3 first...and that gives me direction, It;s only possible to go 1234 or 4321.

So I set up a "contact" as integer to be 1,2,3 or 4...

...so how in all that's holy is it giving me NEGATIVE values (mostly -1 and -4)?

The value is never incrementally changed, it's always assigned directly. I am stumped. Anyone seen this behaviour before

GreyArea

This is what's going on but I don't know why; the left half of the screen is my calibration setup...peaky, bt workable. The inputs are sensor1 (blue) and sensor2 (red). In the calibration there are three clearly recognisable states, plus a baseline (not recorded here, but it's fine at calibration.

But then when I try and get readings in the main program it does this crazy rubbish (right hand side)


TonyWilk

But then when I try and get readings in the main program it does this crazy rubbish (right hand side)
From the graph I'm guessing your calibration routine is taking an average of the blue and red levels  - which will be a line straight thru the wiggly bits, if you are subtracting that av. level you are left with just +- wiggly bits

Signal in the 1st 1/2 of the graph look great...

Try calibrating by taking:

R= average red
B= average blue
RB = average red+blue

Then your trip levels  are:
t1 = RB/2
t2= (R - RB)/2

so:

(sig < t1) = nothing
(sig > t1) && (sig < t2) = RB active
(sig > t2 ) = R active

Yours,
  TonyWilk


 

Grumpy_Mike

#29
Dec 21, 2017, 07:20 am Last Edit: Dec 21, 2017, 07:24 am by Grumpy_Mike
Hi gents:-
Quote
.so how in all that's holy is it giving me NEGATIVE values (mostly -1 and -4)?
Post your code and we can see.

@GreyArea - What you are doing is not capacitave sensing and I suspect that you are using the cap sense libiary. What you are doing is what was suggested by Paul at the end of reply #1. See what I mean about reliability?

@TonyWilk - I like what you have done with adding that noise inducing track. Have you tried putting a high frequency signal on it. I would modify the speed of one of the PWM timers and put something like a 40KHz signal on it. Then couple the sensor tracks into the A/D inputs through a diode. If the diode don't work ( due to the forward volt drop ) I would bias the analogue input pin with a pull up and pull down resistor of 1M and use a 100K to connect the sensor electrodes to the A/D input. It might also benefit from a 100pF capacitor from input to ground to smooth the input. This way you will have a modicum of protection on the analogue inputs. I would also read the inputs twice and only use the second reading to allow the input A/D capacitor time to charge when switching the input channels.

I also note that you titled that picture you posted as capacitave sensing, this is not what you are doing. You are using, as I am sure you know, capacitave coupling to inject noise into a potential divider.

Go Up