12-26-2018 08:12 AM
Hi,
I'm using PCI-6289 with NI DAQmx Python API. (nidaqmx18.6, python3.7) I know that this board only has 'correlated DIO', so I select the digital sampling clock source as 'Dev1/ai/SampleClock' or 'Dev1/FrequecyOutput'. I wrote a test script as:
import nidaqmx
from nidaqmx.constants import *
import numpy as np
if __name__ == "__main__":
# create samples
n = 1000
samples = np.empty(n, dtype='bool')
for i in range(n):
samples[i] = False
samples[n - 1] = True
with nidaqmx.Task() as clock_task:
with nidaqmx.Task() as task:
clock_task.co_channels.add_co_pulse_chan_freq('Dev1/freqout', freq=6250, duty_cycle=0.5)
#clock_task.ai_channels.add_ai_voltage_chan('Dev1/ai0')
#clock_task.timing.cfg_samp_clk_timing(1000)
task.do_channels.add_do_chan("Dev1/port0/line0", line_grouping=LineGrouping.CHAN_PER_LINE)
task.timing.cfg_samp_clk_timing(rate=6250,
source='/Dev1/FrequencyOutput')
task.write(samples)
clock_task.start()
It will not raise any error upon running, but the board does not generate the expected digital signal. Here's what I have tried before:
-Swapping between analog sampling clock and frequency output (the commented lines):
no noticeable difference
-play with the 'auto_start' and 'start()' (According to one material I read before, I'm supposed to start the AI/FrequencyOutput task first then the DO task):
not work
-instead of writing 1000 samples, only write single sample per run
works (Does this mean there's something wrong with the timing)
By the way, if I want a millisecond level precision TTL signal, is it the best way realizing it what I'm doing right now? Thanks!
12-27-2018 04:56 PM
Hello,
What type of digital signal are you expecting to receive, and what signal are you receiving when you run this code?
12-28-2018 03:00 AM
Hi,
I expected there will be a 5V output after some delay (software and communication delay + 1s I have set in the script). When I run this program, nothing happened on the oscilloscope, the output remains 0V.
(But if I write single sample (True or False) to the device, it will change output accordingly)