stm32duino / LSM6DSV16X

Arduino library to support the LSM6DSV16X 3D accelerometer and 3D gyroscope
BSD 3-Clause "New" or "Revised" License
5 stars 6 forks source link

Tilt Angle #8

Closed phhoef closed 1 year ago

phhoef commented 1 year ago

Hi,

I need to measure the tilt angle as precise as possible (<0,1°). I am currently using the Murata SLC3300. This is quite convenient as is directly outputs the angle. Unfortunately, the SCL3300 is quite expensive and therefore I am looking for alternatives. I came across the new LSM6DSV16X and your library. From what I understand the IMU does not have a built-in feature to calculate the angle, right? Would it be possible to re-use the machine learning core for that purpose?

Do you consider implementing the calculation of the tilt angle in your lib?

cparata commented 1 year ago

Hello @phhoef , yes, correct, this component does not have the tilt computation as built-in feature. Maybe, you can reuse the sensor fusion feature of the sensor that returns the orientation in the quaternion format. Converting the quaternion in the Euler angles (yaw, pitch and roll), you could reuse the pitch or the roll (according the orientation of the sensor on your board) to have an estimation of the tilt angles. Unfortunately, the sensor fusion output is not supported yet in the Arduino library. Here, you can find more information about what I mean. Best Regards, Carlo

cparata commented 1 year ago

Meantime, if you are using an STM32 microcontroller on your board, you can try to use also MotionFX Library that should already work and give you as output quaternions and Euler angles. Best Regards, Carlo

phhoef commented 1 year ago

Thanks for your help. I am currently planning to use a custom ESP32 board. But maybe I should reconsider using STM32. Then I would be able to use the MotionFX lib ... Can you recommend a MCU similar to the ESP32?

cparata commented 1 year ago

What are your connectivity requirements? If BLE is enough for you, you can consider a STM32WB MCU like P-Nucleo-WB55RG. If you need also WiFi, you do not have a lot of choice and the only STM32 board that supports BLE and WiFi in STM32duino is B-L4S5I-IOT01A. If, instead, you don't need connectivity at all you can consider whatever STM32 like STM32F401RE or STM32L476RG that you can find respectively in NUCLEO-F401RE and NUCLEO-L476RG. Best Regards, Carlo

phhoef commented 1 year ago

Good question. I like the ESP32 as it has both and I do not need to make a decision 😄 Currently, I do probably do not need BLE and WiFi, but there are a few use cases were it can become handy. So, my idea was to be future-proof to equip both (if not too expensive). The project is currently entirely based on a custom board based on Arduino Due. But I would like to mature and increase performance and connectivity. In a real world scenario, probably no one would use the Arduino framework for production. But biggest problems are libraries for sensors like accelerometer (or inclinometer) and display. I do not want to re-write all the libraries I am using. That's quite hard, take a lot of time and is error prone. I am aware that STM32 has a big toolchain for UI development, unfortunately it's only running on Windows. As I am working on macOS I would like to use something platform independent. Maybe LVGL is an alternative ...

cparata commented 1 year ago

I see. Anyway, if you switch to STM32, you will have many other motion libraries like MotionTL that should work also in Arduino and should be the best one for your use case. I guess you refer to TouchGFX library when you talked about UI development library. Best Regards, Carlo

phhoef commented 1 year ago

yes indeed, TouchGFX is the library I was referring to. STM32 has so many solutions and libraries. It's quite overwhelming to find the sweet spot for my application, as I am not too familiar with the whole ecosystem. The MotionTL lib looks promising. Though, it confuses me as they are talking about X-CUBE-MEMS1. Not sure what this is.

I need also many GPIOs and this is the big downside of ESP32. STM32 controllers have way more IOs. Maybe STM32 would be the better option... :smile:

cparata commented 1 year ago

X-CUBE-MEMS1 package is the equivalent of the MEMS libraries that you can find in Arduino for the STM32Cube, the main framework to program the STM32. So, if you decide to go to STM32, you will find in the X-CUBE-MEMS1 package all the MEMS drivers, Motion libraries and application examples for the STM32Cube environment. Take into account that the MEMS libraries that you can find in Arduino are a subset of all the MEMS libraries that you can find in the X-CUBE-MEMS1 package for STM32Cube.

phhoef commented 1 year ago

Thanks for the explanation. Do you know a good tutorial/overview as starting point to sort out which tools I need and who to use them? My application is has a few components, I need to control with the MCU. It has a display, inclinometer, external device via uart, storage, camera, buzzer, battery and a few buttons.

cparata commented 1 year ago

If you want to give a look at the Cube environment, I think that you need to download STM32CubeIDE that is free IDE to program and debug the STM32. As tutorial, you can give a look on st.com and youtube.com to find some video tutorial.

phhoef commented 1 year ago

Thanks for your help! I am currently using PlatformIO for many years, and was quite happy with it. Are there restrictions to the Cube libraries, when not using STM32CubeIDE?

cparata commented 1 year ago

No, the only license restriction for Cube Motion libraries is that you can use them only with an STM32 and an ST MEMS sensor.

phhoef commented 1 year ago

thanks for your help. I'll try to find a suitable stm32 controller for my use case and give it a try 😄

fpistm commented 1 year ago

Seems answered so I close this issue.