LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Letting user input the number of data channels to daqmx directly instead of creating tasks.

Solved!
Go to solution

Hello

I am writing a program to control the NI USB 6501 DIO Box. I am using the NI LabVIEW 2018 Version.

I am relatively new to LabVIEW and was wondering if it is possible for the program to get the number of data channels needed to be controlled from the user instead of creating new tasks everytime.

 

I would like for the number of the data channels to go directly from the user to the DAQmx function so I can control the DIO Box. I tried to give a big range of data channels to DAQ but I was met with the error of 200524. It says that I need the exact number of data channels to the task channels.

I would like to use my program for huge range that can be scalable and does not necessarily have to be the same number everytime.

 

Please give me an idea on how I can fix this. I am sorry if I left anything out. If there is anymore info needed from my side, I am ready to provide it.

0 Kudos
Message 1 of 6
(1,267 Views)

Hi SR,

 


@SR01 wrote:

if it is possible for the program to get the number of data channels needed to be controlled from the user instead of creating new tasks everytime.

 

I would like for the number of the data channels to go directly from the user to the DAQmx function so I can control the DIO Box.


What have you tried and where are you stuck? Mind to share some code?

 

That being said:

  • You can create DAQmx tasks programmatically.
  • You can define programmatically which channels and how many channels to use within the task.
  • You can have your user select the number of channels using some frontpanel elements.

So the answer would be: yes, you can create a VI where the user can select the number of channels in the DIO DAQmx task…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(1,259 Views)

Hi

Thank you for your quick reply!

So the first time I created this program, I had a fixed number of inputs , for example 12 so I had 12 control switches on my front panel.

But now I would like to scale it upto the user's choice. So the user should be able to give a value (number of cylinders that needs to be activated), say 50 and the program should automatically alot 50 switches and 50 outputs to the DIO Box instead of creating a new task.

 

When I tried to do so, I received the following error.

 

The write operation cannot be executed because the number of channels in the data does not match the number of channels in the task.

For the write operation, data must be provided for all channels in the task. Instead, you can also modify the Task to contain as many channels as written values.

Number of channels in Task: 2
Number of channels in data: 13

 

I have attached the image of the basic program, without the DAQmx.

For now I am able to see which cylinders are active but not able to move them since it is connected to the DIO Box.

 

How would I be able to do this "You can create DAQmx tasks programmatically."

and

"You can define programmatically which channels and how many channels to use within the task."

 

I tried this "You can have your user select the number of channels using some frontpanel elements." But the user would have to select 50 different channels manually.

 

Thanks for helping me out, looking forward to your response!

 

 

0 Kudos
Message 3 of 6
(1,237 Views)

@SR01 wrote:

Hi

Thank you for your quick reply!

So the first time I created this program, I had a fixed number of inputs , for example 12 so I had 12 control switches on my front panel.

But now I would like to scale it upto the user's choice. So the user should be able to give a value (number of cylinders that needs to be activated), say 50 and the program should automatically alot 50 switches and 50 outputs to the DIO Box instead of creating a new task.

 

When I tried to do so, I received the following error.

 

The write operation cannot be executed because the number of channels in the data does not match the number of channels in the task.

For the write operation, data must be provided for all channels in the task. Instead, you can also modify the Task to contain as many channels as written values.

Number of channels in Task: 2
Number of channels in data: 13

 

I have attached the image of the basic program, without the DAQmx.

For now I am able to see which cylinders are active but not able to move them since it is connected to the DIO Box.

 

How would I be able to do this "You can create DAQmx tasks programmatically."

and

"You can define programmatically which channels and how many channels to use within the task."

 

I tried this "You can have your user select the number of channels using some frontpanel elements." But the user would have to select 50 different channels manually.

 

Thanks for helping me out, looking forward to your response!

 

 


Attached Image Shows only the data you are displaying based on your inputs, no DAQmx Code modules to identify your issue.

 

Also, if you don't have parallel data acquisition running you can read status of all the DI Channels and display only the user specified channels (Suggested based on the attached image).

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 6
(1,233 Views)
Solution
Accepted by topic author SR01

Hi SR,

 


@SR01 wrote:

How would I be able to do this "You can create DAQmx tasks programmatically."

and

"You can define programmatically which channels and how many channels to use within the task."


Please open the example finder in LabVIEW.

Then search for DAQmx example VIs. They explain how to create DAQmx tasks programmatically!

 

And now for something completely different:

  • Create one DAQmx task which includes ALL channels.
  • Have your user operate only a limited number of those channels, depending on their needs.

This way you "only" need to limit the user input to reasonable values…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 6
(1,227 Views)

Alright thank you, I will check it out!!

0 Kudos
Message 6 of 6
(1,219 Views)