Answers.Body: <p>Digging a bit into the C source code for the <code>pybricks</code> firmware, I was able to find <a href="https://github.com/pybricks/pybricks-micropython/blob/415910bd5f53cb538f4b58c8a23d2030096c86b6/lib/pbio/drv/imu/imu_lsm6ds3tr_c_stm32.c#L188" rel="nofollow noreferrer">these two lines</a>:</p>
  <pre><code>PT_SPAWN(pt, &amp;child, lsm6ds3tr_c_xl_data_rate_set(&amp;child, ctx, LSM6DS3TR_C_XL_ODR_833Hz));
  PT_SPAWN(pt, &amp;child, lsm6ds3tr_c_gy_data_rate_set(&amp;child, ctx, LSM6DS3TR_C_GY_ODR_833Hz));
  </code></pre>
  <p>...which means that the IMU is set to a sampling rate of 833Hz.</p>
  <p>Please note that this is how the IMU electronics are configured when <code>pybricks</code> starts - this <em>does not necessarily mean</em> that the <code>pybricks</code> firmware nor the hub's microcontroller CPU can keep up with that rate, or that they can run some of your python code 833 times per second, or that <code>pybricks</code> will run python code at that rate.</p>
  <p>It should be possible to change the sampling rate by modifying the <code>pybricks</code> C code and recompiling the firmware. If you want/need to take on this endeavour, read <a href="https://github.com/pybricks/pybricks-micropython#development" rel="nofollow noreferrer">https://github.com/pybricks/pybricks-micropython#development</a> first.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-27T13:35:13.480Z
Answers.LastActivityDate: 2023-03-27T13:35:13.480Z
Answers.UserDisplayName: IvanSanchez
Answers.Body: <p>In the comments of one of the accepted answer on the question here:
  <a href="https://bricks.stackexchange.com/questions/15057/what-internal-electronics-do-spike-prime-and-mindstorms-robot-inventor-use">What internal electronics do Spike Prime and Mindstorms Robot Inventor use?</a>
  it's mentioned that the pybricks people have determined that the IMU module is a STMicroelectronics LSM6DS3TR-C.</p>
  <p>Googling for this I found the following document on the manufacturers website: <a href="https://www.st.com/resource/en/datasheet/lsm6ds3tr-c.pdf" rel="nofollow noreferrer">https://www.st.com/resource/en/datasheet/lsm6ds3tr-c.pdf</a>
  Which list output data rates from 1.6 Hz to 6.6kHz, probably depending on which mode the chip is configured in... I have no way off knowing which mode/value applies, but perhaps someone else does...</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-27T12:07:09.270Z
Answers.LastActivityDate: 2023-03-27T14:21:28.903Z
Answers.LastEditDate: 2023-03-27T14:21:28.903Z
Answers.UserDisplayName: Michael Verschaeve
Body: <p>I was wondering what is the inertial measurement unit sampling rate, because for my project I need 800 Hertz. I tried to look in the firmware file but I didn’t find anything. I use the <code>pybricks</code> firmware on a Lego Spike Prime hub.</p>
  
Tags: <programming><spike-prime><gyro>
Title: What is the gyro sampling rate on the Spike Prime hub?
UserDisplayName: tom
ThreadText: # What is the gyro sampling rate on the Spike Prime hub?
  
  (Asked by: username_0 on 2023-03-25)
  
  I was wondering what is the inertial measurement unit sampling rate, because for my project I need 800 Hertz. I tried to look in the firmware file but I didn’t find anything. I use the `pybricks` firmware on a Lego Spike Prime hub.
  
  **Tags:** programming, spike-prime, gyro
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-03-27. Score: 4
  
  Digging a bit into the C source code for the pybricks firmware, I was able to find these two lines:
  PT_SPAWN(pt, &child, lsm6ds3tr_c_xl_data_rate_set(&child, ctx, LSM6DS3TR_C_XL_ODR_833Hz));
  PT_SPAWN(pt, &child, lsm6ds3tr_c_gy_data_rate_set(&child, ctx, LSM6DS3TR_C_GY_ODR_833Hz));
  
  ...which means that the IMU is set to a sampling rate of 833Hz.
  Please note that this is how the IMU electronics are configured when pybricks starts - this does not necessarily mean that the pybricks firmware nor the hub's microcontroller CPU can keep up with that rate, or that they can run some of your python code 833 times per second, or that pybricks will run python code at that rate.
  It should be possible to change the sampling rate by modifying the pybricks C code and recompiling the firmware. If you want/need to take on this endeavour, read https://github.com/pybricks/pybricks-micropython#development first.
  
  
  ---
  
  ### Answer by username_2 on 2023-03-27. Score: 2
  
  In the comments of one of the accepted answer on the question here:
  [What internal electronics do Spike Prime and Mindstorms Robot Inventor use?](https://bricks.stackexchange.com/questions/15057/what-internal-electronics-do-spike-prime-and-mindstorms-robot-inventor-use)
  it's mentioned that the pybricks people have determined that the IMU module is a STMicroelectronics LSM6DS3TR-C.
  
  Googling for this I found the following document on the manufacturers website: <https://www.st.com/resource/en/datasheet/lsm6ds3tr-c.pdf>
  Which list output data rates from 1.6 Hz to 6.6kHz, probably depending on which mode the chip is configured in... I have no way off knowing which mode/value applies, but perhaps someone else does...
  
  
  ---
  
  