In this post I leave important hints about control loop:
* Measure the time that your loop takes for every time that you run it. This measurement does need to be in second, so make your own unit and if you wanted to make it smaller just shift the bits. This takes much shorter than dividing a number to some floating point constant.
*Make sure your loop is running at more than 30 Hz, 30 Hz is not enough. 100Hz works for sure. I could not manage to get 30 Hz work properly.
* Try to decrease the calculation process as least as possible.
*This point is theoretically wrong however I have tried it myself and this may solve your problem.
A university lecturer told me to apply my speed at the same time in every cycle of my control loop, this is actually right and it makes sense. When I was running my quad at 50Hz I faced an oscillation. I used to apply my speed at last 80% of my control loop which is something like 15ms after the start of loop. This was a safe place where in worst situation the data has already been sent from IMU (My IMU is giving me output through UART). In average this would take around 7ms so it was much better to change motors' speed as soon as the reading is ready. So I did not listen to him and I tried and I achieved a much better result. I think for low frequency this is really helpful. This should not be a problem for higher frequencies from what I assume.
*Make sure your loop is running at the speed that you expect. In order to try that, get an oscilloscope and make an square wave by changing a pin value at the end of each cycle. This will make a square wave with half of expected frequency and double of expected period. This test saved my ass. :)
*Guys it is not as hard as you think just keep moving...
I can't thing of anything else now. I will update this as time passes.
No comments:
Post a Comment