11-13-2014 09:59 AM
NI-USB-6xxx
C#
Is it possible to read the current output value from a digital output line ?
i.e after setting the putput high, i would like to confirm the high state via my c# code.
I don't want to use a analog input to do it.
11-17-2014 03:19 AM
Hi,
This is Gajan an Applications Engineer, could you be a bit more specific in regards of what you are trying to achieve please.
Thanks.
11-17-2014 07:08 AM
I would like to read the current state of a digital output line. Is it high or is it low ?
11-19-2014 11:34 AM
Hi,
There is a KnowledgeBase that describes similar query: http://digital.ni.com/public.nsf/allkb/CB86B3B174763C3E86256FFD007A2511
Could I also know how you are planning to measure the current.
11-20-2014 07:40 PM
Hi,
Use the same tak to read the value of the channel
using (Task digitalWriteTask = new Task()) { // Create an Digital Output channel and name it. digitalWriteTask.DOChannels.CreateChannel("Dev1/port0", "port0", ChannelLineGrouping.OneChannelForAllLines); // Write digital port data. WriteDigitalSingChanSingSampPort writes a single sample // of digital data on demand, so no timeout is necessary. DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(digitalWriteTask.Stream); writer.WriteSingleSamplePort(true, (UInt16)this.numericEdit1.Value ); // Create the reader DigitalSingleChannelReader reader = new DigitalSingleChannelReader(digitalWriteTask.Stream); // Read back the value this.textBox1.Text = reader.ReadSingleSamplePortByte().ToString(); }
Curt