LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Current time that is in-sync with my data feed? (my attempt)

The files are attached for different versions.

 

Ask User.vi isn't necessary to be able to see the code, but it's still attached in case it's needed.

Download All
0 Kudos
Message 11 of 21
(890 Views)

You must have one enormous monitor to be able to work with that code... I can't come close to following it simply because it involves too much scrolling in multiple directions.

 

I do recommend that you eliminate all use of the dynamic data type, since you're needlessly converting from an array of floating point to dynamic data and then immediately converting back again.

 

Generating time stamps in a separate loop with no synchronization to the main loop and then using a local variable to share them is not the right way to go, as you've already discovered.

 

You didn't include the VIs that do the actual data acquisition.  Do they provide any way to obtain a timestamp for the data?  If not, then the next question is, how precise does your timestamp need to be?  It appears that you're acquiring multiple data points at a time.  Is the acquisition hardware-timed - does the hardware make sure that the acquisition rate is constant?  Do you need each of them to have a unique timestamp, or is sufficient for each group of data to have the same timestamp?  You could start with some arbitrary initial timestamp and create an array by adding the known time increment to create an array; save the final new value in a shift register to use as the starting value on the following loop cycle.

0 Kudos
Message 12 of 21
(874 Views)

First, your code is WAY TOO BIG. If I need a wall to see all of the code at once it is nearly impossible to see what is going on or to fully understand it. Generally speaking your code should never be larger than a single screen. If you can't see all of it how can you  understand what is happening.

 

Your code has a memory issue and will consume all of the memory on your machine if it runs long enough. You have a loop with an uninitialized shift register and a build array inside of it. That array will grow to become infinitely large. Or grow at least until you run out of memory.

 

As suggested early at the point that you collect your data place the data and a timestamp into a cluster. Than operate on that cluster. You have timestamp the data the moment you collected it. You will never synchronize two independent tasks. If you want to timestamp the data you have to obtain the timestamp at the point where you collect it.

 

Take a look at the LabVIEW style guide for some tips on good practices.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 13 of 21
(870 Views)

I do have a large monitor! 

 

But, yes...I do need to clean up the code in order for it to be clear on a laptop monitor, since this won't be only used on my computer.

 

 

The device doesn't provide any timing information..only sample number is included. The aquisition rate should be constant at 51.2Hz and I could verify by running the VI for few seconds and looking at the spreadsheet file that is generated along with the timing information i added (in my unreliable approash).

 

A group of data would have the same value for "seconds" which is completely fine, no more precision in timing is needed.

 

The thing is that i am not sure where and how i should add my timing...is the block i'm using for timing good enough?

 

Any more clarification is appreciated...please bare with me, I am trying a lot and looking online, but trial and error is a bit difficult for my level since i'm aquiring data in real time.

0 Kudos
Message 14 of 21
(864 Views)

Mar_Yedinak:

 

The timing method i used wasthe desperate way..i appreciate the clarification on this one.

 

Any suggestion where i should add the timing exactly? What kind of cluster, just the build array block?

 

I am trying to do this, but it won't allow since the two arrays are of different sizes and/or the numeric to string conversion i am doing is not correct.

 

I have attached the picture and the VI of what i am trying to do.

 

Thanks.

Download All
0 Kudos
Message 15 of 21
(863 Views)

Here is how you would bundle the data into a cluster.

 

Cluster Example.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 16 of 21
(860 Views)

Mark,

 

I have succefully applied this, but how i can get the array containing the timing values from this?

 

What i did is basically wiring the 2D array containing all my data to the input of the cluser along with the time stamp...so i end up with a 2 element cluster...and then made the item wired to the culster terminal a typedef.

 

 

0 Kudos
Message 17 of 21
(854 Views)

Since you said it's acceptable if all the data points in one block have the same timestamp, I would make a simple modification to your current code: get the current timestamp as a string, make an array of identical strings the same size as the data, and merge the two string arrays.  This is not the most efficient method but is probably fine for what you're doing.  See image below:

build timestamp array.PNG

EDIT: this works too if you use a 2D array to get the size; you just need to add an Index Array to the output of Array Size to get the correct dimension.

0 Kudos
Message 18 of 21
(850 Views)

nathand,

 

I have applied this to my VI, which did fix the issue, but now all the timing points are equal.

 

I am guess shift regesters need to be used here similar to before (which i couldn't figure out with the initialize array block)?

 

Wouldn't this use up RAM?

 

 

0 Kudos
Message 19 of 21
(836 Views)

We still have not seen the acquisition subVI.

 

The point with nathand's suggestion is that if you are acquiring data at 51.2 Hz, then all the points in the array are separated by (dt = 1/51.2) seconds and you only need a timestamp representing the time of one of the points in the array. You can calculate the time of any other point by multiplying the difference in array indexes by dt. You do not need to store timestamps for every point.

 

Since it appears that your data source does not provide a timestamp and you are creating one (approximately) after you acquire a blcok of data, you can make a reasonable assumption the that the timestamp represents the time of the last elelment in the array.

 

Lynn

0 Kudos
Message 20 of 21
(828 Views)