LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Separate Waveform Graphs for Each Analog Input

Solved!
Go to solution

I'd like to measure two external signals (via a single BNC cDAQ module, if that matters) and display them in separate waveform graphs. I've shamelessly ripped my VI from the "Voltage - Continuous Input" example VI, and I'm trying to modify it to accomplish this task. I learned from a YouTube video that I needed to wire one Read VI's Error Out to the other's Error In in order to not throw and error in the while loop. However, it appears that I am throwing an error when attempting to start 2 tasks at once.

 

I'm still learning how to stand on my own two legs without the DAQ Assistant for the inputs, and I don't fully understand the relationship between the module physically sampling the voltages, the sample clock/timing, and the "task" that needs to run from each VI to the next, so I assume that that is my issue here.

 

For the why: if you open the VI's front panel, you'll note that I'd like to see each input's waveform on a pretty small waveform graph, and displaying them together on the same graph would get quite busy. I would also like to expand this system to include even more inputs in the future.

 

I've included an image of the front panel for those who do not wish to download the VI, as well.

 

In the meantime, my next idea to examine whether I can use the Create VI to sample both channels from the same cDAQ module and split it up in the while loop.

 

Thank you in advance for any advice!

0 Kudos
Message 1 of 5
(738 Views)
Solution
Accepted by topic author curiositas

Assuming you intend to simultaneously sample two Channels from a single DAQ device, configure your Task to "sample two channels from a single DAQ device", do an "Multi-Channel, Multi-point" DAQmx Read inside the While Loop (specifying an Array of Waveforms provides a very convenient output), then simply take your output (which has a 2 x N Array, assuming you specified two Channels) and, using Index Array, send each Channel to a separate Waveform Chart (or Graph, though I suspect you'll want a Chart).

 

When I "got started" with DAQmx, I read Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications .  As a "beginner", I used the "Let MAX help you Create Your Task" method --

  • Open MAX, with your DAQ device connected.
  • Configure the DAQ Task that you want, including which Channels you want to use, how they are scaled, Sampling Rate, Sample Size, etc.
  • Save the Task with a User-Meaningful Name (though I suspect you can't have spaces in the name, something of a pain).

Now you use the "3 DAQmx function" method to build your Acquisition Application.

  1. Drop down a DAQmx Start Task. 
  2. Right-click the Task Input Connector (upper left corner) and "Create Constant".  Right-click the little "triangle" symbol in the (empty) Constant and it should show you Tasks, including the one you just made in MAX.  Choose it.
  3. Drop down a DAQmx Read.  Wire it to the Start Task, and draw a While Loop around it (with Start Task outside the Loop).
  4. Configure the Read for Analog Input (if it isn't already) and N-Channel N-Samples.
  5. Put any other code you want (like displaying Channel 1 and Channel 2 on separate Waveform Charts).  Wire the Stop.
  6. Drop down a DAQmx Stop Task outside the While Loop and wire it to the Error and Task lines.
  7. Try it out.

Once you get the hang of it, you can learn a few other DAQmx functions and can skip "hand-coding" the Tasks in MAX (which, of course, only works on the PC that you used to configure the Task).

 

Bob Schor

0 Kudos
Message 2 of 5
(731 Views)

Bob,

 

Thank you once again for your help, and for the extra details and advice.

 

For others looking into this issue: as I was pondering the problem I originally posted here, I realized that I might be able sample 2 (or more) signals via the same task. Then in the while loop, it might create a 1D array of waveforms which then could be indexed, each element going to its own graph. After wiring it up, this seems to have solved my problem and I am now getting the desired results (so far). I have attached a screenshot of the block diagram and running front panel for any others who might be searching for a solution to this problem.

 

Any further critique of this VI is always appreciated!

Download All
0 Kudos
Message 3 of 5
(726 Views)

Note: You only need one DAQmx Create Channel vi. The trick is to select two channels(or more) in the physical channel control from the front panel by selecting browse from the down arrow and using CTRL click to select your 2 channels. 

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 4 of 5
(701 Views)

Hi curiositas,

 

The error is because you are trying to use the same resource, my advice is to use the same source channel but you must select the channels that you are going to use. In this case 2 channels, then in the read output you can select if you want the data as 2D DBL or as 1D array of waveform DBL.

 

Select browse, then select the channels that you want.

 

GCarlos22_0-1637773135706.png GCarlos22_2-1637773257327.png

 

GCarlos22_4-1637773908552.png

 

GCarlos22_3-1637773854339.png

 

As you can see, now you have two channels in one chart.

GCarlos22_5-1637774112318.png

 

After this, you can "play" with the "DAQmx Read" output values and using different charts to show the data. (split the data with the array functions).

 

 

 

Staff Technical Support Engineer
0 Kudos
Message 5 of 5
(696 Views)