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

Strange Output of PCI-6289 DO

$
0
0

I'm using Python(nidaqmx package) to control phi-6289. I want to generate a digital pulse of given length on port 0, line 0 of PCI-6289, but I get some really strange results on the oscilloscope.

My code is as: 

import nidaqmx
import numpy as np
from nidaqmx.stream_writers import DigitalSingleChannelWriter
from nidaqmx.constants import AcquisitionType
from time import sleep


def done_event(*args):
print('measurement done')
return 0


def pulse(time):
waveform = np.ones(time, dtype=np.uint32)
ending_sequence = np.zeros(100, dtype=np.uint32)
waveform = np.append(ending_sequence, waveform)
waveform = np.append(waveform, ending_sequence)
return waveform


if __name__ == '__main__':
virtual_task = nidaqmx.Task()
do_task = nidaqmx.Task()
# create a virtual analog input channel
virtual_task.ai_channels.add_ai_voltage_chan('Dev1/ai0')
virtual_task.timing.cfg_samp_clk_timing(1000, sample_mode=AcquisitionType.CONTINUOUS)
virtual_task.start()
# configure the digital output task
do_task.do_channels.add_do_chan('Dev1/port0/line0:31')
do_task.register_done_event(done_event)
do_task.timing.cfg_samp_clk_timing(1000, source='/Dev1/ai/SampleClock') # set digital sampling time
do_task.write(pulse(500),auto_start=False)
print('start to write')
do_task.start()
# start the measurement
sleep(3)
virtual_task.close()
do_task.close()

(the parameter of pulse() is the central length of the pulse, and I add 100 zeros on both side of the pulse)

I wire the port0line0 to the oscilloscope and get:

pulse(100): three 0.1s pulses, separated by 0.2s each

(looks like the code is executed for three times)

pulse(300): two 0.3s pulses, separated by 0.2s

(looks like the code is executed twice)

pulse(500): singel 0.5s pulse and the output is not returned to zero

 

Does anyone know what is going on here? Thanks. 

IMG_0874.JPG

IMG_0875.JPGIMG_0876.JPG


Viewing all articles
Browse latest Browse all 2167

Trending Articles



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