Issue with DAQ rms measurement variation with frequency

NI USB-6210 DAQ.
Agilent 33220A Function Generator.
Sampling rate = 125 KHz.
Setting function generator amplitude to 0.3VPP sine wave at given frequency.
Sampling 20 periods minimum.
Using rms() to calculate RMS value of signal.
20-100Hz... looks good - only about 0.02mV variation:
500Hz-20KHz looks OK - about 0.3mV of variation total.
...but ~100Hz-500Hz shows WAY more variation - 0.7mV across 400Hz, and seemingly random noise.
Full spectrum for comparison:
Changing sample rate and/or number of samples seems to have no noticeable effect.

Answers (1)

How exactly did you make these plots? PLease explain your sampling protocol and calculations in more detail. That will help identify the source of variability.
The horizontal spacing of the data points in the plots suggets logarithmically spaced frequencies, which should be accounted for by the description of the sampling protocol and calculations.
What is plotted on the x-axis, including units? Frequency in Hz? I recommend scaling your embedded figures (plots) so they don't extend far beyond the typical viewing window. The last plot shows x= 0 to 2. Is there a factor of 10^4 that was cut off?
If you take a constant number of samples at a constant sampling rate, for each frequency on the signal genrator, then you are likely to get more variation in the rms value at low frequencies, because you are likely to have a non-integer number of cycles, and the fractional cycle (which leads to variability in the rms estimate) will be a bigger fraction of the total complete cycles, at low frequencies. This would explain why 100-500 Hz is more variable than 500 Hz - 20 kHz, but would not explain why 10-50 Hz is less variable than 100-500 Hz.
The variation in rms value at different frequencies could be due to (a) variations in the sine wave amplitude as frequency changes, or (b) frequency-dependent random noise. Option (b) means that the sine wave amplitude is 0.200000 V at all frequencies, but there's also a small Gaussian noise component, whose power depends on the frequency setting of the signal generator.
Even at the worst frequencies, the variation in rms value is quite is small. Are the variations reproducible functions of frequency? In other words, if you rerun your experiment 10 times, are the "bad" (i.e. more variable rms value) frequency ranges the same, every time? I'm asking because maybe you are observing time-dependent random fluctuations. If that is true, then the "bad" frequency ranges may be different on different passes.

4 Comments

"PLease explain your sampling protocol and calculations in more detail."
Frequencies are 20-20480 (10 octaves) at 10 samples per octave (20, 22, 24...40, 44, 48...80, 88, 96.., etc.)
%Calculate number of Samples
ReadTime=20*(1/freq);
if (ReadTime<.2)
ReadTime = 0.2;
end
SampNum = ReadTime*125000;
SampNum = round(SampNum);
%Set Function Generator
app.myFGen.Frequency = freq;
pause(0.1);
%Read DAQ
data = read(app.DAQ,SampNum,"OutputFormat","Matrix");
data_rms = rms(data);
"How exactly did you make these plots?"
Just a dumb command line plot - attempting to debug the issue.
plot([app.TestTable.Freq],[app.TestTable.rms_in])
"What is plotted on the x-axis, including units? Frequency in Hz?"
Correct - Frequency in Hz, 20-20480. Y-axis is RMS voltage in volts.
"Are the variations reproducible functions of frequency?"
Yes... across dozens of runs, the variability is always significantly higher in that region.
There is no directional consistency though - for example, 104 Hz might be well above the meanline one run, and well below it the next run. ... so averaging does work.

Aaron? Thanks for the info. For frequency <=100 Hz, ReadTime is exactly 20/freq, i.e. exactly 20 cycles. The rms value varies little since you sample an exact integer number of cycles. For frequency >100, the sample time=0.2 s, so there’ll be a non-integer number of cycles. The phase of the signal when you start sampling is basically random, since you don’t sync your acquisition with the phase. So you get a partial cycle, from a random part of the waveform, with each acquisition. This adds variability to the rms value. But there are more exact integer cycles in the sample when freq is high, so the noise from the fractional cycle is smaller at high freqs. This explains your observations.

Bingo. Going to an even number of cycles for all frequencies cleaned up the noise. Thank you!
Great that you fixed it!
I simulated your data aquisition 100 times, using random phases, and plotted the rms values (script attached). There are 100 rms values shown at each frequency. The scatter of the points looks similar to what you were getting.

Sign in to comment.

Products

Release

R2023a

Asked:

on 14 May 2025

Commented:

on 15 May 2025

Community Treasure Hunt

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

Start Hunting!