1

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!

kasrus
  • 13
  • 4
  • Do you need help figuring out how to write to a channel or figuring out how to set this specific property of a channel and can already successfully write other properties of a channel? – KDecker May 26 '16 at 18:24

1 Answers1

1

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.

KDecker
  • 6,928
  • 8
  • 40
  • 81
  • Thank you so much for taking the time to respond. Yes, I agree with the poor documentation & lack of examples. It seems like after setting the Tristate property I have to do digitalWriteTask.Control(TaskAction.Commit); for it to take effect. – kasrus Jun 03 '16 at 21:30
  • Hello I need to write some code in C# to set analog output to a value for an external trigger. Could you help me a bit with that? There is no proper documentation. – user16307 Jan 12 '22 at 23:57