LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recording measurements

Solved!
Go to solution

Hello i am new here and i am beginner in Labview. I would like to make Labview program that is capable recoding data from measurements on two hours (from starting the program) and the duration time of reading is one minute with 500 Hz. I have made some code for thermocouples type K but i haven't found any example for delay readings. Thanks for help!

 

Regards

Nejc

 

0 Kudos
Message 1 of 8
(1,985 Views)
Solution
Accepted by topic author Bacil

Nejc,

 

Do you mean every 2 hours (measure 1 minute, wait 2 hours, repeat, etc) or a single 1 minute measurement after 2 hours, then stop? Answer below assumes you mean every 2 hours and repeating, with a measurement as soon as you start the program.

 

One way to do this would be to make a simple state machine (it's not as hard as it looks, and it's one of the most useful ways to structure your program, you can find lots of articles with examples, such as http://www.ni.com/white-paper/3024/en, figure 2 is exactly the structure). Basically a while loop with a case structure inside: every iteration you choose which case you want to go to.

 

You could have state 0 (first page of the case structure) be a measurement of 1 minute @ 500 Hz. This could be as simple as a for loop with all of the code you now have, and stop the for loop after 1 minute (say 60*500 iterations for your case). You'd have to include a timer to control the 500 Hz timing. When the for loop is finished, wire a 1 to your case structure state value.

 

Then have state 1 (second "page" of the case structure) be a simple wait for 2 hours (2*3600*1000 ms using the "ms wait" command). At the end of that transfer back to state 0.

 

There are surely other ways to do this, but this is one very simple way to get you started, if you're willing to look into the state machine.

 

Hope that make some sense.

 

Dan

0 Kudos
Message 2 of 8
(1,972 Views)

Dan thanks! 

 

Yes i mean every 2 hours! I will try as you adviced and i will let you now if i was successful! 

 

Thanks!

 

Nejc

0 Kudos
Message 3 of 8
(1,968 Views)

Dan am i on the right way? I have found some example but i have to up grade it!  I have created for loop and added my code. This is in the True case ( or 0). In false case i have to create wait function.

Need opinion!

 

Nejc

0 Kudos
Message 4 of 8
(1,938 Views)

Looks better, you're on the right track, just implement your timer in the for loop and control the number of iterations and you should have something working.

 

One general thing, open the VI and press Ctrl+u , this is an automatic cleanup feature, which will clean up your code and make it easier to read. Many confusing things becomes much clearer when the code is tidy! (sometimes this feature does ugly things to code for things more complicated, but you can always undo the action).

 

I dont' think you need a wait timer in the false case in this case because you already have on in your general while loop. And since the wait is 2 hours, maybe increase from 100 ms to a few seconds or minutes, unless timing is very critical.

 

Dan

 

 

ps, the way you've done your case structure is fine for this simple example, but say if you wanted a 3rd and 4th and etc case to do different functions, it's not possible with just a T/F variable controlling your cases. If you want more cases switch to an integer 0,1,2,3,etc as the controller for each case. If your program only needs two cases you can leave it as is however!

 

0 Kudos
Message 5 of 8
(1,929 Views)

I made some progress! Smiley Happy I can get some simulated signals on every 0,2 minute! What do you think? 

Now i have to edit "write to measurement file". Any suggestions? What is more common way? Write to measurement file or write to spreadsheet file? I would write each measurement lasting a minute in its own folder.

 

Dan i really appreciate your help! 

 

 

 

 

Download All
0 Kudos
Message 6 of 8
(1,890 Views)

Glad it's working for you. Few things are more satisfying than a program which works and you've written yourself (perfect or not!).

 

Just depends on what file format you want. "Write to spreadsheet file" vi may be the easiest and quickest for Excel. Otherwise try "write to text file" - which you can find an excellent example for under Help -> Find examples and search "write to text file". On all these you can use the create path, merge path, constant to string + string to path, etc icons to make a custom folder/name for each file programmatically.

 

Also, if you have questions that aren't related to the original question here (which I guess is solved for now since you have a working program) you can start a new topic, as you're more likely to get replies from others (and I'm on holiday for a couple weeks as of tomorrow).

 

Happy file saving,
Dan

0 Kudos
Message 7 of 8
(1,873 Views)

Dan many thanks! Have a nice holidays! 

 

Regards, Nejc

0 Kudos
Message 8 of 8
(1,871 Views)