MATLAB Answers

How to increase ScansAvailableFcnCount when using MATLAB to control NIDAQ

17 views (last 30 days)
Shengjie Gao
Shengjie Gao on 7 Sep 2020
Answered: Noah Rubin on 3 Mar 2021
Hey guys,
I am currently trying to use MATLAB to control a NIDAQ (usb-6255) to collect data from my sensor. I want to do real-time plotting while collection the data.
I understand it is a good idea to use a callback function to do the plot like this
dq.ScansAvailableFcn = @(src,evt) plotDataAvailable(src, evt);
I just notice the default ScansAvailableFcnCount is set to a value that the plotting function above will be called 10 times a second (10Hz). My question is: Is there any way to increase the frequnency? I found it is easy to increase the ScansAvailableFcnCount so that the plotting function can be called less than 10Hz. However, when I decrease this value below 0.1*dq.Rate, it will say (here dq.Rate=300)
At the specified rate, the minimum count
allowed is 31.
Thank you very much!

Answers (2)

Anmol Dhiman
Anmol Dhiman on 13 Sep 2020
Hi Shengjie,
Refer to link under Set ScansAvailableFcnCount to change the value for ScansAvailableFcnCount.
Regards,
Anmol Dhiman
  7 Comments
Anmol Dhiman
Anmol Dhiman on 3 Mar 2021
Hi Noah,
This seems to be very specific use case. This might need more follow up and discussions, hence I suggest you to contact Technical Support.

Sign in to comment.


Noah Rubin
Noah Rubin on 3 Mar 2021
Hi Anmol,
Thank you very much for your reply!
To clarify though, the only issue that is actually preventing us from sampling at a higher rate is the fact that we we have:
Fs = 3000;
dq.Rate = Fs;
nSamples = 0.02*Fs;
dq.ScansAvailableFcnCount = nSamples;
Given that Shengjie, Mauro, and Agostina all had the exact same issue as well-- a 10 Hz read limit exactly for everyone involved in this thread-- I do not believe this is an issue arising from our own use case. Unless I am misinterpreting line 1514 in my earlier screenshot, the 10 Hz limit is being set within the source code itself.
Given that we also have our setup working perfectly with the old toolbox, this convinces me further of that possibility.
If you have any other information, it would be greatly appreciated. I am happy to contact technical support if needed.
Thank you again for your time!
Noah

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!