LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing To Text File Help

Hello All,

 

I am a Senior Mechanical Engineering Technology student working on my capstone project. I've been working for a few weeks to get this program right but have had a hard time. I spoke with a person on the phone for help but I guess asking more than one question per phone call is looked down upon, so here I am hoping to get some help. I'm way more familiar with programming with Visual Basic and C++.

 

My capstone involves a series of 4 force transducers that are being used to weigh a five gallon bucket filled with weights. This is not the only part of the project, but the program for this whole thing is what I need help with. 

 

The use of this device is for a spaghetti bridge contest where the bridges are tested. I'm trying to get to the point where I have 2 programs that can run the transducers, first a stand-alone readout, which I have completed and it works very well. I would like to have the second program, which I am currently working on, allow me to operate the final test fixture at the competition as a user interface rather than a simple readout.

 

I'd like to be able to select a school out of a scroll menu. Then when weight is placed in the bucket my standalone program operates as a subvi which outputs the weight. The weight is then displayed on the user interface program. When I click record load, I would like that load to be sent to a file, and the display to be frozen so the weight readout will not change until the trial is complete. Next, I would like to be able to click a pass or fail button according to if the bridge held the weight applied. All of this information would then be sent to a text file for final competition results. 

 

I'm going to attempt to attach the user interface program as it sits. I've got a lot of my user interface set up. Looking at it you will notice a constant 5 that goes to the concatenate function, which represents a load... but in the future will be the input of the subvi. Currently the program writes continuously to the file. I know this has to do with my loop structures but I'm not sure what the best order or method to achieve my goal is.

 

Therefore, I need help with the following:

 

- Writing to file once per trial using the user interface setup 

 

If not much comes of this, I do plan on reconstructing the way it operates using a flat sequence... which would first select a school, then record weight, then pass or fail, then write to file... or along those lines. Maybe that would work... 

 

I'm not looking for someone to do the work for me, I'm just hoping for some assistance in getting this thing operational. I'm in a crunch because the competition is March 20, or 7 days from now.  

 

Thanks in advance for your help. 

Message Edited by HiddenTalent on 03-12-2010 09:31 AM
Message Edited by HiddenTalent on 03-12-2010 09:32 AM
0 Kudos
Message 1 of 11
(2,935 Views)

I only have LabVIEW 8.6, not 2009, so I cannot open your VI.

 

I wrote some sample code for you if you would like to take a look.

 

While the VI is running, you can change the school, weight, and select whether or not the bridge passed.

You then specify the location and name of the text file in the 'File Path' input.

When you have everything set how you would like, press 'Save to File'.

 

That should do what you are asking.

Let me know if you have any questions.

Cory K
0 Kudos
Message 2 of 11
(2,915 Views)
I would strongly suggest using the event structure.  This allow you to only write data when you need to.  You can also do data acquisition in a parallel loop, if you need to.  Check the LabVIEW examples for how to use it.  If you need more information, let us know.
0 Kudos
Message 3 of 11
(2,892 Views)

Cory,

 

I really appreciate that... You will be very surprised to know, even though you cannot see the first 9.0 file that my program looks very much like yours! I haven't done any changes to it, and have saved for previous version so you are able to view it. 

 

I like the way your program functions... it appends to file for each save, however there are a few things that I would like to change on it... and we will see if I can manage to make it happen...

 

I'd like it to save to file when you click pass or fail... and I'd like to have separate buttons for pass or fail... which may be challenging, everything else is perfect with it's function...

 

 

BTW, I'm up in Big Rapids at Ferris. 🙂

 

Keep in touch, I appreciate your help!

0 Kudos
Message 4 of 11
(2,868 Views)

HiddenTalent,

 

          I second the notion that you should explore event based architecture using an event handler. Here is an example of an event handler using some of the functionality you are looking for. Event Structures are special case sturtures that have been built to handle user interface events like button clicks or value changes. Take a look at the functionality in the VI I attached (Example.vi written in LV 2009 SP1), check out ni.com for the LabVIEW Help on Event Structures or all the Developer Zones on Event Structure based architectures, or just post back if you have any questions.

0 Kudos
Message 5 of 11
(2,856 Views)

Cory,

 

I have included my measuring program as a subvi, and included it outside of the loop with the write to file content... with only the addition of the subvi which outputs a weight (replacing the input string), the program will not write to file.

 

Any ideas?

0 Kudos
Message 6 of 11
(2,842 Views)
Post your code?
0 Kudos
Message 7 of 11
(2,839 Views)
Turn on Highlight Execution at the top of the Block Diagram (little light bulb symbol) and run your code. Does it actually ever step into the Write to File area? Does your subVI that gets the weight run as expected? Let us know how things are going. Good luck!!
0 Kudos
Message 8 of 11
(2,805 Views)

I think the subVI would need to be inside the loop.

Because you need to run the program to determine whether or not the individual passed, correct?

Cory K
0 Kudos
Message 9 of 11
(2,785 Views)

I am working on it more in the lab today... have a few things to try...

 

Currently I'm just running the two separate programs together as if I had them how I would like them in one... so it's working well as is!

 

Cory, I put the subvi in its own loop outside of the file stuff, I'll try putting it inside of the loop and see how that runs... The problem is that the subvi only puts out a double, and I need it to a string, so I used a number to decimal string conversion to try and get it into the table that way... It didnt like that for some reason... 

0 Kudos
Message 10 of 11
(2,777 Views)