Hello guys,
I have used GY-80 IMU for my self-balancing robot, I have interfaced accelerometer and gyroscope with arduino, and I am getting perfect output values the problem is while coding PID algorithm, I am not sure of error values which should be coded by looking at gyroscope sensor values. I went through various topics about gyroscope but I am not sure what error values should be suggested to the coding? Any suggestions would be of great help.
Thanks
Is it possible to post your code.
I am not sure of error values which should be coded by looking at gyroscope sensor values. I went through various topics about gyroscope but I am not sure what error values should be suggested to the coding?
Me also trying to understand What error values ur saying
My suggestion will be connect your gyroscope. Then test to calibrate respective angle mention in datasheet.
http://4tronix.co.uk/store/index.php?rt=product/product&product_id=148
send your screen shot of code.
#include <Wire.h>
#define Register_ID 0
#define Register_2D 0x2D
#define Register_X0 0x32
#define Register_X1 0x33
#define Register_Y0 0x34
#define Register_Y1 0x35
#define Register_Z0 0x36
#define Register_Z1 0x37
int ADXAddress = 0xA7 >> 1; // the default 7-bit slave address
int reading = 0;
int val=0;
int X0,X1,X_out;
int Y0,Y1,Y_out;
int Z1,Z0,Z_out;
double Xg,Yg,Zg;
void setup()
{
Wire.begin();
Serial.begin(9600);
delay(100);
// enable to measute g data
Wire.beginTransmission(ADXAddress);
Wire.send(Register_2D);
Wire.send(8); //measuring enable
Wire.endTransmission(); // stop transmitting
}
void loop()
{
//--------------X
Wire.beginTransmission(ADXAddress); // transmit to device
Wire.send(Register_X0);
Wire.send(Register_X1);
Wire.endTransmission();
Wire.requestFrom(ADXAddress,2);
if(Wire.available()<=2)
{
X0 = Wire.receive();
X1 = Wire.receive();
X1=X1<<8;
X_out=X0+X1;
}
//------------------Y
Wire.beginTransmission(ADXAddress); // transmit to device
Wire.send(Register_Y0);
Wire.send(Register_Y1);
Wire.endTransmission();
Wire.requestFrom(ADXAddress,2);
if(Wire.available()<=2)
{
Y0 = Wire.receive();
Y1 = Wire.receive();
Y1=Y1<<8;
Y_out=Y0+Y1;
}
//------------------Z
Wire.beginTransmission(ADXAddress); // transmit to device
Wire.send(Register_Z0);
Wire.send(Register_Z1);
Wire.endTransmission();
Wire.requestFrom(ADXAddress,2);
if(Wire.available()<=2)
{
Z0 = Wire.receive();
Z1 = Wire.receive();
Z1=Z1<<8;
Z_out=Z0+Z1;
}
//
Xg=X_out/256.0;
Yg=Y_out/256.0;
Zg=Z_out/256.0;
Serial.print("X= ");
Serial.print(Xg);
Serial.print(" ");
Serial.print("Y= ");
Serial.print(Yg);
Serial.print(" ");
Serial.print("Z= ");
Serial.print(Zg);
Serial.println(" ");
delay(200);
}
Thanks for replying, while my gyroscope is in 90 degree position I am getting values like
X:8 Y:-2 Z:5
14 1 11
14 4 4
15 3 1
11 2 0
13 0 0
8 1 3
15 -6 2
15 4 4
10 -1 -1
Now my question is while coding PID algorithm, how should I state my error values, for my proportional logic in PID