# A question on adding noise and low-pass filer in Ltspice

I’m planning to implement the following Schmitt-trigger circuit: (left-click to enlarge)

I made some updates with the great suggestions of jonk in my previous question:Some questions on optimizing a Schmitt trigger to eliminate possible glitches.

But now I have two points bothers me regarding these kind of circuits here:

1-) First of all, I just learned that one can add a noise to a signal as in the following way by using behavioral current:

Above a white noise is added to a 4Vpp 10Hz sinusoid.

But in my circuit the switch causes the input signal so wherever I add this current source I get very weird results. I just want to add around 2Vpp white noise to the inverting input of the comparator(Schmitt-trigger in this case) to see the effects of hysteresis band. How can I establish it in this case? How can I add the noise so that it adds up to the signal at inverting input?

2-) Second might sound a bad question for many of you but lets say I want to block frequencies for the signals arriving to inverting input higher than 900Hz. Would you calculate the cut off frequency just by using R9 and C1? Or R7, R9, R10 should also be taken into account when calculating low pass filter’s cut off effect here? (By the way it seems to me in hysteresis equations the resistors connected to the inverting input should not have effect on hysteresis thresholds)

• you cuold right away use a voltage source with a formula including sine and white noise. Also note that white noise is depending on the timestep, so set a low minimal timestep. – PlasmaHH Oct 7 '16 at 10:23

For your first question: the voltage source has specified a resistance. In parallel with it, there's a current source which, by default, outputs a 0.5Vpp signal (the white() function). This means that this current is generated onto the (now) parallel resistance, Rser, resulting in a R*I amplitude. Therefore, Rser will set the amplitude of the noise. In your case, $R_{ser}=3 => 3 * 0.5 = 1.5V_{pp}$. If you need $2V_{pp}$, simply add an $R_{ser}=4\Omega$.

For your second question: the white() function generates a flat bandwidth that starts dropping at around 2*f_specified, when it's some 6dB lower. That's why you have white(2*f*time). So, the easiest approach would be to simply set your noise source for white(2*900*time). If, on the other hand, you need a lowpass filter, then, besides the obvious R8+C1, you also have R7+R_CE(Q1), to which you can also consider R8+R10+R(D3). D1 and D2 also have some parasitic capacitances, but they won't matter here. Still, R8||[R10+R(D3)] will make a voltage divisor with R7, soo they won't matter as much, provided you keep R9 much larger than R7 parallel with the whole dynamic resistance (impedance) of Q1&co. A 10k should be fine. Then, a simple 1st order is calculated with: $\omega=2\pi{f}=\frac{1}{RC}=>C=\frac{1}{2\pi{f}{R}}=\frac{1}{2\pi{900}*{10k}}=17.68n$. Choose an 18nF. To berify this, here's what LTspice has to say:

The input is reduced a bit by the previously mentioned divisor, plus there's a minor "shelf" filter due to interaction, while the final RC does the job.

Edit: Forgot to add that for your noise to be correctly displayed and calculated in LTspice, you'll need at some 10 times its highest bandwidth, so if your highest frequency of interest is 9kHz, then make your timestep as 1/90kHz. As per the suggestion in the comment, you can use a behavioural source, directly, incorporating the signal and the noise. For my part, unless it's just some quick sketch, I'd advise to only use behavioural sources when they absolutely cannot be replaced, as they have an inherent dynamic range loss (for orders of magnitude difference) due to their calculation "on the fly" of any point that is time-dependent, and they add quite the burden of computation, even when used with the undocumented flag nojacobi. Of course, the choice is entirely yours.

I'll add one more thing: for noise and, in general, for "delicate" low/high frequencies, .opt plotwinsize=0 should be a must, to preserve the waveshape.

• many thanks for the detailed answer. im not an advanced user of LTspice and cannot find a good manual or book to learn such advanced features. regarding your 10k choice for R9 i wanted to draw what i understand from your transforming the circuit step by step without considering any diode or transistor. here is what i draw: postimg.org/image/5nsa6gsrd . using thevenin the equivalent resistor network before R9 becomes 250ohm so R9 can be 2.5k by rule of thumb. but u say 10k i think since there will be resistance from diodes and transistor. i hope i got you right. – user16307 Oct 7 '16 at 21:44
• one more question the 390pH caps in my circuit causes sudden jumps on non-inverting input. here it shows the issue: s15.postimg.org/h51yz034b/nossssitled.png do you think i really need those 390p caps? – user16307 Oct 7 '16 at 21:44
• @user16307 The 10k was just a guess, rounded up, to the nearest decade :-) , use whatever gives you the best results. As far as I see, you could give up the resistor completely and simply use the equivalent resistance of the whole circuit behind. As for the caps, well, their purpose is to limit the dV/dt, act like a filter, smooth out the switching waveforms, but if they get in your way, they're not a must. If you do need them, you could add some series resistance. Still, I think it's the LED that's the culprit, with it's capacitance (4148 has low capacitance). I could be wrong, though. – a concerned citizen Oct 8 '16 at 5:41
• i checked with simulation, LED's existence did not have any effect. C3 looks like it doesn't cause those voltage jumps. but if i reduce C4 to 39p or totally remove it there is no more jumps anymore. regarding dV/dt, is there a general approach to set those C3 and C4? I mean how do we determine their values? Do they depend on the resistor values they are in parallel with? – user16307 Oct 8 '16 at 13:12
• @user16307 They just form a lowpass, 1/(2piRC). If they get in your way, just remove them, they're not fixed in stone. But be sure to make this decision after real-life measurements. The same goes for the LED: be sure to use a good model for it, they usually have higher parasitic capacitance, but that's not a rule nowadays. – a concerned citizen Oct 8 '16 at 16:28