02-10-2020 10:22 AM
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'?
02-10-2020 10:27 AM
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.
02-10-2020 10:30 AM
@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.
Thanks!
I'll give it a go
02-10-2020 10:44 AM
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.
02-10-2020 10:59 AM
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.
02-10-2020 12:01 PM
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
02-10-2020 12:16 PM
@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.
02-11-2020 01:38 AM
@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! 😉 )
02-11-2020 02:26 AM
02-11-2020 03:12 AM
@cbutcher wrote:
Perhaps like this:
With whatever settings you cared about varying - of course you could make some of these constants for each iteration and so on.
Thanks!