Author Topic: STM32F407 Discovery Board Motion Sensor Usage  (Read 2539 times)

0 Members and 1 Guest are viewing this topic.

Offline elefurtronikTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: 00
STM32F407 Discovery Board Motion Sensor Usage
« on: June 25, 2023, 09:34:16 pm »
Hello,
I am studying embedded systems with stm32f407 discovery card. There is a motion sensor on the board. I would like to read sensor datas over I2C but I couldn’t find any information in stm documentation about it. How can I use this sensor? Please help. I am studying bare metal programming.
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4986
  • Country: dk
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #1 on: June 25, 2023, 09:41:46 pm »
you figure out how to use I2C and then you look at the datasheet for the sensor
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1840
  • Country: se
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #2 on: June 26, 2023, 08:58:38 am »
you figure out how to use I2C and then you look at the datasheet for the sensor
And that's be the best way to gain an insight of how to manage sensors and I2C in a baremetal environment.
That's what I would do - have done - a good learning experience.

But I'll spoil the suggestion, though, by letting you know that the Cube FW board support package (BSP) for the STM32F4 Disco supports the motion sensor, sparing (usually) quite a bit of grunt work and bring you closer (and 'closer' here is doing some heavy lifting) to a working project if you are e.g. time constrained.

Choose your poison!
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline elefurtronikTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: 00
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #3 on: June 26, 2023, 05:30:12 pm »
Hi,
As motion sensor is on the discovery board I dont know which pin to read to get motion sensor data.
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4986
  • Country: dk
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #4 on: June 26, 2023, 06:01:40 pm »
Hi,
As motion sensor is on the discovery board I dont know which pin to read to get motion sensor data.

so look at the schematic for the discovery board
 

Offline liaifat85

  • Regular Contributor
  • *
  • !
  • Posts: 172
  • Country: bd
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #5 on: June 26, 2023, 07:32:26 pm »
There is a youtube video series on Motion Sensing on the STM32L4 IoT Node. But I could not find the same for your STM32F407 discovery board. You can take a look at those videos if they help. You can also post your question to the STM forum.
 

Offline avaqsemi

  • Newbie
  • !
  • Posts: 5
  • Country: hk
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #6 on: June 27, 2023, 06:49:19 am »
To use the motion sensor on the STM32F407 Discovery board over I2C, you need to follow these steps:

1. Identify the motion sensor: Find out the specific model of the motion sensor on your STM32F407 Discovery board. This information will help you locate the datasheet and understand its communication protocol.

2. Obtain the datasheet: Look for the datasheet of the motion sensor online using its model number. The datasheet will provide you with detailed information about the sensor's registers, communication protocol, and programming instructions.

3. Connect the motion sensor: Ensure that the necessary connections are made between the motion sensor and the STM32F407 Discovery board. Typically, I2C requires connecting the sensor's SDA (data line) and SCL (clock line) pins to the corresponding I2C pins on the STM32F407 board.

4. Initialize I2C: Set up the I2C peripheral on the STM32F407 Discovery board. Refer to the STM32F407 reference manual and programming examples to learn how to initialize and configure the I2C hardware.

5. Read the datasheet: Study the datasheet of the motion sensor to understand its register map, including the addresses of the relevant registers you need to access for reading sensor data.

6. Implement I2C communication: Write code to perform I2C communication with the motion sensor. This typically involves sending appropriate commands or requests to read specific registers and receiving the response from the sensor.

7. Parse sensor data: Once you receive the sensor data over I2C, you need to parse it according to the specifications provided in the datasheet. The datasheet will explain the format of the data and how to interpret it correctly.

8. Integrate with your bare metal application: Incorporate the I2C communication and data parsing code into your bare metal application for the STM32F407 Discovery board. You may need to write functions or drivers specific to the motion sensor to facilitate easier access to the sensor's data.
 

Offline ozcar

  • Frequent Contributor
  • **
  • Posts: 361
  • Country: au
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #7 on: June 27, 2023, 07:08:17 am »
9. Conclude that perhaps it would have been easier to use SPI to talk to the sensor, as the board maker intended.
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 560
  • Country: sk
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #8 on: June 27, 2023, 10:06:52 am »
To use the motion sensor on the STM32F407 Discovery board over I2C, you need to follow these steps:
While formally mostly correct, this sounds an awful lot like ChatGPT.

"Mostly correct" because 3. speaks of the sensor as if it would be external to the board.

JW
 

