New issue 24 by schlat...@phys.ethz.ch: DI-Task, channel with
grouping='for_all_lines' fails
http://code.google.com/p/pylibnidaqmx/issues/detail?id=24
What steps will reproduce the problem?
1. run the attached script
(I tried to make it rather general so that I hope it will run correctly on
other NIDAQmx hardware. If not, look at the script and change it
accordingly).
What is the expected output? What do you see instead?
I expect that a digital input channel gets created and 1 sample is read
from 32-bit wide input port.
However, the script fails with an error because the DigitalTask.read()
method tries to use np.uint256 (which does not exist). It should use
np.uint32.
What version of the product are you using? On what operating system?
System information
==============================
OS: Win7, 64bit
NIDAQmx version = 9.1
Connected devices: Dev1
Global tasks:
Global channels:
Device: Dev1
==============================
Type: NI-USB-6259
Bus type: USB
Please provide any additional information below.
I have attached a patch.
Attachments:
DigitalTaskForAllLines.patch 712 bytes
Darn, I forgot to attach the script. Sorry. Here it is.
Attachments:
test_DigitalInput.py 818 bytes
I wonder if you get all data with your patch?
Namely, nidaqmx docs says
"""
Each line in a channel gets one byte per sample.
"""
In your example, you specify 32 lines, meaning,
to read data with grouping for all lines, one
sample needs 32 bytes == 256 bits.
So, can you check that with 32-bit integer
you actually get all the data. Also, what is the
value of returned bytes_per_sample in your case?
Perhaps the data array needs to be expanded?
For instance, using
data = np.zeros((number_of_channels, samples_per_channel,
number_of_lines),dtype=uint8)
as a fix of the issue?
Mea culpa. You are right. I made that mistake because I did not look at
your code closely enough. I'm so used to using ReadDigitalU32 that I did
not even know that ReadDigitalLines exists. Yes, it gives you one byte per
line, therefore may patch is grossly wrong!
Expansion does not work either. The format that ReadDigitalLines returns is
data = np.zeros((samples_per_channel, sum_of_lines),dtype=np.uint8)
if 'group_by_scan_number' is used. Transposed for 'group_by_channel'. If
ReadDigitalLines is used, the argument 'per_line' or 'for_all_lines' is
irrelevant: The format is the same. I think these are only relevant for
ReadDigitalU(8,16,32)
I did some quick testing by reading 32 lines (as in the script) and
applying +5V to 1 line at a time which worked as expected.
Attachments:
DigitalTaskForAllLines_v2.patch 1.5 KB