Amplifying a smoothed square wave

Thread Starter

rfpd

Joined Jul 6, 2016
101
It's about an octave down guitar effect, I uptaded the schematic as an attachment. Basically, I'm amplifying the guitar signal and leaving it biased, the flip flop will then produce a square wave, which I will center and smooth it, turning it into a 'sine wave' (looks like one). Finally, I use a high pass filter to level the amplitude at differente frequencies as best as I could, since 100Hz would get way more voltage than 300Hz. After this high pass filter I get from 296uV to 660V (300 Hz and 100Hz), and since it's not really a sine wave, I'm struggling to amplify it. I need to amplify it to around 100mV-200mV.
 

Attachments

MrChips

Joined Oct 2, 2009
30,810
What is a "smoothed square wave"?

A linear broad-band amplifier ought to amplify the signal independent of its shape, sine or square, within the limitations of its bandwidth.

A square wave consists of the fundamental and decreasing amplitudes of higher odd harmonics. If you apply a low-pass filter you can attenuate the harmonics giving more emphasis to the fundamental (which is a sine wave).
 

GopherT

Joined Nov 23, 2012
8,009
It's about an octave down guitar effect, I uptaded the schematic as an attachment. Basically, I'm amplifying the guitar signal and leaving it biased, the flip flop will then produce a square wave, which I will center and smooth it, turning it into a 'sine wave' (looks like one). Finally, I use a high pass filter to level the amplitude at differente frequencies as best as I could, since 100Hz would get way more voltage than 300Hz. After this high pass filter I get from 296uV to 660V (300 Hz and 100Hz), and since it's not really a sine wave, I'm struggling to amplify it. I need to amplify it to around 100mV-200mV.

Interesting. Can you post an snapshot of input/output o-scope (from the simulator or the real circuit).
 

Thread Starter

rfpd

Joined Jul 6, 2016
101
Interesting. Can you post an snapshot of input/output o-scope (from the simulator or the real circuit).
The wave with the biggest frequency at the input and the wave with the lowest frequency at the output, but when I pass it through an amplifier.

Actually now I was able to do it, but the signal gets all screwed up.

What is a "smoothed square wave"?

A linear broad-band amplifier ought to amplify the signal independent of its shape, sine or square, within the limitations of its bandwidth.

A square wave consists of the fundamental and decreasing amplitudes of higher odd harmonics. If you apply a low-pass filter you can attenuate the harmonics giving more emphasis to the fundamental (which is a sine wave).
Yes, I did that and now I was able to amplify it, but it changed the shape of the wave.
 

Attachments

Thread Starter

rfpd

Joined Jul 6, 2016
101
I do have a question though, being able to amplify it, I have frequencies that would have 600mV and others that would have 300mV, is there no way to attenuate this difference?
 

MrChips

Joined Oct 2, 2009
30,810
I do have a question though, being able to amplify it, I have frequencies that would have 600mV and others that would have 300mV, is there no way to attenuate this difference?
Any filter circuit, by definition, is a function of frequency.
You have to consider what range of frequencies you want in the pass band and what range you want in the stop band. If these frequencies overlap you are stuck. You cannot do it with a simple low-pass filter.
 

Alec_t

Joined Sep 17, 2013
14,314
is there no way to attenuate this difference?
An automatic gain control (AGC) circuit could do that, but takes severl cycles to stabilise. That may make it unsuitable for live guitar playing.
A 'switched capacitor filter' may do what you want (I have no practical experience of those, but other members here may).
 

AnalogKid

Joined Aug 1, 2013
11,045
Final schematic?

You don't say which capacitors you changes, so here is a little analysis.

Whether high pass or low pass, the corner frequency of a single stage R-C filter is
f = 1 / (2 x pi x R x C)
Using this, you can see in your final schematic that both the U2 preamp circuit and the R1-C1 coupling circuit after the ff have high pass corner freqs of 160 Hz. At this point in the circuit, the frequency response is down by 6 dB (50% attenuation) at 160 Hz, 12 dB (75% atten) at 80 Hz, etc. If you want flat frequency response throughout the system, the best way is to flatten the response as best as possible at each stage; that leaves much less to be fixed at the output. Increasing C1 and C6 to 10 uF does this.

Next is the 3-stage filter after the diodes. 5K and 1 uF yeilds a 32 Hz corner, but three of them in series increases the corner freq greatly. Still, this is attenuating most of your high frequencies, both fudamental tones and harmonics. Also, each section loads the previous section, shifting its corner freq, so the overall response is much more complex to calculate and the transition from flat to attenuated is much more gradual. If you want a true multi-pole filter, a 2-pole active filter (one opamp) will give much better performance.

