Lag when performing stepper motor step generation with STM32 Embedded Coder

3 ビュー (過去 30 日間)
Cameron Zorio
Cameron Zorio 2025 年 2 月 21 日
回答済み: Cameron Zorio 2025 年 2 月 21 日
Hello,
I am trying to setup a simple closed loop system where an IMU reading controls the position of a stepper motor with the STM32 Support Package for Simulink. Below is a picture of my setup. The roll angle of the IMU is read using I2C (with no isses) at 80Hz and used to generate a desired position for the stepper motor. The Stepper Driver function is called at a high frequency using timer interrupts, where if the current position is different from the desired position, a step is generated. The issue is that the stepper motor lags behind the IMU updates by about half a second. This delay seems to be independent of the step generation frequency created by the Timer object. I've tested an identical setup using the STM32CubeIDE with no issues. Is the interrupt overhead when using Simulink Coder simply too much? Since my IMU only updates at 80Hz, is there a way to change the overall model so it only updates at this rate? Any help is appreciated.

採用された回答

Cameron Zorio
Cameron Zorio 2025 年 2 月 21 日
Changing the fundamental sample time of the model to be roughly equal to the IMU sample time fixed this issue.

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by