I'm working on diy flight controller for quadcopter. I have a question for which I can't find a good answer. So perhaps you could help me. I'm using a cascaded PID controller for Pitch and Roll regulation. First there is a stabilize PID and rate PID. For the first (stab.) you input desired angle from transmitter and actual angle from IMU. then this output is feed into rate controler. From there it goes to the motors.
In code I'm pooling a function with "data is ready to read from IMU" which happens every 1ms. In this function I'm calculating one regulator and writing to motors. Loop time when this condition is not true is way lower then that. So one regulator should be inside this slow loop and one outside. So which one should be fast and which one slow? In my understanding, stabilize PID should be the fastest? Is that correct? Also should both regulators be PID?
Thanks for your help!