Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxReadDigitalU8 does not work

Hello,
I have been trying to write a Matlab R13 program for read/write from/to USB-6501 using the function loadlibrary('nicaiu.dll','nidaqmx.h','alias','myni'). I have already managed to write to this board using the DAQmxWriteDigitalU8 command but I am not able to read anything. I think it could be a banal error. Please help me.
The commands I use are following:
 
[a,b,intaskh1] = calllib('myni','DAQmxCreateTask','input',intaskh1)
inchan=['Dev1/port2'];
[a,b,c] = calllib('myni','DAQmxCreateDIChan',uint32(intaskh1),inchan,'',DAQmx_Val_ChanForAllLines)
disp('NI: Start task(s)')
[a]=calllib('myni','DAQmxStartTask',intaskh1)
indata = uint8(1);
[a]=calllib('myni','DAQmxReadDigitalU8',intaskh1,1,10.0,DAQmx_Val_GroupByChannel,indata,1,[],[])

No errors appeared (all 'a' variables were zero).
 
One more question: how to combine read and write in one task? When I tried that, error DAQmxErrorMultiChanTypesInTask appeared (no. -200559).
 
Thank you!
David
0 Kudos
Message 1 of 10
(4,980 Views)
David,
 
I'm not sure how Matlab works with the DAQmx DLL, but I can tell you the basic procedure for reading from a digital port. Here are the function calls you want to make (and some sample function arguments):
 
DAQmxCreateTask("",&taskHandle);

DAQmxCreateDIChan(taskHandle,"Dev1/port0","",DAQmx_Val_ChanForAllLines);

DAQmxStartTask(taskHandle);

DAQmxReadDigitalU32(taskHandle,1,10.0,DAQmx_Val_GroupByChannel,&data,1,&read,NULL);

DAQmxStopTask(taskHandle);

DAQmxClearTask(taskHandle);

Also, you cannot read and write in the same task. You need to make two separate tasks to do that. I hope this helps!

--
Michael P
National Instruments
0 Kudos
Message 2 of 10
(4,959 Views)

Thank you for the reply. My code is exactly the same as you wrote (only I used the DAQmxReadDigitalU8 command). However, neither DAQmxReadDigitalU32 nor DAQmxReadDigitalU8 is working. The values at &data and &read remain unchanged after executing these commands. It is strange as the DAQmxWriteDigitalU8 command works without problems. In Measurment & Automatization Test panel, read and write work. Please, advise me what to do, I do not have any idea.

Is it possible that the highest output frequency is quite exactly 1 kSa/s? I used the DAQmxWriteDigitalU8 command called continually within one task.

Thanks a lot!

David

0 Kudos
Message 3 of 10
(4,946 Views)
David,
 
Try using a different development environment/compiler  (such as Visual Studio or gcc) to see if the problem is reproducible. Let me know what your results are.
--
Michael P
National Instruments
0 Kudos
Message 4 of 10
(4,940 Views)

OK. But it strange when one function is working and another not. I think it has nothing to do with the program environment - I am calling the library directly. 

And is it possible that the highest output frequency is quite exactly 1 kSa/s? I used the DAQmxWriteDigitalU8 command called continually within one task.

 
David
0 Kudos
Message 5 of 10
(4,940 Views)
(From the manual) Each of the USB-6501 DIO lines can be individually programmed as a static DI or DO line. You can use static DIO lines to monitor or control digital signals. All samples of static DI lines and updates of DO lines are software-timed.
 
What this means is that the output frequency is dependent on software.
--
Michael P
National Instruments
0 Kudos
Message 6 of 10
(4,928 Views)
Well. I read this in the manual as well as in another thread of the digital I/O forum. Actually, I would like to ask you for your experience with this board about the achievable input/output frequency (approximately).
 
Thank you!
David
0 Kudos
Message 7 of 10
(4,926 Views)

David,

Take a look at this KnowledgeBase article: USB-6501 Benchmarks with NI-DAQmx. As it states, the data transfer rates of the NI 6501 are software timed, also called unstrobed or nonlatched, and do not require status and control signals so the transfer speeds are completely software/computer dependant

--
Michael P
National Instruments
0 Kudos
Message 8 of 10
(4,914 Views)

Hello,

 

I was wondering where I can find the DLL for the Windows 7 64bit version.  I was going to installed the latest driver, but am not sure if the DLL will be included.  I might look for it in the system32 directory.  I have written my own driver that works for WinXP, but now that I am running it on Win 7, it fails.  I belive it is a DLL problem.  Any help would be greatly appreciated...

 

Thanks,

 

Steve

0 Kudos
Message 9 of 10
(3,549 Views)

Click on the 'Support' link at the top of the page. You will be taken to a page with a DAQmx link which will take you to the download page with the latest driver.

0 Kudos
Message 10 of 10
(3,513 Views)