Go Down

### Topic: Graphite (Read 4234 times)previous topic - next topic

#### AWOL

#15
##### Mar 27, 2011, 06:33 pm
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

#16
##### Mar 27, 2011, 06:35 pm
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

#17
##### Mar 27, 2011, 06:40 pm
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.

#18
Quote
binary fractions

#### AWOL

#19
##### Mar 27, 2011, 06:45 pm
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

#20
##### Mar 27, 2011, 06:49 pm
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

#21
##### Mar 27, 2011, 07:01 pm
Code: [Select]
runningAverage -= runningAverage >> 3;   // multiply runningAverage by 7/8
"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

#22
##### Mar 27, 2011, 07:09 pm
I get it! Thanks!

#### Grumpy_Mike

#23
##### Mar 27, 2011, 09:08 pm
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

#24
##### Mar 27, 2011, 09:22 pm
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

#25
##### Mar 27, 2011, 10:49 pm
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

#26
##### Mar 27, 2011, 11:08 pm
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

#27
##### Mar 28, 2011, 12:21 am
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.

#28
##### Mar 28, 2011, 06:29 pm
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

#29
##### Mar 28, 2011, 09:13 pm
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

Please enter a valid email to subscribe