How to transform a signal into a square wave ?

phonic

Joined Sep 29, 2016
37
Hy Paulo,

The problems you have been experiencing are quite normal.

The core cause of the distortion on your waveform is the layout on the bread board, as has already been stated. And, of course, your probe not being set up didn't help, also as has already been stated.

I am not sure if you know this, but the schematics that you see for a circuit are only theoretical- they do not represent the actual circuit of the physical build. And as the frequency increases this effect becomes more significant.

The reason for this is that components, wires and connectors etc are not perfect. Even a simple piece of wire has capacitance and inductance and at a high frequency a resistor can become an inductor. For a 47 Ohm resistor the frequency is around 200Mhz.

So the message is that if you are building high frequency circuits you need to use a ground plane, short leads, high frequency components and short relatively thick conductors.

I notice that you fitted a decoupling capacitor across the supply lines of the 5MHz oscillator but, if I read your image correctly, the capacitor was not suitable and would provide no decoupling, as you found.

For decoupling at high frequencies you invariably need to use a ceramic capacitor of 10nF or 1nF, while 100nF, 1uF and 22uF ceramic capacitors are good for other applications depending on the frequency and power involved. The best dialectic, taking into account all factors is X7R and you need to select a capacitor suitable for high frequencies. Some of the surface mount multi-layer capacitors are not too good, for many reasons.

The other thing to bear in mind is that what you see on an oscilloscope screen is not necessarily what is going on in the circuit you are measuring.
For example a standard 6 inch oscilloscope probe earth lead can introduce ringing and distortion and the capacitance and insductance of the oscilloscope probe will possibly affect the circuit being measured.

So after all that what is the solution.
(1) Forget about breadboards for high frequency work
(2) Instead build your HF circuits on a piece of copper-clad fiberglass board.
(3) Decouple the power line input with ceramic capacitors for high frequency and electrolytic capacitors of around 47Uf for low frequencies.
(4) Make all leads as short as possible,
(5) Set up your probe for a flat response using a known good square wave
(6) Use as short an earth lead on your scope probe as possible.

The above only scratches the surface of building high frequency circuits and monitoring the wave forms on high frequency circuits.

End of lecture.:)

phonic
 
Last edited:

phonic

Joined Sep 29, 2016
37
... does the fact that the period is 50ns, and the signal travels at 1ns per foot implies that the ringing is not caused by impedance mismatch? I can't see the connection and I'd like to see it!
Ringing in not primarily connected with the speed of signal travel. Incidentally the speed that a signal travels is highly influenced by the conductor.

The signal distortion is mainly cause by the parasitic components, inductors, capacitors, resistors, ringing. It is commonly known as ground bounce for the ringing on the lower part of the wave form and top bounce (if I remember correctly) for the high part of the waveform.

Ground bounce is normally related to the 0V (ground) problems and top bounce indicates supply line problems, insufficient decoupling for example. But it is a complex relationship.

By the way, as the frequency increases the current increasingly flows at the surface of the conductor. This is due to the skin effect and is the reason why you may see seemingly heavy conductors for low current signals.

A ground plane helps in this respect because it provides a solid, low impedance, ground (zero volt) reference voltage for your circuit.

phonic
 
Last edited:

Veracohr

Joined Jan 3, 2011
783
Although I know that signals can be represented by sine waves via fourier series, I had never thought of digital signals as being really high frequency signals and hence why they change so instantly. This is fascinating!
If you have the time and interest, you can use a spreadsheet to construct a Fourier series to see how many harmonics it takes to make a decent square wave. If I recall, it only takes a few to get a passable-looking square wave, and about 15 gets darned-near perfect looking.
 

RichardO

Joined May 4, 2013
2,270
Can I please ask why does the fact that the period is 50ns, and the signal travels at 1ns per foot implies that the ringing is not caused by impedance mismatch? I can't see the connection and I'd like to see it!
I said:
The overshoot and ringing can be indications of poorly matched circuit impedances causing reflections. A signal travels at about 1 ns per foot. If you look at the the top of the waveform you will see about 2.5 cycles of ringing. That would be about 5 cycles of ringing if stretched over the entire square wave. 20 MHz has a period of 50 ns. So, each of those cycles of ringing is about 10 ns. This says that the ringing is _not_ caused by reflections in the wiring caused by poor impedance mismatch. The ringing is caused by distributed inductance and capacitance in the wiring and SBB -- as well as the scope probe ground and tip."

It was not well explained...
The 50 ns is used for a reference to measure the frequency of the ringing. This is how I estimated the ringing is 10 ns.
At 1 ns/foot, the 10 ns the signal would have to travel 20 feet (10 feet out and 10 feet back) to be seen as a reflection. Obviously there are no 10-foot wires in the circuit. ;)

