LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to show simultaneously two different channels on two different indicators using DAQ

Thank you for attaching your VI, so that I can try to understand what you want to do.  Unfortunately, you are a new LabVIEW user, and are (understandably) using the latest version of LabVIEW, while I am an "old" LabVIEW user, using mainly LabVIEW 2019, and thus unable to open your VI.  Could you please open it and "Save for Previous Version", specifying LabVIEW 2019?

 

I generally tell students that they basically need only a few functions in NI DAQmx (see "Learn 10 Functions in NI-DAQmx ..." mentioned in a previous Reply).  Here are some of Bob's Simplified suggestions:

  1. Develop your code "inside" a LabVIEW Project.  A Project will let you configure a DAQmx Task with a helpful name that you pick (like "myDAQ Two AIs") where you define (like MAX does) the Device, the Channels, and other features.
  2. With this DAQmx Task defined in the Project, I can create a VI that will Start the Task (using "DAQmx Start Task"), acquire however many A/D Channels (2) I specified when I created the Task, using the Acquisition Mode ("Continuous"), Samples to Read (100), and Rate (100) (using "DAQmx Read" function set as Analog 1D Wfm NChan NSamp), and plot it on a Waveform Chart inside a While Loop with a Stop Control, and can stop the Task when I exit with a DAQmx Stop Task.  For good measure, I added a DAQmx Clear Task.
  3. This takes 4(!) DAQmx functions. and a defined DAQmx Task (which I defined in the Project).  Here's what it looks like:

Simple AI ProjectSimple AI Project

 

and here is its Front Panel after running, showing two (noisy) signals. 

Simple AI Front PanelSimple AI Front Panel

 

Note that if you want to treat them separately, the output from the DAQmx Read is simply an Array of two Waveforms, so you can get either Channel by itself using Index Array.

 

Now, there is one "trick" (aha, you knew there had to be a trick!).  Notice the DAQmx Start Task function -- where did I get the "Task Constant" that shows "myDAQ Two AIs"?  I right-clicked the Task Index terminal (upper-left of the function) and said "Create Constant".  It put in an "blank" Task Constant (see the little "I/O" on the left?).  Do you see the little downward triangle on the right?  That's a "Selector" -- when I clicked it, it showed me all the Tasks in the Project!  There was only one, the one I created in the first step, above.

 

So don't be afraid of DAQmx, and do stop using the Dreaded DAQ Assistant (and its Evil Twin, the Dynamic Data Wire).

 

And, yes, I built this using a myDAQ (my myDAQ, I might add).

 

Bob Schor

Message 11 of 16
(483 Views)

Hi Bob.

Thanks for you reply.

I'll try soon and I'll update you with results.

 

0 Kudos
Message 12 of 16
(466 Views)

Oops, there's a "catch" (which I hope to remedy here).  I'm so used to working in "Project" view (which means I'm going to "run the code on the Development PC") that I forgot the goal is to create an Executable that can run on any PC with the proper LabVIEW Run-Time and peripherals installed.  So you really need to get the DAQmx device name that you plan to use.

 

Fortunately, DAQmx provides the method to do this, but this is a little more advanced, but easy to use.  I'm attaching a Snippet of a sub-VI I call "Find DAQ Device".  It uses a DAQmx System property node to get the Device Names of all the DAQmx devices attached to the PC (obviously, you cannot run on a USB-25000 if it isn't connected!) and then lets you search for the Device you want to use.  If you have several such devices attached to your PC, you can distinguish between them by Serial Number (illustrated here) if you want.  If it finds the device, it passes it out, otherwise it generates a "User Error" (I choose 5001 as the Error Number -- look up "LabVIEW User Errors" to learn more) and added what I hope is a helpful Error Message.  Notice I stop the For loop as soon as I get a "hit".

Find DAQ Device.png

 

Bob Schor

Message 13 of 16
(452 Views)

Hi.

I'm triyng to understand your solution.

Should you share the file?

Thanks in advance

0 Kudos
Message 14 of 16
(414 Views)

Hi mforbiz,

 

it's a snippet in Bobs last message…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 15 of 16
(410 Views)

Do you know about "Snippets"?  This is a .PNG file that LabVIEW created for me that, when dropped on a blank Block Diagram, expands into LabVIEW (2021, in this case, see upper right corner).  Sometimes it doesn't work, because browsers "capture" too much stuff when you click on an Image, but if you paste what you capture into a Text file and delete some of the stuff at the end, it should work. 

 

One reason I chose the Snippet was to encourage people like yourself to "Learn by Doing".  Do you know where/how to find DAQmx on the Palette?  Right-click on the Block Diagram, click on "Measurement I/O", and there is DAQmx.  Open it.  I presume you know what "Error In" is.  The next two Items are DAQmx Property Nodes.  The first two, unfortunately, are a little hard to find.  Open the Advanced Palette (the last one on the first DAQmx "page") and then open System Setup.  There you'll find the DAQmx System and DAQmx Device nodes.  Click on the lower part to select the Property that you want (such as DevNames).

 

I assume you know about For Loops.  You might not know you can put a "Conditional Terminal" (the little Stop sign that the While Loop uses) by right-clicking the left edge of the For and choosing "Conditional Terminal".  I use it to stop searching for devices when I find the Device I want.

 

I trust the rest of the code you can reproduce.  The Case Statement lets you specify the Product you want (the name needs to match what NI calls it, but you can modify the code to provide you with a list of all the Products that MAX can see, for example), and I also show that if you are looking for a particular device, you can "search by Serial Number".  The final code runs if you do not find a match -- this is code to generate a "User Error" (5001 is what I usually use as my first User Error) and the function shown you will find on the Dialog and User Interface Palette.

 

Bob Schor

 

0 Kudos
Message 16 of 16
(391 Views)