LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save to TDMS file an array of clusters with different sample rates

Hello !

I'm trying to setup an aquisition of system, which is an angle sensor (output cosines and sines) connected to an encoder.

I'm using an external trigger to start the acquisition.


For each analog input I can have more than 1 value for the position of the encoder.

I'd like to store at same tdms file the output array that I've created. However, I'm not able to store an array of clusters with tdms.

 

Anyone have some idea to do so?

0 Kudos
Message 1 of 14
(3,443 Views)

@mrMesteves wrote:

However, I'm not able to store an array of clusters with tdms.


Well you can but it probably isn't what you want.  You likely want to come up with a way to flatten the data a bit into data for the specific channels.

 

If you are dealing with data of different sample rates, there are a couple ways to log data.  One method is to have a different group for each sample rate, and have a single channel in that group define "Time" for those samples, so something like this:

 

  • Temperature Data [Group]
    • Temperature Time [Channel]
    • Temperature 1 [Channel]
    • Temperature 2 [Channel]
  • Voltage Data [Group]
    • Voltage Time [Channel]
    • Voltage 1 [Channel]
    • Voltage 2 [Channel]

 

This works well if you only have a couple of different sample rates and multiple signals at each rate.  If every signal is sampled at different times then it would probably be best to log those all separately, either as their own waveforms where a property can log the start time and the times between samples, or give each channel their own time channel for data that doesn't come in at defined periodic rates.

 

  • Data [Group]
    • Temperature 1 Time
    • Temperature 1 Data
    • Temperature 2 Time
    • Temperature 2 Data
    • Voltage 1 Time
    • Voltage 1 Data
    • ...

And in all of these cases "Time" can be a timestamp, or relative time from something like test start.  Or you could choose to have two time channels one as absolute and one as relative.  There are lots of options with TDMS, so much so that it can be hard to decide what format you want and most of the time I'll start out thinking about how something will be used or read later to help guide the design of the file layout.

Message 2 of 14
(3,440 Views)

Thank you very much for you answer.

I have something closer to this:

  • Voltage Data
    • TimeStamp
    • sin
    • cos
    • -sin
    • -cos
  • Position
    • TimeStamp
    • Position

But, for instance, since it is something that is rotating, I can have multiple position for each analog output.
For instance I have something like this

TimeStamp| cos | sin |-cos| -sin| position

00:00:01 | 0.002 | 0,001 |-0.002|-0.001| 10

00:00:02 | 0.0021 | 0,0011 |-0.0021|-0.0011| 10

00:00:03 | 0.0022 | 0,0012|-0.0022|-0.0021| 10

 

Which, is the output of my cluster of arrays. I don't know how to save it to a file

0 Kudos
Message 3 of 14
(3,431 Views)

In that case what is wrong with flattening all the data and putting it all in one group?  Yeah Position will store the same value but the data will be on the same time scale as everything else.  You could write code that looks for if position has changed, and only log the data when it has but I think that would make consuming the data more difficult on other tools.

0 Kudos
Message 4 of 14
(3,427 Views)

Thank you for you answer.

Yes, you are right, and what you show as an example is what I want.
However, I do not have this type of structure available .

My" sines and cosines" are get from this Analog while loop.

2019-02-14_07h56_10.png

 I thought that would be better putting the "Acquired Data" variable (which is the position" into this while loop, and I created an array of clusters.

 

 

2019-02-14_07h56_29.png

2019-02-14_07h56_46.png

Is it possible to have the data as you suggested at LogTDMS.vi hooovahh ?

I started with Labview 2 weeks ago. it is possible that I'm making a lot of mistakes.

0 Kudos
Message 5 of 14
(3,400 Views)

Hi,

 

Thanks for your post, I think hoovah has posed some good ideas and they have a better grasp of the situation.

 

However, I found a forum that talks about a similar issue further:

 

How to store configuration data from clusters to TDMS files - Discussion Forums - National Instrumen...

 

Let me know if this is of any use.

 

Cheers,

YD

0 Kudos
Message 6 of 14
(3,390 Views)

I do see a lot of local variables which isn't necessarily bad but can lead to things like race conditions.  And I assume this is one of those places that this is happening.  You have a loop just acquireing data, and another loop aggravating the data I assume for logging, but they aren't synchronized in any way.  What if you acquire 1000 times, and then log once?  Well you will record the last time you acquired and the other 999 times you acquired the data will not be logged and will be lost.  This isn't the original question you asked but I assume it is one place you are having issues.  If you know your logging of data takes a short amount of time compared to the time it takes to acquire you can have your logging function in the same acquire loop.  Alternatively you can have a separate loop of acquire and log, but have some kind of method of sending data to the logging loop like a queue, or a channel that is lossless. 

 

As for the structure of the TDMS file.  You can log your array of waveforms without any real issue, but your Acquired Data has no time associated with it, and you don't even have a way of knowing what the delta between samples is.  Even if you logged the Acquired Data separately, there isn't any time information with it, and the number of samples between the Array Waveforms, and the Acquired Data likely won't be the same size.

 

Attached is one way to log the waveforms at least.  It keeps all the acquired data in an array of waveforms, and keeps appending data to it until it reaches a size, and then logs them all to disk and clears the buffer.  This way memory doesn't just continue increasing forever and crash.  I still don't know how to handle the position encoding and I'm not familiar with how it is read so I just am reading single point positions, and getting the time then logging all those times and values in a new TDMS group at the end.

 

If I were to do this application I would have choose a different design, and used more subVIs and State Machines.  I'm sure it doesn't help too much beyond the basics but there are lots of free training things online to learn more about LabVIEW if you're interested.  But honestly the way I learn best is by shadowing someone else and you don't really get that from these training videos.

 

Oh and once you have a TDMS file checkout Scout by SignalX, the TDMS Excel Importer, or the TDMS Viewer on the palette.

0 Kudos
Message 7 of 14
(3,382 Views)

Thank you for the answer.

With this labview code, I got an error. Mainly because the position of encoder is not being updated.
"

DAQAnalog_7_6 Logging Waveforms.vi<append>
<B>Property: </B>RelativeTo
<B>Corresponding Value: </B>Current Read Position
<B>Property: </B>Offset
<B>Corresponding Value: </B>0

<B>Task Name: </B>_unnamedTask<7>

"

I have an external trigger. When it is On, the analog acquistions starts.

I just need to know for each Analog Reading I need to know in which position it is placed.

When the motor reaches the target position, the external trigger goes off -> acquistion stopped flag is on.

 

I don't need an 1337 solution, just one that works, in order to later learn more !

Thank you very much

 

0 Kudos
Message 8 of 14
(3,378 Views)

I'm sorry.

But the error has other aspect. Not that I've thought.

Checking the tdms output we can see there is none waveform group

0 Kudos
Message 9 of 14
(3,369 Views)

State Machines aren't 1337.  They are a very basic computer engineering concept, and one that makes life much much easier.  I'm sure you have little desire to become a LabVIEW expert and just want it to work, but taking the shortest path to this type of goal is the wrong way to go about doing this.  You will pull your hair out and spend hours going in circles changing things you don't fully understand.  It won't be satisfying work, and you likely won't learn anything.

0 Kudos
Message 10 of 14
(3,368 Views)