From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to update input from DAQ assistant to formula node

Solved!
Go to solution

Hi everyone. I am fairly new to both LabVIEW and programming in general so I found myself stuck with this problem.

I am trying to control the temperature of a water bath (CurrentTemp) to remain constant by continuously increasing or decreasing the thermostat temperature (SetTemp). The DesiredTemp is the user-defined temperature that the water bath should reach. Now, I have decided to use formula node for this, and the problem is that my code is working fine until I include a do-while loop, but then the program does nothing and the loop runs continuously. I am guessing I need a way to update the CurrentTemp acquired from the DAQ, but I lack programming skills in order to solve this. Please help!

int32 SetTemp=22;
do{
if(DesiredTemp>CurrentTemp)
SetTemp=SetTemp+1;
else if(DesiredTemp<CurrentTemp)
SetTemp=SetTemp-1;
else
SetTemp=SetTemp;
}while(DesiredTemp!=CurrentTemp);
0 Kudos
Message 1 of 2
(2,166 Views)
Solution
  • Learn a little LabVIEW.  Spend an hour and view the introductory tutorials that are mentioned on the first page of this Forum (unless they moved them ...). 
  • Now you can simply get rid of the Formula Node!  Why resort to text-based programming when working in LabVIEW, a graphical programming environment?
  • if A>B becomes the conditional ">", and feeds a Case Structure that takes SetTemp as an input.  It can either increment it (Numeric Panel, Increment) or do another comparison, "<" leading to another Case, leading to a decrement or to simply wiring across the False case ("do nothing, SetTemp=SetTemp).
  • Build (and test) your program "in pieces".  Write the code that takes Desired Bath Temperature and Current Temp (discussed above, a nested Case Structure having Current Temp coming in and Set Temp coming out) and see if it works as you want (much simpler to debug small pieces).  When you get it working, copy it into your While loop and wire it up.

Bob Schor

Message 2 of 2
(2,147 Views)