A problem here is that if you raise the lowpass filter's corner frequency enough not to kill off the higher frequency fundamental tones, you let through some of the harmonics of the low tones, increasing their square-wavy sound. The range of guitar fundamental frequencies is around 80 Hz to 800 Hz; that translates to 40 Hz to 400 Hz out of the flipflop. If you set the lowpass filter to 400 Hz for a flat passband throughout the guitar range, that does not filter the 3rd, 5th, and 7th harmonics of a low note square wave out of the flipflop. This is the core reason why your approach is not ideal. I'm not picking on you, just pointing out that the fizix of the universe has an opinion. When reconstructing audio (CD's, MP3's, FX boxes, wireless microphones, FM radio, whatever), the lowpass filter *always* is the problem.

Now, about those 741's. Venerated, revered, trusted, reliable - and old. A 741 does not have enough open loop gain and bandwidth to amplify audio signals 1000 times. It becomes its own single-pole lowpass filter, its output stage cannot slew fast enough to preserve a sine shape at high frequencies, and it has bad crossover distortion. A common problem with simulation programs is that they do not reflect accurately the "personality" of complex components. If you are building this circuit for real, seriously consider a more contemporary, "audio" opamp. The NE5534 also is an older part, but was designed from the ground up to fix many of the 741's audio issues. Burr-Brown OPA parts and Texas Inst. TL parts are other options.

ak
 

MrAl

Joined Jun 17, 2014
11,486
I do have a question though, being able to amplify it, I have frequencies that would have 600mV and others that would have 300mV, is there no way to attenuate this difference?
Hi,

If you use a low pass filter you get by definition higher amplitudes for lower frequencies than for higher frequencies. You need AGC control to compensate. Because of these complexities today a modern circuit would be done using DSP. I am not sure how much you are into that though.
 

Thread Starter

rfpd

Joined Jul 6, 2016
101
Hi,

If you use a low pass filter you get by definition higher amplitudes for lower frequencies than for higher frequencies. You need AGC control to compensate. Because of these complexities today a modern circuit would be done using DSP. I am not sure how much you are into that though.
I know nothing about DSP, just doing this for the challenge. I'll look into it, thanks!
 

Thread Starter

rfpd

Joined Jul 6, 2016
101
Final schematic?

You don't say which capacitors you changes, so here is a little analysis.

Whether high pass or low pass, the corner frequency of a single stage R-C filter is
f = 1 / (2 x pi x R x C)
Using this, you can see in your final schematic that both the U2 preamp circuit and the R1-C1 coupling circuit after the ff have high pass corner freqs of 160 Hz. At this point in the circuit, the frequency response is down by 6 dB (50% attenuation) at 160 Hz, 12 dB (75% atten) at 80 Hz, etc. If you want flat frequency response throughout the system, the best way is to flatten the response as best as possible at each stage; that leaves much less to be fixed at the output. Increasing C1 and C6 to 10 uF does this.

Next is the 3-stage filter after the diodes. 5K and 1 uF yeilds a 32 Hz corner, but three of them in series increases the corner freq greatly. Still, this is attenuating most of your high frequencies, both fudamental tones and harmonics. Also, each section loads the previous section, shifting its corner freq, so the overall response is much more complex to calculate and the transition from flat to attenuated is much more gradual. If you want a true multi-pole filter, a 2-pole active filter (one opamp) will give much better performance.

A problem here is that if you raise the lowpass filter's corner frequency enough not to kill off the higher frequency fundamental tones, you let through some of the harmonics of the low tones, increasing their square-wavy sound. The range of guitar fundamental frequencies is around 80 Hz to 800 Hz; that translates to 40 Hz to 400 Hz out of the flipflop. If you set the lowpass filter to 400 Hz for a flat passband throughout the guitar range, that does not filter the 3rd, 5th, and 7th harmonics of a low note square wave out of the flipflop. This is the core reason why your approach is not ideal. I'm not picking on you, just pointing out that the fizix of the universe has an opinion. When reconstructing audio (CD's, MP3's, FX boxes, wireless microphones, FM radio, whatever), the lowpass filter *always* is the problem.

Now, about those 741's. Venerated, revered, trusted, reliable - and old. A 741 does not have enough open loop gain and bandwidth to amplify audio signals 1000 times. It becomes its own single-pole lowpass filter, its output stage cannot slew fast enough to preserve a sine shape at high frequencies, and it has bad crossover distortion. A common problem with simulation programs is that they do not reflect accurately the "personality" of complex components. If you are building this circuit for real, seriously consider a more contemporary, "audio" opamp. The NE5534 also is an older part, but was designed from the ground up to fix many of the 741's audio issues. Burr-Brown OPA parts and Texas Inst. TL parts are other options.

ak
I only want the octave to play the low notes, I don't see much sense in using an octave for playing the higher notes, since they're already in the fretboard. So I just realized I've been worrying about the 300Hz for nothing. I'll play mostly from 82 to 200Hz, 250 maximum. Just the 2-3 thicker guitar strings. Thanks for the help, I'll tweak around the filter values.
 
Top