Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help in NI6602/6259 counting in Matlab

Hi,

 

NI 6259  supposed to be a upgraded version of NI 6602, but why do I got faster count rate with NI 6602

than NI 6259 in Matlab?

In the spec, both cards has the same 80MHz clock/timer frequency and they both acheive 2MHz data acquiring rate in NI Max.

However, the fastest rate I can accuire data is 500 kHz for NI6602/ 30 kHz for NI 6259 in Matlab.  If I try to increase rate and frequency above these numbers, the error message 'Data is overwritten before it can be read by the system...' pops up.   

Could someone please help me to improve the performance of these NI counting cards in matlab?

 

I am using matlab session based interface with the following codes for both cards:

 

% the matlab codes start here

s=daq.createSession('ni');

s.addCounterOutputChannel('Dev1', 'ctr1' ,'PulseGeneration');

s.addCounterInputChannel('Dev1', 'ctr0' ,'EdgeCount');

s.addClockConnection('External', 'Dev1/PFI9', 'ScanClock');

s.Rate=500000;  s.Frequency=500000;

data=s.StartForeground();

% the end of the matlab codes

 

 

 

 

0 Kudos
Message 1 of 3
(5,428 Views)

Hello Jzzz,

 

Thank you for posting on the forums. It sounds like everything is working as expected with your hardware. Checking a device’s behavior in NI MAX is a great way help narrow down the problem of your data acquisition system.

 

If your question has to do with The MathWorks, Inc Data Acquisition Toolbox, then please contact appropriate parties at MathWorks- as they will be better equipped to support you.

 

If you are interested in developing your programs in LabVIEW, then I highly recommend looking through the following Getting Started guide:

 

http://www.ni.com/gettingstarted/setuphardware/dataacquisition/

 

MATLAB® and the Data Acquisition Toolbox® are registered trademarks of The MathWorks, Inc.  All other trademarks are the property of their respective owners.

 

Cameron
0 Kudos
Message 2 of 3
(5,412 Views)

Jzzz,

 

I have never seen Matlab for NI forum you were sent to. What we can offer here is the description of task configuration in Labview,  you can find similar settings in Matlab. Interface is provided by NI, approach and configuration parameters (including names) should be very similar.

 

I do not see a couple things in your code that are required to configure hardware buffered acquisition in Labview:

In counter input:

Type of buffer for acquisition: Finite or Continuous (curcular buffer)

Buffer length. If buffer is overflowing (you are not reading fast enough), this is usually an error. (Very similar to your message)

In counter output:

The same, continuous or finite generation

Overall configuration:

DAQmx in Labview operates using "tasks", it seems it is the same as sessions. I have never used generation and acquisition in one task: One task generates pulses, the other task reads whatever is coming. I can control them  (start, stop, set timing) independently. If needed to synchronize them, set triggered read start.

 

Also you can ask to help you configure counters for your task in LabWindows/CVI part of the forum  It should be even more close to what you see in Matlab. And do not mention Matlab not to confuse 😉

 

0 Kudos
Message 3 of 3
(5,186 Views)