Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
first:adxrs450_gyro_board_frc [26 Jul 2018 22:43] – minor wording change for rev 3 description Kristen Chongfirst:adxrs450_gyro_board_frc [12 Dec 2018 17:21] (current) – [Using the Gyro on Your Robot] Kristen Chong
Line 1: Line 1:
 ====== ADXRS450 Gyro Board for FIRST Robotics ====== ====== ADXRS450 Gyro Board for FIRST Robotics ======
-The [[adi>ADXRS450]] gyro board is a single-axis industrial sensor, designed to get teams up and running quickly without having to load 3rd-party libraries. This gyro is readily accessible through multiple sources and is recommended for all teams, including those with no gyro experience. It plugs directly into the SPI port on the RoboRIO and libraries are already included in WPILib - all you have to do is declare it in your robot code and use it!+The [[adi>ADXRS450]] gyro board is a single-axis industrial sensor, designed to get teams up and running quickly without having to load 3rd-party libraries. This gyro is readily accessible through FIRST Choice and is recommended for all teams, including those with no gyro experience. It plugs directly into the SPI port on the RoboRIO and libraries are already included in WPILib - all you have to do is declare it in your robot code and use it!
 \\ \\
 \\ \\
-Supporting code for the ADXRS450 only exists in the three main programming languages supported by FIRST. If your team wants to use this board with other programming languages, please refer to the [[adi>ADXRS450]] product datasheet for more information on how to communicate with this gyro via SPI.+Supporting code for the [[adi>ADXRS450]] is only available for programming languages supported by FIRST. If your team wants to use this board on other platforms or with other programming languages, please refer to the [[adi>ADXRS450]] product datasheet for more information on how to communicate with this gyro.
 \\ \\
 \\ \\
-===== Getting Started ===== +If you're looking for information on other ADI donation resources[[first:first_robotics_donation_resources|click here]] to go back to the main page.
-There are currently two versions of the FRC Gyro board. The libraries detailed on this page apply to both of these versionshowever there are some considerations to take into account for each one.+
 \\ \\
 \\ \\
-{{:first:gyroaccel.jpg?nolink |}}==== FRC Accelerometer & Gyroscope (REV1) ==== +===== Getting Started ===== 
-This version was made available to FRC teams through 2016It includes both the [[adi>ADXRS450]] and the [[adi>ADXL362]] accelerometer. This board continues to be supported by WPILib and you can even use the WPI Accelerometer library to connect to it if you want. Just note that the accelerometer component is no longer supportedso there's a chance that new RoboRIO firmware released each year may not work with this sensor.+There are currently three versions of the FRC Gyro boardThe libraries detailed on this page apply to all of these versionshowever there are some considerations to take into account for each one.
 \\ \\
 \\ \\
 +{{:first:gyroaccel.jpg?nolink |}}==== FRC Accelerometer & Gyroscope (Rev. A) ====
 +This version was made available to FRC teams through the 2016 FRC season. It includes both the [[adi>ADXRS450]] gyroscope and the [[adi>ADXL362]] accelerometer. Both sensors on this board continue to be supported by WPILib, so the accelerometer library can be used to read acceleration data just like the gyro library is used to read rotation rate.
 \\ \\
-{{:first:am-3555-2.jpg?nolink&150 |}}==== FRC Gyro with Chip Select Jumper (REV2) ==== 
-This version of the gyro board was available for the 2017 and 2018 seasons. The accelerometer was removed in favor of a jumper that allows you to configure the "chip select" pin used to communicate with the sensor in case you want to have other devices on the same SPI bus. To use the libraries built-in to WPILib, the default configuration should be to connect the jumper between the CS0 pin and the unlabeled center pin. If you want to use a different setting, you will need to change the "chip select" pin address when initializing the sensor in your robot code. The sections below detail how to do this for each of the three supported languages. 
 \\ \\
 \\ \\
-==== FRC Gyro With Solderable Jumpers (REV3) ==== +{{:first:am-3555-2.jpg?nolink&150 |}}==== FRC Gyro with Chip Select Jumper (Rev. B) ==== 
-This is the lower-cost, more reliable version of the sensor board made available to teams starting with the 2019 season. To make using the sensor even easier for teamswe removed the chip select pin jumpers and added a solderable jumper. This change improves reliability as there is no risk of the jumper accidentally getting lost or removedbut still allows teams the flexibility of adding additional sensors to the SPI bus.+This version of the gyro board was available for the 2017 and 2018 FRC seasons. The accelerometer was removed in favor of a jumper that allows you to configure the Chip Select (CS) pin used to communicate with the sensor. This change allowed users to have other sensors (or SPI peripherals) on the bus without the gyro interfering. To use the libraries built into WPILib without any changes, the jumper should be installed as shown in the image to the left. If you want to use a different settingyou will need to change the Chip Select (CS) pin address in your robot code. The sections below detail how to do this for each of the three supported languages.
 \\ \\
 \\ \\
