Trouble with rectifying a pulse with a diode

I'm trying to obtain a pulse from a square-wave of a function generator. I thought it is an easy straightforward thing. So in this case the square-wave is +5V to -5V. I use a 1N4001 diode and a 220 Ohm series resistor.

As you see in the below simulation output will go to a comparator's input. Green plot is the output voltage (Out): (V1 represents the function generator)

But I'm having those negative spikes during falling edges both in scope and in simulation.

My questions are:

1-) How can I prevent those negative spikes? I need around zero volt during OFF time of the pulse without such spikes. Why do these spikes occur?

2-) Is 220 Ohm okay or better to use 50 Ohm? (Im asking because at the output of the function generator it is written 50 Ohm)

• Have you tried different diodes? Your frequency isn't that high but 4001 isn't very fast either. – winny Jun 15 '16 at 10:59
• You might want to try familiarizing with how diodes work in real life, what parameters matter and what those are for the specific diode you have at hand – PlasmaHH Jun 15 '16 at 11:02
• If all you're trying to do is get a positive pulse from a function generator, surely you could just adjust the function generator's offset knob such that its square wave output is centered at half of the output amplitude (2.5V for a 5V pulse)? – brhans Jun 15 '16 at 11:15
• how about adding a small (470pF or something like that) cap to smoothen the edge off your signal. Btw. how you got LTSpice to show these negative spikes. For fun I tried your model and I dont get them to show up. – KarlKarlsom Jun 15 '16 at 11:49
• @KarlKarlsom the diode is: .model 1N4001 D(Is=14.11n N=1.984 Rs=33.89m Ikf=94.81 Xti=3 Eg=1.11 Cjo=25.89p M=.44 Vj=.3245 Fc=.5 Bv=75 Ibv=10u Tt=5.7u Iave=1 Vpk=50 mfg=GI type=silicon) – user16307 Jun 15 '16 at 11:52