LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Please help me understand what is happening in this piece of code

I am working on some code we got from France and I am not understanding what is actually going on in this.  We are taking the Max DAQmx tasks and changing it to programmatically create them due to some issues we are having.  I just don't understand what is happening here and how I can programmatically do this.   I have never experienced using the DAQmx Flatten Channel String.vi  What is it doing in this situation?  How do I create this programmatically?  TIA

 

 

French code.png 

0 Kudos
Message 1 of 6
(849 Views)

DAQmx flatten string is just a fancy way to convert the array into comma separated string.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 6
(842 Views)

Hi Sam,

 


@801Sam wrote:

I have never experienced using the DAQmx Flatten Channel String.vi  What is it doing in this situation?  How do I create this programmatically?


It flattens te given list/array of channels into a string containing all channels in expected formatting - as described in the help for this function!

The context help says:

Converts an array of physical or virtual channel names to a comma-delimited list of names. You can use this VI to convert an array of channel names to a single string prior to using the DAQmx Create Virtual Channel  VI or the DAQmx Create Task VI.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(840 Views)

Yes, Thank you.  I read the help.  Does doing this combine the two channels?  I need to figure out how to do this through programming.  I tried creating the two channels then flattening them.  I got this error.  Why I am not trying to use the MAX Tasks is the pc I have this code running on has only the executable and for some reason tasks are not working on it.  So, I found online where it said some MAX tasks have issues.  

 

Possible reason(s):

Specified virtual channel or task is invalid.
If you are attempting to add channels to a task, create a virtual channel using the DAQ Assistant or DAQmx Create Virtual Channel, and then add the virtual channel to the task.
If you are attempting to reference a LabVIEW NXG project task from a LabVIEW NXG VI, any of the following may resolve the error:
1. Ensure the task name is correct.
2. Use a DAQmx Task constant to reference the task from the VI's diagram.
3. Configure the task's owning Application or Library to export or always include the task.

0 Kudos
Message 4 of 6
(825 Views)

Hi Sam,

 


@801Sam wrote:

Does doing this combine the two channels?  I need to figure out how to do this through programming.  I tried creating the two channels then flattening them. 


When you want to add two channels to a DAQmx task you can call CreateVirtualChannel twice one after the other and wire the DAQmx task from first to second…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(810 Views)

Ok, I got it.  The problem I was having was I forgot to change channel name for the second create.  Thank you for your help

0 Kudos
Message 6 of 6
(804 Views)