04-25-2013 04:14 PM
I have a PXI box with PXI 6225 DAQs installed. For some application purpose, I have wired 4 lower lines of digital port 0
to its 4 upper lines so that any digital output on the lower lines can be read as digital input on the upper lines.
In the CVI program I setup two input and output tasks as follows:
Input task:
DAQmxCreateDIChan(digitalInputTask,"PXI1Slot5/port0/line4:7", "InputLines", DAQmx_Val_ChanForAllLines);
DAQmxCfgSampClkTiming(digitalInputTask,"ai/SampleClock", 4000, DAQmx_Val_Rising,DAQmx_Val_ContSamps,2000);
Output task:
DAQmxCreateDOChan(digitalOutputTask,"PXI1Slot5/port0/line0:3", "OutputLines", DAQmx_Val_ChanForAllLines);
DAQmxCfgSampClkTiming(digitalOutputTask,"ai/SampleClock", 4000, DAQmx_Val_Rising,DAQmx_Val_ContSamps, 2000));
DAQmxCfgOutputBuffer(digitalOutputTask,2000);
I have also started an analog input task to make sure the analog sample clock "ai/SampleClock" is running, and I verify
that I am reading correct analog data from my analog lines.
Here is the problem:
I write 2000 identical non-zero samples to the lower 4 lines (port0/line0..3) using the following command:
DAQmxWriteDigitalU32 (digitalOutputTask, 2000, 1,10, DAQmx_Val_GroupByChannel, sampleArray, &written, NULL);
After a while, I try to read the upper 4 lines (port0/line4..7) using:
DAQmxReadDigitalU32 (digitalInputTask, 2000, 10, DAQmx_Val_GroupByChannel,scanArray, 2000, &read_num, NULL);
but the values returned in scanArray are all zero!
If I replace the digitalInputTask with digitalOutputTask in the above function call, I get the correct written samples back
(not sure how the 4 lower lines that are configured in output mode can be read back! could it be just reading the buffer?)
I am sure the hardware configuration is correct, since when I try to mimic this functionality in Labview, it works.
(I use an output DAQ assistant to write to lower 4 lines of port 0, using an input digital wave, and then
reading from upper 4 lines using an input DAQ assitant VI into a digital waveform.
In another test, I write to the lower 4 lines in CVI, then stop my CVI program, start a simple Labview VI to read from
the upper 4 lines, and I can see the values I just wrote in CVI).
Any idea what could be causing DAQmxReadDigitalU32 to read only zeros in CVI?
I have compared my settings in CVI with DAQ assistant settings in Labview and tried to make them identical, but did not help.
Thank you
Solved! Go to Solution.
04-26-2013 05:05 PM
This could be the initial startup states of the card itself, Have you set these in MAX in the configurations for the device?
Regards,
04-29-2013 11:10 AM
@AleAlejandro wrote:
This could be the initial startup states of the card itself, Have you set these in MAX in the configurations for the device?
Regards,
Hi,
Thank you for replying. How would I set these "initial startup states" in MAX? What settings should I set? I looked around and
could not immediately realize what to set. The port 0 is set in tristate mode and when I use the digital I/O test panel and set the
lower lines in input and the upper lines in input, I can easily see the upper lines follow the pattern that I dictate to the lower lines,
so in fact what I desire is happenning there as well. However, the function in CVI returns all zeros regardless or the supplied value.
I think I am missing some configuration in my program but I do not know what.
Thanks
05-01-2013 12:00 AM
Try using these examples to see if you can read and write in CVI
05-01-2013 04:28 PM
Thank you. Your code was quite helpful in finding the problem.
The issue was that we were clocking the digital output lines.
Once we removed the clocking function (DAQmxCfgSampClkTiming)
for the output lines, it seems to be reading fine.