【问题标题】:How to set tri-state on NI-DAQ using C#如何使用 C# 在 NI-DAQ 上设置三态
【发布时间】:2016-09-24 21:33:55
【问题描述】:

我有一个 NI-DAQ 6212,我正在尝试使用 C# 将数字输出设置为三态模式。除了这个参考http://zone.ni.com/reference/en-XX/help/370473H-01/mstudiowebhelp/html/bd33b0d/

我怎样才能做到这一点?非常感谢任何输入!

谢谢!

【问题讨论】:

  • 您是否需要帮助弄清楚如何写入通道或弄清楚如何设置通道的这个特定属性并且已经可以成功地写入通道的其他属性?

标签: c# .net nidaqmx tri-state-logic


【解决方案1】:

NIDAQ 库的文档记录很差,我记得在处理它们时没有太多示例。我继承了一些控制电压控制器的代码,我不得不稍微使用它,但我并不完全理解这个库。

但我很乐意提供我所能提供的,因为我知道这个库有多么令人沮丧。

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;
}

检查NationalInstruments.DAQmx.Task 后,似乎有一个成员DOChannels。您应该能够对其进行迭代或选择All 并设置Tristate 属性。

至于之前或之后的任何事情,我不知道。

【讨论】:

  • 非常感谢您抽出宝贵时间回复。是的,我同意糟糕的文档和缺乏示例。似乎在设置了三态属性后我必须做 digitalWriteTask.Control(TaskAction.Commit);使其生效。
  • 您好,我需要在 C# 中编写一些代码来将模拟输出设置为外部触发器的值。你能帮我一下吗?没有适当的文档。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多