LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wait Until Next ms Multiple

Hiii everyone...

I have one simple question but stil don't know how to solve it....I'm using write to measurement file express to save data in lvm file.Then I want to set it that it  written every 5seconds  for each data....then I open front panel of this express.vi to modify it n put Wait Until Next ms Multiple function to synchronize activities.For the first time I run this prog, n it works like it should.That mean the data will written by every 5s per one data.But then, I realize that the prog have run same as write file worked.That mean when the this express.vi run for 5s,then this prog will run for 5s too...So, my question it how to write this file for 5seconds and its don't bother the prog running for simulation.I mean that this prog still run like usual while the write to file measurement.vi run for 5s for each data....Thank u very muchSmiley Happy
0 Kudos
Message 1 of 13
(4,583 Views)

first of all, the "elapsed time" should not be in the main loop. the way you set it up is : if time has elapsed, then stop loop.

you should do: if time has elapsed, then save data. therefore you might want to put the save inside a case structure in the while loop. every time it is elapsed ,you have to reset the time elapsed (by inserting a new "start time"), and save.

few remarks tough:

1) if you want to do it this way, you will have to keep all the data created in the loops in shift registers, that will be cleaned only when you save. you wont be able to do it with waveforms or dynamic data. what is wrong with saving every iteration?

2) there a several identical operations in your applications. that's why subvis are for.

3) stop condition: a logic OR connected to a false constant??

4) put a short wait in the while loop (e.g. 50ms). since you do a read-write request to VISA, it seems you do not need polling at full speed.

5) i dont understand why you save as waveform, when dt is 0. also, t0 should come from single source. overall, it seems you only want to save the y values together. you can append them using "build array".

6) if you really want to save independantly from the data aquisition loop, then i would suggest setup a second independant loop, dedicated to the task, with your desired timing.

good luck.

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 2 of 13
(4,577 Views)
Hi Gabi1...

Thanks 4 ur reply...i think I understand that what u said...that I should put the save inside a case structure in while loop..But, can u give me example of picture how to program it.because I'm very weak with using case structure.

For answering ur remarks....I didn't save  with every iteration because. next time I want to use this prog n run it for few days.maybe 3 or 5 days.My prog was about power measurement that measure V, I , P and else for residential.So that,  I want to collect data to find energy n efficiency energy after few days later.So that's why I want to save maybe until one minutes per each data to avoid my harddisk become full.

Thank U very muchSmiley Happy




0 Kudos
Message 3 of 13
(4,570 Views)

you have then 2 options:

1) you take data all the time (with some short delay i.e. 50ms), average it every minute, and save the averaged data.

2) you just take a single point data every minute or so, and save it. this option is the easier for now, as you just put a "wait" inside your loop.

case structure: you can use the express vi" time has elapsed". the output is a boolean, that you connect to a true/false structure. in the flase case nothing happens. in the true case, you can put a save on (for example), an averaged value. in such a case ,do not forget to empty the data arrays.

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 4 of 13
(4,558 Views)

a diagram worth 1000 words...

Message Edited by Gabi1 on 09-30-2007 06:35 PM

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 5 of 13
(4,562 Views)
Thank u very much 4 ur idea.i rather choose the 1st option. n Its give me some great idea..Thank u Gabi1..

But there is something i'm not ok with that.Actually...after I try ur method using write to spreadsheet.vi to write data into text file,It means after the prog stop by using elapsed time,40seconds for example,the open dialog will open in windows n choose file to write.it means every 40 seconds by elapsed time, it will write to spreedsheet string by mean of the data. N it will reset again n write for the other 40seconds later.n How to make the write to spreedsheet call the open dialog once n didn't open file dialog again? after the elapsed time will reset?...

Actually,Its not what I mean, I'm using the elapsed time for to make sure the prog will running from one start time to the other last time.So, in the middle of its running in  elapsed time,this data will write to to text file for every minute or hour per each data.For example...My prog will run for 3 days.So while the prog running, It will write to file every one hours per data.that mean for three days it will write for 72 hours or 72 times.So can u give ur opinion..and lastly,thank u very much....Smiley Happy
0 Kudos
Message 6 of 13
(4,489 Views)

first thing you should do is open the context help Smiley Happy (ctrl-H)

the reason is that each native vi (from the pallette), has a short description there and explanation of each connection. as well, you can open from there an extended help document.

if you do so, you'll discover that you can do 2 things:
1) wire a path to the vi. therefore instead of opening a dialog the vi will simply write to this path
2) set "append to file" as true. therefore if file aleady exist, the vi will just apend the data at the end

to note:
1) in your program you might want to automatically create a filename and path.
2) you can still use an express vi to do this task if you feel more comfortable. the rest is same.

i think i have a different LV version than you, which version do you use?

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 7 of 13
(4,474 Views)
Hii Gabi1....

Thank U very much...Now, I'm understand how to using write to spreadsheet.Bcoz I prefer like using express vi then using this before.But this vi is important too...

Actualy i'm using labview version 8.2.it is different from ur labview?..n again... thanks for ur advice k...Smiley Happy
0 Kudos
Message 8 of 13
(4,442 Views)

Can you offer an explanation of how the Wait Until Next ms Multiple Function actually works.  In the Labview Help, it says "Waits until the value of the millisecond timer becomes a multiple of the specified millisecond multiple"    Does this mean that you enter 10, and it causes the WHILE loop to pause until it reaches an integer multiple of 10ms, even though the execution might have an elapsed time that is not an exact multiple of 10?

 

So, if the true execution time of a WHILE loop is 25 ms, but the Wait Until Next ms Multiple is set to 20, then, does the WHILE loop execute again after 40 ms???  Is that a correct interpretation of how this function works?

 

Thanks,

Dave

0 Kudos
Message 9 of 13
(3,970 Views)

You are correct, if the " Wait Until Next ms Multiple" is the LAST thing you execute in the while loop, then if the code in the while loop takes 25 ms, and you have set the wait to 20ms, the complete loop time will be 40 ms. 

But that is ONLY if you are forcing the wait to execute last in the loop.

 

If you don't force the wait to execute last, the loop time will by controlled by how long time your code takes to execute compared to the wait time.

In your example the loop time will be 25ms.

0 Kudos
Message 10 of 13
(3,961 Views)