Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Make a 40kHz square wave on analog output with Python

Hi, I am trying to make a simple sqaure wave 40kHz (+1v) with my NI-6215 on AO1. I am able to do this in C#, but when I try the Python nidaqmx I am not able to.
 
I can write a pulse, but when I add timing, I get no output.
 
This is what I try:
 
import nidaqmx
rate = 40000 # Sample rate in Hz
duration = 1000 # Duration in seconds
 
samples = int(rate * duration)
list = []
for x in range(samples):
    list.append(x % 2)
with nidaqmx.Task() as task:
    task.ao_channels.add_ao_voltage_chan("Dev1/ao1")
    task.timing.cfg_samp_clk_timing(rate)
    task.write(list, auto_start=False)
    task.start()
0 Kudos
Message 1 of 3
(3,104 Views)

Did you get any errors when running the program?

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

Hello Abbadon,

 

Have you seen the following document?

__________________________________________
The best way to thank, is to give KUDOS
0 Kudos
Message 3 of 3
(2,801 Views)