LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement a PID controller in LabVIEW for controlling refrigerant subcooling/superheating temperature?

To make my question clear, I will talke about subcooling temperature only.


I'm a beginner in LabVIEW and I’d like some guidance on implementing a PID controller for my setup.

 

My system involves heating a refrigerant to reach a desired temperature with a specific subcooling degree. Here’s what I’m doing:

  • I measure the refrigerant pressure and calculate the corresponding saturated temperature.

  • Then I subtract the subcooling value to get the desired (target) liquid temperature.

  • I compare this target temperature with the actual measured liquid temperature.

  • If the actual temperature is lower than the target, the heater should turn ON; otherwise, it should turn OFFalhabeeb_0-1761031236683.png

Now I’d like to replace this simple ON/OFF logic with a PID control in LabVIEW to achieve smoother and more stable temperature control.

What type of PID controller (e.g., built-in “PID.vi” or other) would be suitable for this kind of thermal system and how to implement it? 

My VI is attached here.

Thank you!

0 Kudos
Message 1 of 19
(512 Views)

Hi alhabeeb,

 


@alhabeeb wrote:

I'm a beginner in LabVIEW and I’d like some guidance on implementing a PID controller for my setup.

 

Now I’d like to replace this simple ON/OFF logic with a PID control in LabVIEW to achieve smoother and more stable temperature control.

What type of PID controller (e.g., built-in “PID.vi” or other) would be suitable for this kind of thermal system and how to implement it? 


You're not a beginner anymore with your history of LabVIEW questions…

 

The main question is: which kind of control does your heater allow?

  • Can you "just" switch the heater ON/OFF?
    Which parameters apply to that switching? (timings, delays, …)
  • Does your heater allow for an analog input value, like "0%…100% heating power"?

I had done your task some years ago:

  • You can control the heating power - or you could try to control the pressure in the system to maintain a subcooled state…
    (In my experience controlling the pressure works much simpler then controlling the temperature, but that heavily depends on the system you are working with.)
  • You can use the simple PID function that comes with LabVIEW. It works perfectly as long as your system works in a mainly linear fashion as PID controllers are made for "linear systems".
  • When your heater only allows switching on/off you can convert the PID output into a PWM signal, where you control the duty cycle (= PID output) and the cycle time (defined by your heater parameters as asked above).
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 19
(500 Views)

Dear  

 

Thank you for your reply and the helpful explanation.

In my setup, I’m using an NI-9475 module (digital output) to control the heater circuit through a solid-state relay (RST-3-4-40, 3–32 VDC control, 20 mA input).
So currently, the heater can only be switched ON or OFF — it doesn’t accept an analog input for variable power control.

Regarding your point about pressure control: in my case, using pressure as the main control parameter doesn’t help much in maintaining a stable subcooling level, since the heater only works in ON/OFF mode.

That’s why I’m considering implementing a PID controller to make the ON/OFF switching smoother and achieve a more stable subcooling temperature, as you mentioned.

alhabeeb_2-1761038701689.png

 


 

alhabeeb_0-1761038572106.png

Thanks

 

 

 

0 Kudos
Message 3 of 19
(480 Views)

Hi alhabeeb,

 


@alhabeeb wrote:

So currently, the heater can only be switched ON or OFF — it doesn’t accept an analog input for variable power control.

Regarding your point about pressure control: in my case, using pressure as the main control parameter doesn’t help much in maintaining a stable subcooling level, since the heater only works in ON/OFF mode.

That’s why I’m considering implementing a PID controller to make the ON/OFF switching smoother and achieve a more stable subcooling temperature, as you mentioned.


From the image you seem to use a heater with a 3phase supply, so I expect heating power in the kW range.

This usually hints about higher thermal masses and temperature ramps in the lower K/s range.

 

Am I right about these assumptions? (Can you provide more details about specific requirements of your system?)

 

I also worked with an automotive testbench with an external heater in the 100kW range:

  • For this I also used SSR relays to switch on/off several heating elements.
  • I used a PWM scheme with cycle times calculated in multiples of the power supply frequency (Europe: 50Hz). So I used cycle times of ~5s, which gives 250 sine waves (5s * 50Hz) of the power supply.
  • I used special SSRs that switched only on zerocrossings to reduce switching artifacts in the power net.
  • And I used the duty cycle of my PWM generator to switch on/off the SSR within the ~5s cycle time: in the end it means to switch on the heater for a certain number of power net sine waves! (Without needing to monitor the power line in a fast control loop.)

All you need is a small subVI that translates two inputs (duty cycle in %, cycle time in s) into an on/off state of the DO. It's a very simple calculation!

 

Your PID should be configured to output duty cycles, aka set an output range of 0%…100%. Adjust the PID gains to fit with your timing constraints!

(Are you able to measure the temperature reaction when you switch on the heater? This will help you in determining PID gains…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 19
(467 Views)

Dear GerdW,
Yes, you’re right — the heater is a 5.5 kW, 3-phase unit. It’s used to heat a low refrigerant mass flow rate of 0.009 – 0.09 kg/s, raising the temperature from around 30 °C up to 85 °C.
I’m located in Europe, so the power supply frequency is 50 Hz.

Your explanation makes sense and seems very relevant to my setup, but to be honest, I’m not yet familiar with implementing a PWM scheme with cycle times.

As for the controller, there are several PID options in LabVIEW under the Control & Simulation . Could you please advise which specific PID VI would be most suitable for this kind of thermal system?

Thanks

0 Kudos
Message 5 of 19
(457 Views)

Hi alhabeeb,

 


@alhabeeb wrote:

As for the controller, there are several PID options in LabVIEW under the Control & Simulation . Could you please advise which specific PID VI would be most suitable for this kind of thermal system?


You can start with the simple PID -> PID.vi.

(I used the other stuff only for "more complicated" systems, lead-lag or GainSchedule might be helpful…)

 


@alhabeeb wrote:

Your explanation makes sense and seems very relevant to my setup, but to be honest, I’m not yet familiar with implementing a PWM scheme with cycle times.


Your DAQ loop should run with a fixed iteration rate, mine used to run at 10Hz (= 0.1s per iteration).

Now the duty cycle reduces to how many iterations you want to output HIGH within each 50 iterations (10iterations/s * 5s).

 

Example: a dutycycle of 35% means ~17 iterations HIGH and 33 iterations LOW. You can easily count iterations and the rest is simple math/comparison…

 

Btw. I strongly recommend some safety features purely made in hardware. I recommend not to rely only on software for such heating systems!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 19
(446 Views)

Dear GerdW

Thank you for your explanation — it really helps!
However, I’m still a bit stuck at this point 😅
My vi is attached here

 

 

alhabeeb_0-1761058823949.png

 

0 Kudos
Message 7 of 19
(430 Views)

Hi alhabeeb,

 

suggestion:

This example will use a cycle time of 10s (100*100ms)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 19
(415 Views)

Dear GerdW,
Thank you for your suggestion.I did it like in the attahced file. Could you please confirme my code and could you clarify how I can determine the gains?

Thanks

 

Baqer

0 Kudos
Message 9 of 19
(340 Views)

Hi alhabeeb,

 


@alhabeeb wrote:

Could you please confirme my code and could you clarify how I can determine the gains?


The code looks quite ok…

 

On determining PID gains: there are common rules to determine them from a simple open-loop step response. Have you ever heard about Mr. Ziegler and Mr. Nichols?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 19
(320 Views)