5

I am using a DataQ acquisition device in Matlab 32-bit with the Data Acquisition toolbox.

On occasion, when I have my sample rate set to 300, it tells me:

Warning: This hardware could not support the requested value of 300 for SampleRate. SampleRate has been set to 1000"

However, if I set SampleRate to 1000, it sometimes sets it back to 300 with the same error message.

Also, if I set the program so that after the error displays and the device has started recording it returns the SampleRate, this is always at whatever I set it to, not what the program claims it changed it to.

Anyone have any idea how I find out what the actual sample rate was or keep it from resetting mine? I need to know how many samples there are per second for further calculations.

HebeleHododo
  • 3,620
  • 1
  • 29
  • 38
user2312820
  • 53
  • 1
  • 4
  • See Sherryl Radbil's answer [here](http://www.mathworks.com/matlabcentral/newsreader/view_thread/245693). Maybe it will help. What is the maximum sampling frequency supported by the device? You should also account for number of channels you are using for some devices to determine maximum sampling frequency. – HebeleHododo May 10 '13 at 14:22
  • 1
    @HebeleHododo - this appears to concern either a *minimum* sample rate, or a restricted set of valid choices, rather than a *maximum*. – Chris Stratton May 10 '13 at 14:29
  • @ChrisStratton You are right, a restricted set seems more likely. – HebeleHododo May 10 '13 at 14:33
  • If the hardware cannot support the desired sample rate, it may be necessary to use a higher sample rate (preferably an integer multiple of the desired rate) and a decimation filter, ie low pass filter and discard all but every nth sample. If the input is known to be band limited or you aren't too concerned about aliasing, you may be able to just discard all but every nth sample. – Chris Stratton May 10 '13 at 14:36
  • Maybe [this thread](http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/245693) on the MATLAB newsgroup can explain what you are seeing. Is your code similar to that posted in the newsgroup thread? – am304 May 08 '13 at 21:51
  • Hi all, thanks for the help. I don't think its the issue from the first 2 comments, as sometimes each of the sample rates I use is fine. Other times it dislikes either of them...my code is similar to the first thread linked, but the error occurs at 300 sometimes (then it resets to 1000) and also at 1000 sometimes (then it resets it to 300). – user2312820 May 10 '13 at 16:53
  • 1
    Hmm, that sounds like a bug, an issue with not being able to change it once it's set... or possibly a (supposedly?) ongoing concurrent operation which could be locking the sample rate? – Chris Stratton May 10 '13 at 18:59
  • If you have the chance: observe an event with a known duration and then produce the error. This should allow you to find the actually used sample rate with a simple analysis. --- My guess (assuming it is always the same hardware) is that it is indeed reluctant to change the frequency at the moment you try it, but after the msg is shown it will still change anyway. – Dennis Jaheruddin Aug 08 '13 at 08:07
  • We have used the Data Acquisition tool box at work and found it to be riddled with bugs. We eventually gave up and just coded directly to the manufacturer supplied API – PeterM Aug 26 '13 at 23:59

1 Answers1

0

The problem is not with Matlab but with the DAQ. I have a similar "problem" with a NI DAQ. The hardware is set to sample at a very high rate to avoid aliasing. You could sample at a higher rate than required and then use the Matlab command "resample" to reduce your sampling rate. Resample will avoid any aliasing of higher frequencies.

Juan M. Caicedo
  • 1,066
  • 1
  • 7
  • 6