LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save measurment data on every 2 secs?

Hello. I am using LabView to measure temprerature with 6 thermocoplues at the same time. I've uplaoded the image of my block diagram. What i am trying to do is write the data to a file with the measurments beingtaken every 2 secs. I have done that with the Time Delay vi. However i don't want the Time Delay to affect my whole loop, because on the front panel the voltage readings and temperatures are also shown once each 2 secs. My question is how to make the Time Delay vi affect only the Write to measurment file vi?

0 Kudos
Message 1 of 15
(3,015 Views)

If I understand you correctly, you want the while loop to continually update the front panel voltages.  However every two seconds you also want to log these to file?  Correct?

 

The easiest way I can think to do this is have two seperate while loops:  one for data acquisition and front panel updating, a second to log to file.

 

[Loop 1]

 

Keep your old loop the same, but remove the Time Delay and remove the Write to File.

 

This will allow your program to continually read from the thermocouples and update the front panel

 

[Loop 2]

 

Create a local variable for each front panel voltage and write them to file.

 

Add the Time Delay (2 seconds).

 

This is an example of what I mean:

 

example.jpg

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
Message 2 of 15
(3,006 Views)

You mean like this? pls look at attached image. How do i create a local variable, sorry i am new to lab view

0 Kudos
Message 3 of 15
(3,000 Views)

@Blaze888 wrote:

You mean like this? pls look at attached image. How do i create a local variable, sorry i am new to lab view


Not quite.  You cant wire the two while loops together because the data won't get passed out of one until the other compeltely finishes (stops collecting data).  You need them to execute in PARALLEL.  Thats the keyword here.  (See my picture I edited into my above post).

 

To make a Local Variable, do the following:

 

1. Right click the variable on the block diagram, select Create -> Local Variable

 

right click.jpg

 

2. It will look like this

 

local.jpg

 

3. By default, they will be in "Write" mode.  Meaning you can use this to change the value.  You can right click the Local Variable to change it to Read mode:

 

change.jpg

 

Basically a Local Variable is a "clone" of an existing variable.  It allows you to access the value in an already existing variable.  You can read more about them here: http://www.ni.com/white-paper/7585/en/

 

 

 

EDIT:

 

It should look something like this (done very poorly in Microsoft Paint):

 

Untitled.png

 

 

**One thing to note:  If you use a Local Variable to stop both loops (which you probably want), you need to change the Mechanical Action.  On the Front Panel, right click the Stop variable and select Mechanical Action -> Switch When Pressed:

 

switch.png

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 4 of 15
(2,994 Views)

Please note that using local variables to pass data from one loop to another is generally considered ReallyBad® practice. In this specific case, it will probably work. However, if you want to log all your data or specific pieces of your data in the future, you will need to use queues or something similar to avoid synchronization issues (missed and repeated data). Let us know if you need more help.

Message 5 of 15
(2,973 Views)

@DFGray wrote:

Please note that using local variables to pass data from one loop to another is generally considered ReallyBad® practice. In this specific case, it will probably work. However, if you want to log all your data or specific pieces of your data in the future, you will need to use queues or something similar to avoid synchronization issues (missed and repeated data). Let us know if you need more help.


I completely agree.  Local Variables can lead to all sorts of issues, but seeing as the user stated they are new to LabVIEW, I figured a simple approach where synchronization of loops is probably not essential would be the easiest to implement (and digest).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 6 of 15
(2,965 Views)

Thanks a lot it's working. That will do for a newbie i think 😉

0 Kudos
Message 7 of 15
(2,934 Views)

@Blaze888 wrote:

Thanks a lot it's working. That will do for a newbie i think 😉


I'm happy to help!  Glad to hear you got what you needed done.  If you plan on using LabVIEW for the long term, I recommend checking out some training resources.  LabVIEW is often simple enough to "jump right in" as a beginner (as you're experiencing), but I even find myself wasting time or getting stuck when a simple solution is available, had I just took the time to learn a bit more 😛

 

Also, don't forget to mark the solution to this thread so that others don't know that your questions have been addressed!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 8 of 15
(2,928 Views)

@MrHappyAsthma wrote:

@DFGray wrote:

Please note that using local variables to pass data from one loop to another is generally considered ReallyBad® practice. In this specific case, it will probably work. However, if you want to log all your data or specific pieces of your data in the future, you will need to use queues or something similar to avoid synchronization issues (missed and repeated data). Let us know if you need more help.


I completely agree.  Local Variables can lead to all sorts of issues, but seeing as the user stated they are new to LabVIEW, I figured a simple approach where synchronization of loops is probably not essential would be the easiest to implement (and digest).


The user is new to LabVIEW.  This is when you should be teaching them the good habits.  Or, using your approach, let them know this is not a recommended way of doing things.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 15
(2,913 Views)

@billko wrote:

@MrHappyAsthma wrote:

@DFGray wrote:

Please note that using local variables to pass data from one loop to another is generally considered ReallyBad® practice. In this specific case, it will probably work. However, if you want to log all your data or specific pieces of your data in the future, you will need to use queues or something similar to avoid synchronization issues (missed and repeated data). Let us know if you need more help.


I completely agree.  Local Variables can lead to all sorts of issues, but seeing as the user stated they are new to LabVIEW, I figured a simple approach where synchronization of loops is probably not essential would be the easiest to implement (and digest).


The user is new to LabVIEW.  This is when you should be teaching them the good habits.  Or, using your approach, let them know this is not a recommended way of doing things.


While this is also true, learning Local Variables is essential for most users as well.  So it would have been best to answer with many possible solutions, but I choose to take the simpliest one I could think of to start.  And as stated in his reply, Local Variables were sufficient for this application.

 

However if Locals had not been sufficient, I would have had to suggest a more involved approach.  I personally believe this would have caused more confusion and been overkill for his/her needs, so I started by recommending a quick-and-dirty solution.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 10 of 15
(2,905 Views)