-===== Using the Gyro in LabVIEW ===== +==== FRC Gyro With Solderable Jumpers (Rev. C) ==== 
-If you need some help getting up and running in LabVIEW, check out the [[https://wpilib.screenstepslive.com/s/currentCS/m/labview/l/145335-creating-building-and-loading-your-benchtop-test-program|WPI Screensteps]] page to get started on the basics. +This is the lower-costmore robust version of the sensor board made available to teams for the 2019 FRC seasonTo make using the sensor even easier for teamswe removed the chip select pin jumpers and added solderable jumper. This change improves reliability as there is no risk of the jumper accidentally getting lost or removedbut still allows teams the flexibility of adding additional devices to the SPI bus.
- +
-As with any LabVIEW robot projectthere are a few places you must place code in order to use the gyro board: Begin.vi, Finish.vi, and any .vi in which you want to access gyro dataThe screenshots in this example assume you are starting from the Arcade robot projectbut the steps are the same for any robot project. +
- +
-==== Setting Up the Gyro in Begin.vi ==== +
-Open your robot project, or create new one if you don't have one created already, and open up your Begin.vi block diagram. This can be found in the project window under Team Code. +
- +
-The first step is to create a new instance of the gyrothen assign a reference name to it so that you can call the gyro reference anywhere in your robot code. You can find the gyro VI under WPI Robotics Library --> Sensors --> Gyro. Bring the Gyro Open VI into your Begin.vi code. It doesn't matter where you place it in this VI.+
 \\ \\
 \\ \\
-{{ :first:beginvifindinggyrostep1.png?nolink |}} +===== A Note on Offset Calibration ===== 
-{{ :first:beginvifindinggyrostep2.png?nolink |}} +To help the robot minimize start-up drift and improve overall sensor performance, an offset calibration function has been built into the gyro driverThis function captures several seconds worth of data and calculates an average offset which is then applied to the sensor output. By default, calibration is automatically started once the RoboRIO begins executing user code and usually takes about 10 seconds to complete
-{{ :first:beginvifindinggyrostep3.png?nolink |}}+
 \\ \\
-When you first bring the instance into your codeit will default to an analog gyroso you will need to change the type using the drop-down menu below the VI's icon. Select "XRS450 SPI Opento tell your robot that you're working with the ADXRS450 board.+<note important>The gyro used in the [[adi>ADXRS450]] measures //angular rate//not //angle!// Any movement during the offset calibration routine **will** introduce some error into **every** sensor measurement! Over time, this error, will appear as "driftin your angle measurement. **It is VERY important that the robot remains completely stationary during this calibration period!**</note>
 \\ \\
 +<note tip>Offset calibration should be performed as soon as the robot is powered on to prevent the routine from interfering with any autonomous code execution. If your gyro angle readings are drifting drastically, clicking **Restart Robot Code** in the driver station will force the RoboRIO to re-execute the offset calibration routine. This should fix any drift issues caused by a bad offset measurement.</note>
 \\ \\
-{{ :first:beginviplacegyro.png?nolink |}} 
 \\ \\
-Next, you need to tell LabVIEW which SPI "chip select" (CS) it will be using. Right click on the "SPI Bus" pin on the Open VI and click "Create --> Constant" to insert an enumerated variableLabVIEW will automatically assign the gyro to CS0, which is the default. **Unless you are using the CS Jumper version of the gyro and want to use C1 or C2 by moving the jumper, //do not change this variable!//**+===== Using the Gyro on Your Robot ===== 
 +{{ :first:adxrs450_rotation_figure.jpg?nolink|}}The figure to the right illustrates the direction of rotation which will generate a positive response from the ADXRS450 gyroscope.
 \\ \\
 \\ \\
-{{ :first:beginvicreatespiport.png?nolink |}}+For more information on how to add gyro functionality to your robot code, select your team's programming language from the list below.
 \\ \\
 \\ \\
-Now you need to assign a reference name to this gyro so that you can refer to it in other VIs. Grab the Registry Set VI from the Gyro palette and place to the right of your Open VI. Then, connect the GyroDevRef pin on the Open VI to the GyroDevRef on the Registry Set VI.+[[first:adxrs450_gyro_board_frc:labview|Using the Gyro in LabVIEW]]
 \\ \\
 +[[first:adxrs450_gyro_board_frc:cpp|Using the Gyro C++]]
 \\ \\
-{{ :first:beginviplacegyroref.png?nolink |}} +[[first:adxrs450_gyro_board_frc:java|Using the Gyro in Java]]
-\\ +
-\\ +
-{{ :first:beginviconnectrefset.png?nolink |}} +
-\\ +
-\\ +
-Now you need to assign a name to your gyro. Right click on the "refnum name" pin on the Registry Set VI and click "Create --> Constant" and create a unique name that you will use to refer to this gyro in the rest of your code. I've left the default value of "My Gyro RefNum" but you can change this to whatever you want. +
-\\ +
-\\ +
-{{ :first:beginvicreatestringname.png?nolink |}} +
-\\ +
-\\ +
-{{ :first:beginvidone.png?nolink |}} +
-\\ +
-\\ +
-==== Closing Communication in Finish.vi ==== +
-Whenever you open a communication bus in your robot code, you have to close those communications when your robot code finishes, just like you have to close all of the programs running on a computer before you can shut it down properly. This is done in the Finish.vi code. Open your robot project and open up the Finish.vi block diagram. Then, place an instance of the Registry Get VI on the outside of the Flat Sequence Structure (the film strip boxes), and an instance of Gyro Close VI on the inside of the first panel of the Flat Sequence Structure. +
-\\ +
-\\ +
-{{ :first:finishviblocksneeded.png?nolink |}} +
-\\ +
-{{ :first:finishviblocksnplaced.png?nolink |}} +
-\\ +
-Then, connect the GyroDevRef pins of both VIs together. +
-\\ +
-\\ +
-{{ :first:finishviblocksconnected.png?nolink |}} +
-\\ +
-Now, create a string constant by right clicking on the Gyro RefName pin on the Registry Get VI and clicking Create --> Constant. Rename this string to be the same name you used when instantiating the gyro in your Begin.vi code. I've left mine as the default, since that's what I used in my Begin.vi code. You're now ready to call data from the gyro! +
-\\ +
-\\ +
-{{ :first:finishvidone.png?nolink |}} +
-\\ +
-\\ +
-==== Using the Gyro in Your Robot Code ==== +
-{{:first:gyrogetanglevi.png?nolink |}}There are several use-cases for using the gyro output in your code. You may want to use the gyro output to accurately track your robot's direction of travel so that you drive straight, or rotate to the right angle. This offers you more precision than simply telling the motors to drive together at the same rate to move forward. For this kind of action, you will use the Get Angle VI. +
-\\ +
-\\ +
-{{:first:gyroresetvi.png?nolink |}}You may also want to be able to reset the gyro, since any gyro will have some drift as the match progresses. Think of it like zeroing a weight scale - it's good practice to "tare" or "zero" the scale when you first turn the scale on, or when you want to use a cup or container for the substance you're measuring and don't want to have to subtract the weight of the container out yourself. For this, you would use the Reset Gyro VI.+
  
-In the example below, I'll just be reporting the gyro angle to the driver station from the Teleop.vi, but these steps apply to anywhere you want to use either of these VIs. 
- 
-To use any Gyro VI, you first have to call the Gyro you initialized in Begin.VI. You saw this when we completed our gyro setup in Finish.vi. Go ahead and place an instance of Gyro Registry Get in your Teleop.vi block diagram and create the constant for your gyro name. **Don't forget to change the constant value to whatever you called your gyro in Begin.vi!** I've left mine as the default, since that is what I used. 
-\\ 
-\\ 
-{{ :first:teleopviexamplegetrefnum.png?nolink |}} 
-\\ 
-Now, place an instance of the Get Angle VI next to it, and wire it up as shown below, just like you did for Gyro Close in your Finish.vi block diagram. Then, go to your Dashboard pallet in the WPI Robotics Library and grab the NT Write Value VI and place it next to your Get Angle VI. Note that when you first place this VI in your code, it will show as expecting a Boolean. This VI can actually automatically detect which data type you are feeding it and adjust accordingly. You can also use the drop-down menu below the VI icon and explicitly specify what data type you want it to expect, but it is usually best to leave it set to Automatic as shown below. 
-\\ 
-\\ 
-{{ :first:teleopvidriverstationwrite.png?nolink |}} 
-\\ 
-Now, connect the Angle pin on the Get Angle VI to the Boolean pin on the driver station VI you just placed. You will see that the icon will change to indicate what kind of data you are sending, which in this case is a Double. Right click on the Name pin and select Create --> Constant and write a name for the indicator that will appear on the Driver Station. 
-\\ 
-\\ 
-{{ :first:teleopvidone.png?nolink |}} 
-\\ 
-\\ 
first/adxrs450_gyro_board_frc.1532637805.txt.gz · Last modified: 26 Jul 2018 22:43 by Kristen Chong