A quick calculation is in order. Lets assume that the wiring is about 3 inches long. That is, the total length of the signal, power and ground. The circuit is likely more than that even with the best layout on a SBB.

The inductance of a wire is about 20 nH per inch. 3 inches at 20 nH = 60 nH.
There is about 5 pF between a pair of contact strips on an SBB. Let's assume that there are 4 contact pairs in the signal path. 5 pF and 4 pairs = 20 pF.

Resonate frequency of an LC circuit is 1/(2 *pi *sqrt (L *C)).

So, the frequency of the ringing caused by resonance of the SBB and wiring would be very roughly:
1/ (2 * 3.14 * sqrt(60 nH *20 pF)) = 145 Mhz. 1/145 Mhz = 6.9 ns.

6.9 ns is fairly close to the 10 ns I actually measured. This is actually closer than I expected. :D
 

phonic

Joined Sep 29, 2016
37
Just a word about the 5Mhz Xtal oscillator output.

That is a square wave with severe ground and top bounce. The signal is not a distorted sine wave.

By slugging your scope and/or probe response you are masking the true signal. If the sine wave signal you were pleased with actually existed and were used in a digital application (including gated analog circuits), which is what it is designed for, there would be serious problems.with jitter etc.

phonic
 
Last edited:

Thread Starter

PauloConstantino

Joined Jun 23, 2016
266
Hy Paulo,

The problems you have been experiencing are quite normal.

The core cause of the distortion on your waveform is the layout on the bread board, as has already been stated. And, of course, your probe not being set up didn't help, also as has already been stated.

I am not sure if you know this, but the schematics that you see for a circuit are only theoretical- they do not represent the actual circuit of the physical build. And as the frequency increases this effect becomes more significant.

The reason for this is that components, wires and connectors etc are not perfect. Even a simple piece of wire has capacitance and inductance and at a high frequency a resistor can become an inductor. For a 47 Ohm resistor the frequency is around 200Mhz.

So the message is that if you are building high frequency circuits you need to use a ground plane, short leads, high frequency components and short relatively thick conductors.

I notice that you fitted a decoupling capacitor across the supply lines of the 5MHz oscillator but, if I read your image correctly, the capacitor was not suitable and would provide no decoupling, as you found.

For decoupling at high frequencies you invariably need to use a ceramic capacitor of 10nF or 1nF, while 100nF, 1uF and 22uF ceramic capacitors are good for other applications depending on the frequency and power involved. The best dialectic, taking into account all factors is X7R and you need to select a capacitor suitable for high frequencies. Some of the surface mount multi-layer capacitors are not too good, for many reasons.

The other thing to bear in mind is that what you see on an oscilloscope screen is not necessarily what is going on in the circuit you are measuring.
For example a standard 6 inch oscilloscope probe earth lead can introduce ringing and distortion and the capacitance and insductance of the oscilloscope probe will possible affect the circuit being measured.

So after all that what is the solution.
(1) Forget about breadboards for high frequency work
(2) Instead build your HF circuits on a piece of copper-clad fiberglass board.
(3) Decouple the power line input with ceramic capacitors for high frequency and electrolytic capacitors of around 47Uf for low frequencies.
(4) Make all leads as short as possible,
(5) Set up your probe for a flat response using a known good square wave
(6) Use as short an eart lead on your scope probe as possible.

The above only scratches the surface of building high frequency circuits and monitoring the wave forms on high frequency circuits.

End of lecture.:)

phonic

I'm very sorry for the delay. Thank you for your thorough explanation. I appreciate it.

When you say high frequencies, what do you mean? Is 5MHz or 24MHz high frequency?
 

phonic

Joined Sep 29, 2016
37
I'm very sorry for the delay. Thank you for your thorough explanation. I appreciate it.

When you say high frequencies, what do you mean? Is 5MHz or 24MHz high frequency?
Hi Paulo,

High frequency is a term which depends on context, as Richard says above. Here I have used it in relation to the techniques that are required to get a circuit operating correctly. Bear in mind that a 5Mhz square wave with 5ns edges will contain frequencies well over 50MHz. And the frequencies will be even higher with the 24MHz oscillator.

If you move up to the next level, say 100Mhz using emitter coupled logic (ECL), you can no longer use wires, but need to transport signals over matched strip lines or coax cable at 50 Ohms characteristic impedance.

And if you go even higher in frequency you get into another realm again where even a few millimeters of wire can make a big difference.

Then you get into micro waves and then light.

If you took a 1KHz TTL square wave, which looked nice and clean with fast rising and trailing edges on your scope, and expanded out the scope time-base to examine just one of the edges you will invariably see severe ground and top bounce.

