Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 9401 problems using 2 channels simultaniously (matlab)

Solved!
Go to solution

Hello,

 

sorry for my English, it's not my first language.

 

I connected two photoelectric sensors with the NI 9401 (Slot 0 and 1) and now i want to measure with them simultaniously.

Here is the code I use to do that:

-------------------------------------------------------------------------------------

%Lichtschranke 1

l=daq.createSession('ni');

addCounterInputChannel(l,'cDAQ1Mod5',0,'EdgeCount'); %Auf NI 9215(BNC) zugreifen

datal=inputSingleScan(l);

l.DurationInSeconds=10;

l.Rate=10000;

[datal,time]=s.startForeground();

 

 

%Lichtschranke 2

m=daq.createSession('ni');

addCounterInputChannel(m,'cDAQ1Mod5',1,'EdgeCount'); %Auf NI 9215(BNC) zugreifen

datal=inputSingleScan(m);

m.DurationInSeconds=10;

m.Rate=10000;

[datam,time]=s.startForeground();

----------------------------------------------------------------------------------------------------------------------

 

I always get the same kind of error message:

Error using Routine1 (line 35)
The hardware associated with this session is reserved. If you are using it in another session use the
release function to unreserve the hardware. If you are using it in an external program exit that
program. Then try this operation again.

 

Is there any way to use 2 counter inputs at the same time?

 

Thanks for your help.

0 Kudos
Message 1 of 7
(3,857 Views)

Hello LexlRexl,

where did you connect the 9401 to? A cDAQ Chassis, I guess from the code, but which one??  Which drivers have you installed?

Can you talk to the modules in MAX? How many tasks do you run simultaneosly?

 

Guessing right into the blue this will be the source of your error:

How Many Different Tasks Can Concurrently Run on a CompactDAQ Chassis Gen II? - National Instruments
http://digital.ni.com/public.nsf/allkb/5E0B829E50ADE1BC86257AC50062B2D2

 

We need a little more info to help you out there, besides the fact that it is a matlab problem and matlab is really not made for hardware acquision Smiley LOL

Cheers, Niko

Niko NR
Systems Engineer, National Instruments
0 Kudos
Message 2 of 7
(3,776 Views)

Heyho,

 

i connected the 9401 to a Chassis (917x) and i am using a big Multidriver (was a download off 2GB or so).

I can tell you the exact facts tomorrow, when i visit my university again

 

 

0 Kudos
Message 3 of 7
(3,772 Views)

Hello NikoNR,

 

sorry for my late answer, i have been very busy the last few days.

I connected the NI 9401 to the NIcDAQ-9172. I can talk to the modules in Max and i want to run 2 tasks simultaneosly (with the NI 9401, i run another task with the  NI 9273 on the same chassis).

The first Task (NI 9273) is a strain measurement on a fullbridge with a force measuring dose (I have no problems with that).

My 2nd and 3rd Task is to measure the voltage on two different channels. It is not working the way I wrote it in the beginning of my thread.

My Prof. told me to try to use it as a digital channel, but he is not sure. Can that work? How can i run it as a digital channel? What is the easiest way to measure the voltage with MatLab on two different channels?

 

Cheers, Alex

0 Kudos
Message 4 of 7
(3,747 Views)
Solution
Accepted by topic author LexlRexl

Hi Alex,

have you looked at my link? There is a table with  # of Tasks per Module which states that you can only have 1 taks per module. So if you want to use several of the inputs, you have to combine them in one task...

Cheers, Niko

Niko NR
Systems Engineer, National Instruments
0 Kudos
Message 5 of 7
(3,737 Views)

Heyho Niko again,

 

thank you for your help. I put all of my tasks into one. I have one last question:

 

Is this the correct way to setup my device and to obtain data (voltage + timesteps) via this method?

https://de.mathworks.com/help/daq/digital-input-and-output-workflow.html

 

cheers 🙂 and thank you for your help so far

0 Kudos
Message 6 of 7
(3,727 Views)

Hi Alex,

I am glad that it worked out for you so far. 

The workflow looks correct to me, although I can't help you with fore-ground and back-ground operations. i never used that, so I have no experience in there. The rest looks just like it should.

As always: posts marked as solution and/or kudos are very wolcome 😃

Cheers, Niko

Niko NR
Systems Engineer, National Instruments
0 Kudos
Message 7 of 7
(3,695 Views)