From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to new file at midnight but record data constantly

Solved!
Go to solution

Thanks RavensFan, I can run the program now. Now to actually test it out on real data acquisition.

0 Kudos
Message 21 of 37
(1,589 Views)

How do I designate where to save my file to? I'm not sure that I even have the "write to file" in the correct position. Also, I'm not sure I understand the strip and build path functions either.

0 Kudos
Message 22 of 37
(1,574 Views)

Replace the empty file path constant with a control.  Select a reasonable directory.  Fix the strip paths as needed.  You may need to adjust the browse options on the file path control to be able to select a directory as opposed to a file.

Message 23 of 37
(1,563 Views)

Once again, right on the money RavensFan, kudos to you. Now my only problem is having the written text-data "write to file" function writing to the same file that was just created. The function is placed in the wait sequence of my case structure and I'm not sure how to connect it to the newly created file and having it write continuously recorded data to it. Improved code is attached.

0 Kudos
Message 24 of 37
(1,544 Views)

You seem to be having difficulty grasping the state machine concept. I will lead you through one of mine to give you an example to think about. You need to break your program down to descrete tasks, it looks complicated but in the end is is far eaiser to maintain.

 

First I initilize my instrument, in the case an Agilent 34901 data logger.

 

Setup.PNG

 

Then Open a data file (this program is a modified version of a larger program that used two data logggers and opened multipule data files every week) Notie: The week number is placed in the shift register so I can check it later.

 

Open Files.PNG

 

Then I imendendly goto the Scan state and take readings the scan state also displays the data and writes it to the file.

 

Scan.PNG

 

The I wait for the next scan interval in the timer stage, notice here the week number is checked and if it has changed I goto the close file state instead of scan.

 

Timer.PNG

 

Lets say the week has changed so we will close the data file.

 

Close.PNG

 

And open a new one by jumping back to the "Open Files" state and the program continues...

 

 

 

 

========================
=== Engineer Ambiguously ===
========================
Message 25 of 37
(1,526 Views)

Hey Apok,

 

Would you be able to upload a down conversion of your simple state machine VI so that I could have access to it? I have LabView 2012. Thanks!

0 Kudos
Message 26 of 37
(1,503 Views)

Hey Atwalsh,

 

There is a version conversion board that can do it for you when needed....but no problem on your request. Remember to save the file, that said...the new files created (every minute) will be in that same directory.  attached as ver2009

Message 27 of 37
(1,493 Views)

While this is a quick and dirty get ‘er done VI, it is not really a good example of using a state machine.

 

First there should not be so much going on outside the case structure.

 

All the decision making should be made into a one or more discrete states inside the case structure.

 

Second you are opening a file, then closing it and passing the file path, then using "write to spreadsheet" that opens the file, writes, and then closes the file each time it writes.

 

This is a very inefficient way to do file writes.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 28 of 37
(1,476 Views)

RTSLVU,

 

I realize this is not the most efficient way to write and save my data, but due to my lack of knowledge of the program and time, this is what I have to resort to. I appreciate you taking your time to try and explain your state machine, however, I can only take so much away from it without having the VI accessible in front of me. If you would be so kind as to upload your VI, I would be able to learn how a proper state machine can function. Thank you for your time.

 

 

Atwalsh

0 Kudos
Message 29 of 37
(1,450 Views)

@Atwalsh wrote:

RTSLVU,

 

I realize this is not the most efficient way to write and save my data, but due to my lack of knowledge of the program and time, this is what I have to resort to. I appreciate you taking your time to try and explain your state machine, however, I can only take so much away from it without having the VI accessible in front of me. If you would be so kind as to upload your VI, I would be able to learn how a proper state machine can function. Thank you for your time.

 

 

Atwalsh


I could upload it but unless you have the instrument I used (Agilent 34970A) you will not be able to run it anyway.

 

I could throw together a modified version that can run by it's self using a random number generator to make some "data" but I don't have time today. 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 30 of 37
(1,431 Views)