Thank you. I appreciate very much that even with your busy schedule at work/home you are able to provide useful information to guide us in learning about this system.
Overall, I was able to spin the motor using speed control but at lower speeds, I see that sometimes the motor stalls. I am using sensorless mode so I suppose that explains it. The tuning part I will deal later. Maybe an improvement at some point would be to try to estimate the inertia and the friction of the motor within the code to get a better handle on KP and Ki.
Currently, I am looking at using Position control with the goal of being to use the MESC/MP2 as a servo controller. I am using an AS5600 encoder using the I2C interface and some guy has used this before althouhg on a different platform (
ghent360 - Overview). I decided to use the libraries since the AS5600 is cheap and with a few 3-d printed parts can be mounted on a motor.
I did look at the .ioc file that came with the project and noticed that UART3 uses the same pins as the I2C2 interface. on the f405 pill. I disabled UART3, ernabled I2C2 and remove references to |huart3 in main.c ( a few lines below)
UART_HandleTypeDef huart3;
DMA_HandleTypeDef hdma_usart3_tx;
.....
After adding the calls to the libraries for the sensor, a few modifications to the code ( motor sensor mode set to Absolute encoder) , and setting FOC.enc_angle= angle from the AS5600 sensor, I am sort of lost as to what other configuration I need to do.
View attachment 368862
specifically on this part
View attachment 368864
I assume that the pos.set_position is the target position but I am confused why it has to be incremented every time the function is called? Where is FOC.PLL_angle set?
Thanks in advance.