I have a NI-DAQ 6212 & I am trying to set the digital output in tri-state mode using C#. I am not able to find an example on how to set it aside from this reference http://zone.ni.com/reference/en-XX/help/370473H-01/mstudiowebhelp/html/bd33b0d/
How can I accomplish this? Any input is greatly appreciated!
Thank you!
The NIDAQ libraries are pretty poorly documented and don't have many examples from what I remember when I had to deal with them. I inherited some code that controlled a voltage controller that I had to work with slightly, by no means do I fully understand the library.
But I would love to offer what I can because I know how frustrating this library can be.
try
{
using (NationalInstruments.DAQmx.Task digitalWriteTask = new NationalInstruments.DAQmx.Task())
{
string[] channels = DaqSystem.Local.GetPhysicalChannels(PhysicalChannelTypes.DOPort, PhysicalChannelAccess.External);
// Here is how I command the voltage of the system.
digitalWriteTask.DOChannels.CreateChannel(channels[1], "port1", ChannelLineGrouping.OneChannelForAllLines);
DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(digitalWriteTask.Stream);
writer.WriteSingleSampleMultiLine(true, commandValue);
// A clue I might be able to offer about DOChannel Tristate property?
digitalWriteTask.DOChannels.All.Tristate = true;
}
}
catch (Exception ex)
{
Console.Out.WriteLine(ex.Message);
return false;
}
After inspecting NationalInstruments.DAQmx.Task
it looks like there is a member DOChannels
. You should be able to either iterate over it or select All
and set the Tristate
property.
As far as anything before or after doing that, I have no idea.