By Assad Ebrahim

2019-02-07 09:05:40 8 Comments

I built a prototype keyboard/sound synthesizer using a chain of 13 astable multivibrator circuits whose outputs are connected to an audio amplifier chip (LM386) and speaker, all powered off a 9V DC battery.

Each individual circuit gets tuned to one of the 13 frequencies in a musical octave (C5, C#, D, etc. up to C6) by varying a fine-tune trimpot that is in series with specific resistor values and which get the oscillation into the ballpark frequency.

The oscillation is the classic BJT astable multivibrator you can see in Figure 1 here and which is explained in this article.

The prototype stays correctly in tune for a short period (up to a day).

You can hear what it sounds like here. (Safe to start at 0:49s -- Wadsworth's constant ;) )

What I can't figure out is why the circuit appears to get spontaneously detuned, i.e. one or more of the individual circuits end up with frequencies that are different from what they were tuned to (checked against an o'scope and a reference piano).

The frequency deviation of the detuning is typically 2-5%, which is audibly noticeable (e.g. C5 at 523Hz might wander to 540Hz or 510Hz). Interestingly, the detuning never occurs while playing. But several hours afterwards, the keys no longer sound the same.

I had originally thought maybe the trimmer pots were mechanically relaxing by themselves. To eliminate this I replaced the trimmer pots to try to "lock in" the specific frequencies based on resistor values alone so that no variability was left in the design.

But the de-tuning problem persists even after replacing the trimpots with fixed resistor values.

Before: 13-key analog synthesizer with fixed resistor values Before: 13-key analog synthesizer with fixed resistor values

Resolution: Thanks all for the useful feedback, digital design ideas, and historical context to better understand the challenges of a pure analog design. All the answers were excellent. I've accepted ToddWilcox's answer as I get from it that (a) detuning is an expected part of pure analog designs, (b) the artistry lies in how to establish a slick way of tuning the instrument quickly.

To solve the immediate problem, I've put trimmer pots (1-2K ohms) back in the design to give 2-5% tuneability to each key. It takes a couple of minutes at the start of playing to tune up the 13 oscillators, after which they stay in tune for several hours at a time. See new image below.

Will post the results of the experiments using wall-wart, fresh batteries. The digital designs (using digital divider and/or 555 timer chips) are interesting, and would potentially compress the size significantly. Future updates can be found at the project page here.

After: 13-key analog synthesizer with trimmer pots (1-2k ohm) for tune-ability After: with Trimmer Pots added in for tuneability


@WhatRoughBeast 2019-02-08 21:09:12

Yet another factor which has not been mentioned is the fact that the circuit is battery-powered.

Since you are driving a speaker, power consumption will be significant (as evidenced by your use of an LM386), and a 9-volt battery will experience significant voltage drop over a period of several hours. Supply voltage is another factor in determining the operating frequency of your oscillator.

Try replacing your battery with a 9-volt wall-wart and see what happens.

@supercat 2019-02-08 20:07:15

The frequency of a typical RC oscillator is controlled by the RC time constant and the amount of "RC decay" required for each cycle. One of the reasons the 555 circuit is more stable than many other kinds of relaxation oscillators is that the ratio of voltages it swings between is relatively unaffected by the characteristics of the transistors involved. By contrast, the astable monovibrator you're using is very sensitive to the turn-on characteristics of the transistors, which are in turn sensitive to temperature.

I would guess that the instrument takes awhile to tune up, and that by the time it is in tune, all of the transistors will have reached equilibrium operating temperature. If one turns the instrument off, the transistors will cool down. If one turns on power and immediately starts to play, they will be colder than they were when the instrument was tuned, but if one waits for the transistors to reach the temperature at which they were tuned, the tuning should get close to what it should be.

Incidentally, the vacuum-tube electronic organ I had growing up used tuned LC circuits rather than RC circuits. The frequency of a tuned LC circuit will be controlled primarily by the values of the capacitor and tunable inductor. If one wants to minimize the number of amplifying components (the organ used 1/2 of dual-triac tube for each oscillator), using LC circuits may be a practical approach, though tunable inductors of suitable size would probably cost more than most chips.

@CrossRoads 2019-02-07 15:02:09

Answer: detuning occurs due to parts characteristics changing due to heating, temperature change, etc. You can minimize that by putting them in a temperature controlled chamber, and letting it stabilize before using it.

I did the same thing here using a microcontroller to create the 13 tones.

I only had 8 buttons when I did the demo. I used a PC self powered speaker to play them back.

The tones are created at the microsecond level of accuracy. And since they are based on a 16 MHz crystal clock source, they don't drift.

The uC, Atmega1284P, has 32 IO, so 13 buttons and 13 outputs are directly supported.

Want more notes? Add another processor and change the array containing the half-periods of the tones.

Don't like the basically square-wave tone? Add filtering to the outputs.

@Andrey Akhmetov 2019-02-07 15:04:18

This doesn't really address the question. While it is in fact correct that a 16 MHz clock source with minimal drift, combined with a digital system, prevents this issue, it does not discuss why this detuning occurs in the analog system detailed in the question.

@CrossRoads 2019-02-07 15:43:30

Updated the answer.

@Assad Ebrahim 2019-02-08 09:16:01

Very cool demo! The polyphonic capability is neat. And the tones sound very nice compared to the basic square waves in the above. What kind of filtering did you use?

@CrossRoads 2019-02-08 13:00:29

Basically none. Outputs go thru 1uF cap to make them +/- 2.5V, then thru a resistor for the analog mixing. If you search "piano tones micros" in the Arduino forum, the topic will pop up, and there is a schematic there. I cannot access the site from where I'm at, or I'd post it here.

@CrossRoads 2019-02-10 15:03:11

Schematic of my design is here Here's the picture…

@Todd Wilcox 2019-02-07 14:38:27

What I can't figure out is why the circuit appears to get spontaneously detuned, i.e. one or more of the individual circuits end up with frequencies that are different from what they were tuned to (used an oscope, and then a reference piano).

Temperature changes, as mentioned in the other answer.

I'm adding an answer here because, as a musician, I prefer the sound of oscillators that are 100% analog over a design based on:

a circuit that uses as single higher frequency oscillator based upon a close tolerance crystal. Then the use of digital counters are used to divide this frequency down to the desired frequency for each note in the scale.

EEs on this Stack might comment endlessly that I scientifically couldn't be able to hear the difference. Believe me when I say my wallet dearly wishes that I couldn't hear the difference, but I can, and it's not subtle.

Anyway, major 100% analog synth manufacturers such as Moog Music and Sequential Circuits (formerly DSI) have solved this problem in different ways over the years. The old-school solution requires user intervention and frequent tuning. The original Moog Minimoog (AKA "Model D" after its most popular variant) had a crystal oscillator circuit built in that was not part of the signal path, but would create a stable 440 Hz tone. You turn on the 440Hz crystal tone, then play an A on the keyboard, and then turn the Master Tuning knob to re-tune the synth by ear. This was practical because the Minimoog was/is (it's been reissued with some technological improvements) a monosynth. Once you've tuned the bank of three oscillators all together, you're done. The Minimoog also has several adjustment trim pots to calibrate it to the various control voltages, which includes the ability to make sure the different oscillators are in tune and track with each other.

The Sequential Circuits Prophet 5 is a different thing. All of the audio generation and signal path are analog and prone to drift, and in a way, a similar process is used as to the Minimoog for tuning, but instead of the user listening to a crystal oscillator tone and manually tuning the analog oscillators, the Prophet 5 featured microprocessor controlled automatic tuning calibration. According to one source, tuning took about 15 seconds after the Tune button was pressed.

One reason why an automatic tuning system was necessary for the Prophet 5 was that instead of being a monophonic 3 oscillator synth, it was polyphonic with 5 voices of 2 oscillators each, for a total of ten oscillators. As drift could happen in the middle of a show, a fairly quick way to re-tune the synth was required to make it useful to musicians.

So, what I'm suggesting is if you are building your own oscillators in order to get that 100% analog tone, you'll want to come up with some tuning mechanism. You also might have to play with oscillator designs to try to make them as thermally stable as possible.

If I were heading down this road, I would start with the Moog method and make sure I know how to design a master tune knob that I can use to quickly re-tune the synth and work to get a design that is stable for at least an hour in a typical home room. Then I might look at "graduating" to tacking on a microprocessor that can electrically compare the oscillators to the reference crystal and automatically adjust the tuning knob.

Today, both Sequential Circuits and Moog Music have real-time microprocessor-controlled tuning adjustment in the Prophet 6 and Model D Reissue products, and Sequential even offers an additional control which lets you control how well the microprocessor maintains the tuning, to get some vintage-style oscillator drift in the sound.

More about the Prophet 5 design

One way the oscillators for the Prophet 5 were made more stable was by using analog integrated circuits that had as much of a complete oscillator as possible on one chip. That meant that all the components on the chip changed temperature together (at least closer together than discrete components).

There was also "on-chip temperature compensation circuitry". I'm not sure exactly what that involves, but my guess is that it's circuit design that uses on-chip components to make actual voltage drifts due to chip temperature "cancel out", as much as possible.

Page 2-19 of the Prophet 5 Service Manual is very interesting on this topic:

And I found an interesting paper on analog temperature compensation circuit designs for crystal oscillators:

@Edgar Brown 2019-02-07 16:49:58

I am somewhat surprised that digital designs have not risen to the occasion. I would agree there is a difference (symmetry and exact proportions are not always good and could generate unpleasant beats) but it’s something that can be addressed by pseudorandom sequence generators, spread-spectrum oscillators, and PLLs. I suspect a good degree of snobbery is involved.

@Todd Wilcox 2019-02-07 16:54:05

@EdgarBrown If you can make a digital system that sounds as good as the analog ones, people will pay through the nose for it. So far the best digital recreation of analog I've heard is the Kemper Profiler amplifier products. To be fair, there are many live situations where digital modeling is used extensively or exclusively. In a live show, it's hard to hear the top 5% - 10% of quality, so reliability and flexibility wins out. But when you really want to have the sound, there's almost always only one way to get it.

@Todd Wilcox 2019-02-07 16:57:50

@EdgarBrown Also interesting how people are often less surprised that we can't recreate Stradivarius violins or vintage Martin guitars with modern technology, but are more surprised that we can't recreate a 1974 Minimoog or a CS-80. I don't really know why there's a difference in perception there. DSP isn't analog in the same way that modern American maple trees are not 17th century Italian maple trees.

@esilk 2019-02-07 17:07:48

Not a synth exactly, but the Mellotron is another interesting example of this. It operated by playing back long spools of tape, each one note recorded from an instrument (such as a flute), and pressing multiple keys could create enough of a load on the motor to slow it down and detune the notes. Attempts to tune it were often difficult, and Robert Fripp even said "Tuning a mellotron doesn't."

@alephzero 2019-02-07 17:30:59

@ToddWilcox in the end, it comes down to "which exact serial number of Minimoog do you want to recreate accurately." Analog instruments like these all sound different from each other, if your ears are good enough and you care about such things. But then, you can recognize individual Strad violins from their different sounds, as well!

@Assad Ebrahim 2019-02-07 20:33:53

@ToddWilcox - fascinating about the pure analog designs and how each approached the need for tuning. Ok, so I will put the tuning pots back in for now, and think about how to make that slicker (tuning the 13 oscillators individually takes a few minutes, but requires multiple passes, and is not a great user experience). Thanks for sharing the details!

@Cort Ammon 2019-02-08 18:22:50

@ToddWilcox You might be interested in the efforts taken to capture the sound of a Stradivarius. From what I can tell from the article, their goal is to eventually build a digital model of these violins. In the mean times, the requirements on recording that are so strict, that an entire town stayed quiet for a month because the incredible microphones they needed could pick things up from a long ways away, and a glass breaking in a nearby building could ruin a recording.

@Simon Lindgren 2019-02-11 09:06:27

On the topic of Stradivarius violins, there have been blind tests and the superiority is not as obvious then:… It's also kind of the case that if you buy very expensive gear expecting some kind of improvement, chances are you will hear it, whether it's really there or not, because of various cognitive biases.

@Michael Karas 2019-02-07 09:29:41

You have clearly built a circuit that is fully analog in nature and produces a frequency in each oscillator that is dependent upon various factors such as:

  1. Changes to the voltage level of the power supply to oscillator.
  2. Changes of the Vbe level of the transistors with temperature.
  3. Changes of the values of resistors over time and temperature.
  4. Changes of the values of the capacitors over time and temperature.
  5. Changes in capacitor dielectric characteristics in astable oscillator configuration.
  6. Stray circuit behavior changes due to things nearby the prototype.
  7. Position of the moon relative to the sun as viewed from earth.

There are ways to build circuits that do not have as much drift in operational frequency. They are designed to eliminate or cancel out the various effects enumerated above. One conventional way is to design a circuit that uses as single higher frequency oscillator based upon a close tolerance crystal. Then the use of digital counters are used to divide this frequency down to the desired frequency for each note in the scale.

To show the value of a digital circuit approach I created a small spreadsheet that shows the octave of musical notes from C5 through C6. (The nominal frequencies are values taken from a chart found on Google and not computed in the spreadsheet with scale formulas from the A[440] reference).

Using a crystal frequency of 22.1184 MHz (which is a common MCU frequency used in the 8-bit embedded business) you can see that with an integer digital divide factor for each note that the generated frequency is very close to the desired nominal.

enter image description here

@Uwe 2019-02-07 11:03:51

You should use the actual real frequency values (698.456 Hz instead of 698 Hz for F5) to compute the % error. But your % error values are wrong by the factor of 100 anyway, 0.0644 % instead of 0.0008 % for F5.

@Michael Karas 2019-02-07 11:20:23

I used a different chart now. Hope you are happy.

@Uwe 2019-02-07 11:34:32

Looks better now, but I would prefer to write 698.46 instead of 698.4600 when you use values with two digits after the decimal point.

@Michael Karas 2019-02-07 11:35:49

Feel free to post your own answer.

@kebs 2019-02-07 12:21:47

Just love point 7 !

@Scott Seidman 2019-02-07 14:13:55

@MichaelKaras -- I recommend making the second significant digit show in purple ;-)

@Michael Karas 2019-02-07 16:01:16

@ScottSeidman - @^@

@alephzero 2019-02-07 17:17:59

@kebs If you think point 7 is a joke, I guess you never used a fully analogue synth, back in the day - not even a professionally designed one.

@alephzero 2019-02-07 17:20:52

@MichaelKaras your "correct" frequencies are only correct to two decimal places. Of course that is more than good enough for tuning the notes, but it has a big effect on your percentage error calculations. It doesn't change the overall story you are telling in the post, though.

@Michael Karas 2019-02-08 04:11:01

@alephzero - I will have to disagree with you on how much the % error calculations vary between using two decimal place note frequency numbers versus using three decimal place note frequency numbers. Over a full 9 octaves of notes the maximum delta between the %Error numbers are +/-0.0012. These occur at G#4/Ab4 and A#4/Bb4. If you want to see the full spreadsheet send me your email address. You can thread through my profile to figure out how to send it to me.

@DarenW 2019-02-11 07:10:44

Point 7 reminds me of an anecdote years ago that made the rounds among scientists and engineers, about a family. After dinner the dad would run out for ice cream. When got chocolate, he drove home fine. If he got vanilla, his car wouldn't start for the trip home. Explanation was mundane but non-obvious. So I wouldn't be surprised if the Moon had caused trouble in electronics.

@DarenW 2019-02-11 07:12:01

One factor that's easy to overlook is air motion. A slight breeze a human might ignore could be cooling the electronics ever so slightly. Only a slight change is needed to make musical notes sound off-pitch.

Related Questions

Sponsored Content

1 Answered Questions

2 Answered Questions

Sponsored Content