Hi Ioannis,
At what frequency are you currently running the PID-loop?
You have a fairly large timeconstant, 0.22s if I'm not entirely mistaken. Depending on the frequency you're running the loop at this might be a source for your instability. I'd try setting up a timer interrupt to get constant and predicatble timing and try running the PID-loop at something like 5Hz.
The variables pid_P, pid_I and pid_D contains the "effort" each term contributes to the total output with. Those might be interesting to "watch" as you tune the loop.
Also, you might gain quite a lot by using the velocity feed forward. For example, you can't possible get 12V output without feeding the circuit atleast a 50% dutycycle (provided the load doesn't regenerate etc). The velocity feedforward can help you provide this "baseline" output.
If I'm not mistaken you would, for an output of 12V, get a return value from the ADC of ~430 and therefor the setpoint value for a 12V output is 430. To set the velocity feedforward so that it outputs a 50% dutycycle for a setpoint of 430 you set pid_Vel_kFF to 74(dec) because 128/430=0.29 (128 being the value for 50% dutycycle) and 74/256 = 0.29 (because the gain is expressed in 1/256 units).
Finally you must also set the pid_Velocity_cmd variable to equal your setpoint value whenever you change it.
Now the PID regulator only has to worry about "external disturbances" such as power supply voltage variation, load variation and so on.
/Henrik.
Bookmarks