LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

getting seconds to an array

Hi there!
I´m looking for a solution to get the actual elapsed seconds during an
experiment into my data-file (arrays). I want to write it to that file
simultanious with the aquired data.
To obtain the elapsed seconds : ("get time in seconds" outside of the
while-loop) minus ("get time in seconds" inside of the while-loop) = actual
elapsed seconds since start. I got an indicator inside of the loop so I can
see this elapsed time in seconds. Thats fine so far.
I tried to wire the output of the numerical "minus" to an "build array"
(second input is my data-column). May be silly.
"dimension conflict" is everything LV has to say to this attempts.
How can I get them into an array (first column)?

What I want is something like this - first column is
elapsed time in
seconds, second (an so on) column is aquired data:

3,00 2,28 ...
3,50 0,87 ...
4,00 -0,94 ...
4,50 1,83 ...
....
and so on.

Any ideas?
Maybe you can shove me into the right direction...

Thanks so far.
Sascha
0 Kudos
Message 1 of 10
(4,030 Views)
In my opinion, you will need to build the array in two stages. In the first stage you build 1D array of the elapsed time with the acquired data. Next you build 2D array from the 1D arrays. I attached a sample vi, I hope this helps.
0 Kudos
Message 2 of 10
(4,030 Views)
Sascha,

Browse through the LabVIEW examples for some tips and methods on building arrays. This should offer some tips on how to solve the problem while you are waiting for a solution to appear on this forum.

In the meantime, if you would post a screen shot of your diagram, we can better understand the exact circumstances of your situtation, and offer better advice.

-Mike
Message 3 of 10
(4,030 Views)
"Labviewguru" wrote
> In the meantime, if you would post a screen shot of your diagram, we
> can better understand the exact circumstances of your situtation, and
> offer better advice.

There it is:
http://home.arcor.de/neighbourhood-network/monitor_and_capture.jpg

I know that I need an additional input-terminal in my "build array" to get
an extra column for "time in seconds".
The problem is to format the elapsed time the way to fit into an array.

Sascha
0 Kudos
Message 4 of 10
(4,030 Views)
this may not be the best solution but i hope it is what you are looking for.

PS: Beware of array-size building up over time.

ian"
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 Kudos
Message 5 of 10
(4,030 Views)
Hi Sascha, one suggestion is to use the while loop to supply time by using a control rate set to 1000ms tied to the initerations. So the loop, loops once a second and counts 0,1,2,3,4 and so on. And also u can use this to put in your data collection like u want above, by wiring the initeration to your data collection.I had the same problem as u above and i believe this will solve it.

Stuart

P.S. if it a bit confusing, email me at liversj@matthey.com and i will send u an example of this.
0 Kudos
Message 6 of 10
(4,030 Views)
I don't know if this will put the seconds in the right column, but you could try to use another Build Array before the exsiting Build Array. The new one should have two inputs; simply wire your elapsed seconds to both inputs of the new Build Array (this will give the seconds the same dimension as your other inputs) and wire its output into the original Build Array. You will of course get the seconds listed twice in the final array, but at least they'll be there.

Good luck.
0 Kudos
Message 7 of 10
(4,030 Views)
"Sascha Greinke" wrote in message news:...
> "Labviewguru" wrote
> > In the meantime, if you would post a screen shot of your diagram, we
> > can better understand the exact circumstances of your situtation, and
> > offer better advice.
>
> There it is:
> http://home.arcor.de/neighbourhood-network/monitor_and_capture.jpg
>
> I know that I need an additional input-terminal in my "build array" to get
> an extra column for "time in seconds".
> The problem is to format the elapsed time the way to fit into an array.
>
> Sascha


One option you have is to use the "Initialize Array"
command, and you can set it up to initialize an array
of whatever dimension you'd like and have all of the
elements in the a
rray be initialized to your "time
in seconds" variable. You cannot simply append the
"time in seconds" element (a single element) to a
bunch of arrays (with your "Build Array" command);
you'll have to make the "time in seconds" an array
of the same dimension as the arrays you're building.

I hope this is reasonably clear. If not, feel free
to email me at the above email address, and I may
be able to provide some more clarity.

Jeff
0 Kudos
Message 8 of 10
(4,030 Views)
Sascha,

It will give you a timestamp for each index of the 1D array for the data you acquire (i.e. the timestamp will be duplicate for the number of values in the buffer size) but try this:

Get the size of one of the data arrays and wire that to a for loop. Wire your seconds into the for loop, and then back out. This will build an array of duplicate numbers. Then, add this to the top of your array.

Your data will look something like this:

index time ch1data ch2data ch3data...
0 0 1.4 15.2 0.5
1 0 1.6 12.6 0.3
2 0 1.4 17.6 0.8
3 12 1.9 18.1 1.5
4 12 2.0 18.5 1.8
5 12 2.2 19.2 1.7
...

If you still need help, emai
l me, and I'll post here and email you as well...
Message 9 of 10
(4,029 Views)
Hi LabviewGuru,

> Get the size of one of the data arrays and wire that to a for loop.
> Wire your seconds into the for loop, and then back out. This will
> build an array of duplicate numbers. Then, add this to the top of
> your array.

I tried some things and they seem to work.
But I discovered another problem: My VI gets those data and buffers them.
Buffer size is about 2500 and I wired the input for "number of scans to read
(-1)" at the "AI Read" with a constant "50".
So the VI reads 50 scan at one time out of the buffer to write it to my
file.
The problem is, that only when writing to file - and that is every 50 rows -
the VI writes the timestamp in that file, too.
I tried to decrase the "scans to write at a time" to 1, so I g
et a timestamp
to every row, but now the buffer is overrunning.
I have to think about that.

The solution wizard gave a very interresting solution that works for my
tasks, it also puts a timestamp into my file, but it looks something like
this:

2002 Oct. 05 07:15:12 28,4879 14,24 15,79
2002 Oct. 05 07:15:12 27,9476 15.14 14,84
2002 Oct. 05 07:15:13 ...

And so on.
Ok, fine. Something I could live with, if the seconds would be written with
more than 0 digits of precision.
I think I´ll have to watch this VI exact so I may find a way to solve that.

> If you still need help, email me, and I'll post here and email you as
> well...

Thanks so far, I think if I bite on granite, I´ll use your offer and send
you an email.

Sincerely,
Sascha
0 Kudos
Message 10 of 10
(4,029 Views)