I’m trying to implement a closed loop controller with the KOP Gyro, and it seems to have a major flaw !!!
The initial symptoms were that if you locked the current heading when the operator stoped turning the bot (joystic returns to detent), the controller would steer the robot BACK about 30 degrees.
I initially suspected my code, but finally I had to start looking at the actual Gyro input. By just wiring the Gyro to a stand-alone RC unit on analog channel 1, I could display the gyro angle whenever it changed.
If I spin the gyro, the heading starts changing immediatly, but when I stop it, the heading changes continue on for almost another SECOND. Once again I suspected my software (maybe overflowing the serial port), so I changed the input to a pot so I could simulate gyro input.
With the POT, the heading stopped as soon as I returned the put to neutral.
So, it really looks like the Gyro output doesn’t go to zero (bias) quickly when the turning stops. I even tried widenning the deadband, but that didn’t help either. Can anyone verify/disprove this from recent experience?
So, it seems to me that with such a long run-on, the gyro is next to useless for any sort of high speed control. The best I can expect is a drunken meander across the field.
Any suggestions would be greatly appreciated.
Also keep in mind that if you are printing to standard out, what you see can lag behind “real time”, mainly if you are printing out every program loop. When outputting that fast, the buffer can’t keep up. If you make it so that it only prints out every .1s or so, it will keep up better.
Yeah, I really did suspect the serial port, so I went out of my way to test that aspect…
I coded up a simple state machine so that the only thing that was printed was when the gyro stated moving and when it stopped. This way you could see exactly when the first and last change occured… typical output was:
This indicate two 90 degree rotation sequences (First CW then CCW, showing tenths of a degree). So no chance of overflowing any buffers etc…
What I find odd is that the angle appears correct although the “Stopped” value was printed a second after I actually stopped. (Despite trying dead-bands all the way from 4 to 20).
Also, for the record, if you output too fast using Printf’s you just lose characters… they don’t back up.
Has anyone actually looked at the output of one of the lastest KOP Gyros on a scope? Does the output cut off immediatley after a rapid rotation?
I’m having reasonable sucess using the Gyro to drive straight (for autonomous mode), but forget about using it after quick turns.
After a fast turn I need to wait for the gyro rate to drop to zero before locking in a new heading. This makes the robot look like it’s having a momentary brainer… but then it takes off again, and drives straight.
The KOP gyro has a maximum number of degrees it can turn in one second before it ‘overflows’ and loses accuracy. To the best of my knowledge, this value is ~85 degrees in one second for the KOP gyro. If you try turning 180 degrees in one second, you will overflow the sensor and drastically lose accuracy. (This is the same as exceeding the +1G acceleration on the accelerometer.)
For use of the gyro with our drive-train on our robot this year, we purchased an additional gyro with a maximum turn-rate of 300 degrees in one second from Spark Fun Electronics. (Which has tons of great sensors, BTW.) Seeing how our drive-train this year is geared for 9 ft/sec at 85% of the CIM motor free speed, the increased turning-rate of this additional gyro was much appreciated.