06-09-2014 07:06 AM - edited 06-09-2014 07:06 AM
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?
06-09-2014 07:12 AM - edited 06-09-2014 07:20 AM
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:
06-09-2014 07:19 AM - edited 06-09-2014 07:19 AM
You mean like this? pls look at attached image. How do i create a local variable, sorry i am new to lab view
06-09-2014 07:25 AM - edited 06-09-2014 07:38 AM
@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
2. It will look like this
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:
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):
**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:
06-09-2014 07:31 AM
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.
06-09-2014 07:35 AM
@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).
06-09-2014 08:22 AM
Thanks a lot it's working. That will do for a newbie i think 😉
06-09-2014 08:41 AM - edited 06-09-2014 08:42 AM
@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!
06-09-2014 10:35 AM - edited 06-09-2014 10:37 AM
@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.
06-09-2014 10:45 AM - edited 06-09-2014 10:46 AM
@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.