Offline
Newbie
Karma: 0
Posts: 8
|
 |
« on: December 05, 2012, 03:27:34 pm » |
Hi, I am trying to use the Tinkerkit Accelerometer with my Arduino board and am able to successfully read the values of X and Y axis from it, but am having trouble wrapping my head around what these values mean. What do the changes in X and Y values mean? Which is the X axis and Y Axis from a real world view? Any help greatly appreciated. TIA
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: December 05, 2012, 04:27:51 pm » |
X and Y are relative. If the device is on a flat, horizontal surface, conventionally (Cartesian coordinate system) x positive is to the right, x negative is to the left, y positive is forwards (away from the observer), and y negative is backwards (towards the observer)
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #2 on: December 05, 2012, 05:31:05 pm » |
Thanks for the reply. However I notice that I continuously get different values for these 2 even when the accelerometer is at rest. Any ideas why?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #3 on: December 06, 2012, 01:23:39 am » |
Noise, poor grounding, long wires, malicious gravity.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #4 on: December 06, 2012, 03:35:40 am » |
hmm... ok so that isn't normal then? Any ideas/suggestions how to work around that?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #5 on: December 06, 2012, 04:00:33 am » |
I don't know - I can't see your sketch, code, schematic or results.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25577
Solder is electric glue
|
 |
« Reply #6 on: December 06, 2012, 04:50:40 am » |
ok so that isn't normal then? It is normal to get a signal that changes all the time by a bit. However as you have not said by how much we can't tell if it is normal.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #7 on: December 06, 2012, 09:27:22 am » |
Here is the code I am using, int yAxisValue = 0; // value read from the accelerometer's y-axis int prevY = 1023;
void setup() { // initialize serial communications at 9600 bps Serial.begin(9600); }
void loop() { // read the joystick x-axis values: yAxisValue = accelerometer.getYAxis();
if (prevY != yAxisValue) { // print the results to the serial monitor: Serial.print("Y="); Serial.println(yAxisValue);
//Serial.write(yAxisValue); prevY = yAxisValue; }
// wait 50 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(50); }
The results I see on the serial monitor are Y=3xx range numbers (from 310 to 350 etc.), BTW, could someone please let me know how I may capture the output from the /dev/tty.. device to a file. TIA
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25577
Solder is electric glue
|
 |
« Reply #8 on: December 06, 2012, 09:33:16 am » |
Use the code tag icon, the # not the quote next to it when posting code.
You can average say ten readings to get a more stable number.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #9 on: December 07, 2012, 06:47:46 am » |
Thanks that does give me more workable values.  BTW, I am trying to use this accelerometer for a simple game 'Ping Pong' to move the paddle on the screen, but am beginning to wonder if an accelerometer should be used here in the first place? Can accelerometer values be used to represent movement?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #10 on: December 07, 2012, 06:54:58 am » |
Remember that a body at constant velocity is not accelerating, so you can't tell if your device is stationary or moving at 100 kmh-1; you can only detect changes of velocity.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Dallas, TX
Offline
Sr. Member
Karma: 10
Posts: 315
|
 |
« Reply #11 on: December 07, 2012, 12:44:47 pm » |
Remember that a body at constant velocity is not accelerating, so you can't tell if your device is stationary or moving at 100 kmh-1; you can only detect changes of velocity.
What about if it's changing direction but maintaining velocity? 
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #12 on: December 07, 2012, 12:47:18 pm » |
What about if it's changing direction but maintaining velocity? That isn't possible. Velocity is a vector; a direction and a rate of displacement. If you change either, the velocity has changed.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Dallas, TX
Offline
Sr. Member
Karma: 10
Posts: 315
|
 |
« Reply #13 on: December 07, 2012, 01:45:40 pm » |
What about if it's changing direction but maintaining velocity? That isn't possible. Velocity is a vector; a direction and a rate of displacement. If you change either, the velocity has changed. Sorry, you're absolutely right. I was thinking about a constant speed and a changing direction which is a change in acceleration. Carry on! 
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #14 on: December 07, 2012, 06:05:42 pm » |
How can I use the received values to determine the angle at which the accelerometer is at any moment?
|
|
|
|
|
Logged
|
|
|
|
|
|