Go Down

Topic: Accelerometer X and Y axis reading meaning (Read 2292 times) previous topic - next topic

BootComp

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

AWOL

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

BootComp

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?

AWOL

Noise, poor grounding, long wires, malicious gravity.
"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.

BootComp

hmm... ok so that isn't normal then?
Any ideas/suggestions how to work around that?

AWOL

I don't know - I can't see your sketch, code, schematic or results.
"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.

Grumpy_Mike

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

BootComp

Here is the code I am using,
Quote

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

Grumpy_Mike

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.

BootComp

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?

AWOL

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

Papa G


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?  :)

AWOL

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

Papa G


Quote
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! :)

BootComp

How can I use the received values to determine the angle at which the accelerometer is at any moment?

Go Up