LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you run two case structure at same time?

I initially tried running two case structures simultaneously by applying while loops around each structure, but what happens is that one graph runs normally and the other graph, the x-axis runs too fast and no signals are ploted on the graph.

 

I need information from two different channels from the same DAQ board (Dev1:Ai16, Dev1:Ai17) to be graphed at the same time.

 

PS: Also how can I start the x-axis of the graph of x(time)=0?

Download All
0 Kudos
Message 1 of 8
(3,971 Views)

I can't open newer than 2015. I would suggest saving for previous version for more assistance.

 

You should be reading both of those channels at the same location in your code because they're the same device. Normally, even if they are different devices, you should be reading in the same location. This would allow you to plot them together quite easily.

 

You can set the timestamp on a graph to display as Relative time.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 8
(3,952 Views)

I uploaded to a previous version of labview!

0 Kudos
Message 3 of 8
(3,946 Views)

Okay a few things:

 

You have a total of 4 while loops in your program and none of them are able to stop ever.  How do you expect the application to close?  How are you going to ensure that a cleanup process happens and your hardware is left is a good known state so it can be used again?  Aborting the VI is like crashing your car into a tree to stop it.  It will stop it, but in what condition will it be in?  You should have a proper way to stop your loops by usig a stop button, or a better design uses the event stucture so you can just close the window but that might be bit complicated with two loops.

 

So you setup two AI tasks, to use continuous samples, at a rate of 100 hz.  Then you start them in parallel.  So one will start the other will generate an error.  How will you know there is an error?  Well you won't, because you don't stop your loops on error, and you have no error handling.  Plop down a Simple Error Handler in your while loops and you'll see many errors stating you can't start a task on hardware that already has a task running.

 

Your device only has one clock, you can only have one task running on it at once.  So your top loop runs fine, your bottom won't, or vise versa.  You need a task with all channel in that one task.  They can go to separate graphs.

 

Then you read one sample of your 100...why did you tell it to take 100 then just tell it to take one.  Then you go into a for loop, with your one sample.  Why use a for loop if you only ever have on sample?  You then do an average on that one sample, resetting the history each time so your value will not change.  Then you apply a filter on that one sample.  Then turn that one sample into a 2D array with one sample.  Then you add to it in one dimension your target and put it on the chart.  Is this really what you want?  I'm guessing not.  What do you actually want it to do?

 

I also prefer the waveform graph over chart because there is more control, but you can set the X axis using property nodes.

0 Kudos
Message 4 of 8
(3,941 Views)

Yes, you should read both channels with the same DAQ train. You can discard the data of one channel if you don't always need it.

 

  • You are not handling or detecting any errors, because the "daq clear task" can never be reached, ever! (it would create an automatic error popup if reached for all instaces that generate an error.
  • Why are you using local variables instead of hooking the graph terminals up directly?
  • Please don't use neon colors on the diagram. Very distracting!

 

0 Kudos
Message 5 of 8
(3,931 Views)

How would I create a task with all channels in that task?

0 Kudos
Message 6 of 8
(3,920 Views)

Getting Started with NI-DAQ

Essentially: Create Task, Create Channel A, Create Channel B, Create Channel C, Start, Read, Read, Read, Read, Read, Read, Read, Read, ...., Stop, Clear

The data comes out as an array of values in order of when you added the channels to the task.

e.g. Create Channel A = ai0:2, Create Channel B = ai4, Create Channel C = ai7. Read will result in an array size 5 with the first 3 values corresponding to Channel A.

This way above is one way, but is the hard way. If all you channels are analog input, then they can all fit in to the same Create Channel input. "Dev1/ai0:2, ai4, ai7, Dev1/ai4, Dev1/ai7"

 

 

"Give me six hours to chop down a tree and I will spend the first four sharpening the axe."  - Abraham Lincoln

 

Here are some free training tools primarily focused on LabVIEW and NI hardware to help get started.

NI Learning Center

NI Getting Started

-Hardware Basics

-MyRIO Project Essentials Guide (lots of good simple circuits with links to youtube demonstrations)

-LabVEW Basics

-DAQ Application Tutorials

-cRIO Developer's Guide

Learn NI Training Resource Videos

3 Hour LabVIEW Introduction

6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training

 

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 7 of 8
(3,916 Views)

@jkook6 wrote:

How would I create a task with all channels in that task?


Sometimes all you need is read the help. 😄

0 Kudos
Message 8 of 8
(3,907 Views)