LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Online Digital Data Acquisition Write to File Problem

Hello, I must say that I am extremely new to Labview and its different applications, so I would really appreciate it if you can answer considering my level of understanding.  In my experimental setup, I am trying to record 2 different digital signals (1's and 0's) created by 2 rota-meters and log them into a single file. What I am trying to do in the end is, counting the 1's and 0's that each rota-meter sends out in a given time interval and then convert this value to a flow-rate value. I was able to do some of the task using a For loop inside a While loop. 

 

In the beginner's code which is attached, I am able to record 10 distinct points for the boolean in a second and write it in an array, then sum it up in order to use it for that specific seconds flow-rate value. However I am not sure if the while loop waits for the for loop to collect all the 10 data points and then restart the loop or not. In order to do that, I have included a wait in the while loop; but I could not figure out how to write the value of the sum at the end of each second to the log file. As you can see in the log file, it writes multiple values for a given time (recorded in the same milisecond value).

Can someone point me out to the right direction?

In addition, any kind of improvement to the general code structure or Labview conventions would be very helpful for a beginner. Thank you in advance.

Download All
0 Kudos
Message 1 of 5
(3,149 Views)

Have you seen the example programs in the help menu? They contain recommended ways to program things like DAQ and writing to files, and they show the most efficient way to do things.


Using express VI's in loops is not recommended. They open and close the hardware reference each loop iteration and can greatly hurt performance and slow the program.

 

https://www.ni.com/en/support/documentation/supplemental/06/learn-10-functions-in-ni-daqmx-and-handl...

 

Chase
NI Technical Support Engineer
Message 2 of 5
(3,091 Views)

Thank you for your reply, I will thoroughly examine the link you have provided. In the meantime, would you have any simple recommendations for my specific application? Any simple thought showing me the right direction to proceed with the code would be much appreciated.

0 Kudos
Message 3 of 5
(3,081 Views)

Hello! Can you please clarify what you are trying to explain here:

 


@onurdogu wrote:

Thank you for your reply, I will thoroughly examine the link you have provided. In the meantime, would you have any simple recommendations for my specific application? Any simple thought showing me the right direction to proceed with the code would be much appreciated.

Not too sure what you are trying to do there, but everything in a loop must finish before it goes to the next iteration. So in your while loop, the entire 10 iterations of the for loop inside must finish before the while loop restarts.

 

Two recommendations I would make in general:

 

[1] I agree with Chase.E that you should move away from Express VIs, especially the DAQ Assistant Express VI. See the examples under Help » Find Examples » Hardware Input and Output » DAQmx » Digital Input/Output. This will show you how to use the DAQmx functions themselves. Performance will be better and your program will be more customizable.

 

[2] Look into Producer/Consumer. This is a must-know for LabVIEW architecture. The basic principle is that one loop collects data and another loop does the (slower) data processing. A queue passes data between these two loops and ensures no data loss. This way, processing does not slow down acquisition; it can happen at its own speed. In your application, Booleans would be read in Producer and all that summation and writing to file would happen in Consumer. Side note though, you can also use a DAQmx function to write to TDMS file during acquisition. Not really sure what is better for you applications.

 

 

Personal recommendations for the topics you need to read up on that are most important to LabVIEW:

  • State Machines. Whenever possible, use these over Sequence Structures.
  • Producer/Consumer Loops
  • Data Flow

Lastly, look at the other examples that come with LabVIEW! They are really, really useful and cover most everything. Good luck!

Message 4 of 5
(3,060 Views)

Thank you very much for all the recommendations. I have already started reading some of the manuals and doing the tutorials. I will keep in mind the topics you have recommended.

0 Kudos
Message 5 of 5
(3,050 Views)