02-14-2013 11:46 AM
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!
Solved! Go to Solution.
02-14-2013 01:30 PM
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.
02-14-2013 01:53 PM
Hmm for some reason it won't populate the cDAQ device in the "session in" I/O constant.
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:
I guess I can use a simple regex to grab anything called cDAQ1Mod*
02-14-2013 02:07 PM
Alright, I used the following code to generate an array of all of the modules that are present.
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.
02-14-2013 02:50 PM
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...
This code is not super elegant, but I hope it gives you come ideas.
02-14-2013 03:25 PM
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?
02-14-2013 03:38 PM
@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.
02-14-2013 03:42 PM
@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.
02-14-2013 05:01 PM
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
I have attached my code if someone wouldn't mind taking a look at it.
02-14-2013 05:11 PM