Jump to content

Design DAQmx tasks: many channels/task?


Recommended Posts

Hello everybody,

I am writing a Labview program (using LV 7.1.1) to control valves on a chemical installation (each valve is connected to a digital I/O of the board), there are 30 to 40 valves in all, and there is a physical separation in that we use three different instruments. Some valves are only to allow reactants in/out, others will need to be pulsed during the experiments.

I am wondering how to write the tasks in MAX, would you recommend a single task per valve, with the advantage that it will have a human-readable name in the programs and that I can create arrays of tasks later, or maybe directly a task per instrument (i.e., containing about 10 DIO for 10 valves) to more simply deal with arrays of bool later? Or maybe many redundant tasks (I mean tasks that act on the same channels) to pull out like global variables, in the latter case I would use a 10-channels task for initialization and then a single-channel task for pulsing or opening a valve?

What would be the recommended way? Most flexible and simpler to code for?

Now, I have tried the one-task-per-valve approach and then, these tasks put into an array. But I have a problem with finding which channel to switch for changing the state of a single valve in the array. I have written an ENUM to name the tasks in the array, but it is not very flexible (because the ENUM and the array of tasks are separated and easily fall out of sync: different files, different coding priorities...). The latter may actually be my biggest problem here.

Link to comment
  • 4 weeks later...

Hello everybody,

I am writing a Labview program (using LV 7.1.1) to control valves on a chemical installation (each valve is connected to a digital I/O of the board), there are 30 to 40 valves in all, and there is a physical separation in that we use three different instruments. Some valves are only to allow reactants in/out, others will need to be pulsed during the experiments.

I am wondering how to write the tasks in MAX, would you recommend a single task per valve, with the advantage that it will have a human-readable name in the programs and that I can create arrays of tasks later, or maybe directly a task per instrument (i.e., containing about 10 DIO for 10 valves) to more simply deal with arrays of bool later? Or maybe many redundant tasks (I mean tasks that act on the same channels) to pull out like global variables, in the latter case I would use a 10-channels task for initialization and then a single-channel task for pulsing or opening a valve?

What would be the recommended way? Most flexible and simpler to code for?

Now, I have tried the one-task-per-valve approach and then, these tasks put into an array. But I have a problem with finding which channel to switch for changing the state of a single valve in the array. I have written an ENUM to name the tasks in the array, but it is not very flexible (because the ENUM and the array of tasks are separated and easily fall out of sync: different files, different coding priorities...). The latter may actually be my biggest problem here.

I think you are on the right track with an array of tasks, however the tracking of the tasks is a problem, as you say.

I am working on a similar situation where I have multiple references for various instruments and I need to keep track of what role each instrument performs.

My suggestion:

create a global which is a cluster

put in this cluster an array of tasks

add an array of strings

[optional]

create an ENUM, customize it, edit the list of items and create an item for each valve type ("in", "out", etc.) and save it as a Type Def. customized control.

add an array of ENUM

Now when you initialize your system you create an array of tasks. At the same time create an array of strings labelling these tasks, in fact you could cleverly construct these strings like "IN:water", "OUT:water", "IN:blue dye", "OUT:HF", or whatever you need.

Then write both the array of tasks and the array of strings into the global.

Later when you need the valve which controls water output, read the string array from the global, then search the array for the string "OUT:water". (In fact if you have logic which specifies the liquid name and the valve direction you could programmitically construct the search string using the concatenation function.) Then read the tasks array and use the index from the string array search to retrieve the proper task.

This way you don't need to keep track of the order of the tasks, you only need to make sure that when you initialize your program that the tasks and the string descriptions are saved in matching order.

If needed you can put error checking later in your program which will read the tasks array and the strings array from the global and check to see if they are the same length: if they are not, then throw and error and gracefully exit with a dialog.

Best of luck.

Leif Kirschenbaum

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.