Go Down

Topic: Tinkerkit Gyroscope, help to understand outputs (Read 2119 times) previous topic - next topic

marcus barnet

I'd like to use a gyroscope to control my robot path: for example, to control if the path does not diverge from the received path.
If this occurs, i control the motors in order to follow the correct path.

I'm using a tinkerkit gyroscope with a tinkerkit shield but i'm not able to understand the outputs i read from the serial monitor.
In particular, i'm using the sample code to test the gyroscope, the same you can find on the product page:

I try to rotate or to move the gyroscope with my hands but i do not understand the output parameters, in particular roll and pitch angle.
When do they change? i try to turn the gyroscope on its axis, but parameters does not seem to change a lot.

Can you help me, please?

TinkerKit! Gyroscope [T000062-64] Test Example

Roll_Rate: -7   Roll_Angle: 357   Pitch_Rate: 21   Pitch_Angle: 10   Servo: 87
Roll_Rate: 3   Roll_Angle: 355   Pitch_Rate: 21   Pitch_Angle: 31   Servo: 85
Roll_Rate: 3   Roll_Angle: 358   Pitch_Rate: 25   Pitch_Angle: 54   Servo: 88
Roll_Rate: 3   Roll_Angle: 1   Pitch_Rate: 32   Pitch_Angle: 82   Servo: 91
Roll_Rate: 3   Roll_Angle: 4   Pitch_Rate: 32   Pitch_Angle: 114   Servo: 94
Roll_Rate: 7   Roll_Angle: 9   Pitch_Rate: 40   Pitch_Angle: 150   Servo: 99
Roll_Rate: 3   Roll_Angle: 14   Pitch_Rate: 36   Pitch_Angle: 188   Servo: 104
Roll_Rate: 3   Roll_Angle: 17   Pitch_Rate: 32   Pitch_Angle: 222   Servo: 107
Roll_Rate: 10   Roll_Angle: 23   Pitch_Rate: 18   Pitch_Angle: 247   Servo: 113
Roll_Rate: 10   Roll_Angle: 33   Pitch_Rate: 7   Pitch_Angle: 259   Servo: 123
Roll_Rate: 3   Roll_Angle: 39   Pitch_Rate: 18   Pitch_Angle: 271   Servo: 129
Roll_Rate: 3   Roll_Angle: 42   Pitch_Rate: 18   Pitch_Angle: 289   Servo: 132
Roll_Rate: 3   Roll_Angle: 45   Pitch_Rate: 14   Pitch_Angle: 305   Servo: 135
Roll_Rate: 3   Roll_Angle: 48   Pitch_Rate: 14   Pitch_Angle: 319   Servo: 138
Roll_Rate: 3   Roll_Angle: 51   Pitch_Rate: 10   Pitch_Angle: 331   Servo: 141
Roll_Rate: 3   Roll_Angle: 54   Pitch_Rate: 14   Pitch_Angle: 343   Servo: 144
Roll_Rate: 3   Roll_Angle: 57   Pitch_Rate: 10   Pitch_Angle: 355   Servo: 147
Roll_Rate: -14   Roll_Angle: 52   Pitch_Rate: 3   Pitch_Angle: 1   Servo: 142
Roll_Rate: 0   Roll_Angle: 52   Pitch_Rate: 3   Pitch_Angle: 4   Servo: 142
Roll_Rate: -3   Roll_Angle: 51   Pitch_Rate: 0   Pitch_Angle: 4   Servo: 141
Roll_Rate: 7   Roll_Angle: 53   Pitch_Rate: -3   Pitch_Angle: 3   Servo: 143
Roll_Rate: -3   Roll_Angle: 55   Pitch_Rate: 7   Pitch_Angle: 5   Servo: 145
Roll_Rate: 7   Roll_Angle: 57   Pitch_Rate: 3   Pitch_Angle: 10   Servo: 147
Roll_Rate: 10   Roll_Angle: 65   Pitch_Rate: 7   Pitch_Angle: 15   Servo: 155
Roll_Rate: 3   Roll_Angle: 71   Pitch_Rate: 10   Pitch_Angle: 23   Servo: 161
Roll_Rate: 0   Roll_Angle: 71   Pitch_Rate: 10   Pitch_Angle: 33   Servo: 161
Roll_Rate: 18   Roll_Angle: 80   Pitch_Rate: 10   Pitch_Angle: 43   Servo: 170
Roll_Rate: 7   Roll_Angle: 92   Pitch_Rate: 10   Pitch_Angle: 53   Servo: 170
Roll_Rate: 43   Roll_Angle: 117   Pitch_Rate: 95   Pitch_Angle: 105   Servo: 170
Roll_Rate: 29   Roll_Angle: 153   Pitch_Rate: 84   Pitch_Angle: 194   Servo: 170
Roll_Rate: -29   Roll_Angle: 153   Pitch_Rate: -146   Pitch_Angle: 163   Servo: 170
Roll_Rate: 3   Roll_Angle: 140   Pitch_Rate: 14   Pitch_Angle: 97   Servo: 170
Roll_Rate: 3   Roll_Angle: 143   Pitch_Rate: 10   Pitch_Angle: 109   Servo: 170
Roll_Rate: 3   Roll_Angle: 146   Pitch_Rate: 10   Pitch_Angle: 119   Servo: 170
Roll_Rate: 109   Roll_Angle: 202   Pitch_Rate: 14   Pitch_Angle: 131   Servo: 170
Roll_Rate: 3   Roll_Angle: 258   Pitch_Rate: 14   Pitch_Angle: 145   Servo: 170
Roll_Rate: 3   Roll_Angle: 261   Pitch_Rate: 14   Pitch_Angle: 159   Servo: 170
Roll_Rate: 3   Roll_Angle: 264   Pitch_Rate: 14   Pitch_Angle: 173   Servo: 170
Roll_Rate: 7   Roll_Angle: 269   Pitch_Rate: 10   Pitch_Angle: 185   Servo: 170
Roll_Rate: 3   Roll_Angle: 274   Pitch_Rate: 10   Pitch_Angle: 195   Servo: 4
Roll_Rate: 7   Roll_Angle: 279   Pitch_Rate: 10   Pitch_Angle: 205   Servo: 9


