IMU+ velocity/position control CL

Hi guys, I would like to do a speed check: I read the angular speed from an imu on a stator and bring the stator to zero speed using a motor with simpleFOC. how do I modify the “velocity_control” code to add the angular velocity of the stator measured by the imu to control to zero?

It’s probably me, but I don’t understand your question at all.
The speed of the stator?

I have a cube that is free to rotate on the z axis (let’s call it a stator). an IMU with a gyroscope is mounted on it, the motor with a rotor connected to the shaft. If the stator rotates in any direction around the z axis, the imu records the position and angular velocity of the stator. since I want to brake this rotation (and subsequently also control the position of the stator). I would need a way to insert this information of the IMU to be controlled into the speed control and position control.

It’s not a reaction wheel you are using right ?
The motor is directly controlling the spinning, but your sensor is an IMU.

yes I want to make a reaction wheel, but I don’t know how to use the gyroscope info inside the speed_control and Posizion_control code

Have you this recent discussion?
https://community.simplefoc.com/t/reaction-wheel-inverted-pendulum-with-imu/4637?u=candas1

No, I just joined the forum, I’ll take a look to see if there’s a solution, thanks!

I looked at the code carefully and some points don’t add up to me: I don’t understand the usefulness of doing a paired check and generating a single LQR command also using the encoder in such an explicit manner. my reasoning was to use an IMU and read the position and speed of the stator to be stabilized and use them in two PID loops: so that the desired and real position error generates a desired speed from the first PID which in turn with the speed true enters a subsequent PID which finally generates a torque to be given to the motor (then the encoder is used to verify that the torque has been reached). how could I do?