Quantcast
Channel: Digital I/O topics
Viewing all articles
Browse latest Browse all 2178

Analog In- and Output with NIDAQmx in Python

$
0
0

Hi guys,

 

I am using the USB-6002 and want to read an analog input and write an analog output. I am using therefore the Python Package NIDAQmx and the package asyncio to make asynchronous working possible.

My problem is now, that the write-methods always needs unread samples in the buffer and it is really hard to guess, how many samples are available and how many samples need to be written. For the output I am currently using the following configuration: 

# Create tasks for the analog outputs
with nidaqmx.Task() as output_task:

# Configure analog output channels
for channel in output_channels:
output_task.ao_channels.add_ao_voltage_chan(channel)

# Configure the sample rate and the number of samples per channel
output_task.timing.cfg_samp_clk_timing(sample_rate,
samps_per_chan=samples_per_channel,
sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS
)

output_task.out_stream.regen_mode = nidaqmx.constants.RegenerationMode.DONT_ALLOW_REGENERATION

 

And I am using the standard output_task.write() method to write samples into the output buffer. 
Now I am wondering if there is a possibility to change from continuous acquisition to something like "changing output state". Means, if there is a possibility to just change the output state for example from 0V to 1V if a defined condition is fulfilled. This would make it possible to just change the state and to stay in this state for example 3 seconds, without writing samples continuously and without providing unread samples in the output buffer the whole time.

 

Is there a function, which is able to do something like that?

I would be really thankful if somebody knows an answer to my problem.

 

BR, Kathi


Viewing all articles
Browse latest Browse all 2178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>