Showing results for 
Search instead for 
Did you mean: 

Question Regarding Convert from Dynamic Data & Scalar Data Selection

Go to solution

Hi NI Labview Community,


I recently wrote a program that shows and records the distance measured using a string pot. I was able to get the program to work but I have a question regarding the data that is being presented. I am using 4000 Hz for my sample rate and 2000 for the number of samples. This translates to (correct me on this if this is wrong) 1000 samples every .5 seconds. The input signal is being read as a voltage and if I take the dynamic data wire into a Write to Measurements File, it shows all the 1000s of data points in the excel data sheet. But if I take the dynamic data wire into a "Convert from Dynamic Data" channel and select single scalar in the resulting data type in the conversion selection and take the scalar wire into a Write to Measurements File, it shows 1 data point for displacement every (roughly) .5 seconds.


My question is if the displacement value being shown in the excel spreadsheet the scalar value at that .5 seconds or is it an average of all the 1000 samples collected during that .5 seconds. Also when the time value is recorded, it looks like the data is being collected every .48 seconds (i.e. .48, .96, 1.44 and so on). I want to know why there is a .02 seconds lag in the time being read. I have attached the code and sample excel data to this post. Thank You for your input and help.





Download All
0 Kudos
Message 1 of 4

Ah, yes, the Dreaded DAQ Assistant and its Evil Twin, the Dynamic Data Wire.  Here are some comments:

  • If you set a sampling rate of 4000 Hz and ask for 2000 samples, then ... every half-second (2000 samples divided by 4000 samples/sec = 2000/4000 sec = 0.5 sec) you get ... 2000 samples, what you requested.
  • Do you see the two Convert from Dynamic Wire functions you put on your Block Diagram?  Notice that the input is a Dynamic Wire (all kinds of evil can be hidden there), but the output is a thin orange wire, which any LabVIEW users after taking the minimal amount of tutorials would recognize as carrying Floats (probably Dbls) because of the orange color, and carrying a scalar (a single number), because of the thinness.  Indeed, you told the function to "throw away the 2000 points and give me a single Dbl", which it did.

The problem with the Dreaded DAQ Assistant and its Evil Twin is that too many of the details are buried so that you cannot tell what is being done just by "looking at the code" -- you actually need to have the code in front of you and "poke at it" to discover its properties.


If you do a Web Search for "Learn 10 Functions in NI DAQmx" (there's more to the title, but this will find it for you), you can learn how to Configure a Task, including Channels and Timing (you can define it in MAX, test it, and name it so you can use it in a Start Task function), do a DAQmx Read (inside a While loop), and Close/Stop a Task.  When you configure the Read, you can specify the format for the Output.  Now you'll have all of the data in front of you (well, the time and channels could be "hidden" in the Task definition inside MAX, but you can "get a clue" by looking at whether the DAQmx Read is for "N Channels, N Samples" or "1 Channel, 1 Sample", for example).


As for your timing, who knows?  What was the hardware?  [Hardware-timed loops are generally pretty accurate].


Bob Schor

0 Kudos
Message 2 of 4

Hi Bob,


Thanks for the reply. My apologies, 2000 samples every .5 seconds.


For hardware, I am using a NI 9239 module. The string pot is connected to the 4th channel on the module. You stated below that "you told the function to "throw away the 2000 points and give me a single Dbl" ". Is the function throwing away the first 1999 points and then giving me the last point or is it picking a point from the 2000 samples and giving that. I did some preliminary tests where I tested the string pot by performing the measurement alongside a ruler and the program is correctly showing what is being measured (+/- .1''). Eventually a more accurate fixture will be built to check that the string pot is working properly (versus using a ruler).


If the program is picking one data point from the entire 2000 samples and then sending that scalar value over that could be an issue because that individual value could be off due to noise in the signal itself. Another approach that I was thinking about was increasing my samples per sec to higher amount like 10. Then take all the 2000 samples every .1 sec, average them out to a single scalar value and send that scalar to the build array versus sending the dynamic data wire into a Convert from Dynamic Function and the program picks a data point from the sample of 2000. I selected 10 samples/ sec to be reported because that would be more than sufficient to capture the fine change in displacement that happens in second.


I will look into the code behind the DAQAssistant and learn about the code behind it.

0 Kudos
Message 3 of 4
Accepted by topic author rowsdower

Read Learn 10 Functions in NI-DAQmx ... and you will be off to a good start.  You'll notice that there are a few DAQmx functions that occur before a While Loop, a Read DAQmx that is inside the loop, and functions to turn off acquisition when the loop exits.  So inside the Loop, there will be a single Acquisition, say 2000 points.  What you could do is average them (very quick) getting a single point whose characteristics you know (you averaged 2000 points), or else take the first point (called "decimation"), another action you'll know, and then plot that single point, giving you a plot that updates 2 points/second.  If you want more frequent updates (say, 20/sec), you could sample at the same rate, but take fewer points (you do the math ...).


Bob Schor

0 Kudos
Message 4 of 4