I am trying to learn the basics of PID. I have made a contraption to try to implement a PID controller.
I am not using carbon fiber, but rather a chopstick.
So I am controlling the speed of the propeller with a PWM signal through a mosfet from an STM32. I think 14Khz...Dont recall what frequency I set it to. My counter control register which controls my duty cycle can vary from 0 to 1000.
I am reading the pot value through the an ADC channel.
In my attempt to implement one control method at a time. P then I then D I never got past P because I dont know what to do with the value I get.
For example, Let say my chopstick is level (parallel to floor) at an ADC value of 2000. and I currently read 1200 then my error is 800. According to PID literature this gets multiplied by a gain. lets say the gain is .5 So now my P value is 400. But what do i Do with that? I cant set the PWM CCR to 400 that is too low a duty cycle and it will drop even more.
So that is my issue how do I translate the value to something useful.
All I am doing right now is that if my error is grater than zero then PWM = PWM - 1; and vice versa for error less than zero Obviously it works really slow because I am using the value of 1 but this is NOT proportional control. At least i dont think it is.
EDit: I think has to do with my issue. SO Like I said in the comments I can get it to work (sort of) so long as when i disturb it I dont make it go above a certain point, otherwise It will fly all the way vertical have a huge error and then drop have another huge error and just keep going and going. And god forbid I try to make a target point that is above 0 deg that stays put for a few seconds and then oscillates again. I just think the complexity of this system requires more then the simple PID tutorials you see everywhere involving speed control of a motor. I would follow the edx course on this but I dont understand the math and their notations. No real number examples or anything. I do not learn well just seeing bunch of variables and no real world examples.