555 square to sine circuit

Started by disorder, August 02, 2016, 06:58:41 PM

Previous topic - Next topic

disorder

I'm working on building a basic signal injector. Purchased a few 555 square wave modules from ebay and constructed a fixed filter network to get me a pseudo-sine. It works pretty good but it needs some refinement, notably DC-blocking at the output and a voltage divider to get the amplitude closer to guitar range (200mVrms or so I think).


And the simulation results which match what I'm getting on breadboard aside from some loading/rounding of the source square wave: http://i.imgur.com/IuPJmQq.jpg

1 - Are there better RC values to choose to minimize loading of the 555 and filter stages?

2 - Speaking of loading what would be the ideal way to incorporate a DC blocking cap at the end and a voltage divider? Since I will be driving guitar pedal inputs I'm assuming a cap plus 10k-100k trimpot would be ok?

Any suggestions appreciated.

R.G.

#1
I suggest that you vary the frequency of the 555 in your simulation and see what it does to your waveform.

There is a problem in your approach. A square wave contains the main frequency, plus some third harmonic, fifth harmonic, seventh, and so on toward infinity. Your network is a passive third-order low pass filter with a fixed corner frequency. It makes things sine-ish if the fundamental and third harmonic are on opposite sides of the corner frequency, where the fundamental is not cut much, but the third and higher harmonics are cut.

If you lower the frequency of the input signal to that filter, at some point the third harmonic of the input signal rolls down into the pass band, and you see this as a not very sine looking waveform. It gets worse as you keep lowering the frequency. As you increase the input frequency, the higher harmonics are cut, but when the fundamental hits the corner frequency, it starts being cut down just like the upper harmonics are and output signal droops.

This approach only gives passable results at a few frequencies near the corner of the filter. The filter also has problems, as the second and third sections load down the earlier sections, and do not behave ideally.

Converting a square to a sine with a filter is very difficult. It is much easier to filter a triangle to be more sine-like,  but it still has the problem of needing the filter frequency to track the input frequency.

This set of interacting problems is why most people use a sine wave oscillator of some sort to start with. The Quick and Dirty Oscillator and it's improved version was created to solve exactly the problem you're proposing the 555/filter for. It suffers from not being easily frequency tuned.

You'll get better results with a waveform generator chip or a phase-lock-and-synthesize approach for variable frequency sines of low distortion.

What you're describing is another of those things that "ought to be" easy, but isn't.

Edit: As an example, the entire Hewlett Packard company was started with a clever solution to a sweepable sine wave oscillator instrument. It was hard enough that they could sell the things to the electronics industry and get a whole big company running.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

ysba

Once I tried to do something like that... I wanted to build some kind of oscillator for debuging my audio circuits.

At first I tried to filter some square waves, but this is terrible. So I built an wien bridge sime wave osc, which works nice until you start to change much the frequency...
Putting this osc to work is kind of tricky if you have a single supply. And when you change the frequency some distortion appears...

I also tried to digitally generate a sine wave using a pic microcontroller, modulating a pwm output with previously stored sine values. The problem was the mcu i had didnt have enough clock to generate a reasonable resolution for the frequency I wanted. As a rule of thumb when you want to filter a pwm signal to create another signal, pwm frequency must be at least 10x greater than the signal frequency.


So I finally had an insight... Why the hell am I trying to reinvent the wheel? We all have super smart phones in our hands which can do all sort of wonderful things. So I just downloaded an free tone generator and built a small cable.

But here's the thing: if I had gone straight to the easy way, I wouldn't had learnt these things.

disorder

Thanks R.G. I bought the 555 modules on ebay because they were cheap and because google gave me a few articles saying this was possible, without mentioning the challenge of tracking the source freq. Is this a problem even if I plan on keeping the 555 freq fixed (and low pass filters dialed in for that freq)?

disorder

Quote from: ysba on August 02, 2016, 10:50:09 PM
So I finally had an insight... Why the hell am I trying to reinvent the wheel? We all have super smart phones in our hands which can do all sort of wonderful things. So I just downloaded an free tone generator and built a small cable.

But here's the thing: if I had gone straight to the easy way, I wouldn't had learnt these things.

I'm actually using my phone now as a generator, works just fine, but I'm treating this "audio sniffer" project as a way to get into a few different areas of DIY I haven't been before. The generator and probe with internal amp/speaker will be in one box. It is run off a 3.7V LiPo battery so I'm fooling around with charger IC's as well as a 5V step up circuits etc. It's a pet project I'm willing to go the long route to make it in one nice fancy box. Like you said, giving me a chance to learn.  :icon_cool:

