Go to Post but eventually it seems that we realize that there's an I in FIRST, and the I stands for Inspiration, not for "me" - MrForbes [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-02-2008, 21:50
pheadxdll pheadxdll is offline
Registered User
AKA: Alex
FRC #1225 (Amperage Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: North Carolina
Posts: 168
pheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud of
Gyro Sensor Questions

I was thinking about using this years gyro in the KOP to keep our robot driving straight, but a mentor expressed to me that the gyro would have problems detecting the slow rate of turn we have. He said that the gyro was better at detecting drastic turns like 90 degrees.

You teams that have used the KOP gyro before, can you tell me how realible and sensitive it is for detecting turns and for keeping the robot in a straight path?

Much appriecated,

Alex
__________________
Amperage Robotics Team 1225
Site under-going revamp. :/

Last edited by pheadxdll : 15-02-2008 at 22:08.
  #2   Spotlight this post!  
Unread 15-02-2008, 23:05
EricS-Team180's Avatar
EricS-Team180 EricS-Team180 is offline
SPAM, the lunchmeat of superheroes!
AKA: Eric Schreffler
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Apr 2002
Rookie Year: 2001
Location: Stuart, Florida
Posts: 561
EricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond repute
Re: Gyro Sensor Questions

we've been using 300deg/sec analog devices gyros since 2004. We've had great success with them for driving straight. We've also integrated the signal to give an angular orientation. Since the k.o.p. gyros will saturate at lower turn rates, we have not used them, but for aiding in straight driving, I see no reason not to try them. We sample the gyro during disabled mode and let a neutral point value settle out. This becomes neutral for the next 2min and 15 sec. We typically take the average of the current and last pass readings and use that, minus, the neutral point, as the error. Then with a multipler (proportional gain) like 1/4 * the error , we add the delta value to the motor pwm on the side it is drifting towards.

We just read the gyro in the main loop (38hz), and it works like a charm.
__________________

Don't PANIC!
S. P. A. M.
  #3   Spotlight this post!  
Unread 15-02-2008, 23:15
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Re: Gyro Sensor Questions

if you use the KOP gyro, a quick decelleration will throw the integration of the signal WAY off. be careful. Personally, i dont really trust the gyro for absolute positioning, though it does help drive straight.
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY
  #4   Spotlight this post!  
Unread 15-02-2008, 23:17
dsm dsm is offline
Registered User
no team
 
Join Date: Jan 2008
Location: U.S.
Posts: 9
dsm will become famous soon enoughdsm will become famous soon enough
Re: Gyro Sensor Questions

Agreed, our team used the gyro for driving straight last year, and it worked very well.

Your mentor is correct, in that the gyro probably isn't good for, say, automating subtle turns with high precision, but we have had no problem using it to keep the robot from drifting off to one side when it shouldn't.
  #5   Spotlight this post!  
Unread 07-04-2008, 21:17
Demothesis's Avatar
Demothesis Demothesis is offline
Team Leader/Programmer
FRC #2169 (KING TeC)
Team Role: Leadership
 
Join Date: Dec 2006
Rookie Year: 2007
Location: Prior Lake
Posts: 32
Demothesis is on a distinguished road
Re: Gyro Sensor Questions

As long as you're on the topic, where did you go to learn how to use the gyros? Is there another way besides using Kevin's code? Like always, the simplest solution will be the best and I find that Kevin kind of goes overboard with his code (hence the need to all but re-write the default code).

Demothesis
  #6   Spotlight this post!  
Unread 07-04-2008, 21:34
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: Gyro Sensor Questions

Quote:
Originally Posted by Demothesis View Post
As long as you're on the topic, where did you go to learn how to use the gyros? Is there another way besides using Kevin's code? Like always, the simplest solution will be the best and I find that Kevin kind of goes overboard with his code (hence the need to all but re-write the default code).

Demothesis
Really... you need almost all of the 'overboard' code he writes. If you're planning on integrating rate of rotation up to absolute angle with any kind of repeatability, you MUST have extremely precise sampling timing so that you don't under or over integrate a specific sample of rotation rate. Any variations in the sample rate will cause erroneous headings.

The reason kevin's code looks so confusing at first is that it allows the analog converter to run in a hardware triggered mode. This way, as much of the time critical sampling as possible is done on a hardware only basis, to cut out any possibility of interrupt overhead causing a variation in sampling interval.

It's a really great system... that would be even greater if the processor in the FIRST controller had DMA like some of the newer/fancier Microchip processors... imagine hands-off gyro oversampling that only bothers to interrupt your code after all the samples have been taken, since they were directly recorded to RAM by the DMA.

-q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
  #7   Spotlight this post!  
