Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 6501 & 6008 IO - write and read back output values

Hi,

When I activate an output (either analog/digital),  how  can I read back the output value?

I'm using the USB IO cards 6501 (digital IO) and 6008 (analog IO). The programming language is C#

Snippet of my digital output activation:

using (Task diowritetask = new Task())
{
     diowritetask.DOChannels.CreateChannel("Dev1/port2/line0", "",ChannelLineGrouping.OneChannelForAllLines);
     DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(diowritetask.Stream);
     writer.WriteSingleSampleSingleLine(true, true);
}

Analog output activation implementation is done similarily.

As all IO lines are reserved in my application, I can not connect output lines to digital input lines just to read its value.


Thank you in advance,

Raul
0 Kudos
Message 1 of 3
(3,653 Views)
update:

If I set Dev1/port2/line1 value to true and later on execute the following snippet of code, the previously set output value will be reset. Why is it happening???

                using (Task tsk = new Task())
                {
                    tsk.DOChannels.CreateChannel("Dev1/port2/line1", "DUMMY", ChannelLineGrouping.OneChannelForEachLine);
                    DigitalSingleChannelReader aaa = new DigitalSingleChannelReader(tsk.Stream);
                    bool tere = aaa.ReadSingleSampleSingleLine();
                    Trace.WriteLine(tere);
                }

0 Kudos
Message 2 of 3
(3,645 Views)

Hi Raul,

In your first post, you asked whether it was possible to read back the output value of a digital or analog output.  To read back the analog output value you simply need to create and analog input task and use the physical channel:  _ao0_vs_aognd" and/or "_ao1_vs_aognd".  This will allow you to check the analog output level without using any physical connections to an analog input.  Click here for the developer zone tutorial on how to do this within LabVIEW.  You should be able to use the same physical channel names in C#.  In regards to your second question, you should be able to read the value of the digital output by simply using the digital read single sample.  This all occurs on the same digital output task. 

In regards to your second post, the digital output should not reset unless you write a new value to the output.  So, simply doing a DigitalSingleChannelReader should not reset the output value.  Let me know if this is the case, but it shouldn’t be happening.  Based on your second piece of code, you created a new task to read the digital line. You could do this within the same task as created in the first piece of code.  

I hope this helps,
Paul C.

0 Kudos
Message 3 of 3
(3,624 Views)