Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 1 | namespace frc971; |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 2 | |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 3 | // The values in the DIAG_STAT register for the ADIS16470. |
| 4 | table 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 Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 10 | clock_error:bool (id: 0); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 11 | |
| 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 Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 18 | memory_failure:bool (id: 1); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 19 | |
| 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 Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 24 | sensor_failure:bool (id: 2); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 25 | |
| 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 Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 29 | standby_mode:bool (id: 3); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 30 | |
| 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 Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 35 | spi_communication_error:bool (id: 4); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 36 | |
| 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 Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 40 | flash_memory_update_error:bool (id: 5); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 41 | |
| 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 Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 47 | data_path_overrun:bool (id: 6); |
Ravago Jones | e12b790 | 2022-02-04 22:50:44 -0800 | [diff] [blame] | 48 | |
| 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 Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 55 | // Values returned from an IMU. |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 56 | // All of these are raw from the hardware, without any form of zeroing or |
| 57 | // temperature compensation applied. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 58 | table IMUValues { |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 59 | // Gyro readings in radians/second. |
| 60 | // Positive is clockwise looking at the connector. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 61 | gyro_x:float (id: 0); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 62 | // Positive is clockwise looking at the right side (from the connector). |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 63 | gyro_y:float (id: 1); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 64 | // Positive is counterclockwise looking at the top. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 65 | gyro_z:float (id: 2); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 66 | |
| 67 | // Accelerometer readings in Gs. |
| 68 | // Positive is up. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 69 | accelerometer_x:float (id: 3); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 70 | // Positive is away from the right side (from the connector). |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 71 | accelerometer_y:float (id: 4); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 72 | // Positive is away from the connector. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 73 | accelerometer_z:float (id: 5); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 74 | |
| 75 | // Magnetometer readings in gauss. |
| 76 | // Positive is up. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 77 | magnetometer_x:float (id: 6); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 78 | // Positive is away from the right side (from the connector). |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 79 | magnetometer_y:float (id: 7); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 80 | // Positive is away from the connector. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 81 | magnetometer_z:float (id: 8); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 82 | |
| 83 | // Barometer readings in pascals. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 84 | barometer:float (id: 9); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 85 | |
| 86 | // Temperature readings in degrees Celsius. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 87 | temperature:float (id: 10); |
Brian Silverman | 5f17a97 | 2016-02-28 01:49:32 -0500 | [diff] [blame] | 88 | |
| 89 | // FPGA timestamp when the values were captured. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 90 | fpga_timestamp:double (id: 11); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 91 | // CLOCK_MONOTONIC time in nanoseconds when the values were captured, |
| 92 | // converted from fpga_timestamp. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 93 | monotonic_timestamp_ns:long (id: 12); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 94 | |
Ravago Jones | e12b790 | 2022-02-04 22:50:44 -0800 | [diff] [blame] | 95 | // 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 Kuszmaul | 53507e1 | 2022-02-12 18:36:40 -0800 | [diff] [blame] | 108 | // 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 Jones | e12b790 | 2022-02-04 22:50:44 -0800 | [diff] [blame] | 112 | |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 113 | // For an ADIS16470, the DIAG_STAT value immediately after reset. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 114 | start_diag_stat:ADIS16470DiagStat (id: 13); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 115 | // For an ADIS16470, the DIAG_STAT value after the initial sensor self test we |
| 116 | // trigger is finished. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 117 | self_test_diag_stat:ADIS16470DiagStat (id: 14); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 118 | // 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 Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 121 | previous_reading_diag_stat:ADIS16470DiagStat (id: 15); |
Brian Silverman | 7be68ba | 2020-01-08 22:08:40 -0800 | [diff] [blame] | 122 | |
| 123 | // The value read from the PROD_ID register. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 124 | product_id:uint16 (id: 16); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | root_type IMUValues; |