01-15-2024 03:15 AM
Hi all,
I am quite new in this forum. I am writing because I have a problem with a VI that should manage a tank.
Attached you can find my vi.
I read this discussion: https://forums.ni.com/t5/LabVIEW/refrigerator-temperature-control/m-p/1096003#M484777
What I am not able to do, it is to set an analog input. In fact, if I run it, it is frozen to a constant value.
Thanks for your help,
Samuele
01-15-2024 04:57 AM - edited 01-15-2024 04:57 AM
Hi Samuele,
@fgjdgf wrote:
What I am not able to do, it is to set an analog input. In fact, if I run it, it is frozen to a constant value.
THINK DATAFLOW!
When the control is read only once before the loop then its value will not change inside the loop…
Recommendation: typedefine your state enum!
01-15-2024 05:28 AM
Great, Thank you.
I did something like the vi attached and it seems to work, now.
Just one thing: what do you mean with
Recommendation: typedefine your state enum!
Thanks
01-15-2024 05:51 AM
Hi fg,
@fgjdgf wrote:
Just one thing: what do you mean with
Recommendation: typedefine your state enum!
Create a typedefinition from your enum and use instance of that typedefinition in all places. Now changes to the typedefinition will be applied automatically to all instances…
01-15-2024 08:53 AM
@fgjdgf wrote:
I did something like the vi attached and it seems to work, now.
Attached where?
01-15-2024 09:14 AM
@fgjdgf wrote:
What I am not able to do, it is to set an analog input. In fact, if I run it, it is frozen to a constant value.
Please don't attach a VI verbatim that you downloaded blindly from the forum. A link is sufficient. (obviously this 14 year old code is completely dysfunctional with dataflow problems and a greedy loop. Controlling a tank or refrigerator is a slow process, so spinning the loop millions of times per second just wastes power).
Then you talk about "analog input", which typically has a very special meaning involving measurements, not controls on the front panel. You also don't define "frozen". The control is not frozen and you can set a new value at any time, it's just that the code does not care because it is read only once.
You talk about a tank, so it is probably the tank volume, not refrigeration control.
Maybe as a first step define the problem you are trying to solve. What are the inputs (max volume, min volume, etc.) What are the process variables (pumps, valves, flow rate, etc.). What are the outputs (current tank volume, etc.)? Then define all possible states in an enum (filling, draining, idle, etc.).
Properly done, the code would probably fit on a postage stamp.
01-15-2024 10:12 AM
Here's a very simple tank simulation with a deadband. Maybe it can give you some ideas....