Electronic – Trouble with rectifying a pulse with a diode

diodesrectifier

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):

enter image description here
(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)

Best Answer

Look up the reverse recovery time in the diode datasheet. The 1N400x series sssslllllooooowwwww. These are meant for 50/60 Hz power rectification, not for fast signals.

Either use a fast signal diode like the 1N4148, or a Schottky. Due to the physics of Schottky diodes, their reverse recovery time is very fast. It can often be considered 0 in ordinary applications. The general downsides to Schottky diodes is that they aren't available for high reverse voltages, and they have much higher reverse leakage than full silicon diodes, especially at high temperatures.