05-19-2020 12:33 AM
Hi everybody.
I have some trouble trying to write my text file.
1. First I pretend to run de VI.
2. Then start the play button and goes to the true case.
3. Goes to flat sequence and the first frame opens a file.
4. In the second frame, a random number is saved and wrote in "write to text file" until the time finish in my for loop.
5. and the third frame, close the file.
My problem is that in the second frame the for loop is not finished yet and immediately goes to the next frame, close the file and the flat sequence starts since the beginning, open and close a new file many times until the times up.
I would like to stay only in my second frame until the time finished. I hope it was clear
Thank you.
05-19-2020 02:12 AM - edited 05-19-2020 02:14 AM
Hi cheko,
@chekoR wrote:
I have some trouble trying to write my text file.
My problem is that in the second frame the for loop is not finished yet and immediately goes to the next frame,
I would like to stay only in my second frame until the time finished.
What's the point in using this sequence frames at all? Don't you trust "THINK DATAFLOW!"?
When the loop finishes immediatly then the data wired to "N" is less than 1. Did you check this while debugging your code?
Why do you need to divide and multiply by 0.1?
Why don't you use FormatIntoString instead of NumToString followed by ConcatString?
Why do you need to reset "Play"? Wouldn't it be easier to switch this boolean control to a Latching mode?
05-19-2020 04:10 AM - edited 05-19-2020 12:58 PM
@chekoR wrote:
1. First I pretend to run de VI.
I would suggest to actually run the VI. Jus pretending doe nothing.
Gerd already pointed out most problems.
So.
Have an outer while loop with two states (cases of a case structure) and some reasonable loop time. (1) Saving or (2) not. Open the file before the toplevel while loop and close once the loop has finished.
When play is pressed, take the reference time and go to the saving state. Look at the elapsed time and go back to the idle state once the time has elapsed.
Here's a quick draft.
05-19-2020 12:51 PM
Hello GerdW.
Thank you for your answer. Maybe I need to explain why my project doesn't make sense now. I'm a student learning LV The propose of my project is to shake a horn as a vibration machine using output sound controls of LV and at the same time measure the acceleration of a structure and check the vibration response.
Until now I can read acceleration and write output sound without any problem. But now I need to combine with a graphic and easy environment interface for the final user. My code needs to run the VI but without doing nothing of vibration and acceleration, because first I need to set the parameters of the frequency, amplitude, and the time of the test vibration. When I have the parameters I need to push a play button and start my vibration and acceleration measurement test for 60 seconds for example. Then save the acceleration data response in a text file and my test has finished but the program has to continue running if I want to do another test with other parameters and create a new text file for a second test. That's why I try to do a flat sequence and I have a led traying to see whats is happening in my code and understand better but trying to write a file with those conditions is really getting difficult for me.
And because I'm learning I tried to do this dummy code to learn how tools work and have a better understanding. Maybe there are betters tools to do my code but I don't know them yet and I need more experience, this is great software.
Thank you for your help. it really helps me a lot to have a better understanding
05-19-2020 01:00 PM
Hello altenbach.
Thank you for your answer and a quick draft. I wrote the reason why my code doesn't,t make sense in the previous answer.
I going to follow your advice to get a clear code.
Regards.