0
\$\begingroup\$

I have a question about LTSpice. I put a Sample & Hold block in a sheet to quantize a continuous sine signal like below: enter image description here But the resolution is not desired. I have a 16-Bit ADC with a 1v reference voltage. even I changed the spice lines and opened the SAMPLE.asy symbol but I really couldn't find any solutions.

Thanks


@andy-aka I really appreciate you for your reply. (due to my low reputation I couldn't upvote for you) Yes. I had forggoton the principle :) actually N=Fs/F. so we have N=10Meg/1Meg=10 points per each cycle. enter image description here

if it's possible I have an another question :) when the ADC resolution is Vref/(2^16), can I implement it in LTspice like below:

Vres=Vref/(2^16)
out=int(Vin/Vres)
if abs(Vin)>=Vref
Vin=1
end
\$\endgroup\$
  • \$\begingroup\$ If it still matters, the reference is set with ref=<...>, default 0.5 (right-click on the symbol, add it to one of the four lines). But you're also talking about quantization, which is not achieved with an S&H (it will always have infinite precision, or machine-precision). You could add a behavioural source for this, int(V(x)*2**N)/2**N for example, but accuracy will be lost with to many steps, even with opt plotwinsize=0 and imposed timestep, because LTspice can only go so far given a certain dynamic range. 16bit could be done, but with care and patience (it will be slow). \$\endgroup\$ – a concerned citizen Aug 7 '17 at 5:56
  • \$\begingroup\$ I added ref=0.001 or ref=1 to one of the four lines biu I couldn't sense anything :) \$\endgroup\$ – user159141 Aug 7 '17 at 15:28
  • \$\begingroup\$ That's because you are referring to the reference voltage for the sampling clock. In your case, the rise/fall times are 1ns, so you won't really see any difference. There is no reference voltage for the analog input; it doesn't make sense in an S&H block, the signal is sampled when the clock reaches a threshold. BTW, unused inputs may be left floating (i.e. there's no need to ground the - input). Also, AC 1 will not have any impact, A-devices do not allow AC analysis. \$\endgroup\$ – a concerned citizen Aug 8 '17 at 6:03
  • 1
    \$\begingroup\$ Please don't vandalize your posts. \$\endgroup\$ – Glorfindel Oct 20 '17 at 8:33
  • \$\begingroup\$ your users are not polite. most of the time they don't put an answer and give me negative points. I'm deleting my questions and leaving here completely. \$\endgroup\$ – user159141 Oct 20 '17 at 8:36
1
\$\begingroup\$

You will have perfect resolution with this circuit but you are seeing the effects of sampling at exactly 10 samples per sinewave. If you lowered the sinewave input frequency by ten you would see ten times as many samples in a cycle of sinewave and you will see many more points of resolution.

Alternatively, if you altered the sinewave frequency by just a little bit and looked at many cycles you would also see many more points of resolution. At the moment all your sample points are hitting the same parts of the sinewave and making you think your resolution is bad (but it isn't).

The sinewave below has been sampled 26 times in a cycle and you can see that there are more points with tighter resolution: -

enter image description here

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I really appreciate you for your reply. (due to my low reputation I couldn't upvote for you) Yes. I had forggoton the principle :) actually N=Fs/F. so we have N=10Meg/1Meg=10 points per each cycle. \$\endgroup\$ – user159141 Aug 6 '17 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy