ADXRS450 Gyro Declarations/Calibration

We just got our new gyro, an ADXRS450 Analog Devices gyro, and declared it in our include statements and put a declaration for it. We put the value from the gyro into Shuffleboard, but when we enable the robot and drive it in teleop, we get no output from our gyro.

Here are the statements we are using:
#include <frc/ADXRS450_Gyro.h>

frc::ADXRS450_Gyro gyro{frc::SPI::Port::kMXP};

frc::SmartDashboard::PutNumber(“Gyro Angle”, gyro.GetAngle());

Where did you put the code to SmartDashboard::PutNumber? If it’s not called periodically, it wouldn’t update.

We put the code to Smart Dashboard in Teleop Periodic.

Also, in driver station, we are getting an error saying “could not find ADXRS450 gyro” even though there is a green light on the gyro and the electrical team verified that it was placed on the RoboRio correctly.

Are you using the FIRST Choice board? If so, those hoop up to the dedicated SPI header, and you need to be using kCS0 when constructing the gyro. kMXP is only used if hooked up to the large 40 pin mxp port

Thank you for your response! We are hooked up to the SPI header, so we tried the only option we had which was kOnboardCS0. However, that didn’t work and it still said “could not find ADXRS450 Gyro,” so we tried the same command but with CS 1, 2, and 3, but the same problem was occurring. Also, driver station would say “no robot code” after we deployed the new code with the kOnboardCS(0/1/2/3) addition.

Furthermore, the gyro angle in shuffleboard remained 0 for the kOnboardCS0, 1, 2, and 3 attempts that we made and it wasn’t possible to do just kCS0, since it came up with the error “enum ‘frc::SPI::Port’ has no member ‘kCS0’,” so we were wondering if there is anything else we are missing or if we need to calibrate the gyro in some way to get an output

Did you try using “kOnBoardCS0” instead? If I remember correctly WPILIB won’t recognize kCS0.

Yes, we started with kCS0, and when that didn’t work we tried kOnBoardCS0, which did not create errors in the code, but we still had errors in driver station that said “could not find ADXRS450 gyro” and didn’t get any output in shuffle board.

We still had this issue, and we were wondering if there was anything else we need to do as far as calibration or if we need to get the angle somewhere else first. Also, we were wondering if we need to declare it as an Analog Gyro even though we have an ADXRS450 Gyro (which we didn’t think made sense to do), but we are just confused because we didn’t know if there was any other code we need to write for the gyro (by the way the green light on the gyro was on).

As of right now, we are still running into issues with the gyro. We tried adding the gyro.Calibrate() function to see if it would get the angle from the gyro, but we were never actually able to test that change and any of our other changes since driver station wasn’t getting robot code. We were also wondering if we might have placed the gyro on the robot wrong even though there is a green light because we saw other posts about wiring using PWM cables while we just placed the gyro directly onto the SPI ports.