08-15-2018 09:00 AM
1. You can combine your voltage and temperature channels into a single task. This will simplify your code.
2. Since you only want 1 sample based on whenever your loop gets around to it, set the timing type to Finite Samples with a size of 1. This will eliminate the need for the DAQmx Start, DAQmx Stop, and unreserving the task. You can just do the DAQmx Read when your loop iterates.
3. I am not even seeing a reason to break your loops up. Combine them into a single loop and, again, things will be simpler.
08-15-2018 09:16 AM
Thank you so much, most of what you just said resolved many of my previous issues, and I did not know the most efficient way of solving them at the time. For example, I was getting an error stating that a resource was already reserved for a certain task or something like that, so implementing the start, stop, and unreserve was my workaround.
Thanks!!
08-15-2018 02:47 PM
The Stop Button is deliberately defaulted to "Latch When Released". Certain buttons, such as "Play", "Stop", "Start", etc. (the ones with rectangular Button icons, in general) are meant to act almost like Push buttons, i.e. they should always be "Ready to Push". They are designed to work with the LabVIEW Event Structure and to handle "one-time" tasks.
There are really three "timed actions" with a Latch When Released button. Let's assume it is off. Reading it returns, of course, False. Now you push it (and hold it down) -- still nothing happens, the value is still False. Now you let go, and the Value becomes True. It remains True (i.e. "latches") until you read it, when it reverts to its Default Value (which happens to be False).
So here's how you use them in an Event loop. Create an Event for Stop, Value Changed, and put the Stop button inside the Event. Now, when you push the Stop button, whenever LabVIEW gets around to handling the Event (probably almost immediately if you've coded the Event loop correctly), LabVIEW will Read the Stop (returning True), will reset the Stop (setting it back to False), and if you were to read it again (which you probably shouldn't do), it would say "False".
Write yourself a little VI to test this behavior -- it is quite instructive, and you'll remember how this Boolean Mechanical Action works.
Bob Schor
08-15-2018 02:49 PM
Thanks so much for your detailed response! I will get right to it 🙂
08-16-2018 07:36 AM
Why not use a local variable, very simple. Here are the examples for each method:
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LmXSAU
08-16-2018 11:26 AM
@LennartM wrote:
Why not use a local variable, very simple. Here are the examples for each method:
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LmXSAU
Local variable has been suggested, but requires switch action and has some side effects as mentioned. Personally, I prefer the solution using an event structure, and that one is not even mentioned in your link. 😄
08-23-2018 02:18 PM
How do I combine my voltage and temperature channels into a single task if it's two different units?
08-29-2018 04:08 PM
Is it okay to use the tag channel wire to stop the loops if the loops are running at different speeds or is there a better way to approach that?
Thanks,
Harsh
08-29-2018 10:02 PM
Ah, that's a great idea. The Tag Channel is perfect for this. I posted a Snippet a few weeks ago where I stopped 5 loops (I think) with a single Stop button, and to stop 25, I would only have had to branch the Channel (which you can do with a Tag).
Bob "Channel Wire" Schor