Pages: 1 [2] 3   Go Down
Author Topic: Graphite  (Read 1977 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24449
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
void draw()
You may wish to omit that from your Arduino sketch.
Logged

"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.

Connecticut
Offline Offline
Edison Member
*
Karma: 16
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24449
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Connecticut
Offline Offline
Edison Member
*
Karma: 16
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
binary fractions
???
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24449
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Connecticut
Offline Offline
Edison Member
*
Karma: 16
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24449
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
runningAverage -= runningAverage >> 3;   // multiply runningAverage by 7/8
runningAverage += newReading >> 3;       // add in 1/8 of the new reading.
Logged

"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.

Connecticut
Offline Offline
Edison Member
*
Karma: 16
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I get it! Thanks!
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31541
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Connecticut
Offline Offline
Edison Member
*
Karma: 16
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
God Member
*****
Karma: 2
Posts: 711
a, b = b, a+b
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Connecticut
Offline Offline
Edison Member
*
Karma: 16
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Boston Suburbs
Offline Offline
God Member
*****
Karma: 14
Posts: 955
I am above your silly so-called "Laws", Mister Ohm.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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..

Logged

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

New Hampshire
Offline Offline
God Member
*****
Karma: 13
Posts: 779
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Connecticut
Offline Offline
Edison Member
*
Karma: 16
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I FIGURED IT OUT!!!!!! smiley smiley smiley smiley 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
Logged

Pages: 1 [2] 3   Go Up
Jump to: