View unanswered posts | View active topics It is currently Fri Nov 22, 2019 6:08 am






Reply to topic  [ 36 posts ]  Go to page Previous  1, 2, 3
Gyro PID 
Author Message
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: Gyro PID
akash329dsouza wrote:
I was just wondering could you explain to me how your gyro driver works and how it's different than Xanders? Because for some reason yours was able to calculate the drift out almost entirely for us and with xanders it was going up nearly one per second. So I wanted to figure out why. Thanks!

I am not sure which of Xander's drivers you are referring to? Are you talking about the ones come with RobotC 3.x or 4.x? I am not aware of Xander's drivers doing any integration for heading. In fact, I just checked both 3.x and 4.x driver, it is returning the gyro turn rate (HTGYROreadRot in hitechnic-gyro.h). You need to do the integration yourself if you are using those drivers. How did you come to the conclusion that those drivers have integration and they have a drift? If you are using a different driver, please point me to it and post your other code so I can probably take a look to see if you are calling it correctly.


Thu Dec 25, 2014 2:54 am
Profile
Novice

Joined: Tue Dec 16, 2014 10:25 am
Posts: 81
Post Re: Gyro PID
Well we were using xanders drivers and doing the integration ourselves but it was drifting about 1 per second while sitting still .We knew it was the correct code because after we used some example code from the driver and it was still drifting.

_________________
Thanks!


Fri Dec 26, 2014 2:29 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: Gyro PID
If you were doing the integration yourself then you need to understand what may cause the drift. Without seeing your code, I can only comment on generic reasons. There are two main things you need to calibrate for the gyro before integration. One is the offset and the other is noise level. Xander's driver provides a calibration function that will determine the offset. You need to call this calibration function to eliminate the offset. This is done by averaging 50 data points while the robot sits still. Without calling this calibration function, you get a default offset which may not be completely accurate. This could cause the drift you are seeing. After the offset is taken out of the equation, you need to determine the noise level. This could be done by the same calibration loop to determine the noise margin. To eliminate the noise while the robot sits still, you make the noise margin as a deadband. This means when the robot sits still, there may be a small amount of noise that causes drift if you integrate the noise. It is arguable if you really need this because if the offset is truly eliminated, the noise should net a zero in integration. But I found eliminating the noise helps in my case. Finally, I have seen others doing integration by multiplying a constant period that is used in wait1Msec(). In reality a robot loop that does things and then does a wait1Msec takes more time than the parameter used in wait1Msec and the time taken to do 1 loop is not constant. That may cause drift as well. Therefore, you need to accurately determine the time it takes for each robot loop so you can do the integration accurately. If you are using our gyro module, you can examine the code and see how it does it yourself.


Fri Dec 26, 2014 4:24 am
Profile
Novice

Joined: Tue Dec 16, 2014 10:25 am
Posts: 81
Post Re: Gyro PID
Ok thanks!

_________________
Thanks!


Fri Dec 26, 2014 9:20 am
Profile
Novice

Joined: Tue Dec 16, 2014 10:25 am
Posts: 81
Post Re: Gyro PID
Another quick question, you were saying that if there is a weight difference or friction on one wheel. We have a weight difference and it curves without balancing it out but shouldn't that mean that the program isn't working? Because it should be correcting for that shouldn't it? Thanks!

_________________
Thanks!


Sun Dec 28, 2014 7:23 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: Gyro PID
It should still correct it but the K constant may need to be higher. It also means your robot is not symmetrical so if K is tuned correctly for curving right, it may be too strong for curving left. So it's better to balance it to make the robot symmetrical. Alternatively, you could have two different K values one for each direction but that's messy.


Sun Dec 28, 2014 8:25 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 36 posts ]  Go to page Previous  1, 2, 3

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.