LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I read what I wrote to a DAQmx digital output channel

How can I read back what I wrote to a DAQmx digital output channel? I have a digital output that I set to a value and later, from another isolated part of the program, I need to read back what I wrote to it. I could use a global to cache what is being written, but that is a bit difficult for some reasons I'd rather not detail. Also, I think it's better to get the actual value from the hardware as cache can get stale in error conditions.

 

Many Thanks!

 

David

 

 

0 Kudos
Message 1 of 12
(9,688 Views)
FYI, I'm using DAQmx Write (Digital 1D Bool 1Chan 1Sample) that is fed by multiple comma separated lines into DAQmx Create Channel.
0 Kudos
Message 2 of 12
(9,687 Views)

You can't.

 

I don't understand what you mean by the "cache can get stale in error conditions".  How does it get stale?  What error conditions?  Exactly what LabVIEW construct are you using when you say "global cache?"

 

You can use a functional global variable where you write to the FGV at the same time you write a value to the Digital Output.  Then you can read that functional global variable anywhere else in your code.

Message 3 of 12
(9,676 Views)

Hi David,

 

DAQmx does not have this functionality.  One way that you could do this would be to make a physical connection to another DIO line and read that line as an input.

Regards,
Jim Schwartz
0 Kudos
Message 4 of 12
(9,657 Views)

What device are you using?

 

Just call DAQmx Read (yes, with your output task) and you'll get back the current value.

Message 5 of 12
(9,654 Views)

In LabVIEW it would look something like the attached image.

 

 

Message 6 of 12
(9,645 Views)

I tried the DAQmx read and got an error message. I think the folks who said it isn't possible might be right (and that's very wrong, it SHOULD be possible to do this!). Is there some "back door" way of reading the state of DAQmx digital outputs - there must be?!?

 

As for the cache issue, what if LabView stops running, and then restarts? There's no way to persist the last value (and no, I'm not doing a server or writing it to a file); but the DAQmx module knows what it's state is - we just need to figure out how to query it - there has got to be a way!

0 Kudos
Message 7 of 12
(9,618 Views)
The DAQmx Read does work - at least with my M series card. I just ran the example and had absolutely no problems. If you are getting an error and want help in getting rid of the error, you need to provide the error code/message. It would also help if you provided the model number of the DAQ card and the code you are running.
0 Kudos
Message 8 of 12
(9,609 Views)

Hey,

I don't know what you application is. I tried this on my M-Series it works fine. If you are looking for hardware compare check these DIO hardware 6551 and 6552  where you have per cycle tri-state hence can do hardware compare.

Cheers

 

lab

0 Kudos
Message 9 of 12
(9,585 Views)

FYI. Readback of digital outputs works with USB-6009, nidaqmx version 0.5.0 and Python code:

 

import nidaqmx
def usb6009_do_get(self, dev_str="dev1/port1/line0:3"): """ Readback state of digital outputs :param dev_str: = "dev1/port1/line5, dev1/port1/line0:3" :return: d0_values as list in the order specified in dev_str """ with nidaqmx.Task() as task: task.do_channels.add_do_chan(dev_str, line_grouping=LineGrouping.CHAN_PER_LINE) do_is = task.read(number_of_samples_per_channel=1) return do_is

""" example of how to use the function to readback do values """
do = usb6009_do_get("Dev1/port0/line4, Dev1/port0/line0:2, Dev1/port1/line0:3")
print("do=",do)

 

 

Message 10 of 12
(5,815 Views)