Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Adressing Counter/Timer of PCI-6023 with MatLab

I'm using the data acquisition card from National Instruments (PCI-6023) together with MatLab. For my intended purpose I have to create a TTL Pulse with a accuracy in timing of about 1 micro second. A precise time period  after this pulse I want to start the data acquisition.
As the timing must be precise I want to use the two hardware counter/timer on the DAQ card. Sadly MatLab doesn't support the adressing of the counter/timer directly, but it should be possible using "generic dll calling" and that's the point where I'm in need of help.
I tried to figure out how this generic dll calling works but couldn't get it running. In the following I describe what (I think) I've done:

1. loading the nidaq32.dll together with the header files nidaq.h and nidaqcns.h
MatLabcode> addpath(['C:\Programme\National Instruments\NI-DAQ\Include'])
MatLabcode> loadlibrary 'C:\WINDOWS\system32\nidaq32.dll' 'nidaq.h' addheader nidaqcns

2. Calling the function "CTR_Pulse" which should generate after 4s a pulse with a duration of 2 s
MatLabcode> deviceNumber= 1;
MatLabcode> ctr= 0;
MatLabcode> timebase=5;
MatLabcode> delay= 400;
MatLabcode> pulseWidth=200;
MatLabcode> calllib ('mynidaq', 'CTR_Pulse', deviceNumber, ctr, timebase, delay, pulseWidth)

After calling the function I just get back a number (-10403), but cannot meassure any voltage change on the counter 0 out. The voltage stays around 5 V.
As I don't get any error message it's hard to solve this problem.

Did I miss calling some important function or where is my problem? I'm glad for any help!

Thanks and best regards

Frank Muehlbaue
0 Kudos
Message 1 of 3
(3,774 Views)
error -10403 means that the selected device can not perform this typer of operation, this means that either the device number is invalid, or one of the parameters. Your parameters look good from my point of view, so maybe the device-number is not correct? have you checked the device-number in MAX?
 
Here you can find an ANSI C example for pulse generation:
0 Kudos
Message 2 of 3
(3,757 Views)
Thanks for the reply, but the device number seems to be alright. I've checked it with Max and with a Matlab command. What else could be the problem? Any advice would be great.
0 Kudos
Message 3 of 3
(3,745 Views)