Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Technical Discussion (http://www.chiefdelphi.com/forums/forumdisplay.php?f=22)
-   -   Best gyro for frc. (http://www.chiefdelphi.com/forums/showthread.php?t=130538)

Andrew Schreiber 22-12-2014 17:28

Re: Best gyro for frc.
 
Quote:

Originally Posted by seg9585 (Post 1415936)
Correct -- I accumulated the last 50 samples, averaged the value (divide by 50), and calculated the new heading (this means the heading is updated at 20Hz, not every 20ms).

The reason I had to do this is because the most accurate Timer I could find in the Arduino was only accurate to the nearest 1ms and this introduced significant heading error when calculating time delta, particularly at high rates.

Happy to post my code if interested.

What do you mean the most accurate timer was 1ms? Unless you meant microsecond instead of the millisecond I'm assuming that means.

seg9585 22-12-2014 17:34

Re: Best gyro for frc.
 
Quote:

Originally Posted by Andrew Schreiber (Post 1415946)
What do you mean the most accurate timer was 1ms? Unless you meant microsecond instead of the millisecond I'm assuming that means.

Hmm, I was using the millis() function and did not realize there was a micros() available. Reviewing the Arduino library I now see it is available, so I'll go back and modify my code to use it. This could help to increase heading sample rates.

Andrew Schreiber 22-12-2014 17:40

Re: Best gyro for frc.
 
Quote:

Originally Posted by seg9585 (Post 1415947)
Hmm, I was using the millis() function and did not realize there was a micros() available. Reviewing the Arduino library I now see it is available, so I'll go back and modify my code to use it. This could help to increase heading sample rates.

That's what I assumed, do note that micros() returns multiples of 4 (or 8 on 8mhz arduinos).

You might also want to look into using interrupt driven timers.

And while on the topic of timing and arduino, for timing dependent tasks write the code yourself. Tests I did a couple years back showed that there's a SIGNIFICANT overhead for the arduino digitalWrite compared to the comparable C code. I'd always assumed they were just macros but they actually include a fair bit of code.

seg9585 22-12-2014 17:52

Re: Best gyro for frc.
 
Quote:

Originally Posted by Andrew Schreiber (Post 1415950)
That's what I assumed, do note that micros() returns multiples of 4 (or 8 on 8mhz arduinos).

You might also want to look into using interrupt driven timers.

And while on the topic of timing and arduino, for timing dependent tasks write the code yourself. Tests I did a couple years back showed that there's a SIGNIFICANT overhead for the arduino digitalWrite compared to the comparable C code. I'd always assumed they were just macros but they actually include a fair bit of code.

As in the long variable returned will always be a multiple of 4 (or 8), or a return of "1" actually means 4ms? If the former, no impact since I am just comparing time now to time at last sample collection.

I'm using SPI.transfer(data), not digitalWrite. Is there a more efficient method than this one?

Cash4587 22-12-2014 18:00

Re: Best gyro for frc.
 
Has anyone thought about making an aftermarket board that plugs straight into the expansion port on the rRIO that includes a gyro built in as well as pwm expansion and dI/O and analog expansion?

seg9585 22-12-2014 18:08

Re: Best gyro for frc.
 
Quote:

Originally Posted by Cash4587 (Post 1415958)
Has anyone thought about making an aftermarket board that plugs straight into the expansion port on the rRIO that includes a gyro built in as well as pwm expansion and dI/O and analog expansion?

Gyros are very sensitive to electromagnetic fields, this may be a problem so close to the roboRio.

Even if it wasn't, the chip I tried in particular is a single-axis gyro and will require more precise mounting on the robot. Many teams like to mount cRios/roboRios vertically or in a way convenient for troubleshooting or maintanence. Maybe an embedded 3-axis gyro would solve that problem, like the rRio's 3-axis accelerometer.

seg9585 22-12-2014 22:38

Re: Best gyro for frc.
 
Quote:

Originally Posted by Andrew Schreiber (Post 1415950)
That's what I assumed, do note that micros() returns multiples of 4 (or 8 on 8mhz arduinos).

You might also want to look into using interrupt driven timers.

And while on the topic of timing and arduino, for timing dependent tasks write the code yourself. Tests I did a couple years back showed that there's a SIGNIFICANT overhead for the arduino digitalWrite compared to the comparable C code. I'd always assumed they were just macros but they actually include a fair bit of code.

I added a calibration task that samples 5 seconds of data at 1kHz and calculates the bias from this. And I used micros() instead of ms counts and removed the smoothing, so now the heading is updated at 1kHz as well.

Result: ~1 deg drift in 10 minutes. I think that'll be good enough.

Photo of the setup (3D printed protective case):


Serial Output:

Andrew Schreiber 23-12-2014 09:16

Re: Best gyro for frc.
 
Quote:

Originally Posted by seg9585 (Post 1415955)
As in the long variable returned will always be a multiple of 4 (or 8), or a return of "1" actually means 4ms? If the former, no impact since I am just comparing time now to time at last sample collection.

I'm using SPI.transfer(data), not digitalWrite. Is there a more efficient method than this one?

Looks like you already figured it out, the returned value will always be a multiple of 4.

I'd be willing to bet doing the SPI write yourself would be more efficient but it's probably not a huge deal. The only reason I did any tests was I needed faster executing digital writes. It was mostly an example of how the wrapper library is pretty inefficient.





Mounting the gyro near the roboRio probably won't be an issue. Every time I've run a gyro has been an analog gyro, the issue was that the signal got messed up by the magnetic fields caused by currents driving motors. Minimizing transmission distance should help you there. But this gyro talks SPI so it's less susceptible to that issue.

AustinSchuh 23-12-2014 12:54

Re: Best gyro for frc.
 
Quote:

Originally Posted by Andrew Schreiber (Post 1416338)
Mounting the gyro near the roboRio probably won't be an issue. Every time I've run a gyro has been an analog gyro, the issue was that the signal got messed up by the magnetic fields caused by currents driving motors. Minimizing transmission distance should help you there. But this gyro talks SPI so it's less susceptible to that issue.

You can also throw a ground plane under the gyro to block most of the magnetic fields that might be there. That's good practice anyways.

ayeckley 23-12-2014 13:46

Re: Best gyro for frc.
 
Quote:

Originally Posted by AustinSchuh (Post 1416407)
You can also throw a ground plane under the gyro to block most of the magnetic fields that might be there. That's good practice anyways.

Not to bust your chops, but that's true for electric fields -- not so much for magnetic fields. Effective magnetic shielding requires the use of a material with a high magnetic permeability such as Mu-metal (Carpenter Specialty Alloys). Rolled foil copper such as that found on PCBs has little effect.

AustinSchuh 24-12-2014 01:51

Re: Best gyro for frc.
 
Quote:

Originally Posted by ayeckley (Post 1416425)
Not to bust your chops, but that's true for electric fields -- not so much for magnetic fields. Effective magnetic shielding requires the use of a material with a high magnetic permeability such as Mu-metal (Carpenter Specialty Alloys). Rolled foil copper such as that found on PCBs has little effect.

I wasn't quite sure that I hadn't mixed the two up when I wrote the post. Thanks for calling me out on it :o

slibert 25-12-2014 17:15

Re: Best gyro for frc.
 
Quote:

Originally Posted by Cash4587 (Post 1415958)
Has anyone thought about making an aftermarket board that plugs straight into the expansion port on the rRIO that includes a gyro built in as well as pwm expansion and dI/O and analog expansion?

Kauailabs will be announcing exactly what you describe on January 3.

mman1506 25-12-2014 18:02

Quote:

Originally Posted by slibert (Post 1416906)
Kauailabs will be announcing exactly what you describe on January 3.


Awesome, any plans to offer official Python support?

AdamHeard 25-12-2014 18:09

Re: Best gyro for frc.
 
Quote:

Originally Posted by slibert (Post 1416906)
Kauailabs will be announcing exactly what you describe on January 3.

What gyro specifically?

Thanks

slibert 25-12-2014 19:30

Re: Best gyro for frc.
 
Quote:

Originally Posted by AdamHeard (Post 1416911)
What gyro specifically?

Thanks

Invensense MPU-9250 (9-axis sensor).

Plus an on-board 32-bit ARM microcontroller, providing motion processing and calibration algorithms for accelerometers, gyros and magnetometers. Minimal yaw drift due to filtering/fusion algorithms. UART, SPI, I2C and USB interfaces. Open source hardware and firmware. C++, Java and Labview libraries for the Roborio will be available, too.


All times are GMT -5. The time now is 15:25.

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