I am going to build the quick and dirty oscillator tomorrow. But now I have two little 555 square wave generator pcb's. Anyone know what I can use them for?

TejfolvonDanone

QuoteBut now I have two little 555 square wave generator pcb's. Anyone know what I can use them for?
If you hook the CV input through a cap to a guitar input you can create a really wierd ring modulator (FM). Like this: (The modulating signal input would be the guitar signal)
https://electroviees.files.wordpress.com/2013/09/111.jpg
...and have a marvelous day.

287m

OOT
this thread make me look for velleman mk105
oh, simple usefull circuit

mac

QuoteWhat you're describing is another of those things that "ought to be" easy, but isn't.

The problem is the discontinuity, that abrupt jump you see in a square wave.
Mr. Fourier did not even consider the use of discontinuous functions like squares waves to get smooth ones :)

mac
mac@mac-pc:~$ sudo apt install ECC83 EL84

disorder

I'm trying to simulate RG's quick dirty oscillator. Can anyone tell me what I'm screwing up here? I just recently switched sim programs, currently trying to learn Simetrix Elements. You'll notice there's some oscillating happening but it's not clean and it's minuscule in size. 

http://imgur.com/a/TqCIW

PRR

> RG's quick dirty oscillator.

Not the same as the 555-sine concept at all.

> minuscule in size.

Does that say "aV"? ATTO-volts? 10^-18?

If so; that's not real, that is "mathematical noise". Rounding-error in 64-bit arithmetic.

Simulating near-linear oscillators in SPICE is difficult, sometimes frustrating. This type oscillator starts s-l-o-w-l-y. Maybe thousands of cycles.

I *have* simulated oscillators in SPICE, but the runs are very long, and I usually have to "kick start".

For a circuit with just two transistors, just build it. Especially since you already "know it will work".
  • SUPPORTER

PRR

> some oscillating happening

No; as said, numeric "noise".

Here's how I would do it. I find a way to insert a small "kick". I observe that the bias is 27K+27K or like 54K base to emitter. If I throw another 500K across that, the bias will be about 10% different. Then I remove that added part while the sim is running. In my sim there is a "timed open switch" part. I set it to open the added 500K after 1mS.



We see no visible oscillation at first. In a real circuit, the "oscillation" here would be micro-Volts, transistor hiss. This will build up over many-many cycles. But SPICE does not directly account for circuit hiss in a TRANsient run. I flogged my Pentium for some time, no oscillation started.

Then at 1mS the switch opens. The transistor bias "kicks" about a tenth of a volt. That throws a transient into the system. The filter centers the transient at one frequency. The amplifier builds it up. We see the amplitude build up over several cycles. It almost doubles each cycle. 5 cycles later, the 0.1V kick is trying to be 2^5= 32 times higher, but runs into clipping and can't rise any more. If the "kick" were only thermal hiss, build-up would take much longer (OTOO 21 cycles, not bad). Since SPICE does not have thermal hiss, simulated build-up can be infinitely long.

Yes, the wave is clipped, not a perfect sine. We can adjust gain (increase the 22 Ohms) for less clipping, but longer and less-certain start-up. A "clean" sine needs another time-constant (more complication). However this is not a sine generator, it is a guitar stimulator! Guitars do not make perfect sines. The overtones added by clipping make a richer more music-like tone which also lets you hear some brighter/duller effect of treble controls.
  • SUPPORTER

PRR

#11
Another SPICE trick, depending on your SPICE, may be directly relevant and helpful.

SPICE starts a .TRAN by ignoring all caps and coils, computing DC conditions, then pre-charging caps/coils to those conditions, then starts "time". The circuit has very little tendency to wander off those conditions.

My SPICE's .TRAN has an option "Skip initial transient solution". This "bangs" the power onto a "cold" circuit. In this case (and many others), this hard-start will get oscillations going.

(I had forgot that because my last stroll through this field was a tremolo oscillator, which may have to be killed when trem is not wanted, but must be ready to go quickly when trem is demanded. Hot-switching the power connection usually starts-up a little more violently than is desired in a tremolo.) Here, you would naturally power-up the guitar stimulator before you began using it. And you would not do it in front of a paying crowd which might be annoyed by a bang-start.
  • SUPPORTER

disorder

#12
Quote from: PRR on August 12, 2016, 09:25:23 PM
Here's how I would do it.

That's a cool trick and works as explained in the TINA spice program.

Quote from: PRR on August 12, 2016, 10:09:16 PM
Another SPICE trick, depending on your SPICE, may be directly relevant and helpful.

I have calculate op point, use initial conditions, and zero initial values. Seems like you described the first and third, and I could perhaps I could use the second option to set my own conditions and get the oscillator going without the use of the bias altering switch.