12-15-2022 12:08 PM
Hello,
I'm attempting to code a PID loop that controls the pump voltage using the flowmeter reading to match a fixed set point flow rate. For eg., I require a constant flow rate of 100 mL/min. The flow meter reading changes depending on system parameters. So I want to increase/decrease the pump voltage to match the flowmeter reading.
I am using a DC power supply (Agilent N6700) as the power source for the pump. Initially, I used constant voltage to run the pump using an Agilent instrument driver. I am using the same driver in the PID loop. The problem is it looks like the pump voltage keeps dropping to zero (I can see the pump stopping intermittently) resulting in a very oscillatory pump voltage (and thus an oscillatory voltage). I have not adjusted the gains yet but I think the reason for this might be something to do with the code I have.
Please let me know if you find any obvious mistake here that I'm missing. Any help would be greatly appreciated. Attaching a VI below showing what I have.
Thank you!
Solved! Go to Solution.
12-15-2022 12:15 PM
Screenshot of my VI
12-15-2022 12:58 PM
Hi rohan,
@rohan_koka wrote:
I'm attempting to code a PID loop that controls the pump voltage using the flowmeter reading to match a fixed set point flow rate. For eg., I require a constant flow rate of 100 mL/min. The flow meter reading changes depending on system parameters. So I want to increase/decrease the pump voltage to match the flowmeter reading.
Why do you create a new DAQmx task - with each iteration of your loop?
Why do you never delete that task?
Why do you initialize the Agilent in each iteration of your loop?
Have you learned from the example VIs coming with LabVIEW?
Suggestions:
12-15-2022 03:05 PM
Hi GerdW,
Thanks for the quick response and the suggestions. I implemented your suggestions in my VI (attached below).
However, when I try to keep only the AgilentVoltage VI, it returns zero voltage. It needs the output_range, current_limit, and enable_output VIs along with the AgilentVoltage VI in the loop for some reason.
Even with the changes I still notice the pump voltage jumping from zero to the maximum (turning on/off intermittently). I'm using the default PID gains right now but I'm planning to use the toolkit to figure out the right values. Do you think the PID gains would resolve the jumping of voltage? Does the VI seem to have any other issue according to you?
Also, when I run the program now, the waveform chart stops at 30 mL/min and becomes constant for the reading from the flowmeter. The actual range is from 100-1000 mL/min. I checked the scaling and it looks ok. When I remove the scaling VI and run the program, the voltage seems to be in the expected range. It makes me question the way I am using the scaling VI.
Curious to hear your thoughts. Appreciate your help!
Thanks again!
12-16-2022 01:12 AM
Hi rohan,
@rohan_koka wrote:
However, when I try to keep only the AgilentVoltage VI, it returns zero voltage. It needs the output_range, current_limit, and enable_output VIs along with the AgilentVoltage VI in the loop for some reason.
I'm using the default PID gains right now but I'm planning to use the toolkit to figure out the right values. Do you think the PID gains would resolve the jumping of voltage?
Do you really need to configure the whole powersupply setup just to change the output voltage? Seems the wrong device for that task…
Why do you think the default PID gains will fit for your control loop? Have you heard about Mr. Ziegler and Mr. Nichols before? They told you how to determine PID gains without any toolkits…
@rohan_koka wrote:
Also, when I run the program now, the waveform chart stops at 30 mL/min and becomes constant for the reading from the flowmeter. The actual range is from 100-1000 mL/min. I checked the scaling and it looks ok. When I remove the scaling VI and run the program, the voltage seems to be in the expected range. It makes me question the way I am using the scaling VI.
Then your scaling parameters are maybe wrong.
Why don't you use the "Map ranges" polymorphic instance instead? It is much "safer"/"easier" IMHO…
12-16-2022 03:03 PM
Hi GerdW,
You were right! I was totally off in assuming the PID gains had nothing to do with the intermittent pump operation. I used the Ziegler-Nichols method and it worked like a charm. Although I still need to "tune" the gain for different system conditions, I think it can be done using gain scheduling.
Thanks a lot for your guidance and suggestions, I appreciate it!
12-17-2022 04:10 AM
Hi rohan,
@rohan_koka wrote:
I used the Ziegler-Nichols method and it worked like a charm. Although I still need to "tune" the gain for different system conditions, I think it can be done using gain scheduling.
PID controls are mainly intended to be used with "linear systems".
When your system shows (very) non-linear behaviour you need to prepare your PID algorithm to handle that nonlinearity.
One way is to use some gain scheduling to define PID gains for more than one operating point of the control loop.
Another way is to implement a feed-forward algorithm using a map of system-specific information to predict the output value and let the PID only handle deviations from that expectations…