blob: 565e3a43e1e270ac0169a7b90b0f34366a5d2d93 [file] [log] [blame]
Alex Perrycb7da4b2019-08-28 19:35:56 -07001namespace frc971;
Brian Silverman5f17a972016-02-28 01:49:32 -05002
Brian Silverman7be68ba2020-01-08 22:08:40 -08003// The values in the DIAG_STAT register for the ADIS16470.
4table ADIS16470DiagStat {
5 // True indicates that the internal data sampling clock (fSM, see Figure 15
6 // and Figure 16) does not synchronize with the external clock, which only
7 // applies when using scale sync mode (Register MSC_CTRL, Bits[4:2] = 010, see
8 // Table 101). When this occurs, adjust the frequency of the clock signal on
9 // the SYNC pin to operate within the appropriate range.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080010 clock_error:bool (id: 0);
Brian Silverman7be68ba2020-01-08 22:08:40 -080011
12 // True indicates a failure in the flash memory test (Register GLOB_CMD, Bit
13 // 4, see Table 109), which involves a comparison between a cyclic redundancy
14 // check (CRC) computation of the present flash memory and a CRC computation
15 // from the same memory locations at the time of initial programming (during
16 // production process). If this occurs, repeat the same test. If this error
17 // persists, replace the ADIS16470 device.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080018 memory_failure:bool (id: 1);
Brian Silverman7be68ba2020-01-08 22:08:40 -080019
20 // True indicates failure of at least one sensor, at the conclusion of the
21 // self test (Register GLOB_CMD, Bit 2, see Table 109). If this occurs, repeat
22 // the same test. If this error persists, replace the ADIS16470. Motion,
23 // during the execution of this test, can cause a false failure.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080024 sensor_failure:bool (id: 2);
Brian Silverman7be68ba2020-01-08 22:08:40 -080025
26 // True indicates that the voltage across VDD and GND is <2.8 V, which causes
27 // data processing to stop. When VDD ≥ 2.8 V for 250 ms, the ADIS16470
28 // reinitializes itself and starts producing data again.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080029 standby_mode:bool (id: 3);
Brian Silverman7be68ba2020-01-08 22:08:40 -080030
31 // True indicates that the total number of SCLK cycles is not equal to an
32 // integer multiple of 16. When this occurs, repeat the previous communication
33 // sequence. Persistence in this error may indicate a weakness in the SPI
34 // service that the ADIS16470 is receiving from the system it is supporting.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080035 spi_communication_error:bool (id: 4);
Brian Silverman7be68ba2020-01-08 22:08:40 -080036
37 // True indicates that the most recent flash memory update (Register GLOB_CMD,
38 // Bit 3, see Table 109) failed. If this occurs, ensure that VDD ≥ 3 V and
39 // repeat the update attempt. If this error persists, replace the ADIS16470.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080040 flash_memory_update_error:bool (id: 5);
Brian Silverman7be68ba2020-01-08 22:08:40 -080041
42 // True indicates that one of the data paths have experienced an overrun
43 // condition. If this occurs, initiate a reset, using the RST pin (see Table
44 // 5, Pin F3) or Register GLOB_CMD, Bit 7 (see Table 109). See the Serial Port
45 // Operation section for more details on conditions that may cause this bit to
46 // be set to 1.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080047 data_path_overrun:bool (id: 6);
Ravago Jonese12b7902022-02-04 22:50:44 -080048
49 // True indicates that the Raspberry Pi Pico recieved a packet
50 // from the imu that had a bad checksum but still sent a message
51 // containing a timestamp and encoder values.
52 checksum_mismatch:bool (id:7);
Brian Silverman7be68ba2020-01-08 22:08:40 -080053}
54
Brian Silverman5f17a972016-02-28 01:49:32 -050055// Values returned from an IMU.
Brian Silverman7be68ba2020-01-08 22:08:40 -080056// All of these are raw from the hardware, without any form of zeroing or
57// temperature compensation applied.
Alex Perrycb7da4b2019-08-28 19:35:56 -070058table IMUValues {
Brian Silverman5f17a972016-02-28 01:49:32 -050059 // Gyro readings in radians/second.
60 // Positive is clockwise looking at the connector.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080061 gyro_x:float (id: 0);
Brian Silverman5f17a972016-02-28 01:49:32 -050062 // Positive is clockwise looking at the right side (from the connector).
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080063 gyro_y:float (id: 1);
Brian Silverman5f17a972016-02-28 01:49:32 -050064 // Positive is counterclockwise looking at the top.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080065 gyro_z:float (id: 2);
Brian Silverman5f17a972016-02-28 01:49:32 -050066
67 // Accelerometer readings in Gs.
68 // Positive is up.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080069 accelerometer_x:float (id: 3);
Brian Silverman5f17a972016-02-28 01:49:32 -050070 // Positive is away from the right side (from the connector).
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080071 accelerometer_y:float (id: 4);
Brian Silverman5f17a972016-02-28 01:49:32 -050072 // Positive is away from the connector.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080073 accelerometer_z:float (id: 5);
Brian Silverman5f17a972016-02-28 01:49:32 -050074
75 // Magnetometer readings in gauss.
76 // Positive is up.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080077 magnetometer_x:float (id: 6);
Brian Silverman5f17a972016-02-28 01:49:32 -050078 // Positive is away from the right side (from the connector).
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080079 magnetometer_y:float (id: 7);
Brian Silverman5f17a972016-02-28 01:49:32 -050080 // Positive is away from the connector.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080081 magnetometer_z:float (id: 8);
Brian Silverman5f17a972016-02-28 01:49:32 -050082
83 // Barometer readings in pascals.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080084 barometer:float (id: 9);
Brian Silverman5f17a972016-02-28 01:49:32 -050085
86 // Temperature readings in degrees Celsius.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080087 temperature:float (id: 10);
Brian Silverman5f17a972016-02-28 01:49:32 -050088
89 // FPGA timestamp when the values were captured.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080090 fpga_timestamp:double (id: 11);
Brian Silverman7be68ba2020-01-08 22:08:40 -080091 // CLOCK_MONOTONIC time in nanoseconds when the values were captured,
92 // converted from fpga_timestamp.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080093 monotonic_timestamp_ns:long (id: 12);
Brian Silverman7be68ba2020-01-08 22:08:40 -080094
Ravago Jonese12b7902022-02-04 22:50:44 -080095 // The timestamp when the values were captured by the Raspberry Pi Pico.
96 // This has microsecond precision.
97 pico_timestamp_us:int (id:20);
98
99 // The number of this reading produced from a 16-bit counter.
100 data_counter:int (id:19);
101
102 // The number of messages recieved by the Raspberry Pi that had bad checksums
103 failed_checksums:int (id:21);
104 // True if this packet has a bad checksum
105 // from the Raspberry Pi Pico to the Raspberry Pi.
106 checksum_failed:bool (id:22);
107
James Kuszmaul53507e12022-02-12 18:36:40 -0800108 // The position of the left drivetrain encoder in meters
109 left_encoder:double (id: 17);
110 // The position of the right drivetrain encoder in meters
111 right_encoder:double (id: 18);
Ravago Jonese12b7902022-02-04 22:50:44 -0800112
Brian Silverman7be68ba2020-01-08 22:08:40 -0800113 // For an ADIS16470, the DIAG_STAT value immediately after reset.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800114 start_diag_stat:ADIS16470DiagStat (id: 13);
Brian Silverman7be68ba2020-01-08 22:08:40 -0800115 // For an ADIS16470, the DIAG_STAT value after the initial sensor self test we
116 // trigger is finished.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800117 self_test_diag_stat:ADIS16470DiagStat (id: 14);
Brian Silverman7be68ba2020-01-08 22:08:40 -0800118 // For an ADIS16470, the DIAG_STAT value associated with the previous set of
119 // readings. This will never change during normal operation, so being 1 cycle
120 // state is OK.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800121 previous_reading_diag_stat:ADIS16470DiagStat (id: 15);
Brian Silverman7be68ba2020-01-08 22:08:40 -0800122
123 // The value read from the PROD_ID register.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800124 product_id:uint16 (id: 16);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700125}
126
127root_type IMUValues;