Go Down

Topic: Graphite (Read 2 times) previous topic - next topic

AWOL

Quote
void draw()

You may wish to omit that from your Arduino sketch.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

baum

And I should be able to port this over to Arduino? I wanted to put all the math on the arduino and as little as possible on processing.

AWOL

Quote
And I should be able to port this over to Arduino?

Yes, though you may wish to not use float, and use binary fractions instead.
Depends on how much processing (with a small "p") you need to do.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

baum

Quote
binary fractions

???

AWOL

Instead of multiplying the running average by 0.8 and adding in 0.2 times the new reading, subtract from the running average a fraction (found by dividing (by shifting) the running average by 2/4/8/16/32), and add in the appropriate fraction of the new reading.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

baum

But how can I use binary fractions? Are they integers? I haven't ever seen a "fraction" data type. Can you please paste some pseudo code so I can see what you mean?

Thanks!

baum

AWOL

Code: [Select]
runningAverage -= runningAverage >> 3;   // multiply runningAverage by 7/8
runningAverage += newReading >> 3;       // add in 1/8 of the new reading.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

baum

I get it! Thanks!

Grumpy_Mike

see Fractions in binary in the link
http://en.wikipedia.org/wiki/Binary_numeral_system

However I don't think there is an answer to your original question as the false reading is the result of varying contact pressure. Therefore it is not false at all but real. So no amount of averaging will get rid of it.

baum

But when I pull up the serial monitor, these "out of line" readings are only for 3-4 readings so averaging the readings should help.

fkeel

just for the record, the code I posted will not work on your arduino (but I think thats been made clear anyway). I just posted it, so that you can take a look at the logic behind it ... as I said, you'll have to find your own implementation which works for your setup...

but i have used this approach to solve similar problems.

good luck

p.
http://embodimentlabs.tumblr.com/
http://paulstrohmeier.info/

baum

The lowpass filter actually performs better than the averaging. averaging the data returns about 6~10 haywire readings after pen is lifted. Low pass filter gives none, sometimes 1.

Excellent!

focalist

Great.  Averaging is probably the simplest form, but the low-pass will perform better for obvivous reasons.  There's even implementations that use confidence intervals and standard deviations, if you go looking around... but they all have the same idea in mind.. smoothing out oddball data to make a dataset more usable..

When the testing is complete there will be... cake.

jraskell

You're going to have to use some sort of wired stylus device in conjunction with the graphite anyways to close the circuit.  This stylus could integrate a spring loaded pushbutton that is only active when an adequate amount of pressure is applied to the point, thus telling the Arduino when to read and calculate stylus position.

baum

I FIGURED IT OUT!!!!!! :) :) :) :) Yay!


Here's how:

Instead of having one alligator clip, I'll have two: one at each end of the line. Then I can take the average of these two values.
Think about it. With one clip, as I lift up, ? increases, arduino thinks I am touching farther away. With two clips, ? increases equally. So if I am in the middle, pressing down with the right amount of force (no idea how much force that is) I should get 512 or so on both sides. As I lift up, each side maybe increases too 600. then I do 1023-600 to get 423. the average of 423 and 600 is 511.5, so close enough.

For my touchpad, I'll just use 4 clips (one for each corner) and solve for 4 different triangles, taking the mean coordiantes.


Thanks for all the help!

baum

Go Up