Unread 07-04-2008, 21:36
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Re: Gyro Sensor Questions

Quote:
Originally Posted by Demothesis View Post
As long as you're on the topic, where did you go to learn how to use the gyros? Is there another way besides using Kevin's code? Like always, the simplest solution will be the best and I find that Kevin kind of goes overboard with his code (hence the need to all but re-write the default code).

Demothesis
There is no need to rewrite the default code... kevin's code just requires an initialization call in the init function, and an ADC processing call in the fast loop. nothing really big.

To learn how to use a YRG, you need to mainly read the manual, and understand that every gyro is essentially different. Each gyro has its own 'zero' point, and this point varies with temperature. Thats why it is required to 'calibrate' the gyro's zero point when you turn the robot on. basically all this does is average all the zero samples together to get the absolute midpoint.

Next you have to understand its a RATE sensor, so in order to get an absolute position, you need to integrate. this means you have to esentially keep a running summation of all the values returned from the gyro (minus its midpoint) times time.

thats all there really is to it... kevin does a couple of other things like degrees-to-radians and sampling/deadzone modifications for different gyros, but thats just to deal with the consumers of his code that have different hardware.
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY
  #8   Spotlight this post!  
Unread 07-04-2008, 21:39
Team 1708 Dave's Avatar
Team 1708 Dave Team 1708 Dave is offline
Lead Robot Inspector
no team
 
Join Date: Mar 2008
Rookie Year: 2008
Location: McKeesport, PA
Posts: 66
Team 1708 Dave is on a distinguished road
Re: Gyro Sensor Questions

We were just discussing this issue. Our team really needs help in this area. Who makes a dependable gyro and sensors for track position and where to get it these items? And helpful hints for putting it all together. This is my first post, so excuse the lack of zest... Dave
  #9   Spotlight this post!  
Unread 07-04-2008, 21:51
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: Gyro Sensor Questions

Quote:
Originally Posted by Team 1708 Dave View Post
We were just discussing this issue. Our team really needs help in this area. Who makes a dependable gyro and sensors for track position and where to get it these items? And helpful hints for putting it all together. This is my first post, so excuse the lack of zest... Dave
I hate to hover/monopolize but... well I was in the area.

You can't go wrong too easily with the ADXRS150EB. This product will soon become unavailable due to (i think) RoHS/Pb-Free conversion, but should be replaced by the soon to be activated part: EVAL-ADXRS613.

Other than that, look to Kevin Watson's awesome code library for the 18F8722 processor. He has a driver already all boxed up and ready to run the whole gyro. It can be used straight out of the box with the gyro, or can be easily modified to fit pretty much any application for sensor data integration over time you can come up with (i.e. getting velocity from an accelerometer).

If you need anything more specific, just post/PM/see us in Atlanta.

-q

p.s. I just realized you said position too. For that, look to grayhill or my favorite, U.S. Digital. They have some economical yet robust encoders that are great for FIRST. Couple these with an appropriately sized spring coupler to increase life/reliability.
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08

Last edited by Qbranch : 07-04-2008 at 21:55.
  #10   Spotlight this post!  
Unread 07-04-2008, 22:51
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,080
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Gyro Sensor Questions

For driving straight, you don't actually need to integrate the gyro output. While that method results in more intuitive controls code, you can re-arrange your controller to accept the non-integrated gyro rate.

Consider the following pseudo-code:

Code:
Left_Motor[n] = Left_Motor[n-1] + Gain*(heading[n] - desired_heading)
Right_Motor[n] = Right_Motor[n-1] - Gain*(heading[n] - desired_heading)
Where "n" is a time index.

This is essentially two proportional velocity controllers with the gyro angle (integration of the rate) as the process variable.

We can differentiate (in a discrete sense) both sides of these equations!

Left_Motor[n] becomes (Left_Motor[n] - Left_Motor[n-1]).
Left_Motor[n-1] becomes (Left_Motor[n-1] - Left_Motor[n-2]).
heading[n] becomes rate[n], and desired_heading (a constant) becomes desired_rate (which is zero).

Repeat for the right side.

So now,
Code:
Left_Motor[n] - Left_Motor[n-1] = Left_Motor[n-1] - Left_Motor[n-2] + Gain*rate[n]
You can do some algebra and re-arrange to get:

Code:
Left_Motor[n] = 2*Left_Motor[n-1] - Left_Motor[n-2] + Gain*rate[n]
Look weird? Absolutely. But will it work correctly? Yes.

You do probably will want to filter the rate[n] input since Kevin's oversampling and heading calculation essentially accomplishes this for you (integration can be considered a low-pass filter).

I haven't tried this method myself, as Kevin's code saves us a lot of time and works great, but if you really want to DIY, this will let you cut out the hardware ADC.

