08-21-2020 07:30 AM
Hi. Actually I'm not sure if this is related to LabVIEW, but I have no idea where to ask this question. So please help me if it's possible, or remind me if I should remove this thread.
I'm trying to create a LabVIEW subVI, which simulate level of a water tank.
(the SimulateInlet's range is between 0-100, which will increase the level of tank if Inlet's value is true; the ControlValve's range is between 0-100, which will decrease the level)
The subVI above is used inside a while loop in main VI, and execute every 3 seconds:
I also have a code in C language like this:
float error=Level - levelsetpoint; (the levelsetpoint is fixed at 30, for example)
sum_error+=error;
controlvalve=Kp*error+Ki*sum_error+Kd*(error-previouserror);
previouserror=error;
(the code is run every 3 seconds)
The problem is, I don't know how to find the value of Kp, Ki and Kd.
08-21-2020 07:37 AM
Also, I have tried to use Matlab Simulink, like this:
I think this is supposed to be exactly the same with my LabVIEW and C project, if I set the sample rate of MATLAB Simulink 3 seconds.
Then, in order to find Kp, Ki, Kd using Zieggler Nichols, I set the Kp=50, Ki=0, Kd=0, but the result looks like this, while I want it to be a sinusoid respond, right?
So, can you suggest me some way to find Kp, Ki, Kd? Or should I modify my LabVIEW model?
Thank you so much
P/S: I add this to the comment to separate the question, because I think it is easier to understand.
08-21-2020 07:48 AM - edited 08-21-2020 07:49 AM
Hi meihk,
@meihk wrote:
I also have a code in C language like this:
float error=Level - levelsetpoint; (the levelsetpoint is fixed at 30, for example) sum_error+=error; controlvalve=Kp*error+Ki*sum_error+Kd*(error-previouserror); previouserror=error;
(the code is run every 3 seconds)
The problem is, I don't know how to find the value of Kp, Ki and Kd.
You find the PID gains in LabVIEW in the same way as you would find them in C or MATLAB.
Ever heard of Ziegler-Nichols?
08-21-2020 10:27 AM
Hi GerdW,
Thank you for replying.
Actually I have tried to use Ziegler-Nichols to calculate gains for my PID controller in MATLAB Simulink (I mentioned it in the comment, sorry for not being clear). But when I set Ki=0 and Kd=0, and adjust Kp, the respond always shows a straight line instead of a sinusoids (may be my plant is not correct).
I will try the PID in LabVIEW, thank you for recommending that.