Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the current value of a digital output line on a NI-DAQ in C#

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.

0 Kudos
Message 1 of 5
(5,193 Views)

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.

0 Kudos
Message 2 of 5
(5,139 Views)

I would like to read the current state of a digital output line. Is it high or is it low ?

0 Kudos
Message 3 of 5
(5,132 Views)

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.

0 Kudos
Message 4 of 5
(5,095 Views)

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/po​rt0", "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

 

0 Kudos
Message 5 of 5
(5,067 Views)