Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple DO lines, single writer?

Hi all,

 

Need a recommendation for the following.

I have the next DO lines from a configuration file:

 

Pump1, Dev1/port0/line6

Pump2, Dev1/port0/line7
Pump3, Dev1/port1/line3
Valve1, Dev1/port1/line1
Valve2, Dev1/port1/line2
Valve3, Dev1/port1/line0

 

So, two ports and some lines. I want to control the DO lines individually. What is the recommended way to go?

All separate tasks with their corresponding writers seem a bit overkill here.

An array of 6 booleans in this case? How to deal with the lines that are not to be changed?

 

bool[] arr = new bool[6];

arr[line] = linevalue;

this.digitalOutwriter.WriteSingleSampleSingleLine(true, arr);

 

Looking forward for some suggestions!

Thanks a lot!

 

Martin

 

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

Use the multiple line version of write and you've to keep track of the last written values for all lines, update with new values for required lines and write all lines. 

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
(1,207 Views)

Hi,

 

Thanks for your suggestion. This came up to me as well ;), but you have to memorize last written values. I hoped that this kind of bookkeeping was arranged by DAQmx.

I worked arround it by using instant creation of a Task and a Writer when a line (bit) must be changed:

 

using (Task task = new Task())
{
task.DOChannels.CreateChannel(ch, "", ChannelLineGrouping.OneChannelForEachLine);

DigitalSingleChannelWriter digitalOutWriter = new DigitalSingleChannelWriter(task.Stream);

digitalOutWriter.WriteSingleSampleSingleLine(true, value);
}

 

where: ch="Dev1/port0/lineXX"

 

I do not know what the performance will be, but in my case the digital out lines need no high frequencies.

 

Greetz

 

 

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

Hi  MVW

First of all let me know witch hardware your are using to be more clear understandable.

Also tell me in witch programming language you wrote this code, I guess it might be Measurement studio. 

 

And if it's not problem can you describe more clear what do you want to do with those DO lines?

 

Regards )

0 Kudos
Message 4 of 6
(1,170 Views)

Ofcourse. I am using C# in Visual Studio 2019 using the latest 2022 Q3 DAQmx libraries. At the moment the NI USB-6008 hardware must be supported, but as far as I know is the DAQmx generic for al their products. As said, the DO lines are used to control valves and pumps and therefore does not have to be high frequent signals. Performance is not an issue here.

Cheers

0 Kudos
Message 5 of 6
(1,147 Views)

@MVW wrote:

Ofcourse. I am using C# in Visual Studio 2019 using the latest 2022 Q3 DAQmx libraries. At the moment the NI USB-6008 hardware must be supported, but as far as I know is the DAQmx generic for al their products. As said, the DO lines are used to control valves and pumps and therefore does not have to be high frequent signals. Performance is not an issue here.

Cheers


If performance is not an issue, create 1 task per DO channel, and do not configure DAQmx timing (this tells the task to work in software timed i.e., whenever you send data). Based on what channel you need to change index the appropriate task and write data. Note, you cannot change the state for multiple DO lines at the exact time (but a few uS apart sequentially). No need to create and clear the task repeatedly, just create once and clear at the end once.

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 6 of 6
(1,135 Views)