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: 

Updating values from spreadsheet inside timed loop

Hello all,

 

I am trying to read values from a spreadsheet and feed those values to my controllers. I have attached the VI where every task is being carried out. Each VI has specific function written in it like reading data, writing data and evaluating/manipulating data. All these are timed loop. Inside the EVAL VI I am trying to read data from spreadsheet after each second and feed that data to my controllers. I have attached the  block diagram of how it is being done. 

 

The problem is when I run the EVAL VI block diagram it doesn't read the data after first row from spreadsheet, also it seems like my other data also get static as in they do not change frequently as they should. I am new to LabVIEW, so i do not understand what i should do? 

 

I tried putting a while loop inside timed loop with wait function at 1 second but that didn't work and I also think while loop is wrong as i am already using a timed loop.

 

Is there some synchronisation issue between different timed loop VIs? Please suggest what to doMain VIsMain VIsInside EVAL VIInside EVAL VI

0 Kudos
Message 1 of 5
(2,338 Views)

Attach VIs, not pictures of VIs!  Grrr.  I see you are a brand new member, so you haven't heard me yell about how difficult and frustrating it is for those of us who would like to help you and to have to contend with incomplete and hard-to-read images that we can't examine closely, can't edit, and can't execute.  Oh, well.

 

I assume you are not running on a specialized LabVIEW Real-Time Platform (such as a PXI or a RIO).  If this is the case, don't use the Timed Loop!  It is (probably) inappropriate and will (probably) steer you down the wrong path.  Learn to use LabVIEW's parallelism (think Data Flow) and think, for yourself, what tasks need to be timed, and how they need to be sequenced and prioritized.  For Timing of those tasks that need timing, use Hardware Timers (I see you are doing Reads and Writes of some, possibly DAQ, equipment, so take advantage of their hardware timing capabilities, which usually are far superior to Windows) or use LabVIEW's Wait functions (to slow down loops).  For sequencing, the Error Line Is Your Friend.  For synchronizing, learn about the Producer/Consumer Design Pattern (briefly, the Producer loop acquires data and hands the data off to a parallel Consumer loop that processes it -- in your case, you get data from the DAQ device and "export" it, often via a Queue, to another loop that processes and saves it "on the fly").

 

Oops -- I just re-read your original post, and have my Producers and Consumers mixed up.  In fact, you might not need such a complex system, as your data rates are so slow you can do it all sequentially.  Here's the plan (and how you should learn to think "outside the box" about problems like this):

  • Get everything ready.  Get the DAQs initialized and Ready to Roll.  Open the Spreadsheets and get ready to read data (or, alternatively, read all the data and save it in memory).  Actually, since the data pre-exist, I'm going to "make it simpler" and say "Read all the data".
  • In a For Loop, pass the Data Array.  The Indexing Tunnel of the For Loop will give you one point at a time.  Put a Wait with 1000 wired to the input inside the Loop -- the loop will now run once a second.
  • Inside the Loop, take your current data point, process it, and send it to your DAQ device(s).  You've got a whole second (a very long time in computer ticks) to do this.
  • When all your data have been processed, the For Loop will exit, and you can shut down the DAQ devices and end the program.

Bob Schor

 

0 Kudos
Message 2 of 5
(2,317 Views)

Sorry for not attaching the VI. Please find it, the code was written by someone else and I am trying to add some functions to it.

0 Kudos
Message 3 of 5
(2,313 Views)

Thanks.  The code is pretty clear.  I also understand that the code was "someone else's".  What is not at all clear is what is intended by this code.  What is clear is that the design is largely "wrong".

 

This is a classic example of focussing on "How to do so-and-so" (in your case, emphasizing multiple Timed Loops and some code to manage a DAQ resource) instead of concentrating on "What do I want to do" (which can often be best conveyed by a simple paragraph or two of narrative, with absolutely no care/thought to the process or code you need to do it.

 

Here are some of the things this narrative should include:

  • What kind of DAQ device are you using?  Are you sampling Analog voltages?  Digital levels?  How many channels?  At what rate?  How many points (or "until when", if continuous)?
  • Are you doing any DAQ output?
  • It looks like you are trying to save data in a SpreadSheet.  Are you trying to save the data as it comes it?  Are you trying to do anything else with the data as it comes in and goes out to disk?
  • Can you put the various parts in a sequential or parallel "order"?  For example, "Set up 4 channels of analog input, start collecting when the User pushes Button "Start", as the data comes in, low-pass filter it and write the resulting signal to disk, continuously, until the user pushes the button "Stop", then clean up by closing all the files, turning off the DAQ, and exit".

Once you know what you want to do, it is much easier to describe LabVIEW "conventions" that will facilitate it.  If it does not include LabVIEW RealTime, then I would strongly suggest that you should not be using Timed Loops.  The Descriptive Narrative described in the previous paragraph should make clear what parts are sequential, which parts are parallel, what the timing needs to be, what processing needs to take place.

 

Bob Schor

0 Kudos
Message 4 of 5
(2,281 Views)

So, the code is intended to do following:

 

  • When user runs the welcome(launch) screen, a front panel showing the experiment setup should appear where there are various parameters.
  • The parameters are input by the user which are then written to an analog output daq which controls my third party devices - ouput analog voltage range is 0-5v.
  • There is also an NI analog input device which reads the voltage from third party device which is to see if my input parameter and ouput given by the device physically are same or not.
  • Now i also have 2 NI-9214 daqs which are measuring temperature from my setup and saving those values in a spreadsheet. There are 21 channels or temperature readings in total - These read data points are just stored and not manipulated or used later.
  • In the front panel there is a button named Transient which when user clicks all the parameters described in 1st point except one named ''Ethanol''(whose value i determine and input and is fixed for the experiment) are decided based on a spreadsheet which is present in Transient MFC eval.vi by some basic addition and subtraction. The values from spreadsheet row after row should be read after 1 second and change the parameters.
  • So, the code is working when I am not using the transient button, but when i click the transient button it reads i think only the first row values from spreadsheet, manipulates the parameters and then stops or i don't  know.
  • Also, what i observe is that the frequency at which my temperature readings and analog input from my third party devices were changing is not changing very frequently in the front panel as if they have stopped or slowed down.
  • I have to take the measurements(temperature and analog input) continuously from my daqs to monitor how temperature readings are changing.
  • I stop taking the readings when user stops the front panel. Transient button can be turned off in between if i want to manually enter the parameters.

 

So i don't know why turning on the transient button doesn't take readings and slows down the measurements being read from my daq.

 

Sorry, for bothering you. It's just i have to do the experiments and deadline is in 3 days and i have been at it for so many days. 

 

0 Kudos
Message 5 of 5
(2,273 Views)