diff --git a/website/lab/05/index.mdx b/website/lab/05/index.mdx index b7ca7a00e7a..c9ae944062e 100644 --- a/website/lab/05/index.mdx +++ b/website/lab/05/index.mdx @@ -19,7 +19,7 @@ import TabItem from '@theme/TabItem'; - Chapter 12 - *Peripherals* - Chapter 12.3 - *SPI* -4. **Invensense**, *[MPU-6000 Six-Axis (Gyro + Accelerometer) MEMS MotionTracking™ Device](https://invensense.tdk.com/products/motion-tracking/6-axis/mpu-6500/#documentation)* +4. **Invensense**, *[MPU-6500 Six-Axis (Gyro + Accelerometer) MEMS MotionTracking™ Device](https://invensense.tdk.com/products/motion-tracking/6-axis/mpu-6500/#documentation)* 5. **Paul Denisowski**, *[Understanding SPI](https://www.youtube.com/watch?v=0nVNwozXsIc)* @@ -152,7 +152,7 @@ To figure out which pins work with SPI and what channels they are associated wit We also need a `CS` pin, that is simply a GPIO output pin. We will initialize it as such. Any pin can be used. For multiple subs, multiple pins will be initialized. ```rust -let mut cs = Output::new(p.PQa, Level::High, Speed:Low); +let mut cs = Output::new(p.PQa, Level::High, Speed::Low); ``` Now we have set up the SPI, and can use it to communicate with the connected sub. To activate the sub, we need to set the `cs` pin to `low`. @@ -247,7 +247,7 @@ The STM32 Nucleo-U545RE-Q has three SPI channels. Each channel has a multiple se ![STM32 Nucleo-U545RE-Q Arduino Headers Pinout](images/Arduino_Headers.svg) ![STM32 Nucleo-U545RE-Q CN7 Pinout](images/CN7.svg) -![STM32 Nucleo-U545RE-! CN10 Pinout](images/CN10.svg) +![STM32 Nucleo-U545RE-Q CN10 Pinout](images/CN10.svg) @@ -281,18 +281,18 @@ For this lab, we will be using a *digital sensor*, which is an *upgraded* versio ![Digital_Sensor](images/digital_sensor.svg) -## MPU-6000 Inertial Measurement Unit +## MPU-6500 Inertial Measurement Unit -The **MPU-6000** is a *digital* gyroscope and accelerometer designed by InvenSense. It can be interfaced both with SPI and with I2C. This means that we can read the acceleration and angular velocity values directly from the registers of the MPU-6000 using SPI. +The **MPU-6500** is a *digital* gyroscope and accelerometer designed by InvenSense. It can be interfaced both with SPI and with I2C. This means that we can read the acceleration and angular velocity values directly from the registers of the MPU-6500 using SPI. :::info **[DATASHEET](https://invensense.tdk.com/wp-content/uploads/2020/06/PS-MPU-6500A-01-v1.3.pdf)**: Describes the chip and its capabilities. \ **[REGISTER MAP](https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6500-Register-Map2.pdf)**: Describes how to configure and get values from the sensor. ::: -### MPU-6000 Memory Map +### MPU-6500 Memory Map -| address (HEX) | Name | Access +| address (HEX) | Name | Access | |-|-|-| | 1B | GYRO_CONFIG | R/W | | 1C | ACCEL_CONFIG | R/W | @@ -315,7 +315,7 @@ The **MPU-6000** is a *digital* gyroscope and accelerometer designed by InvenSen #### Registers -`WHO_AM_I` register - contains the ID of the MPU-6000 +`WHO_AM_I` register - contains the ID of the MPU-6500 `GYRO_CONFIG` register - used for configuring the gyroscope @@ -363,9 +363,9 @@ The values read from the sensor are 16-bit signed integers and must be interpret ::: -### MPU-6000 wiring +### MPU-6500 wiring -The MPU-6000 has 5 pins: +The MPU-6500 breakout board has the following pins: | Pin | Function | |-|-| @@ -383,17 +383,17 @@ The MPU-6000 has 5 pins: ![mpu6500_wiring](images/mpu6500_wiring.png) :::note -The MPU-6000 can also be interfaced through I2C, using the same pins but with different functions. +The MPU-6500 can also be interfaced through I2C, using the same pins but with different functions. ::: :::note -The MPU-6000 can also act as an I2C master and communicate with external sensors. This functionality will be ignored. +The MPU-6500 can also act as an I2C master and communicate with external sensors. This functionality will be ignored. ::: -### Reading data from the MPU-6000 sensor using Embassy +### Reading data from the MPU-6500 sensor using Embassy -To get the data we want from the digital sensor, we need to access its internal registers. The MPU-6000 has some rules when it comes to reading and writing to these registers, that must be extracted from the [datasheets](https://invensense.tdk.com/products/motion-tracking/6-axis/mpu-6500/#documentation). Every sensor has different registers, and different ways of interfacing them, so reading the datasheet is usually required, especially when we don't have the leverage of using already existing libraries for these sensors. +To get the data we want from the digital sensor, we need to access its internal registers. The MPU-6500 has some rules when it comes to reading and writing to these registers, that must be extracted from the [datasheets](https://invensense.tdk.com/products/motion-tracking/6-axis/mpu-6500/#documentation). Every sensor has different registers, and different ways of interfacing them, so reading the datasheet is usually required, especially when we don't have the leverage of using already existing libraries for these sensors. First, we make sure our SPI is initialized correctly. @@ -415,7 +415,7 @@ let clk = p.PZo; let mut spi = Spi::new(p.SPI1, clk, mosi, miso, p.GPDMA1_CH0, p.GPDMA1_CH1, config); // make sure to actually choose a pin -let mut cs = Output::new(p.PQa, Level::High, Speed:Low); +let mut cs = Output::new(p.PQa, Level::High, Speed::Low); ``` @@ -440,7 +440,7 @@ let mut cs = Output::new(p.PIN_N, Level::High); -In section 6.5 of the [datasheet](https://invensense.tdk.com/wp-content/uploads/2020/06/PS-MPU-6500A-01-v1.3.pdf), we get the information we need in order to read/write to a register of the MPU-6000. +In section 6.5 of the [datasheet](https://invensense.tdk.com/wp-content/uploads/2020/06/PS-MPU-6500A-01-v1.3.pdf), we get the information we need in order to read/write to a register of the MPU-6500. ![SPI_read_write_MPU6500](images/spi_read_write_mpu6500.png) @@ -538,7 +538,7 @@ let screen_dc = Output::new(p.PYm, Level::Low, Speed::Low); let screen_cs = Output::new(p.PZo, Level::High, Speed::Low); let spi_bus: Mutex = Mutex::new(RefCell::new(spi)); -let display_spi = SpiDeviceWithConfig::new(&spi_bus_mutex, screen_cs, screen_spi_config); +let display_spi = SpiDeviceWithConfig::new(&spi_bus, screen_cs, screen_spi_config); let mut screen_buffer = [0; 10 * 4096]; @@ -644,11 +644,11 @@ Make sure to check out the [documentation](https://docs.rs/embedded-graphics/lat ## Exercises -1. Connect the MPU-6000 as described in the [wiring configuration](#mpu-6500-wiring) (**1p**) -2. Read and create a debug log with the [WHO_AM_I](#mpu-6000-memory-map) register. Does the result match the [data sheet](https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6500-Register-Map2.pdf)? (**1p**) +1. Connect the MPU-6500 as described in the [wiring configuration](#mpu-6500-wiring) (**1p**) +2. Read and create a debug log with the [WHO_AM_I](#mpu-6500-memory-map) register. Does the result match the [data sheet](https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6500-Register-Map2.pdf)? (**1p**) :::tip -Take a look at the [Reading data from the MPU-6000 sensor using Embassy](#reading-data-from-the-mpu-6500-sensor-using-embassy) section. +Take a look at the [Reading data from the MPU-6500 sensor using Embassy](#reading-data-from-the-mpu-6500-sensor-using-embassy) section. ::: 3. Get the acceleration and angular velocity readings from the sensor. diff --git a/website/lab/06/index.mdx b/website/lab/06/index.mdx index 78116484560..1788e9671a3 100644 --- a/website/lab/06/index.mdx +++ b/website/lab/06/index.mdx @@ -243,8 +243,8 @@ The BMP390 is a digital temperature and pressure sensor designed by Bosch. It ca You can find its datasheet containing more relevant information [here](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp390-ds002.pdf). -:::tip BMP280 Address -The default I2C address of the BMP280 is `0x76`. +:::tip BMP390 Address +The default I2C address of the BMP390 is `0x76`. ::: ### Register map @@ -327,26 +327,6 @@ The temperature data is split and stored in three consecutive registers. The mea | 0x08 | `DATA_4 (TEMP_LSB_15_8)` | Contains the middle 8 bits (**temp[15:8]**) of the raw temperature measurement. | | 0x07 | `DATA_3 (TEMP_XLSB_7_0)` | Contains the least significant 8 bits (**temp[7:0]**) of the raw temperature measurement. | -Based on the BMP390 datasheet, the temperature data registers have moved to addresses 0x07 through 0x09, and the resolution is now 24 bits. - -Here is the adapted content: - -Register DATA_3...DATA_5 (Temperature Data) (0x07...0x09) - -The temperature data is split and stored in three consecutive registers. The measurement output is an unsigned 24-bit value. - -Address Name Description -0x09 DATA_5 (TEMP_MSB_23_16) - -Contains the most significant 8 bits (temp[23:16]) of the raw temperature measurement. - -0x08 DATA_4 (TEMP_LSB_15_8) - -Contains the middle 8 bits (temp[15:8]) of the raw temperature measurement. - -0x07 DATA_3 (TEMP_XLSB_7_0) - -Contains the least significant 8 bits (temp[7:0]) of the raw temperature measurement. :::danger Important Burst Read Required To guarantee data consistency (shadowing), you must use a single burst read to read all data registers at once. Reading registers individually may result in mixed data from different measurement cycles. @@ -390,7 +370,7 @@ These are `u8`, `i8`, `u16`, and `i16` factory-calibrated parameters stored insi ### Temperature computation formula -This formula is based on the **Compensation formula in fixed point** which can be found in section **8.5** of the [datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf). +This formula is based on the **Compensation formula in fixed point** which can be found in section **8.5** of the [datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp390-ds002.pdf). **Coefficient Conversion** before calculating the temperature, convert the raw NVM coefficients into floats using the scaling factors defined in **Section 8.4**: @@ -441,7 +421,7 @@ The BMP390 is integrated already integrated in the lab board, having some of the ### Reading and writing to the BMP390 -Instructions on how to use I2C with the BMP280 can be found in the [datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf), at section 5.2. +Instructions on how to use I2C with the BMP390 can be found in the [datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp390-ds002.pdf), at section 5.2. Before we start, we initialize the I2C driver with the pins and channel we will be using. @@ -521,7 +501,7 @@ In section 5.2.1 and 5.2.2 of the datasheet, we get the information we need in o #### Reading a register -![i2c_bmp280_read](images/i2c_bmp390_read.png) +![i2c_bmp390_read](images/i2c_bmp390_read.png) To read the value of a register, we first need to send the BMP390 the address of the register we want to read. Afterwards, the sensor will send back the value of the register we requested. @@ -552,20 +532,20 @@ This is explained in section 5.3 of the datasheet. #### Writing to a register -![i2c_bmp280_write](images/i2c_bmp390_write.png) +![i2c_bmp390_write](images/i2c_bmp390_write.png) To write to a register, we need to send the sensor a buffer containing pairs of register addresses and values we want to write to those registers. For example, if we wanted to write `0x00` to `REG_A`: ```rust let tx_buf = [REG_A, 0x00]; -i2c.write(BMP280_ADDR, &tx_buf).await.unwrap(); +i2c.write(BMP390_ADDR, &tx_buf).await.unwrap(); ``` If we wanted to write both `REG_A` and `REG_B` to `0x00`: ```rust let tx_buf = [REG_A, 0x00, REG_B, 0x00]; -i2c.write(BMP280_ADDR, &tx_buf).await.unwrap(); +i2c.write(BMP390_ADDR, &tx_buf).await.unwrap(); ``` ## AT24C256 EEPROM