Hey guys, i am trying to implement some PID control and have downloaded the header and source file form lib-stock for PID in MikroC.
I am a little confused as to how to implement the functions.
What is the purpose of the header and source file?
I can see the header- file has descriptions of the functions, and defines a few variables.
The source file appears to be an implementation of these functions with some commenting to provide context.
Am I correct in assuming that i simply include both files in my code, then call the functions as if they were normal library functions?
using the init function to tune the PID loop and the calculate function to input my process variable and my set-point?
PID for MikroC
PID for MikroC
- Attachments
-
- 1320082633_pid_library_mikroc_pic.zip
- (1.51 KiB) Downloaded 299 times
Re: PID for MikroC
I am a little confused with the code also.
It states that the minimal value of the output should be < 0.
I am confused as to how this will work with a PWM variable whose value is between 0 and 1023
Code: Select all
void Init_PID(float Kp, float Ki, float Kd, float MinOutput, float MaxOutput);
// Initialises the PID engine
// Kp = the "proportional" error multiplier
// Ki = the "integrated value" error multiplier
// Kd = the "derivative" error multiplier
// MinOutput = the minimal value the output value can have (should be < 0)
// MaxOutput = the maximal value the output can have (should be > 0)
I am confused as to how this will work with a PWM variable whose value is between 0 and 1023
- darko.minic
- Posts: 747
- Joined: 01 Dec 2014 11:10
Re: PID for MikroC
Hi,
You should contact Author of library, he can give you best explanation for your problem.
Regards,
Darko
You should contact Author of library, he can give you best explanation for your problem.
Regards,
Darko
Re: PID for MikroC
Thanks.
I will need to constrain my duty between 100-1023 anyway to ensure my mosfets wont overheat.
It seems to be working okish totally untuned and with the minimal output at 0.
I will need to constrain my duty between 100-1023 anyway to ensure my mosfets wont overheat.
It seems to be working okish totally untuned and with the minimal output at 0.