The pitch and roll angles vary between 0 and 360, what more do you expect?  These are angles in degrees, there are 360 degrees to one complete rotation.  If that's not what you're seeing you'll have to explain further as we only see the figures, not the motion that lead to them.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


I am experiencing the same problem.
I tried modifying the variable "Sensitivity" from 0,67f (which should be for the 4x) to 0.167f (for the 1x).
But that did not help.

The output is random, or at least it starts with a zero reading on both axises, but once moved I cannot find a relationship between the inclinations I make with the gyroscope and the results printed on the monitor.

I took the tinkerkit shield off and tried measuring the output pin with a simple analogRead and Serial.print format.
The output starts at about 500 for both x and y axises which should be correct, but it never goes + or - 50 from that value no matter how much I move the gyroscope.

Finally I used a voltmeter to measure the output pin: it starts at 2.5V but I could not get a reading higher than 2.7V or lower than 2.3V (again, no matter how much it is moved, slowly or fast) .

Anything else we can try?


If the device is not constrained to rotate about a single axis only then you need to use a full DCM or quaternion orientation algorithm to keep track of orientation (3D rotations are not commutative).  Also rate gyros always drift anyway, so after a few minutes you'll be seeing nonsense unless there is a source of absolute correction information.

Since (if I've found the right page) that is a 2-axis gyro you don't have full information to track orientation in 3D - you will only get consistent information if rotations are about one of the two axes at a time.  The rate information from a 2-axis gyro can be combined with tilt info from an accelerometer to give useful information, note, since in the long term the accelerometer gives absolute pitch and roll.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Yes, it is indeed a 2 axis gyro.
The intention was to use it with the tinkerkit Accelerometer T000020. Since the two together were not giving a reasonable feedback i checked the two sensors separately. The acceler. works fine.

I understand that the gyro alone tends to drift anyway, but should it not still give a reasonable feedback? i.e. if it starts flat on the table with an analog output of 500 (range 0 to 1023) and I revolve it on the axis, say by 90 degrees, it should give an output of about 750. Because of the drift it might start off higher or lower, but shouldn't it still give a feedback of + or - 250 if again i turn it 90 degrees on the same axis?


Its a rate gyro, the output is proportional to the rate of turn, will always output zero when stationary (zero is usually represented at V/2 where V is the gyro supply).  You integrate the output to get an estimate of angle.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131