Lauszus:
First of all, how did you calculate your sensitivity?
If you use either 3.3 or 5 volt as reference, it's either:
0.0033/3.31023=1.023
or
0.0033/51023=0.67518
As the sensor has a sensitivity of 3.3 mV/ °/s
Or do you use a different reference? As i can calculate you use 4.711952801 volt as reference (0.0033/4.711952801*1023=0.716454545).Why do you need this line:
gyroAngle = abs((gyroRotation - 360 * ceil(gyroRotation / 360))); // Round up between 0-360
What you call "gyroRotation", is actually the angle
For more precision use integration.
Something like this would work:#define OFFSET 0.0005
gyroRaw = analogRead(0);
gOffset = OFFSET * gyroRaw + (1-OFFSET) * gOffset;
gyroSpeed = (gyroRaw - gOffset)/sensitivity;
gyroAngle += gyroSpeed*dtime/1000;
See this page for more information: http://www.hitechnic.com/blog/gyro-sensor/htway/ Regards Lauszus
Hey, thanks for the replay.
I'm using 3.3v so i changed the sensitivity to 1.023, now the numbers are even less precise.
the gyroZero after calibration is around 325, and the gyro goes about -+300.
I removed the gyroAngle = abs((gyroRotation - 360 * ceil(gyroRotation / 360))); // Round up between 0-360
When i use this:
#define OFFSET 0.0005
gyroRaw = analogRead(0);
gOffset = OFFSET * gyroRaw + (1-OFFSET) * gOffset;
gyroSpeed = (gyroRaw - gOffset)/sensitivity;
gyroAngle += gyroSpeed*dtime/1000;
The numbers goes crazy and keep going up even when the gyro doesn't move.
Bottom line:
Sensitivity = 1.023 - When i move my object 90 Degrees, the gyro showes 50-55 Degrees.
Sensitivity = 0.716454545 - When i move my object 90 Degrees, the gyro showes 83-88 Degrees.
Those drifts just getting worse every move so after few movements the gyro isn't helpfull.
Any ideas ?