I am now using gyro sensor to measure the degrees my robot turns. I changed the SensorScale[gyro] to 137 and when I push the robot slowly rotate 180 degrees counter-clockwise, it’s no more than 1.5 degrees error, which is satisfying I think. But when I turn the robot back (e.g another 180 degrees but clockwise), the gyro will give about 5 degrees reading(which is 50 from SensorValue[gyro] in the robotC debugger window). Is this normal?
And when I restart the program(e.g. re-initialize the gyro sensor), and then rotate the robot 180 degrees clockwise, the reading is about -187, which is almost double the error when I turn the robot counter-clockwise. How could this happen?
As for the ‘drifting’ issue of gyro sensor in other threads, I have not noticed much drifting when the robot is completely still, so I think this should not be the cause of the problems above.
So if I want to use the gyro to auto-turn the robot for certain degrees, how can I eliminate the errors above to get a more precise value? Should I just turn the robot in only one direction throughout the auto phase? And should I zero the sensor value every time when I call the turn() function? Any tips?
Thanks for your suggestions, I am indeed using rubber spacers to isolate the gyro to decrease vibration, and it works quite well.
My root question is the mentioned asymmetry values when rotating in opposite directions, which is weird and hard to eliminate; and whether should I zero out the sensor value each time before the call to turn() function? Do you have experience in these before?
I modified your gyroLib2 code to display gyro values in LCD screen, and I find out that when I set the scale factor to 137, my five gyro sensors work quite well when rotating the robot counter-clockwise, which will give almost 1800 (no more than 20 error) for 180 degrees; but when I slowly turn the robot in the opposite direction, e.g clockwise, the error would be 30 to 40, which means about -1770 for -180 degrees. Have you ever experienced this before?
I did do a test last night, the gyro just isn’t very accurate, there is a tradeoff between removing drift and being able to detect slow movement. I also tried the simulation I had posted in the gyro lib project and it was working slightly better. Perhaps try turning off the drift control code I had added (or just look at the raw sensor values).
It sounds like you have a sensor with an asymmetric scale factor. I think that might be caused by mismatched push pull components on the board, but I’m not really an EE so I could be flat wrong.
If that is the case, you could take the raw vakue (after removing the bias) and scale it with different constants depending on if it’s positive or negative. You have already figured out your scale in one direction (137). With a little pen and paper or trial and error you could get the other.