LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write 1D Array To File at Specific Sample Rate

Solved!
Go to solution

Hey everybody! I'm back again to ask what is probably another simple question.

 

I have 6 custom load cells that are read in a subVI. The subVI is inside a for loop, which is inside a case structure, which is inside a while loop. Here's what it looks like:

loadcell_inception.PNG

What I need to do is take the 1D array going to "Channel Weights" and log it to a file (preferably TDMS) once every 5 minutes.  It would also be best if this didn't require going into the subVI that produces the data, as I use it as a driver in other VIs.

 

Please let me know if I'm not being clear enough, as I've left out important details in the past.

_____________________________

0 Kudos
Message 1 of 6
(2,795 Views)
Solution
Accepted by topic author Matub

So is the "Serial - Mantra Count" vi the one that you do not want to go into?

 

You could use a Functional Global Timer, if you want to create your own, or you can use the Express VI Timer to see if 5 minutes have passed.  If the time has expired, then save it to the file.  You will have to add logic as to when to reset the timer.

 

Now this assumes that for that 5 minutes, you are still looping through the "Read" state (continuous logging).  If you read all your values in say 3 min, and then go do something else, then it will not save the data, as the time has not elapsed yet.

 

If however you are only wanting to take data every 5 minutes, then you would want to enclose the For loop in a case structure, with the Case Terminal tied to the Time Elapsed? Output (when time has elpased, read data and log).

 

Another option is to break out another loop on the block diagram, or create a daemon, which will periodically save the data.

Kenny

Message 2 of 6
(2,777 Views)

Is your question how to perform this operation every 5 minutes, or how to write the data to a file?

 

If you need to write every 5 minutes then you will have to store the data in a shift register and utilize something along the lines of what Kenny was talking about.

 

If you're having trouble writing to the TDMS file, then fear not.  Literally all you have to do is open the file (TDM Streaming Pallete) and then wire your array into the Write funtion.  Close the file and you're done!  This can be done over and over again to append to the file.

Chris
Certified LabVIEW Architect
Certified TestStand Architect
Message 3 of 6
(2,771 Views)

I ended up doing a hybrid of these two answers.  I was initially worried about showing the data streaming somewhat constantly but only taking a reading every five minutes.  After sitting back and thinking that no one is going to be watching the stream, I just added a wait to my while loop.

 

I did what PackersFan (great username, btw. Go Pack Go!) suggested and put the data in a shift register. That then feeds into a For loop that is controlled with a boolean switch. Ex:

for_loop_control.PNG

 

This does what I want it to and doesn't bog down my system like I thought it would.

 

Thank you so much, guys!

_____________________________

0 Kudos
Message 4 of 6
(2,747 Views)

untitled.JPG

 

Hi your Vi should be look like this

This is Implimented in a case struchere with whilw loop.

There are three cases first pool case startedrunning till the specified timing is reaching. this iwill dose by  the elapsed timing vi.

once it reaches the 5 min(let say) it execute the read loop inside that you should keep all your pressur reading.... thenit come back to poll case until the 5 min reaches

in the POLL case itself the error checking everyloop once stop butten presser VI will stop...

0 Kudos
Message 5 of 6
(2,732 Views)

untitled.JPG

 

Hi your Vi should be look like this

This is Implimented in a case struchere with whilw loop.

There are three cases first pool case startedrunning till the specified timing is reaching. this iwill dose by  the elapsed timing vi.

once it reaches the 5 min(let say) it execute the read loop inside that you should keep all your pressur reading.... thenit come back to poll case until the 5 min reaches

in the POLL case itself the error checking everyloop once stop butten presser VI will stop...

0 Kudos
Message 6 of 6
(2,732 Views)