From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Python readback of analog output channel on USB-6216

Solved!
Go to solution

I'm adding a USB-6216 to some existing control software that uses knowledge of the hardware output state to control output sweeps (basically designed to ensure the instrument doesn't unintentionally run outside of voltage bounds and blow up an essentially irreplaceable sample). Is there a way to read from the USB-6216 what the voltage it is supplying to a given ao channel is? I have tried this using something like:

 

with nmx.Task() as task:
    task.ao_channels.add_ao_voltage_chan(self.port)
    outputLevel = task.read(number_of_samples_per_channel=1)

 

But it tells me you cannot read from this type of input. You can usually do it in LabView? Either directly or as an 'internal channel' feeding back the information.

Does anyone know how this can be done with python nidaqmx?

 

Thanks.

 

0 Kudos
Message 1 of 3
(2,360 Views)

As an add-on to this, I've worked out how to make it work in labview. Code is:

Readback.pngSo my issue now is only how I implement in python. I guess this boils down to two questions:

 

1. How do I do the equivalent of entering I/O filtering settings and switching internal channels on, which I can do in Labview with a right click menu and check-box.

2. Probably the easy bit, how to read the internal channel (I suspect usual analog input read on _ao0_vs_aognd).

 

Will post details if I manage to solve...

 

/A

0 Kudos
Message 2 of 3
(2,300 Views)
Solution
Accepted by topic author AdMico

I think I'll close this off solo. 1. wasn't an issue. Code for 2. is:

2019-08-06_1415.png

Tested for retained function after a reboot (without running labview to set anything re: I/O Filtering) so I suspect this solution works 'out of the box' as a way to direct read output.

 

/A

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