Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Use M-Series cards with DAQmx in Matlab!

Jens,
From what I've seen it is because you can't perform analog inputs from multiple threads.  You also can't read separate channels at separate times when in the same thread.  It appears to be limitations of the NiDaq driver or API.  I haven't been able to find any info in documentation though to back up my thoughts.

Example of failure:
disp('NI: Create Tasks')
taskh1=uint32(1);
[a,b,taskh1] = calllib('myni','DAQmxCreateTask','',taskh1)
taskh2=uint32(1);
[a,b,taskh2] = calllib('myni','DAQmxCreateTask','',taskh2)

disp('NI: Create AI Channels')
taskchans1=['Dev1/ai0'];
taskchans2=['Dev1/ai1'];
[a,b,c,d] = calllib('myni','DAQmxCreateAIVoltageChan',uint32(taskh1),taskchans1,'',-1,-10,10,DAQmx_Val_Volts,'')
[a,b,c,d] = calllib('myni','DAQmxCreateAIVoltageChan',uint32(taskh2),taskchans2,'',-1,-10,10,DAQmx_Val_Volts,'')

disp('NI: Start task(s)')
[a]=calllib('myni','DAQmxStartTask',taskh1)
[a]=calllib('myni','DAQmxStartTask',taskh2)
0 Kudos
Message 41 of 106
(4,885 Views)
Jens, thanks for the tip, but it seems this isn't it. I tryed with differend refresh rates (from 10Hz to 300Hz, including 150Hz), tryed to set the falling edge, finite samps instead of continous....but allways with the same result.
 
Anyway i guess i will try some more combinations....if you come with something new, let me know 🙂
 
Peter
 
0 Kudos
Message 42 of 106
(4,871 Views)
Whenever I attempt to use the NImess code, all that is returned to me is matrix of ones.  I've used the code that Andreas Kapp posted on the Central File Exchange at the Mathworks and that works fine for one channel, but when I try to add additional channels, it doesn't work.  I'm using MATLAB r2006a.  Any ideas as to why this would be happening?  I've set samptime as 3 seconds, but each time I run with multiple channels, the elapsed time is less than 0.02 seconds.  So it's not even recording data.
0 Kudos
Message 43 of 106
(4,787 Views)
Hi Vince,
I'm really very sorry to get back to you so late, I totally forgot this! 😞
Well, I do not know what your problem is, you should really get some kind of error code with it.
I assume you used Andreas' code?
Have you tried with my original version on
www.jr-worldwi.de/work/matlab/index.html
?

Best of luck

Jens

Message Edited by Jens_DE on 01-30-2007 04:50 PM

0 Kudos
Message 44 of 106
(4,727 Views)

Hi Vince,

 

I had the same problem when i tryed that code (dont know why, but i got only ones in the data array). I realized i had to put this line before starting the task.

err = calllib('ni','DAQmxTaskControl',task1,DAQmx_Val_Task_Commit);

 

Hope it works for you too.

 

Peter

Message 45 of 106
(4,708 Views)

Peter,

I tried adding that line of code and got an error in MATLAB

??? Error using ==> calllib
Parameter must be a number.

Error in ==> TestDAQCard2007 at 73
err1 = calllib('nicaiu','DAQmxTaskControl',taskh1,DAQmx_Val_Task_Commit);

I've attached my code (Andreas' code with minor changes).  I appreciate the help.

0 Kudos
Message 46 of 106
(4,685 Views)

Jens,

I get error code -200089 when I try to create the task, then receive -200088 for what looks like every other operation I try to perform.

Again, using MATLAB R2006a and NI USB-9162.  Robot Sad

Message Edited by Vince B on 02-13-2007 06:01 PM

0 Kudos
Message 47 of 106
(4,633 Views)
Hello Vince,

If you go to the Help menu in LabVIEW and select Explain Error... you should be able to find more information about the error codes you are receiving. For example, error code -200089 gives the following explanation:

"Error -200089 occurred at an unidentified location

Possible reason(s):

Task name specified conflicts with an existing task name."

This would indicate that you are trying to create or a reference a task that already exists. You can find more information about the creation and destruction of DAQmx tasks here. I would also recommend a brief tutorial called Creating a Task in NI-DAQmx and Using it in LabVIEW as well as this document ragarding DAQmx programming.

The second error message you are receiving has the following explanation:

"Error -200088 occurred at an unidentified location

Possible reason(s):

Task specified is invalid or does not exist."

Based on your description, I would guess that this error is a result of the previous error (-200089). The task is not created because there is an error. So, when you try to reference the task later in your program, you receive an error indicating that the task does not exist. I would recommend that you resolve the first error, which should take care of this error as well.


Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 48 of 106
(4,602 Views)
Matt,

I was able to get the program to run last night after upgrading from MATLAB R2006a to R2006b.

Thanks, everyone, for all of you help.

-Vince
0 Kudos
Message 49 of 106
(4,590 Views)
Hi Vince!
I'm glad you got it to work!
I just tried with 2006a and no problems for me. Weird...
Maybe a problem that just occurs with certain NIDAQmx.dll and Matlab combinations?

Jens
0 Kudos
Message 50 of 106
(4,584 Views)