Offline ArdWar

  • Frequent Contributor
  • **
  • Posts: 721
  • Country: sc
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #9 on: June 27, 2023, 10:20:03 am »
For ST MEMS, you really need to look at the accompanying Application Notes in addition to their Datasheets. The datasheets are very "dry". Most of the walkthrough at how to actually set up the sensors, acquire their data, or even explanation of what the configuration registers actually do are contained in the appnotes instead.
 
The following users thanked this post: wek

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 4591
  • Country: gb
  • Doing electronics since the 1960s...
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #10 on: June 27, 2023, 12:54:03 pm »
Quote
this sounds an awful lot like ChatGPT.

I was thinking exactly the same.

The chip is probably LIS3DH
https://www.mouser.co.uk/datasheet/2/389/lis3dh-1849589.pdf
which can do I2C or SPI and I would definitely use SPI for it. Much more widely used.

It's actually quite a good chip; 0.001g resolution and 0.0005g/degC zero drift. I am toying with building a navigation product but AFAICT (my maths is crap) you need a 3 axis accelerometer and you need three yaw gyros because slowly spinning the accelerometer(s) around their centre will not register anything but will result in a completely bogus direction in space.

So one needs to be pretty clear what this is to be used for. The 1G gravity vector is easily detected but you can't detect yaw around the vertical axis.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline elefurtronikTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: 00
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #11 on: June 27, 2023, 06:14:29 pm »
Thanks for all the answers. I actually checked the documentation and couldnt find that which pin the stm connected this sensor on board. Sensor is on board but there is no schematic to see thag which pin is the sensor connected
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 4591
  • Country: gb
  • Doing electronics since the 1960s...
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #12 on: June 27, 2023, 07:10:46 pm »
It is probably jumpered. I have the circuits of the 407-DISCO and had a look and could not find it; it may have been on a standalone sheet which I discarded (since my project doesn't use it).
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4986
  • Country: dk
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #13 on: June 27, 2023, 07:53:45 pm »
Thanks for all the answers. I actually checked the documentation and couldnt find that which pin the stm connected this sensor on board. Sensor is on board but there is no schematic to see thag which pin is the sensor connected


https://www.st.com/en/evaluation-tools/stm32f4discovery.html#cad-resources
 
The following users thanked this post: elefurtronik

Offline eutectique

  • Frequent Contributor
  • **
  • Posts: 474
  • Country: be
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #14 on: June 27, 2023, 07:53:49 pm »
Thanks for all the answers. I actually checked the documentation and couldnt find that which pin the stm connected this sensor on board. Sensor is on board but there is no schematic to see thag which pin is the sensor connected

Click here: https://www.st.com/content/ccc/resource/technical/layouts_and_diagrams/schematic_pack/group1/0f/91/8b/39/b3/78/4d/c4/MB997-F407VGT6-B02_Schematic/files/MB997-F407VGT6-B02_Schematic.pdf/jcr:content/translations/en.MB997-F407VGT6-B02_Schematic.pdf

Page 6, bottom left, U5.

SPI1_MOSI -- PA7
SPI1_SCK -- PA5
etc...
 
The following users thanked this post: elefurtronik

Offline ozcar

  • Frequent Contributor
  • **
  • Posts: 361
  • Country: au
Re: STM32F407 Discovery Board Motion Sensor Usage
« Reply #15 on: June 27, 2023, 08:01:26 pm »
The chip is probably LIS3DH
https://www.mouser.co.uk/datasheet/2/389/lis3dh-1849589.pdf
which can do I2C or SPI and I would definitely use SPI for it. Much more widely used.

Thanks for all the answers. I actually checked the documentation and couldnt find that which pin the stm connected this sensor on board. Sensor is on board but there is no schematic to see thag which pin is the sensor connected

When I went looking for a schematic yesterday, this is what I turned up:

https://www.st.com/content/ccc/resource/technical/layouts_and_diagrams/schematic_pack/group1/0f/91/8b/39/b3/78/4d/c4/MB997-F407VGT6-B02_Schematic/files/MB997-F407VGT6-B02_Schematic.pdf/jcr:content/translations/en.MB997-F407VGT6-B02_Schematic.pdf

If that is the correct schematic, then it does show the MEMS sensor connections (on the last page).

Again, assuming that is the correct schematic, it shows the sensor as a LIS302DL, which supports either I2C or SPI. However, given the MCU pins it is connected to, it seems to me that the intention is for the SPI1 peripheral to be used, hence my addition to the possibly ChatGPT generated narrative above.

I did not check what alternate peripheral functions can be mapped to those pins, so I2C may still be possible (or worst case, bit-bang it). But why swim against the tide unless perhaps as a pure learning exercise?
 
The following users thanked this post: elefurtronik


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf