How do I work out what the highest and lowest values are? Please help.

When I move the accelerometer about.. the values of 'AcY, 'AcZ', 'Gyx' change..

How can i know its limits ? whats the highest and the lowest..

I have tried it manually but I know that way cant be 100% accurate

#include<Wire.h>
const int MPU_addr=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);
}
void loop(){
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)     
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);
  delay(333);
}

Some form of

resultMin = ((lhs < rhs) ? lhs : rhs);
resultMax = ((lhs > rhs) ? lhs : rhs);

lloyddean:
Some form of

resultMin = ((lhs < rhs) ? lhs : rhs));

resultMax = ((lhs > rhs) ? lhs : rhs));

Thank you so much for the reply..

But arent the result function for after you have ran the code..

I just want to know even before running the program.. how far each of them 'AcY, 'AcZ', 'Gyx' can go..

I want to know its limits..(the highest and lowest value each is possible to move to)

Wouldn't that be in the accelerometer datasheet?

Sorry, I misunderstood the question.

http://www.tutorialspoint.com/c_standard_library/limits_h.htm

aarg:
Wouldn't that be in the accelerometer datasheet?

Mine is called a 'MPU 92/65'

where will I be able to get the datasheet for that one?

lloyddean:
Sorry, I misunderstood the question.

http://www.tutorialspoint.com/c_standard_library/limits_h.htm

Is this what I have to insert to get what I want?

#include <stdio.h>
#include <limits.h>

int main()
{


   printf("The minimum value of INT = %d\n", INT_MIN);
   printf("The maximum value of INT = %d\n", INT_MAX);

  
   return(0);
}

If you want to know what the maximum and minimum values are you can possibly get (probably in mv), you are going to have to look at the data sheet for that device. It will specify what the output is for a given acceleration.

Delta_G:
If you just want the maximum value of an int then you can just do the math. An int is 16 bits wide and one bit is the sign bit. So it's 2 to the 16th power minus 1. Or 32767.

But how can i do it using the arduino software.. what do i need to put into my code?

Delta_G:

Serial.println(32767);

Will print the maximum value of a 16 but int. It is unclear what exactly you need or why.

Is that better than the code below

#include <stdio.h>
#include <limits.h>

int main()
{


   printf("The minimum value of INT = %d\n", INT_MIN);
   printf("The maximum value of INT = %d\n", INT_MAX);

  
   return(0);
}

It's far better to use the constants in limits.h as they, being provide by the compiler vendor, are far more likely to be correct and portable than some hardcoded value used by some programmer of questionable experience.

Delta_G:
Do you want to know the maximum size of an int or the largest value the accelerometer can read?

I want to know what is the maximum and minimum values these 'int variables' can reach

int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

Benny_Leonard:
I want to know what is the maximum and minimum values these 'int variables' can reach

int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

But, do you mean in software, or in hardware? The max and min that an int can store, or the max and min that the accellerometer can produce?

'INT_MAX', in limits.h

aarg:
But, do you mean in software, or in hardware?

In the software 'Serial monitor'

Delta_G:
Not where do you want to display it. Which number do you want?

I want the numbers of these below

int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

I want to display it at the bottom of the software.. underneaf the code

Delta_G:
Dammit man. That could be two different numbers. Do you want (1)the maximum number that can be stored in an int or (2)the maximum that you can get from your accelerometer.

Just answer with a 1 or 2 since you don't seem to be able to express it in words.

(2)the maximum that you can get from your accelerometer.

Benny_Leonard:
(2)the maximum that you can get from your accelerometer.

Then look in the datasheet.

Benny_Leonard:
(2)the maximum that you can get from your accelerometer.

I need 1 as well..

(1)the maximum number that can be stored in an int

Delta_G:
Ok. The arduino won't know that. You can only get that from the data sheet. It is a function of the accelerometer itself and how it is read by the code. For example if you read with analogRead then the largest is 1023 and the data sheet will tell you what acceleration that equates to. If you read it by some serial protocol then the data sheet will tell you the limits it might send. Either way you need the data sheet and the code to figure that out. But limits.h has nothing to do with it. It doesn't know anything about accelerometers. Only the maximum size of variable types. An int can hold up to 32767 but that doesn't mean the accelerometer will ever give you a value that big.

Edit: written before #26 was posted

What if I want the (1)the maximum number that can be stored in an int