Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

"Timeout expired before operation could complete" while using NI-9423 in Matlab

Solved!
Go to solution

Hello,

I'm trying to read data from Digital Module NI-9423 installed in a CompactDAQ chassis cDAQ-9191. I have simple photoelectric sensor connected to NI-9423. 

I'm running following comands in Matlab (I named my device "net1" in NI MAX and have my sensor connected to port0/line0):

 

s = daq.createSession('ni')
s.addDigitalChannel('net1','port0/line0', 'Inputonly');
addClockConnection(s,'external','net1/PFI0','ScanClock');
data = startForeground(s);

This simple code keeps giving me "Timeout expired before operation could complete" error.

 

In NI MAX test panels everything works fine. State is changing in right port and right line when I'm putting something in front of the sensor. I can also run command in Matlab:

inputSingleScan(s)

and the answer is presented with no problems (1 when there is something in front of the sensor and 0 otherwise). But i need to work with real time data collected with startForeground command.

 I also tried simulating exactly the same configuration (NI-9423 installed in cDAQ-9191) in NI MAX and tried to work with simulated device in Matlab, running the same code as posted above. This approach works fine, I'm getting matrix "data" with zeros and ones alternately, exactly how it is presented in test panel of simulated device. But of course I need to work with real device and real data.

Can someone please tell me what I can try to fix my issue?
Any help would be greatly appreciated.  

PS. Here is output of command getVendors in Matlab containing my version of Matlab and NI driver version:

>> daq.getVendors

ans = 

Data acquisition vendor 'National Instruments':

            ID: 'ni'
      FullName: 'National Instruments'
AdaptorVersion: '3.13 (R2018a)'
 DriverVersion: '17.6.0 NI-DAQmx'
 IsOperational: true

 

0 Kudos
Message 1 of 2
(3,120 Views)
Solution
Accepted by topic author vector818

I figured it out by myself. I made very simple mistake, just added wrong clock connection.
If you have similar error try running command terminals and use other terminal to clock connection. For example I modified my clock connection:

addClockConnection(s,'external','net1/100kHzTimebase','ScanClock')

And now command:

data = startForeground(s);

works just fine.

0 Kudos
Message 2 of 2
(3,078 Views)