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

Create Digital Output using nidaqmx with Python

$
0
0

Hello, I have issues trying to generate a digital output with clock sampling. I am using NI USB-6353 and basically I want to create a custom waveform, made by an array of 1 and 0, with very precise timing (I cannot use counters for a series of reasons).

 

This is pretty much my code:

 

wave = np.array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],dtype=np.uint32)

task = nidaqmx.Task()
task.do_channels.add_do_chan("Dev1/port0/line0")
task.timing.cfg_samp_clk_timing(1000)
writer = DigitalSingleChannelWriter(task.out_stream, auto_start=True)
writer.write_many_sample_port_uint32(wave)

 

My code is perfectly working and I see the waveform on my oscilloscope if I don't use the "task.timing.cfg_samp_clk_timing(1000)" but that's not what I want, I want that samples are written at well defined intervals. If I use the timing configuration I don't see the waveform anymore but strange pulses, and they change if I change the clock timing from 1000 to other values. 

 

What am I missing? What exactly does this instruction: "task.timing.cfg_samp_clk_timing(1000)"? I thought it would have set 1000 samples in 1 second, am I wrong?

 

Please help me. Thanks a lot to anyone who answers.


Viewing all articles
Browse latest Browse all 2182

Trending Articles



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