1
\$\begingroup\$

I try to use the Sample and Hold function, to show its output on the spectrum analyzer. But it gives me this error "Spectrum cannot be displayed for continuous or infinite sample times", while I dont have infinite, not continuous sample times. The scope shows the output just fine thought.

Sample and hold spectrum analyzer issue

I want the output of my "Sample and hold" block to be shown on the spectrum analyzer.

EDIT:

@Tony Stewart EE75 is right. For some reason the pulse generator for the "Sample and hold" filter behaves like a real pin's output, and if a higher output frequency is used for the trigger, it starts losing its shape.

Here are the settings that can work the simulation just fine (I lowered the trigger frequency to 1900):

Sample and hold spectrum analyzer

And here below one can notice two things:

  1. that I have increased the frequency of the PWM output for the trigger, and the pulse is not square anymore.

  2. Even though I have increased the frequency of the trigger, because I opened a new MATLAB window, the spectrum analyzer works now! So the previous window was bugged.

Sample and hold spectrum analyzer unbugged

Someone who had the same issue as me: https://www.mathworks.com/matlabcentral/answers/296993-how-can-i-generate-a-high-frequency-signal-with-simulink

\$\endgroup\$
2
  • \$\begingroup\$ did you try a non-zero sample time? \$\endgroup\$
    – D.A.S.
    Commented Apr 29, 2022 at 12:30
  • \$\begingroup\$ Yes, I tried various values, 1/200e6 was a good one for the waveform, but no difference on the spectrum analyzer. \$\endgroup\$ Commented Apr 29, 2022 at 13:32

1 Answer 1

2
\$\begingroup\$

You must have a setup error in Matlab for your external square wave or pulse clock frequency and duration of sample. You show 0 time which appears to be continuous.

The Scope will have a very fast S&H and ADC but you have shown a simple S&H but no specs for clock rate or sample duration.

I can demonstrate a different simulator with a variable 2f to 1kHz sampling clock with just an RC filter and variable sample duration.(d.f.)

enter image description here

Note that unless you over-sample by a great ratio, you will need a Nyquist (anti-alias) sampling-noise-blocking LPF filter. You can see why when the frequency slider is towards the left.

Note that I chose 100 Hz sine and 201 f-min so you could see amplitudes change (Max=...) as Nyquist rate of 2f only preserves 1f content exists but does not preserve amplitude or distortion products unless synchronized somehow in phase or peak detect with the signal.

The switch has a capacitance load so memory errors exist with a transient output on S&H. So it depends on how you do the S&H. This simple method obviously lacks a buffered hold value between samples.

This 2 stage S&H effectively works as another LPF on the spikes from the previous values during sampling.

\$\endgroup\$
2
  • \$\begingroup\$ I think you are right, the output of the pulse generator is not always square. Its square if I lower its frequency enough (which should not happen in a matlab's simulation...). \$\endgroup\$ Commented Apr 29, 2022 at 14:03
  • \$\begingroup\$ The hold occurs on the trailing edge of the pulse so, it doesn't matter that much as long as you have >10T settling time. So the pulse width matters for settling times.. \$\endgroup\$
    – D.A.S.
    Commented Apr 30, 2022 at 18:48

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.