LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How select DACmx lines dynamically

So I have this problem where I need to be able to autogenerate the selection of lines to output waveforms on.

 

Normally to select multiple lines, one would write for example 'cDAQ1Mod3/port0/line0:7' or 'cDAQ1Mod1/ao0,cDAQ1Mod1/ao1,cDAQ1Mod1/ao2,cDAQ1Mod1/ao3' to the 'DACmx Create Virtual Channel' but how to do that dynamically?

 

If it were a string, my approach would have been to have array where all the output lines are listed and concatenate those lines that are needed and input the result to be block.

 

Is this possible with 'channel constant'?

 

Alternatively it is possible to 'disable' lines that do not from part of the 'output selection'?

 

 

 

 

0 Kudos
Message 1 of 11
(3,794 Views)

I'm not 100% certain what you're trying to do, but just so you know, channel names CAN be strings, and they'll coerce automagically. Formatting multiple ones requires knowing the rules on formatting multiple strings (like the 0:7 you mentioned), but fortunately there's a VI for that called "DAQmx Flatten Channel String". It produces a string, not a channel, but it can be wired as if it were a channel constant and it'll work just fine.

 

BertMcMahan_0-1581351989098.png

Message 2 of 11
(3,792 Views)

@BertMcMahan wrote:

I'm not 100% certain what you're trying to do, but just so you know, channel names CAN be strings, and they'll coerce automagically. Formatting multiple ones requires knowing the rules on formatting multiple strings (like the 0:7 you mentioned), but fortunately there's a VI for that called "DAQmx Flatten Channel String". It produces a string, not a channel, but it can be wired as if it were a channel constant and it'll work just fine.

 

BertMcMahan_0-1581351989098.png


Thanks!

 

I'll give it a go

0 Kudos
Message 3 of 11
(3,787 Views)

You can also use the Create Virtual Channel in a FOR loop.  I recommend using a shift register to hold your task and Create Task to initialize it.  I find this route more useful since it allows you to have different settings for each channel.



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 4 of 11
(3,781 Views)

And you can even combine both 🙂 I think for milti-line digital tasks you have to specify all of them at once with a single "Create Virtual Channel".

 

Otherwise yes, crossrulz's method is the better one if you need any flexibility in channel to channel settings.

0 Kudos
Message 5 of 11
(3,773 Views)

Off-topic:  is there generally any value in the call to DAQmx Create Task?   I've almost never used it over all these years, I just start with DAQmx Create Virtual Channel.  In the specific example here, I can see that it's a convenience for initializing the shift register, but otherwise, have I been missing something by not using it?

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 11
(3,755 Views)

@Kevin_Price wrote:

Off-topic:  is there generally any value in the call to DAQmx Create Task?


It does allow you to copy a task that you have already configured and then edit as necessary.  Personally, I have only used it to initialize the shift register as in the example I already gave.



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 7 of 11
(3,750 Views)

@crossrulz wrote:

You can also use the Create Virtual Channel in a FOR loop.  I recommend using a shift register to hold your task and Create Task to initialize it.  I find this route more useful since it allows you to have different settings for each channel.


 

 

Sounds like an interesting solution....

 

If it is not too much trouble would it be possible for your to post any example of such a setup? (screenshot of block diagram would be more that enough! 😉 )

0 Kudos
Message 8 of 11
(3,700 Views)

Perhaps like this:

Example_VI.png

 

With whatever settings you cared about varying - of course you could make some of these constants for each iteration and so on.


GCentral
Message 9 of 11
(3,694 Views)

@cbutcher wrote:

Perhaps like this:

Example_VI.png

 

With whatever settings you cared about varying - of course you could make some of these constants for each iteration and so on.


Thanks!

0 Kudos
Message 10 of 11
(3,689 Views)