LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find cDAQ modules and channels

Solved!
Go to solution

I have searched around previous posts, but can't seem to find quite what I am looking for.

In most of my experience, I have set up some DAQ and once the modules and channels are all in place, that is where they stay forever.

Since I know things aren't going to move, I create tasks in DAQmx.

 

I'm working on a new setup now, but the issue is that in the cDAQ things will not be in the same place every time.

The application is to read a number of strain gages, which will be connected to NI 9235 modules.

 

There will be anywhere from 1 to 3 modules hooked up, and they can be in any of the 8 available slots of the cDAQ 9172 chasis.

Also, within a given module, anywhere from 1 to 8 channels will be connected.

 

So basically, I guess my questions are at run time:

 

1) How many modules are connected, and where?

 

2) In each module how many channels are live and how many are empty.

 

From there, I can use the DAQmx palette to take care of things.

 

Thanks!

Cory K
0 Kudos
Message 1 of 10
(5,518 Views)

Cory, can you use something like the code below on cDAQ? With this code, I have found two devices on slots 5 and 6.

 

As far as the channels being live or empty, I would just ping each channel for data real quick when I start. An open (non-existant) strain gauge should be easy to detect. Make an array of "active" channels that way. Smiley Happy

 

Equip.PNG

 

Richard






Message 2 of 10
(5,502 Views)

Hmm for some reason it won't populate the cDAQ device in the "session in" I/O constant.

 

System.png

It only populates the list if I place a DAQmx Device Name constant, as shown in the bottom of the code.

 

The only way I have been able to programatically determine the devices is the following:

 

cDAQ.png

 

I guess I can use a simple regex to grab anything called cDAQ1Mod*

Cory K
0 Kudos
Message 3 of 10
(5,496 Views)

Alright, I used the following code to generate an array of all of the modules that are present.

 

Devices.png

 

Now I just have to figure out how to create a task on the fly.

I think when I was watching the device in MAX, any channel that has a gage gives a reasonable reading.

Any channel that is empty just gives a maxed out value (such as 59,000 microstrain).

So once I find a module, I can just check every channel to see if it's value is above some threshold, like 10,000 microstrain.

 

Do you know how I would go about creating a task if I input the device from the above code? I have only done this in MAX, not actually coded it in LabVIEW.

Cory K
0 Kudos
Message 4 of 10
(5,491 Views)
Solution
Accepted by Cory_K

So with each new start of the program, you'll have a known device (your strain gauge device), but unknown channels. Here's the way I attacked that a few years ago...

 

  • Use DAQmx Create Task to create a task.
  • Make an array constant of all known possible channels. Say this is 8 elements, and compare that to an array of USED channels, making phony channels out of the "Not Used" channels, and real channel names out of the Used ones. Conditionally check which ones are used to pick off the correct channel, and add DAQmx Virtual Channels appropriately. The VI snapshot below goes into more detail. I brought in not only the used channels, put the channels properties as well, such as min/max and bridge info. My VI also performed bridge nulling, conditionally, depending which sensor the user wanted to null (that part is not shown.

This code is not super elegant, but I hope it gives you come ideas.

sETUPsTRAINtASK.PNG

Richard






Message 5 of 10
(5,477 Views)

That looks like it should do the trick!

 


@Broken_Arrow wrote:
  • Say this is 8 elements, and compare that to an array of USED channels, making phony channels out of the "Not Used" channels, and real channel names out of the Used ones. 

Can you elaborate on this a bit? Where did that array "Strain Gauge Array" come from? Did you create that cluster with all the gage properties? 

Cory K
0 Kudos
Message 6 of 10
(5,467 Views)

@Cory_K wrote:

That looks like it should do the trick!

 


@Broken_Arrow wrote:
  • Say this is 8 elements, and compare that to an array of USED channels, making phony channels out of the "Not Used" channels, and real channel names out of the Used ones. 

Can you elaborate on this a bit? Where did that array "Strain Gauge Array" come from? Did you create that cluster with all the gage properties? 


I didn't explain the "Not Used" channels very well. Notice the cluster unbundle called "Used?". Let's say the third channel is being indexed from the array constant. In the "Strain Gauge Array" there's a boolean that was turned to TRUE if the user is using that channel. I can tell the user is using the channel because they moved the selector from "Not Used" to an actual channel number.

 

Yes, the Strain Gauge Array is an array of clusters. The clusters have the channel name (or Not Used), and all the gauge properties. Your situation is a bit different - maybe similar enough to get *some* use out of the screenshot. Sorry for not posting the actual code - not allowed.

 

Richard






Message 7 of 10
(5,460 Views)

@Broken_Arrow wrote:

I didn't explain the "Not Used" channels very well. Notice the cluster unbundle called "Used?". Let's say the third channel is being indexed from the array constant. In the "Strain Gauge Array" there's a boolean that was turned to TRUE if the user is using that channel. I can tell the user is using the channel because they moved the selector from "Not Used" to an actual channel number.


 

Oh, so you actually have toggle switches on the front panel that has the user tell you what they plugged in and where?

 


Sorry for not posting the actual code - not allowed.


Completely understandable! I appreciate the help.

Cory K
0 Kudos
Message 8 of 10
(5,458 Views)

Alright I'm making slow but steady progress on this.

 

I seem to be stuck on the actual task of actually aquiring the measurements from the gages.

Ideally, I would like to acquire 1 sample per channel at a rate specificed by the user on the front panel.

 

However, for some reason it will not allow me to use "NChan 1Samp", it keeps telling me this

 

DAQ error.png

 

I have attached my code if someone wouldn't mind taking a look at it.

 

Cory K
0 Kudos
Message 9 of 10
(5,436 Views)
Apparently I just need to do this really difficult thing called read the error message. Smiley Very Happy

I added a Sample Clock function and everything is working now.
 
Thanks again!
Cory K
0 Kudos
Message 10 of 10
(5,430 Views)