LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing wavefrom to array trouble (PMX,HBM)

hi,

 

I am currently working on a project with Labview. We are doing measurements with a loadcell. The loadcell is connected to a PMX module from HBM (analog in). So we are using the HBM drivers for that. The output of the VI is a waveform (see picture). It is no problem to get the data displayed on a wavefrom chart. (sampletime is 20ms).

 

We need to store this data for later use. On this forum i allready tried to find how to read excel files in labview but i think that's a bit too complicated for a beginner like myself. Now i'm trying to store the data in an array. That way it would be possible to use 1 array as the x-axis and another as the Y-axis so we can form a new wavefrom.

 

But it doesn't work with my code. The array will only store a few points. The amount of points stored seems to depend on the sample time. It's like the array will only store the data of the last second of the measurement

 

Althought when i open the excel file i can see all the data. (excel file is attached + picture of a measurement)

 

Currently i used the "get wmf comps" and try to write the Y in an array.

 

Could anybody help me to store all my data in a array.

Thanks in advance!

Laurens

Download All
0 Kudos
Message 1 of 9
(3,104 Views)

The Y array will only be the data from the last read.  If you want to store more data, then you need to use a shift register and Build Array to add to the data.  But this is dangerous as you are likely to run out of memory.

 

Personally, I would save the data to a TDMS file.  There is a simple API for reading from and writing to the TDMS file and it will work directly with your waveforms.


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 2 of 9
(3,096 Views)

You've attached a picture of your code.  If I wanted help on a Matlab (or C++, or Java) program, I wouldn't send a picture of a 1000-line program, I'd send the code itself.  Attach your VI (or VIs) so we can (a) see the whole thing, (b) see "behind" Case structures, (c) edit your code, and even (d) test your code.  If you are developing this as a LabVIEW Project (New, Project), compress the folder holding the Project file and the VIs, and attach the .ZIP file.

 

So I don't understand what you want to do, nor much about the timing and amount of data.  I gather that you are collective Waveform data (what is the sampling rate, and how many samples are you collecting?  Are you doing Finite or Continous sampling?).  How do you want to save these data?  Note that a .csv file (Write Delimited Spreadsheet) is not an "Excel" file, although Excel "hijacks" the Icon for these files to fool you -- it is an ordinary text file for 2D numeric or string data, with rows separated by New Lines and columns separated by a delimiter, by default <tab> but by the name, Comma-Separated Values, a comma.

 

I don't understand what you mean by "one array as the X-axis and another as the Y-axis so we can form a new waveform" (incidentally, the word is "waveform", as in "the form of a wave").

 

I look forward to seeing you post real LabVIEW code (meaning VIs) and explaining better what you are trying to do.  I'm pretty sure we can make some helpful suggestions.

 

Bob Schor

0 Kudos
Message 3 of 9
(3,024 Views)

hi,

 

Thx for the quick responses! I can see now that i gave too liltle information. I'll try to get back to u tonight. But in the meantime this is my VI (hope i attached every instance of it : /).

Also: I need to read data from loadcell and data from an encoder (pulse counting, this is not yet implimented) and with these two i will need to make a new wavefrom. Loadcell data as x-axis and encoder data as y-axis. (that's why i wanted to store it in an array, but reading from a file will do just fine too).

 

greets, and thx alot! I will be right back!

 

0 Kudos
Message 4 of 9
(3,016 Views)

hi,

So... atm all i need to do is write data from my loadcell into a file or array or anything that will allow me to read all the data back when i want it. I need to be able read all data that was written during the measurement. From that data i need to be able to get plot it as the Y-axis.

 

Simultanious i need to be able read another measerument + read all data when called. This other measerument should be used as the x-axis of the same plot. So in total i should able to write 2 measurements at the same time + store them + be able to read them back and use the data to construct a graph.

So far all i can do is write the data of 1 measurment into an csv file but i'm not yet able to read all data back. The second measurement is not connected yet but my guess is when i'm able to do it with one it will just be a copy paste thing.

 

greets

 

Laurensde

0 Kudos
Message 5 of 9
(2,998 Views)

OK, I'm going to write some "Demo" code.  As it happens, you are using LabVIEW 2017 which I have not (yet) been able to safely install on my three main computers (NI knows about the problem, but so far has been unable to duplicate it -- I only have it running on a VM which is currently not available to me ...).  So I'm going to use LabVIEW 2016 -- you can simply open the VI with LabVIEW 2017 and it should run OK.

 

So here's what I'm going to do (not knowing that much about your data, sampling rate, # samples, etc., in part because, through no fault of yours, I can't (yet) view your VI) -- I'm doing to generate 1000 points from "Sim Load Cell", 1000 points from "Sim Encoder", write both of them to a CSV ("Delimited Spreadsheet") file, read them back, and plot them, with Load Cell on the Y axis and Encoder on the X.  I'm going to assume these signals are related, with Load Cell signal being U(0,1) "noise" (so a noisy signal with a mean of 0.5 and a range of 0 to 1), and Encoder being 2*Load Cell with U(0,1) "noise" added.  I'll make two plots -- one showing the two sets of data (I incremented the second plot by 1 so the data points don't overlap), and the other the X-Y plot you were describing (which makes no sense to me).

 

Here's the code:

DEMO Sim Data.png

 

and here is the result:

DEMO Sim Data FP.png

Bob Schor

 

 

0 Kudos
Message 6 of 9
(2,989 Views)

Oops, forgot to attach the VI, here it is...

 

BS

0 Kudos
Message 7 of 9
(2,986 Views)

thank you very much! i will try it first thing in the morning.

I am actually trying to build a universal testing machine ( google translate gave me the english name :p). And i need to plot a stress-strain curve. The loadcell will give me the stress and the encoder i will use to get the strain at each point.

 

greetz and a big thanks!

LD

0 Kudos
Message 8 of 9
(2,976 Views)

 


@LaurensDe wrote:

I need to plot a stress-strain curve. The loadcell will give me the stress and the encoder i will use to get the strain at each point.

 


Aha!  You are plotting two variables against each other, so you are correct that you want to plot an XY Graph (which, I must admit, is precisely what you said -- I just "didn't get it").  So even my "crazy Demo" shows (in the XY Graph) that there is some relationship between the (noisy) X Data and the (also noisy) Y Data, namely that the Encoder value is (ignoring the noise) twice the Load Cell.

 

So all you need are the two arrays representing the simultaneously-recorded values from the two Measurement channels (the measurement time is irrelevant, you just need paired "Load Cell/Encoder" values) and you can use the Graph part of the Demo.

 

Something to consider is to create a Stress-Strain Cluster to hold the pair of Load Cell and Encoder data, emphasizing the paired relationship of these data to each other without the (often-assumed) implicit assumption of "arrayed" data as representing equally-spaced time samples.  Of course, you can't write an Array of Clusters using Write Delimited Spreadsheet, so you'd need to (in a For Loop) split each Cluster element into its two components and reconstitute them as a 2D array (as I did in the Encoder For Loop and subsequent Build Array) just for the purpose of using the Read/Write Delimited Spreadsheet functions.  Oh, well.

 

Bob Schor

0 Kudos
Message 9 of 9
(2,962 Views)