07-06-2009 08:32 PM
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
07-06-2009 08:37 PM
07-06-2009 09:09 PM
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.
07-07-2009 12:55 PM
07-07-2009 01:08 PM
What device are you using?
Just call DAQmx Read (yes, with your output task) and you'll get back the current value.
07-07-2009 01:21 PM
In LabVIEW it would look something like the attached image.
07-08-2009 03:40 PM
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!
07-08-2009 04:02 PM
07-09-2009
12:07 PM
- last edited on
03-21-2024
09:13 PM
by
Content Cleaner
09-23-2018 04:48 AM
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)