"Could not find ADXRS450 gyro on SPI port 0" Error - Java

Hello Chief Delphi,

I am attempting to implement the ADXRS450 gyroscope (http://firstchoicebyandymark.com/fc16-000) that was included in the kit of parts this year with Java, but running into the following problem:

ERROR 1 could not find ADXRS450 gyro on SPI port 0 org.usfirst.frc.team1188.robot.Robot.robotInit(Robot.java:10)

I have looked at this CD thread and this FRC Reddit post, as well as several other CD threads relating to this chip and the Analog Devices FRC page, but nothing has helped me.

Here is code from my Robot.java file. I was trying to just isolate the gyro, and have no logic in any of the other methods (teleop periodic, etc.)


import edu.wpi.first.wpilibj.ADXRS450_Gyro;
import edu.wpi.first.wpilibj.IterativeRobot;

public class Robot extends IterativeRobot {    
    ADXRS450_Gyro gyro;
	
    public void robotInit() {
    	gyro = new ADXRS450_Gyro();   // This is the line specified in the error message.
    }
}

I get a very similar error when trying to use the chip’s ADXL362 accelerometer, though it specifies SPI port 1 instead of port 0. I’m hoping the solution to this problem solves that as well, but it’s secondary because I can always use the built in accelerometer.

I have tried using the other constructor specified in the wpilib, that requests an SPI port. I have tried both ports 0 and 1; same error for each (but the SPI port in the messages changes as expected.)
I have NOT tried this chip on any other RoboRIO, or any other chip with this code. I have also not tried any other device in this RoboRIO’s SPI port, so I can’t rule out hardware as a problem. But, I also don’t know of a good way to test that quickly.

Has anyone gotten this device to work in Java? The internet seems to have very little information on it in an FRC-context, but with every team getting one this year I’m hoping someone can help.

Please let me know if I need to provide any additional details. Thank you in advance!

Our team is using this gyro and it works great. We don’t have any problems with it.

Have you hooked up a probe to the clock and message lines to the spi gyro to make sure that valid data is being exchanged? If the RIO isn’t sending data you may have a firmware issue. If data is being sent than either your not lighting the right chip select line or you have an issue with the gyro

Hi mikets and Arhowk, thank you for your replies.

Mikets, under the hood, your code looks similar to our code. I downloaded it and ran it, and I get the same problem. This leads me to believe we have a hardware issue. But, the knowledge that other teams are using this successfully with Java is important, so thank you.

Arhowk, no, we haven’t done that. I think that’s what our next step needs to be, but unfortunately due to resource constraints (in particular time), I’m not sure that we will in the imminent future. I was hoping this would just be a silly code issue.

I think for now, we will be reverting to the old kit of parts gyro. If we have time to either test our SPI or test a different ADXRS450 sometime before the end of season, we’ll try that. If not, perhaps after our season ends.

Thanks again for the help!

We use the same gyro and it works fine. Here is the line that I used to call the gyro.

public static ADXRS450_Gyro gyro= new ADXRS450_Gyro();

Do you guys use any roboRIO expansions since I don’t think it is an error how you guy’s code