LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Write measurement to file There is a huge lag

I have written a code where it simulates faults i.e the primary i/p the square wave would have a high duty cycle <thats not the problem>

 

 

The problem is i have to store all the data and i'm using Write measurement to file .... but after some time there is a lag between real time and the time it has processed

 

require urgent help

 

 

 

0 Kudos
Message 1 of 6
(2,686 Views)

------ Seeing the Code --------- I'll edit that post when i finish.

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

There are some really odd things in your code.  Why do you have a Stop function, the function that is equivalent to aborting your VI, with a False constant wired to it?    That is like saying "don't abort my code".  If you eliminated that, you'd have the same result.  Actually using the Stop (Abort) function is bad practice.  It is equivalent to breaking your code and never letting it finish cleanly just like you hit the abort button on the tool bar.

 

I don't know why you have a Read Measurement File Express VI in a While Loop.

 

You have a lot of stacked structures where there are Event structures inside of case structures.  While loops inside of case structures inside of  other while loops.  A deeply nested structure almost guarantees you'll get your code buried into execution somewhere and it does not seem to return quickly.  It seems like you should be using a state machine.  With the proper selection of states, you can often flatten out your code so that you only have a single while loop with a single case structure inside of it.

 

You also have an abundance of local variables.  Probably the depth of your structures forces you to do this because you never have a wire containing the data you want to use present.  Again, flattening the architecture would probably allow you to remove most if not all the local variables.

 

Why the .dll calls for Browse for Folder?  It seems that LabVIEW file dialog functions would do the same thing without requiring calls to a .dll.

 

How many files are you trying to read and/or write to here?  It seems like a lot.

 

Is there a reason why you are using a boolean to generate a True or False as a string then using that string to drive a case structure rather than using the boolean itself?

 

I think if you clean up your architecture, your lag problems might just go away.  Or at least make it easier to see where the delays are coming from.

0 Kudos
Message 3 of 6
(2,668 Views)

Such Kind of TimeOut to editing the first post but...

 

 

"real time and the time it has processed"  

 

That's correct.  

The main reason of that is the Lack of Architecture in our code and overusing of Variables/Inner Loops/Bunch of Writing Files/Express VIs and one Fantastic DLL call... Everything in same Loop.

Its an heavy computional intensive to process everything without correct using of dataflow concept (Especially in ur Case). I'm still frightened...  Anyway.

 

Here some tips:

 

Avoid Variables: They can lead Race Conditions in our code and made some copies of data in memory. 

Avoid Stack Sequence Structures: Use DataFlow Concept to put everything in sequence

Decouple Processes: Create one Loop to UI actions, one to Data Acquisition/Generation, one to Log Raw Data, one to Create Report and Perform some analysis.Create some mechanism with Queues/Notifier to inter process communication (See Queue Message Handler Architecture).

Avoid Express VI: They are Inneficient,bad codded (Except File Dialog when there's one VI...) and put bunch of dependencies in your project. 

Create SubVIs: Provide Modularity and code reuse.

Stop Button needs to STOP:  Self Explanatory

 

Here some links about good pratices:

 

http://www.ni.com/white-paper/7117/en

http://www.ni.com/white-paper/5560/en/

https://decibel.ni.com/content/docs/DOC-22047

http://lavag.org/old_files/post-705-1100237457.pdf  <--- (That's good one)

Message 4 of 6
(2,664 Views)

Well nobody has ever though me labview (and i have been doing self learning) . . . and i've been using it for less than a month  . . .

can you please explain it to me bit briefly .... why not to do what you said... in sense wat might or will happen

 

 

by the way i reduced the sampling time down and it seems to work fine (but you know the waveform is not as beautiful loking anymore)

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

the stop function was an accident ... i was using it for testing purpose .... whereas the while loop was present because whenever an end of file appears it shows up an error... just to get rid of it quickly .... as the loop would run only once....

the multiple files are for the different info that is stored

if you had to jump to one particular fault of the complete waveform stored .....

this is a few reasons why i had many case structures .... but i have no clue why there are so many while loops... i didnt design the whole system from the start .... i did it as i progresses as i did not know many of labviews functions .... then i would reach a point were removing something from earlier would create a lot of chaos ... so i decided to go with the flow... 

 

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