1
\$\begingroup\$

I am currently using AD9833 to output a sine wave signal. I have seen the sine wave signal on oscilloscope and saved a CSV file on my flash drive.

I plan on using an Excel or Matlab to determine the stability of the sine wave peak to peak voltage, but the issue is I have never done this before. I have always used an oscilloscope peak-to-peak voltage measurement.

Can anyone please tell me how you would determine the stability of the peak-to-peak voltage using Matlab or Excel.

I hope to hear your response.

\$\endgroup\$
7
  • \$\begingroup\$ Find maximum value in every period ( after some filtration if data are noisy of course). \$\endgroup\$
    – user208862
    Dec 1, 2021 at 21:26
  • \$\begingroup\$ Look for the MAX value and the MIN value. The difference is your p-p value. \$\endgroup\$
    – Kartman
    Dec 1, 2021 at 21:27
  • \$\begingroup\$ @Kartman that is a very numerically unstable estimator, and not usually what oscillloscopes do (they do apply some smoothing) \$\endgroup\$ Dec 1, 2021 at 21:32
  • \$\begingroup\$ Excel can mathematically generate sine wave. Not only that, the generation of the sine wave can be synchronized to the sampled data. Not only that, Excel can generate statistical analysis, error detection, and etc etc. Well, basically, you can write whole simulations and analysis without Matlab, almost. Extreme end, I wrote a proprietary assembler/compiler using Excel. \$\endgroup\$
    – jay
    Dec 1, 2021 at 21:36
  • 1
    \$\begingroup\$ @jay Is it OK if I say that this is an awesome display of enthusiasm, but Excel should probably not be the tool of choice if people have access to Python or Matlab? Because, honestly, it is an awesome display of enthusiasm, but people who don't know about the things you can do incorrectly in excel will have an easy time making mistakes, and also, generating a 100000 point sine in anything else is trivial, but in Excel, it's a RAM exercise and an exercise in extending a formula over 100000 cells... \$\endgroup\$ Dec 1, 2021 at 21:39

1 Answer 1

0
\$\begingroup\$

I'll go ahead and assume that as you said, you care about stability, not about the actual peak-to-peak values (which really are just min() to max()), because these are just noisy and not a good estimator, especially if your signal is oversampled significantly (which it probably is).

So, let's talk about how we can understand "oscillation amplitude stability" in frequency domain:

If the sine wave's amplitude changes, then it's not an unmodulated sine wave anymore .

This means it has no longer a pure line spectrum.

So, the solution is quite straightforward: do a frequency analysis, with high resolution. Determine the bandwidth of your signal.

This exact measure is called linewidth (for the line spectrum reason mentioned above) in lasers! It's the main measure for "clean-ness" of the oscillation.

Spectral lines Origin of the term line width: spectrum of a chromatic emitter. The lines that are wider happen because the oscillating things (in this case, the energy levels between which electrons are exchanged, leading to photon emissions) are less well-defined, whereas the narrow lines happen because the energy of an oscillation is very well-defined. Source: Wikimedia, "Emission Lines", Author: stkl.


as an aside:

saved a csv file on my flash drive.

CSV is kind of the worst-case file format here. If you have any better format, you'd get less rounding errors, and smaller file size. Rounding errors also lead to a broadening of your bandwidth.


on matlab or excel

Excel is really not the tool for signal analysis! I've seen engineer fight with excel because they were afraid to start matlab or python, and then regret it very much once someone came around that did a better analysis with less error in much shorter time.

In Matlab, you'd load your data (using the appropriate file reader for your specific file format / CSV dialect), and then you'd just do a spectral estimation on your data. In a simple case, that might just be plot(abs(fft(data))), but that's typically not a great way to go about this, because the accuracy is severely limited when your sine's period is not exactly a factor of length(data) (otherwise, the mathematical effect called leakage happens). pspectrum might be your friend!

Personally, I'd go for something more involved: I know there's exactly one sine in my spectrum. I know the frequency only roughly, and I don't want to risk leakage as described above. So, I first estimate the fundamental frequency as precisely as possible, and then I look for the the bandwidth around that main frequency that contains 90% of the overall signal power. If that bandwidth is high, your tone is instable. If the bandwidth is low, it's very stable.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.