Showing results for 
Search instead for 
Did you mean: 

Save timestamp from 2D array

Greetings, I have found this question or very similar asked often, but haven't found a solution that fits. I am collecting data from a PXI 6361, coming from 6 (more to come) sensors. I need the data as an array of doubles since I first manipulate it, then add it to a .tdms which is not the main focus here at the moment. What I would like is having a timestamp for each sample to know when it was taken but the read VI only gives timestamps when requested data is in waveform format. Here's my code, which adds a 10 elements buffer to be saved to memory in case a particular event occurs; right now I am gathering data from a simulated device since I don't have the real device handy, and here's the SubVI needed, created from the DAQ assistant.



0 Kudos
Message 1 of 8

Good Morning,


It would be possible to change your queue type to a cluster which has your 2D Array and also a Variant or TimeStamp Constant (variant would give you more scalability). Then you could Get Current Time in the Producer loop and bundle it in to the Cluster for each reading.



0 Kudos
Message 2 of 8

While it would indeed give me a timestamp, it would be the same timestamp for every value, which may not be the best solution if my end user wants more precise data information. Might try that for the meanwhile, but I would really prefer a more precise timing like what DAQ generates with assistant or waveform.

0 Kudos
Message 3 of 8

Is it possible to create multiple single channel Tasks and build them into an array and auto index within a for loop to attach the time stamp ? That way each sensor has it's own Task and each Task has its own time. Is that your intent?

0 Kudos
Message 4 of 8

I have tried to do that, and actually that was my original intent, but no. When I created several individual tasks only one of them got thru, while the rest got a "reserved or unreachable resource" error, it has to be a multi-channel task, which is not the problem, I'm perfectly fine with that format.


What I mean is that, by using a get current timestamp, I would have the very same timestamp for each one of the 2k samples, which might not be optimal if my user wants to know more accurately when each sample was taken. I would like an individual time stamp for each of the samples in the column, which would be shared across rows, since all of the samples were taken at the same time either way. Synthetizing:


-All data columns will share the same timestamp column, since all of the samples were taken at the same time, regardless of what AI they come from I'm ok with that.

-Each row will have its own unique timestamp when it was taken, which might but ideally will not be shared by previous or subsequent rows (2 samples might have same milisecond taken, but not all of them)

-This data will be saved alongside the samples, so it is easier for end user to know exactly when each sample was taken.



0 Kudos
Message 5 of 8

Try this:


*I can't open your VI as I am running 2012 so I'm unsure of your case structure in your consumer loop.. but try this logic and see if it works, it won't puke on the channels as it's still N Chan.

 *Set Physical Channel control to PXIxSlotx/ai0:5 


This should iterate 2000 times with NChan 1Samp, bundling all channels timestamp with 1 sample, and indexing that array 2000 times. Your cluster will be 2D Array of Doubles and 1D Array of TimeStamps. You may have to do some more array manipulation to get it in the right form at Circular Array, but I think with this producer setup you will be able to get 2000 samples of 6 channels, each with individual time stamp per read. 

0 Kudos
Message 6 of 8

Here is something that would work for your producer loop. Example is worked, you can't have an array with Time and Double as the data types aren't the same, therefore you need a cluster, check this out and see if it helps you reconstruct your VI.



0 Kudos
Message 7 of 8

If you want the time stamp data, then read it as a waveform, then use the Get Waveform Time Array function to get an array of time stamp values, where each value in the array corresponds to each value in the Y.  Then pull out the Y values from the waveform components and send them both over on the queue.  Or just send the waveforms over and do the manipulation after pulling them out.


EDIT:  Sorry I missed those replies



0 Kudos
Message 8 of 8