But circuit layout is not only concerned with high frequencies- a bad layout can turn an audiophile amplifier into a foul sounding distortion generator. And it can also completely wreck the accuracy of a precision circuit, like an amplitude to digital converter (ADC) or a digital to analog converter (DAC).

And finally, for now, a bad layout can turn an amplifier, especially an operational amplifier which typically has an open loop voltage gain of one million, into an oscillator.

Layout is one of the main reasons why newbee electronic engineer's projects do not work. And breadboards are one of the biggest causes of problems (breadboards are useful for some experimental work though).

The good news is that there is a wealth of information on layout and if you follow a few simple rules, you will have reliable circuits with good performance.

End of another lecture.:)

phonic

PS: this is what a simple capacitor really is:

 
Last edited:

Thread Starter

PauloConstantino

Joined Jun 23, 2016
266
I said:
The overshoot and ringing can be indications of poorly matched circuit impedances causing reflections. A signal travels at about 1 ns per foot. If you look at the the top of the waveform you will see about 2.5 cycles of ringing. That would be about 5 cycles of ringing if stretched over the entire square wave. 20 MHz has a period of 50 ns. So, each of those cycles of ringing is about 10 ns. This says that the ringing is _not_ caused by reflections in the wiring caused by poor impedance mismatch. The ringing is caused by distributed inductance and capacitance in the wiring and SBB -- as well as the scope probe ground and tip."

It was not well explained...
The 50 ns is used for a reference to measure the frequency of the ringing. This is how I estimated the ringing is 10 ns.
At 1 ns/foot, the 10 ns the signal would have to travel 20 feet (10 feet out and 10 feet back) to be seen as a reflection. Obviously there are no 10-foot wires in the circuit. ;)

A quick calculation is in order. Lets assume that the wiring is about 3 inches long. That is, the total length of the signal, power and ground. The circuit is likely more than that even with the best layout on a SBB.

The inductance of a wire is about 20 nH per inch. 3 inches at 20 nH = 60 nH.
There is about 5 pF between a pair of contact strips on an SBB. Let's assume that there are 4 contact pairs in the signal path. 5 pF and 4 pairs = 20 pF.

Resonate frequency of an LC circuit is 1/(2 *pi *sqrt (L *C)).

So, the frequency of the ringing caused by resonance of the SBB and wiring would be very roughly:
1/ (2 * 3.14 * sqrt(60 nH *20 pF)) = 145 Mhz. 1/145 Mhz = 6.9 ns.

6.9 ns is fairly close to the 10 ns I actually measured. This is actually closer than I expected. :D

Thank you for your thorough explanation !

Hmm...
Hi Paulo,

High frequency is a term which depends on context, as Richard says above. Here I have used it in relation to the techniques that are required to get a circuit operating correctly. Bear in mind that a 5Mhz square wave with 5ns edges will contain frequencies well over 50MHz. And the frequencies will be even higher with the 24MHz oscillator.

If you move up to the next level, say 100Mhz using emitter coupled logic (ECL), you can no longer use wires, but need to transport signals over matched strip lines or coax cable at 50 Ohms characteristic impedance.

And if you go even higher in frequency you get into another realm again where even a few millimeters of wire can make a big difference.

Then you get into micro waves and then light.

If you took a 1KHz TTL square wave, which looked nice and clean with fast rising and trailing edges on your scope, and expanded out the scope time-base to examine just one of the edges you will invariably see severe ground and top bounce.

But circuit layout is not only concerned with high frequencies- a bad layout can turn an audiophile amplifier into a foul sounding distortion generator. And it can also completely wreck the accuracy of a precision circuit, like an amplitude to digital converter (ADC) or a digital to analog converter (DAC).

And finally, for now, a bad layout can turn an amplifier, especially an operational amplifier which typically has an open loop voltage gain of one million, into an oscillator.

Layout is one of the main reasons why newbee electronic engineer's projects do not work. And breadboards are one of the biggest causes of problems (breadboards are useful for some experimental work though).

The good news is that there is a wealth of information on layout and if you follow a few simple rules, you will have reliable circuits with good performance.

End of another lecture.:)

phonic

PS: this is what a simple capacitor really is:




In your first reply, you were talking about high frequencies, however my crystal was 5MHz and 24MHz frequencies. Compared to today's gigahertz crystals, I couldn't understand why you were talking about high frequency design
 

phonic

Joined Sep 29, 2016
37
In your first reply, you were talking about high frequencies, however my crystal was 5MHz and 24MHz frequencies. Compared to today's gigahertz crystals, I couldn't understand why you were talking about high frequency design
It is not the comparison with frequencies that is important, it is the absolute frequency.

In order to get good performance you need to use a good layout with a 5Mz and 24Mz signal.

Gigahertz frequencies are in the microwave band and are a different thing altogether and require extreme layout rules.

spec
 
Top