LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Storing irregular sample data in TDMS

Solved!
Go to solution

I don't fully understand what you are asking, but I think it is best to try to understand what your data is representing.  If you have a whole bunch of encoder frequencies, I would write a time stamp associated with when the frequencies were determined, and write that as a separate channel in the TDMS file.  Then you would have something [Encoder 1 Frequency] and [Encoder 1 Time], repeated for all encoder readings you have.  If all your encoders have a reading at the same time you can have one channel of [Time] then [Encoder 1 Frequency ] and [Encoder 2 Frequency].  Since they all share the same time you shouldn't need to write all that duplicate data.

 

You may need to post some code so it can be better understood.

0 Kudos
Message 11 of 18
(531 Views)

Hi,  thanks for the quick response.

 

The attached VI is what I have so far.  I started with the 3 analog inputs, indexed the array to apply different calculations and pull individual charts.  Then rebuilt the new array and wrote that to a TDMS file.  It worked and I could record the 3 different channels under the one group name.

 

Then I added the encoder channel reading frequency, but can't wrap my head around how to do what you are saying.  I tried building an array of timestamps by adding the periods (inverse of frequency).  I tried using shift registers to build the array.  Anytime I try to build an array of timestamps, I can't add it to an array of other data type, such as the calculated WFS array of DBL.  Such a build array function always breaks.

 

Furthermore, how do I associate a timestamp with when the frequencies were measured?

 

On a side note, I was using the group name to describe the test conditions when performing the same test under different conditions.  This gave me one TDMS file per test but included multiple test runs of the same device.  Is this not a best practice?  I only ask because if the encoder frequency (WFS) and timestamp go under a different group name, then I will need to rethink how to record multiple runs. Not a big deal.

 

Thanks!

0 Kudos
Message 12 of 18
(524 Views)

Okay there are a few ways to do this, and they are up to you.  But the main issue with the broken wires goes back to what I mentioned on what the data represents.  Here you have an array of doubles.  This is an array of numbers with each sample corresponding to a counter reading.  Then you are inverting that, and adding it to time.  What you read was an array of frequencies.  Like it samples a bunch of readings and then determines with those readings, that what it is seeing is a certain frequency.  I'm unsure how the sample rate works and if you can just invert it, to get the times of each reading.  But even if you can you would get the times but you aren't logging the values.

 

Attached is a quick and dirty solution of what I'm thinking.  It generates a TDMS file, then reads 10 encoder readings (the for loop running 10 times simulates it).  It will log a single value to the Time channel, then log the 10 readings to 10 different groups.  Let it run for a few seconds then press Stop.  It will open the log in the TDMS Viewer and you'll see the time channel, then a channel for each encoder.  You'll see that there is one time value, and that will be the same for all encoder readings at that time.

0 Kudos
Message 13 of 18
(517 Views)

There is a difference between

a) irregular (random and/or exactly timestamped) samples,

b) samples that use the encoder slope as sample clock  and

c) capture an analog signal and a encoder output (position or velocity or counter or ...) at a constant sample rate.

 

 

a) needs two arrays/channels  and ignore dt 

b)   one channel just by changing dt to dr  (r for angle or distance) 

c) just two channels 😉

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 14 of 18
(505 Views)

Hello Henrik,

 

So, this thread is scenario a) ?

 

I think I am looking for b) or c) and I was led to believe that b) with it's implicit timing was the more precise method because the difference of +/- 1 count could mean a significant error.  That is what I thought irregular samples were.  Sorry if I misunderstood. 

Do you suggest c) instead?

I want to be able to record (TDMS or any) the speed of something (calculated from rotational speed from encoder) along with the other analog inputs.  Visualizing all plots together along a time axis would be ideal for making observations.  As the encoder timing is currently implicit, how to do correlate the time to the measurement?  I tried building a waveform using t0, dt=period, and Y= calculated value.  Didn't work so far. 

 

Hooovahh,  thanks for the sample vi.  I don't quite get how the second for loop works.

 

Sonnige Grüsse aus der Schweiz

0 Kudos
Message 15 of 18
(498 Views)

@Surfmase wrote:

 

Hooovahh,  thanks for the sample vi.  I don't quite get how the second for loop works.


It is just generating unique names for each sample being read.  I thought you had multiple encoder readings, so I was assigning a unique name for each.  But now I see you have it configured for N samples but 1 Channel.

0 Kudos
Message 16 of 18
(489 Views)

Hi Hooovahh,

 

another question: what is the usefullness of having these times on their own channel?  I can see them in the TDMS increasing nonlinearly.  But what I think is more usefull is to see a speed measurement vs these times in order to draw correlations with the analog data being measured with its own time data.  Or is this to be done somehow in the TDMS viewer?

 

cheers,

0 Kudos
Message 17 of 18
(469 Views)

@Surfmase wrote:

 

another question: what is the usefullness of having these times on their own channel?  I can see them in the TDMS increasing nonlinearly.  But what I think is more usefull is to see a speed measurement vs these times in order to draw correlations with the analog data being measured with its own time data.  Or is this to be done somehow in the TDMS viewer?


Logging the times and data separately means you can graph them on an XY plot with unevenly spaced data.  Some viewers make this easy to do, but I don't see the settings to allow a channel to be the X axis in the one from my example I gave.  Scout and Excel both have that option, and if you write your own VI you can do it as well.

0 Kudos
Message 18 of 18
(449 Views)