From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Two AI Modules for Array Creation

Hello,

 

I would like to create clever way to handle cDAQ chassis for all module configurations. I couldn't figure out how to create array that fits two modules with null elements if one of two modules are turned off or removed.

 

For example, I put two AI (32 AIs each) modules in cDAQ chassis on Slot 1 and Slot 2.  I put two serial Create Tasks for AI voltages of two resources on Mod 1 and Mod 2 and I have DAQmx AI Read connected and it will create 64 elements of AI voltage (32 x 2). 

 

However, I put case diagram on both so I can turn off either module.. When I turn off either module, DAQmx AI Read will create only 32 elements of AI voltage.  I don't want that. I would like to KEEP 64 elements from DAQmx Read but half would be 0 as "null". For example, if I want to turn off Mod 1 module and keep Mod 2 module on then DAQmx read would create first 32 elements at 0 then next 32 elements of actual data read out from Mod 2.   I don't want to use insert array method because of so many perumations of 6 different AI modules of all combinations for insert arrays. I just thought of simplier way to add 32 dummy elements via "turned off" Mod 1 to be added internally then it goes thru Mod 2 create task to open up another 32 channels on top of first 32 dummy channels to enable DAQmx Read to create 64 elements rather than 32.  Is it possible?  

I am attaching the VI that has 6 AI-based modules (2 other modules are not AI) for you to take a look. When I turn all on, it works fine but I want greater flexibility of turn off/on any modules without screwing up DAQmx array indexes that connected to all indicators. I know that insert array for all perumations which will be messy and headache. Adding dummy virtual channels are much easier and cleaner but how?


Thanks.

0 Kudos
Message 1 of 10
(4,508 Views)

Don't have LabVIEW right now, so this thought process isn't completely thought out.  But if you have an array of tasks, you just read using a FOR loop.  Use Replace Array Subset to set the values in your array.  To do this, you would need to initialize the array based on how large each task is.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 10
(4,504 Views)
I don't think you can have a task with non-existent channels/devices without the driver throwing an error.
0 Kudos
Message 3 of 10
(4,502 Views)

@Dennis_Knutson wrote:
I don't think you can have a task with non-existent channels/devices without the driver throwing an error.

Grr. That's what I am afraid of. Thanks. I guess that I have to do the longer, sloppy way is perumations of (insert and replace) arrays of all different configurations of 6 modules to preserve the indexes of DAQmx Read Array regardless of configurations for the sake of hundreds of indicators connections that don't require re-wiring every time configuration changes .

0 Kudos
Message 4 of 10
(4,482 Views)

I created simulation cDAQ on/off module configuration of 6 modules following 2^6 permutations of different combinations showing that it's long, inefficient approach but that seems is only way. It gets worse with more modules.  My original idea of adding null task channels as "off" module to replace "on" module of same array indexes to be added

to next module create task array to maintain the same final array indexes regardless of on/off modules combinations to keep same indicators connections. It seems is not possible. It would be nice to be added to that so I don't have to deal with permutation approach that gets worse with more modules while original idea maintains the same efficient level no matter how many modules I have to deal with.

Here's the simulated vi to give the idea or share with anyone who is interested in. It doesn't require NI modules at all. Replace simulated arrays with actual create task for NI modules in true conditions if you want to work with modules.

Grr. I seems can't add vi here. I tried to "add attachment" and it does nothing..

0 Kudos
Message 5 of 10
(4,455 Views)

William_Wood wrote:

Grr. I seems can't add vi here. I tried to "add attachment" and it does nothing..


Try zipping up your code and posting that.  VIs seem to be a hit or miss for attaching them to forum posts.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 10
(4,448 Views)

Ok, I'm trying to add Configuration Test.zip here and see if it works.

It only compressed from 52 KB to 49 KB and the "add attachment" won't do anything. 😞

0 Kudos
Message 7 of 10
(4,445 Views)
Do you really need all permutations? Can't you just permanently say module x of always going to be in slot 1, module y in slot 2, etc? What is the reason that modules get turned off or removed?
0 Kudos
Message 8 of 10
(4,444 Views)

@Dennis_Knutson wrote:
Do you really need all permutations? Can't you just permanently say module x of always going to be in slot 1, module y in slot 2, etc? What is the reason that modules get turned off or removed?

Passing modules around in different labs on regular basis and we sometimes don't need all of them. We sometimes need some modules for specific experiments. Configurations also are useful for trouble shooting without removing modules but narrow down problems, etc especially for huge VI program with so many modules. I like greater flexiblity of removing unneeded modules to give to other teams for a month or two without needing to re-code the program and get those modules back when need them. Also, broken modules won't screw program up, I simply turn that broken module off and run the experiment with all active sensors minus those sensors that wouldn't work due to that broken module that would be allright as temporary rather than be stuck with the unworkable program due to broken module creating errors.

 

Yes, I keep same modules in same slots and I don't swap them. But problem is.. For example, when I have 6 AI modules on slot 1, 2, 3, 4, 5, and 6.. When I remove AI module out of slot 2, the stacked AI array index beyond 2nd slot gets shifted down that screws up indexes of all elements beyond 2nd slot that are connected to all sensor indicators. Permutations to replace "loss" of elements due to removal with 0 will keep indexes intact.

0 Kudos
Message 9 of 10
(4,441 Views)

I switched from IE to Chrome and the attachment works. Go figure..

0 Kudos
Message 10 of 10
(4,433 Views)