with my hobby project I started to rewrite the classic interrupt driven software to a new one with RTOS. I am using an STM32 with FreeRTOS but it is not important because my question is generally related to the problem that how to implement a fast PI with an RTOS.
Idea: Put the current (torque) controller to an interrupt (for example: to the interrupt of the timer which used for the PWM) and then put the position controller to a thread, or into a sw timer.
Idea Put the current controller to a thread witch waits for a signal based on a timer interrupt where the signal will be raised.
Current controller should be fast so I cannot put into a sw timer, but documents which I read about the RTOS said that I should put minimal code into the interrupt handler function when using RTOS and a PI controller is not that I think. This is why the 1. idea seems to be problematic.
But if I put the fast current controller into a thread which a signaled much faster than the systick, will it be able to handle it at all? Is it a terrible idea?
So the exact question is that: How should I implement a fast PI controller with an RTOS when the required frequency is well above the system frequency?
Thanks for the help!