Hello,I am using the Hitechnic NXT gyro sensor to control our robot's turn degrees. Right now I am just testing the code on a Lego robot. I have found that the ability of the nxt to run through the code quickly seems to be inhibiting me. I have one task calculating the gyro average while having a function calculate the degrees turned. Basically, my problem is this, when the robot turns at a very slow speed, the robot stops precisely enough, but when it spins at a faster speed, it will overshoot the number of degrees I want it to spin. What is the quickest way to make the program execute?Thanks for any help.

Here's the code: (Some things are in comments which I used to be using but am not using at the moment)

I don't understand why you need to do all this complex averaging on a separate task. If you want to turn a given angle as fast as you can without overshooting, why can't you do PID controlled turn? i.e. You turn hard initially but when you are close to the target angle, the turn will slow down.

Wed Feb 09, 2011 10:03 pm

ThePaperplaneologist

Rookie

Joined: Wed Feb 09, 2011 7:28 pmPosts: 14

Re: Fastest Code Execution

Well, I am not all that familiar with PID, but I'm pretty that there is no way to read the angle directly off the gyro, so somehow I must use the speed and time to calculate the number of degrees I have turned. (unless there's something I don't know about) I do think that the idea of turning quickly and then slowing down sounds like a good one. Is that all you meant by PID control?

Thu Feb 10, 2011 1:15 pm

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1519

Re: Fastest Code Execution

Yes, that's integration. Integrating angular velocity against time gives you angle. Yes, PID control is about approaching your set target as quickly as possible but slowing down when you are almost there. But these are two separate problems. We have a gyro library module that does the integration and gives you the heading. If you want to take a look at how it is implemented, it is here:http://proj.titanrobotics.net/hg/Frc/20 ... nxt/gyro.hThere are many articles on the Internet about PID control theory if you are interested in reading more about it:http://en.wikipedia.org/wiki/PID_control

Thu Feb 10, 2011 1:26 pm

ThePaperplaneologist

Rookie

Joined: Wed Feb 09, 2011 7:28 pmPosts: 14

Re: Fastest Code Execution

MHTS wrote:

Yes, that's integration. Integrating angular velocity against time gives you angle. Yes, PID control is about approaching your set target as quickly as possible but slowing down when you are almost there. But these are two separate problems. We have a gyro library module that does the integration and gives you the heading. If you want to take a look at how it is implemented, it is here:http://proj.titanrobotics.net/hg/Frc/20 ... nxt/gyro.hThere are many articles on the Internet about PID control theory if you are interested in reading more about it:http://en.wikipedia.org/wiki/PID_control

Thanks

Thu Feb 10, 2011 1:40 pm

gcurtis79

Rookie

Joined: Sat Jan 14, 2012 12:13 pmPosts: 3

Re: Fastest Code Execution

MHTS wrote:

Yes, that's integration. Integrating angular velocity against time gives you angle. Yes, PID control is about approaching your set target as quickly as possible but slowing down when you are almost there. But these are two separate problems. We have a gyro library module that does the integration and gives you the heading. If you want to take a look at how it is implemented, it is here:http://proj.titanrobotics.net/hg/Frc/20 ... nxt/gyro.hThere are many articles on the Internet about PID control theory if you are interested in reading more about it:http://en.wikipedia.org/wiki/PID_control

The header file won't load in my robotc, I'm trying to understand the gyro better, but I can't seem to figure out how to time the calculations accurately. I get many errors when including the header file, gyro.h, example:

Who is online

Users browsing this forum: No registered users and 2 guests

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