LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Choose of multiple sensors from same module DAQ

Hi, 

I'm trying to build a program where I can choose different kinds of sensors connected to the same module. 

At this point, I can get readings from 4 channels and log the output. 

My problem is, that when I select "No sensor" connected, my array skips the port, and mess my program up because of no output from the case structure. 

Is there some way to lock the array to the specific port or move a zero into the array? So even when there is no sensor connected to ex. channel 1, channel 2 still gets the readings from sensor 2.

 

Best regards

 

0 Kudos
Message 1 of 3
(2,105 Views)

Hello M.,

First some general advice: Apply the benefits of modularity. Use subVIs! If I am not mistaken, you have the exact same, huge case structure in your code four times. If you need to change something, you'll need to change it four times to not introduce a bug. Tricky...

 

Regarding your question, I normally use an approach like this, in the order of execution:

  1. Using drop-downs similar to yours to let the user set channels. Making sure that a channel is not picked multiple times etc.
  2. From that input, I'll generate an array of clusters. Each cluster contains a channel definition and all additional configuration data (min/max values etc.).
  3. If that array is >0 (so more than no channel is picked), I'l use an auto-indexed for loop to add the virtual channels to the DAQmx task (assuming all shall have the same timing).
  4. I'll then do the same for reading the channels.
  5. Iterating over the channel array of clusters, I know which data belongs to which channel. It's basically an auto-indexed for loop using the array's data to determine what each item is.

Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
Message 2 of 3
(2,051 Views)

Hi Ikaiser, 

Thanks a lot for your answer and your advice. This is my first program, so I am still learning. But I can see it would help me a lot if I just make SubVIs. 

Is it possible to see an example of your approach? Sounds very similar to what I am trying to make. 🙂

 

best regards.  

0 Kudos
Message 3 of 3
(2,045 Views)