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: 

Record data into Excel while program continues running

Solved!
Go to solution

Dear Labview community,

 

I am tasked with creating a DAQ-based (RPM, power,torque,temperature,pressure) program which is, among other things, supposed to log its measurements into excel. I have not had problems creating the actual log system, however, I do have a specific problem still: I am supposed to implement a function whose task is to record those values while a record button is pressed down, and stop recording once the user presses a stop button. The program is not supposed to stop running - it records data from a running engine, and the only time the program is supposed to be stopped is when we stop the engine.

 

Now, I have tried many ways to implement it, but have failed so far, getting error -2146827284 at undefined location (an error within the excel functions, it would seem). The ways I tried:

 

  • Flat sequence structure, first trying to perform writing to excel, then stopping logging within the collector VI, then resetting the record/stop to initial values.
  • Writing to excel, then taking a boolean output from the case structure where writing is performed, and feeding it back to stop logging and reset buttons to initials.
  • I have an idea of pausing the while loop while file saving/creation is performed, but I don't know how to implement it, especially so it doesn't interfere with the daq's working on acquisition.

 

I have tried to include a maximally stripped-down version of the VI's so troubleshooting is easier for whoever is willing to help me. Saved in LV2012, I think that is the earliest version that supports the excel functions that I implemented.

Included are the VI's, and the very basic excel template that I am using for this test. 

 

Thank you for your attention, and I hope I don't offend anyone with any ignorance that the VI's may feature. I am rather new to Labview.

Download All
0 Kudos
Message 1 of 9
(3,443 Views)

Unfortunately the code was for LV 2016, and I do have LV 2012, so I could not open it.

 

One thing you might consider is writing your values to a CSV file during the test, or keeping them in a buffer of some sort (shift register, feedback node), then after you finished recording you can dump it to an XLS file. 

 

I remember having a problem in the past of closing and opening an Excel file very quickly, but without seeing your code I don't know if that could be the issue.

0 Kudos
Message 2 of 9
(3,429 Views)

Heya, thank you for the quick reply.

I have reuploaded the archive in LV2012 (my bad, compressed the wrong folder). Tried to comment as best I could.

 

The code (most preferably! for ease of interpretation and use) needs to be based on a template. I have included a picture of a formatting that I am working towards.

I am already using a buffer, a collector VI. I am not familiar with manually building a queue (yet), and so far, it seemed to work just fine (even if express VI's are frowned down upon.)

0 Kudos
Message 3 of 9
(3,416 Views)
Solution
Accepted by xen20

Hi, there is a lot of room for improvement. One thing that may fix your problem quickly is to change the mechanical action of "stop recording". Right now it is set to "switch when pressed". You want a latching mechanism, so it only dumps the data once. Try "latch when released". As it is right now, as soon as you click "stop recording" it tries to write and re-write and re-write your Excel sheet as quickly as the main while loop will allow it to. Change it to latching so it only writes once.

Message 4 of 9
(3,404 Views)

Are you trying to do your "record and write data" process multiple times while the VI is running? It does not look like it is set up to handle that, since you are not using the "reset" input on your collector VI.

 

I think you would be much better served by an event structure rather than polling (reading the value every loop) of your buttons, if you care to look into that.

0 Kudos
Message 5 of 9
(3,401 Views)

Dear gregoryj,

 

I can't believe that that was actually all I required. Yes. For this simple VI this has indeed worked - I am sad not to have seen this myself - but now I see the logic perfectly.

 

I will scale this to the actual program tomorrow ( it is rather late here right now (00:32) ), and if I manage to do it, I will mark your post as a solution - I am not closing this right now because I don't want to open another thread should I encounter any problems.

And yes, I didn't think about the reset on collector at all. As to an event structure - I didn't know of its existence, so I implemented as I could.

 

Thank you.

0 Kudos
Message 6 of 9
(3,399 Views)

Hi gregoryj,

I have changed up the main program, and this solution seems to work. Thanks a lot! I have accepted your answer as the solution.

0 Kudos
Message 7 of 9
(3,360 Views)

You are welcome. Please look into "state machines" and "event driven state machines", it will make your life much easier!

0 Kudos
Message 8 of 9
(3,353 Views)

After this project is submitted to the company that requested it, I will pass labview core1+core2 to get a better theoretical base of how Labview works exactly - state machines seem to be included in core 2. The school mentioned the state machine/event driven state machine in brief, but didn't give any exercises, so I hope to get to know them that way.

 

Again, thanks.

0 Kudos
Message 9 of 9
(3,328 Views)