General Note: This method of differentiating both sides of a controls difference equation is a powerful tool, and is a good way to derive control equations that you hadn't thought of before! Just beware that integration is usually a GOOD thing in control systems and you usually don't want to remove it without a compelling reason. But if you, for example, remember the position version of a PID equation, you can quickly generate the equivalent velocity control PID equation using this method.

Last edited by Jared Russell : 07-04-2008 at 22:59.
  #11   Spotlight this post!  
Unread 07-04-2008, 23:28
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Re: Gyro Sensor Questions

Abwehr: I understand your code, but in essence it is only correcting for a rate. Sure, it will get the 'drive straight' stuff done, but if the robot gets knocked off course it wont know where to go to.

Given the depth of your post though, i think you already know this d=


We had something similar implemented in our code for the purpose of having the robot 'turn' or 'arc' at a predictable rate... it was good except for the jitter.
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY
  #12   Spotlight this post!  
Unread 08-04-2008, 22:50
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,080
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Gyro Sensor Questions

Quote:
Originally Posted by Uberbots View Post
Abwehr: I understand your code, but in essence it is only correcting for a rate. Sure, it will get the 'drive straight' stuff done, but if the robot gets knocked off course it wont know where to go to.

Given the depth of your post though, i think you already know this d=


We had something similar implemented in our code for the purpose of having the robot 'turn' or 'arc' at a predictable rate... it was good except for the jitter.
Actually, it will return to the same position (assuming that the rate signal is not jittery ).

Try it out in excel, and you'll see that you are actually performing integration implicitly.

Make one column a time index (n) 1, 2, 3,... (A)

Make one column a detected gyro rate (random numbers if you want). (B)

Make one column the gyro heading (i.e. =SUM(B[1]:B[N])). (C)

Make two columns for the outputs under the different algorithms (D and E)

D, the original algorithm, would be =D[N-1] (or 0 for the first cell) + Gain*C[N].

E, the non-integrating algorithm, would be =2*E[N-1] - E[N-2] + Gain*B[N].

Fill in 0 for E[N-1] and E[N-2] where those values would be outside the bounds.

Columns D and E will be identical.

The problem with this simplification is it essentially assumes that a 38Hz integration gives valid data. Like I said in the above post, this method is a sort of numerical curiosity - it would throw out all of Kevin's oversampling and timer-based ADC code and the benefits that that brings.

Last edited by Jared Russell : 08-04-2008 at 22:53.
  #13   Spotlight this post!  
Unread 08-04-2008, 23:23
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Re: Gyro Sensor Questions

I agree, that is a numerical curiousity. I guess ill actually have to do the math out to see that one then.
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY
  #14   Spotlight this post!  
Unread 09-04-2008, 00:52
dtengineering's Avatar
dtengineering dtengineering is offline
Teaching Teachers to Teach Tech
AKA: Jason Brett
no team (British Columbia FRC teams)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Vancouver, BC
Posts: 1,833
dtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond repute
Re: Gyro Sensor Questions

This was our first year using a gyro. We used the one from the KoP. We used it to help keep the robot on the "straight and narrow", and it worked okay... at least in conjunction with two other advances (well, they were advances for us).

One: the joystick code was retuned using a lookup table to approximate exponential readings (ie, very little turning when the stick is near centre, but full readings when near the edges.)

Two: we used the IFI USB Chicklet attached to a Logitech game controller. The game controller has two analog joysticks, one for each thumb. We use one thumb for forward/reverse and one for left/right. By seperating the two we no longer have to worry about accidentaly making the robot turn when we are trying to drive straight.

In any case, as far as learning to use the gyro, just hook it up to an analog input and use printf statements to show you the readings so you can get a feel for it. Yes, you can turn the KoP gyro slowly enough that it won't show any readings... but is that EVER a slow turn. Then stick it to your robot and experiment with some of the code samples as posted above.

Adding stuff like the gyro not only makes your robot easier to drive, but helps you to explain to people the differences between tele-operated mode, where the robot makes decisions based on your input, and plain old radio controlled toys where the toy follows your decision mindlessly.

Jason
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ADXRS150 Gyro Yaw Sensor sensitivity? hinewwiner Technical Discussion 5 08-02-2008 09:20
Quick Gyro Questions Jake M Programming 5 24-01-2008 22:36
Gyro/accelerometer/Gear tooth sensor sparrowkc Technical Discussion 2 11-01-2008 22:47
Gyro Questions Jeff G Control System 8 03-12-2004 19:15
Gyro Sensor Questions sanddrag Electrical 8 27-09-2003 20:58


All times are GMT -5. The time now is 20:50.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi