03-12-2018 10:51 PM
I'm new to using DAQmx / C# for writing a DAQ application. I have a USB-6001 connected to my computer. Some of the digital ports are used as outputs while others are inputs. I can read the state of my digital input lines successfully.
What I'm not clear about is how persistent is an operation to set a line to a digital output? For instance, here is my code to set the state of a single digital output line (pardon the messed up formatting):
try
{
using (NationalInstruments.DAQmx.Task digitalWriteTask = new NationalInstruments.DAQmx.Task())
{
digitalWriteTask.DOChannels.CreateChannel(sPortText, sChannelName, ChannelLineGrouping.OneChannelForAllLines);
DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(digitalWriteTask.Stream);
writer.WriteSingleSampleSingleLine(true, bIsOn);
bWroteOK = true;
}
}
catch (DaqException ex)
{
bWroteOK = false;
}
How long will the channel specified in sPortText remain as an output in the desired state?
Thanks in advance,
Ken
03-14-2018 01:10 PM
Hi Ken,
I think I understand your question, but please clarify if I am mislead.
When you create a virtual channel (what you are doing with sPort) those lines (and more importantly the resources associated with the task) will remain reserved until you clear the task. So, if you try to configure another task with anything reserved by the previous one, you would get a resource reserved error.
Let me know if this helps or if you have follow ups!
Best,
03-14-2018 10:03 PM - edited 03-14-2018 10:04 PM
Hi Clint,
Thanks for taking the time to reply and the information.
What I was actually trying to figure out was if I were to set a digital output to a particular state, would it remain in that state even after the task went out of scope in my example code. I found that was the case be writing some test code and doing some experimenting with my hardware.
Thanks again for taking the time to reply.
Ken