LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Log data from different VIs/loops

Hello,
 
I created a VI to capture data from different instrument (from top to bottom: thermocouple with NI9211, force and torque using load cells and NI, three axis accelerometer using NI9230, and RPM using an optical sensor and 9401). Originally, each sensor had its DAQmx read in a separate while loop. 
 
However, I couldn't figure out how to log data from different while loops (or VIs) in the same csv file (one column per sensor, with the same time axis). Only solution I found so far is to merge the different while loops into one, but that creates some buffer issues. Also, I cannot incorporate the RPM into this since it only creates data when the counter sees a 5V rising edge, and not at a specified interval like the other sensors. 
 
How could I do this differently?
 
Thank you very much,
0 Kudos
Message 1 of 6
(3,126 Views)

How could I do this differently?

 

--- You could make your diagram bigger 😉

 

The way I do this is to have a separate "data manager" VI.

 

It would have several functions you can call:

INIT

STORE TYPE 1 DATA

STORE TYPE 2 DATA

STORE TYPE 3 DATA

WRITE 

SHUTDOWN

 

 

Each source loop calls it with a STORE command.

 

Somebody calls it periodically with a WRITE command.

 

The STORE commands only stash the given data in local shift registers )one for each data type).

 

The WRITE command takes ALL the data from all ShiftRegs, and writes a line to the file.

 

No interference.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 6
(3,109 Views)

What you need to do is put all of your Analog Input into a single task.  They are all in the same chassis and run at the same rate, so it only makes sense to put them together.  This could solve your "buffer issues".

 

As far as logging, you really should be using a separate loop.  Every iteration of the AI loop, you just send all of the data you got so far.  When there is an update to the frequency measurement, send that.  The logging loop can hold the RPM measurement in a shift register to keep logging that value until an update comes in.  You might want to have a look at the Producer/Consumer for a better idea of how to log in a separate loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 6
(3,038 Views)

Thank you for your answers,

 

Separating the while loops fixed my buffer issues. I implemented the producer/consumer model and I am now logging temperature, torque, thrust, and x, y, z acceleration into a csv file.

 

1) However, I am unsure how to add the RPM to that same file. All of the other data is being acquired continuously, but RPM only generates a frequency when the optical sensor sends a 5V signal. So the while loop won't be able to keep logging the value in a shift register, since the while loop won't be executed until the rising edge is detected. 

 

2) Also, all of the producer loops are producing 1D array of waveform. The RPM sensor is the only one that is on demand, and hence producing a scalar, that I then convert to dynamic data to get time associated with the y. How could I get this as a 1D array of waveform as well, and bypassing the dynamic data altogether?

 

Thanks again!

0 Kudos
Message 4 of 6
(2,995 Views)

Cannot look at your code right now, but you should have a cluster with a string (or enum) and a variant as your queue data type.  The string tells the logger what to do with the data.  So when the frequency gets updated, it sends the message to the logger.  The logger holds the latest frequency value in a shift register and uses that value when logging everything else.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(2,984 Views)

Thank you for your help. I used the producer/consumer model with data queues to log data from my different loops. 

0 Kudos
Message 6 of 6
(2,944 Views)