Is a Processor-controlled Oscillator Possible? - Page 1
Forum section: electronics / projects

author: Richard_S
author_rank: Contributor
timestamp: September 17, 2022, 08:13:20 am
content: Maybe they exist already and just I have never seen one. I am talking about a low-distortion Wien bridge audio sinewave generator. Generally they have that feedback bit for controlling the gain don't they? Typically something like an opto device is used taking the output signal level and using that to control the gain of the oscillator stage to provide a stable signal level (I am sure that some kind person will correct me if I got that wrong; but I think that's how they work). Anyway, it always seems that these opto parts which provide the feedback are the achilles heel. They aren't always linear, and often when there's a good one which has been used in a design, it's no longer available.My question is then could a motorised potentiometer be used for that function? The isolation being provided by the separation between the motor drive and the wiring of the pot. The sort of device used in remote controlled amplifiers and the like where you activate volume up with the remote and the physical control rotates the resistor. Only perhaps it needs a linear pot not a log volume-style one (both are available I think). The processor would read the level of the output of the oscillator, as usual using a precision rectifier, and then feed that signal to an A to D. Once processed, this signal is used to drive the motor back or forth moving the potentiometer to adjust the gain of the Wien bridge. With the feedback loop in software, it can be adjusted for best performance and even do things like change the gain according to whether the oscillator is just starting or settling to provide stable low-distortion contnuous output.The same processor could also be used to adjust another motorised pot for adjusting the frequency too, in the same manner. It could tune the oscillator while measuring the period of the waveform to achieve a more exact frequency than just a calibrated rotary manual potentiometer.Well, that's the theory but does it make any sense.Has it been done?Is it even possible?Would it be economic or sensible?Give me your thoughts please.

author: oPossum
author_rank: Super Contributor
timestamp: September 17, 2022, 09:31:24 am
content: How low distortion?0.0001 % is possible with a OTS USB DAC.For example...https://www.audiosciencereview.com/forum/index.php?threads/topping-d90-balanced-usb-dac-review.10519/

author: T3sl4co1l
author_rank: Super Contributor
timestamp: September 17, 2022, 10:14:14 am
content: ...Yyyes, processor control is possible.They're a few orders of magnitude more advanced than you are thinking, however.Analog circuits are prone to component tolerances, and the noise adds up (for an oscillator: noise floor and phase noise). Mixers are expensive, and perform poorly (high noise, distortion, drifty). And if you want variable frequency besides, you need a ton of 'em.That's basically 1960s thinking: use these new fangled transistors to do what we've been doing (i.e. the classic HP oscillator or the like), but with control voltages instead of trim pots and varicaps.And, mind, not giving dates to imply backwards thinking -- just to highlight the state of the art in a given era. (Your thinking, I assume, is more from a standpoint of familiarity with period equipment, or the relatively basic circuits that were the style at the time. Such circuits never go away, you can still build them just as well today as you could back then -- though you have much lesspurposeto, given modern alternatives -- but just that we can trace the first instance of such circuits back to around these dates.)1970s, the most annoying parts get integrated, and you have OTAs (operational transconductance amplifiers) for example: a crude mixer, but performing much better than one made from discrete transistors. Maybe some early digital circuitry, which includes options for direct synthesis (say, clock + divider + filter for sinewave output), as well as CPU control (though I doubt there were any synthesizer instruments, quite this early, that were largely, or hybrid, digitized..??).Or if you want to put in the effort, a DDS can be made from logic gates, EPROM and DAC. You'll still need a good filter to clean up the spurs and quantization noise, but it won't need to be as precise as a controlled oscillator or tracking bandpass would. Typically this consists of a clock source, N/M divider (PLL), and a phase accumulator (adder + register) which addresses the EPROM, which is a sine table, thus generating sine values for the DAC. Finally the DAC is multiplying type (R-2R being very common back then, and, still to this day, really) so you get amplitude control from a fixed (DC) VREF. Which itself can be programmable if you like (add another DAC). Such a system would take up one or two letter-size PCBs, made from contemporary logic and other ICs, and consume probably a couple amperes at 5V.And you could swap or bank-switch the EPROM to get different waveforms, so you also get wavetable synthesis, great for synth audio as well as lab purposes. Or use RAM for arbitrary waveform generation (readily programmable).Downside for test equipment, the output is rather slow; a few MSps would be typical for moderately-pricey (i.e. not custom and hybrid) 70s parts I think? So you don't even get much of a triangle wave, say, at more than some 10s of kHz. (I don't know what all was offered as far as brand-name test equipment, but I imagine HP had some ECL-based hot-shot gear pushing 50 or 100MSps, and at 12 or more bits, as long as you're sitting down to hear the sticker price kind of thing.)Flash forward to the 80s, more integration and more customization for-purpose. Electronic synthesizer instruments became widespread, if still not cheap, but professionally quite attractive and easy to use. FM and wavetable syntheses offer rich sounds, integration offers low cost (at least, relatively speaking) and polyphony. And test equipment continued to improve specs, while offering lower cost and even more programmability.So, needless to say -- these are wholly solved problems, in the digital domain, by the 80s or 90s; the state of the art has been perfected. Since then, sample rates and bit depths have continued to rise, and the form has changed a little. In addition to custom ASICs, FPGAs and MCUs have come into common and cheap use, while offering more power than ever. You can replace all the discrete logic of a DDS with a few dozen lines of code on an MCU -- who cares that the MCU contains two orders of magnitude more transistors, the cost of transistors trends very close to zero these days(!!!). Many even offer integrated ADC and DAC, so you don't need any external chips to do it (well, maybe a VREF, internal ones can still be kinda crummy -- well, ADCs too, depends; many MCU families have surprisingly good ADCs though).For something like audio -- you really don't have to go any further than what you're already holding / looking at. 24-bit 96kSps (or higher) sound cards are widespread, integrated into one chip on the motherboard (or even further integrated on the system chips for cell phones and the like). They might indeed be very simple devices, little more than a bus interface and DAC/ADC -- indeed the main CPU is so powerful these days, it's trivial to compute the entirety of a multi-channel mixer, with filter effects (frequency response, spacial tricks, etc.), and total software synthesis (wavetable, FM, etc.) for MIDI or other support -- in a fraction of a percent of CPU cycles. All done in floating point precision, no less (reduced to 24-bit fixed point for the hardware in one final step).Performance of which, is largely limited by, well, the analog hole of course -- you need good op-amps and grounding to get even 20 bits out of such a system, let alone the nameplate 24 bits (which is mostly fluff, just, easy enough for interface and manufacturing purposes, and a little bit of specsmanship). But it is indeed possible (that is, to push the Johnson noise floor at whatever sample rate is in use), and the digital samples can be mathematically exact to as many bits as are used, so you can get extremely low distortion sines at any frequency in the bandwidth you like, or indeed any other waveform you can imagine.Tim

author: Richard_S
author_rank: Contributor
timestamp: September 17, 2022, 12:16:49 pm
content: Hi oPossum. Apologies if it's me but I'm struggling to see the link between your reply and my question. Thank you anyway.

author: Richard_S
author_rank: Contributor
timestamp: September 17, 2022, 12:25:19 pm
content: Hi T3sl4co1l. That's a very long reply! Thank you.I guess my simple question is can a motorised potentiometer (controlled by a processor) be used in lieu of the directly connected optical or magnetic devices to isolate the amplitude measurement part of the Wien bridge circuit from the oscillating resonant generator part?Perhaps I did not put that as well as I should have. I hope that's clearer.

author: MasterT
author_rank: Frequent Contributor
timestamp: September 17, 2022, 01:04:53 pm
content: The idea is not new, it was done many times in the past. I checked wiki, one article mention it:Quotehttps://en.wikipedia.org/wiki/Harrison_Audio_ConsolesBe aware, that most common potentiometers is not distortion free, carbon composition exhibits semiconductors property. Also speed limits, and mechanical wearing are strong arguments against using motorized pots.Modern digital audio volume controls IC reached about the same THD level as mechanic.

author: David Hess
author_rank: Super Contributor
timestamp: September 17, 2022, 01:05:30 pm
content: An operational transconductance amplifier works fine as the gain control of a low distortion Wien bridge oscillator. Check out the design of the Linear Technology part per billion Wien bridge oscillator (1) for an example. There is no reason to insert the microcontroller into the feedback loop controlling gain.Operational transconductance amplifiers can also be used to make voltage variable capacitors, resistors, and inductors, but I am unsure how well they will perform for low distortion.A state variable oscillator is more amendable to electronic control because it relies on a pair of operational integrators, and there are all kinds of ways to electronically control an operational integrator.I think all of the electronically controlled audio oscillators I have seen used function generation or a state variable oscillator. None of these performed as well as a modern audio DAC, and I think if you wanted to do better, you would have to start with something like the Linear Technology part per billion design (1) which is what is required to *test* modern audio ADCs.(1) Found starting on page 62 ofLinear Technology application note 67.

author: Richard_S
author_rank: Contributor
timestamp: September 17, 2022, 02:59:06 pm
content: Hi David. Thank you very much for that information on what looks to be the definitive way of building low-distortion, stable sinewave generators using transconductance amplifiers.To summarise what you are saying, transconductance amplifier can be used instead of the optical or magnetic parts for that gain feedback function. This therefore makes for an alternative to the intelligently controlled motorised potentiometer I asked about. This would not suffer the issues that optical and magnetic parts do. This design suffer the age-related degradation that opto and magnetic parts can suffer. Nor would the transconductance amplifier supper potential interference from external fields.From the datasheet that all seems to make sense. I can see that this makes the motorised pot with its digital control seem over-complex - an argument that I would struggle to rebuff.I am still curious though as to whether the motorised pot would work. As far as I can guess, it's problems regarding this application would be:like the optical parts of old, a motorised potentiometer would change and indeed degrade over timecontrol may not be fast enough or perhaps fine enoughBoth of which I would imagine are not an issue for the transconductance amplifier.Thanks again David, very interesting.

author: moffy
author_rank: Super Contributor
timestamp: September 17, 2022, 03:05:47 pm
content: I have been thinking along similar lines, but instead of using a motorised DAC, using a low distortion multiplying DAC as the gain control element. You can get 16 bit multiplying DACs with better than -100db THD, and the variable gain element would only need about 10% range to cope with the gain variation over frequency, so it would inject distortion into say the Wein Bridge at better than -120db. The Wein Bridge would also tend to attenuate the distortion products, the important part would be not introducing ripple into the amplitude control signal, but there are techniques for minimising that as well.

author: Richard_S
author_rank: Contributor
timestamp: September 17, 2022, 04:53:58 pm
content: Hello Moffy. I can't say I quite understand but I'm sure a circuit diagram would help me a lot. I'm not the sharpest tool in the box sometimes! Anyway, sounds interesting and maybe another different way of getting the gain feedback loop working.

author: Conrad Hoffman
author_rank: Super Contributor
timestamp: September 17, 2022, 04:57:16 pm
content: You can. Just because you can doesn't mean you should!I feel your pain as I have several nice General Radio Corp. oscillators that control gain via vacuum thermistors. A couple are bad and you haven't been able to source those parts for decades. Now, I have a torch for glassblowing, tubing, a vacuum pump, Dumet wire and a package of micro thermistors. Someday after I retire I'll try to make my own. The vacuum thermistors did an excellent job but were probably expensive to produce and the market dwindled to near zero because of more modern technology.For an analog solution, look at the oscillators used with THD analyzers. A good example is Bob Cordell's design here-http://www.cordellaudio.com/papers/build_a_thd_analyzer.shtmlIt's not difficult or expensive to build and he provides a PCB design. The circuit will do < 0.0002% midband.That's still a lot of fussing around in the analog domain. For most things look at something like this-https://www.analog.com/en/analog-dialogue/articles/dds-vs-analog-pll.htmlThere are various solutions, depending on the frequency you need.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: September 17, 2022, 05:55:41 pm
content: To do it with a motorized pot assumes the pot has fine enough control and fast enough response that the oscillator doesn't simply run away in the mean time before it can respond. Which is tens of milliseconds -- mechanical stuff is SLOW.Any tiny scratch/dead spot in the pot's transfer function will completely stuff it up -- but guess where the region of greatest wear will be?Sounds like a bad idea just in general; which, is no surprise that the other methods took over since then.Tim

author: rhb
author_rank: Super Contributor
timestamp: September 17, 2022, 06:54:27 pm
content: Read “Max Wein,Mr. Hewlett-Packard and a Rainy Sunday Afternoon” by Jim Williams. He offers a great explanation of how a Wein bridge works and what causes harmonic distortion ina a sine wave oscillator.Expecting a motorized pot to respond at multiples of the fundamental frequency is not realistic even at low frequencies.

author: mag_therm
author_rank: Frequent Contributor
timestamp: September 17, 2022, 07:09:10 pm
content: AF gen here is a vintage Heathkit IG18.Not exactly a Wein, but similar with a series lamp controlling the feedback level.The problem is that the gain pot setting has to be varied frequently to get stability and calibration across the 4 decades of frequency.And removing/replacing the Al lid to do so, messes up the setting.So I have added the "Armstrong" fine-motor-pot, being a plastic shaft on the gain pot sticking vertically up through a hole drilled in the lid, with a knob.Better than messing up the circuit and front panel, and it works.

author: Conrad Hoffman
author_rank: Super Contributor
timestamp: September 17, 2022, 07:51:06 pm
content: Weird, suspect something's wrong with the Heath. I've used those with no trouble at all and no fiddling needed. There are also some low thd upgrades published.

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 17, 2022, 07:53:51 pm
content: Why would you do that to yourself though?

author: Richard_S
author_rank: Contributor
timestamp: September 17, 2022, 09:20:10 pm
content: Hi rhb and thank you. I did take a read and it was very interesting.Maybe I am getting it wrong here rhb but actually, it seemed to be saying to me that the motorised pot is not just OK but particularly suitable. As I understand it, the need is for the variable gain control to have a long time constant relative to the frequency being generated. In other words, that the pot must move slowly not quickly. To move with a time constant much longer than the period of the generated frequency.The beauty of the motorised pot in this regard is that it is inherently slow meaning it cannot possibly act cyclically within the period of the waveform - at most frequencies anyway. Plus, that with the feedback loop being in software, the design could easily make the response longer for lower generated frequencies thus ensuring a sluggish response across all frequencies.As I said, I think that's what I read but if I am wrong, happy to hear it.

author: Richard_S
author_rank: Contributor
timestamp: September 17, 2022, 09:23:26 pm
content: Thank you Conrad. Greatly appreciated.

author: Richard_S
author_rank: Contributor
timestamp: September 17, 2022, 09:57:15 pm
content: Yes T3sl4co1l thank you, you are possibly right, maybe even probably. I have a feeling though that probably and definitely are a margin apart and I don't like the idea of not thinking something through because itmaynot work.For example, I believe that a slow response is good in this case and in fact tens of milliseconds is not what's needed (see my reply to rhb). Keep in mind that the light bulbs used for optically stabilising Wien bride oscillators had response times in the hundreds of milliseconds.As for the potentiometer tracks getting cracked, dirty and so on, yes, that could well be an issue. Experience teaches me though that pots that are not moved suffer more than ones that are so I think this could be a benign environment. As for wear, well again it could be an issue but flying fader sound mixing desks (such as Neve) had potentiometer tracks moving sometimes almost constantly that seemed to last.So, once again, thank you.

author: Richard_S
author_rank: Contributor
timestamp: September 17, 2022, 09:58:44 pm
content: Hi mag_therm. That sounds interesting. Sort of a similar thing then?

author: moffy
author_rank: Super Contributor
timestamp: September 18, 2022, 01:09:12 am
content: Richard_S, here is the requested circuit diagram for using a multiplying DAC to control the amplitude of a Wein Bridge oscillator, the logic/micro to monitor the amplitude is not shown. The actual measurement of the amplitude has been left out for simplicity, so that the multiplying DAC won't be lost in other detail. Please excuse any mistakes, this is at best a rough draft for illustration purposes.The Wein Bridge composes U3A and U3B, with U3A being the Wein bridge and U3B providing the necessary gain for oscillation. With R1/2k and R2/3.9k the gain through U3B is 1.95, just below the 2 needed for oscillation. Extra controllable gain is provided by the multiplying DAC, the AD5543, through R4. Assume that the output of the oscillator is controlled for 20Vp-p, the input to Vref on the DAC is reduced to about 5Vp-p to meet the THD (-103db) of the spec sheet. The output is further reduced by R4 being 5k to give a roughly 10% gain control range. If the amplitude is low then the micro increases the count/value to the DAC increasing gain, if the amplitude is too high then the micro reduces the count/value to the DAC decreasing the gain.The input to the DAC Vref is inverted, to compensate the inversion that occurs at U2As output.I hope this clarifies any questions.

author: rhb
author_rank: Super Contributor
timestamp: September 18, 2022, 03:10:08 am
content: Quote from: Richard_S on September 17, 2022, 09:20:10 pmI think you’re right. I commented reflexively with the Jim Williams article as it is probably my all time favorite electronics article. But you’re right. The point of the lamp was the long time constant. I’m still paging electronics into active memory :-(

author: Richard_S
author_rank: Contributor
timestamp: September 18, 2022, 04:44:17 am
content: Hey there Moffy. Yes, I get it now. Like other suggestions here, that looks like it would be superior to my crude motorised potentiometer concept. If your idea would work, and I hope it does, it would seem to be superior in that there's no mechanics, no issue of the track wearing or crackling and all that.It would then seem to have that advantage over the alternatives of allowing adjustment of the time period of the gain control loop. Meaning that could track the oscillator frequency over its whole range (for audio frequencies). That may be its benefit over the transconductance amplifier solution, a solution which otherwise looks really incredibly good. I wonder if there's a possible hybrid solution using both techniques, the multiplying DAC and the transconductance amplifier?While I am throwing yet more questions out there, can your technique be applied to control the frequency of the oscillator making that tunable by the controller too?Are you going to have a go and build one?Lastly, what is essentially a rhetorical question. I once wrote a servo loop in software to manage the speed of an electric motor. The requirement was for ultimate stability in speed, and the servo achieved that. As the load increased however, the servo completely reconfigured itself and just applied lots of torque. Necessarily there was a clever transition between the two modes. The result was a solution which maintained speed accurately but when excessive loads were encountered drove really hard to get back to the sweet zone. It was a best of both worlds type solution and for that reason, better than any analogue servo. I wonder if this type of thinking on the software side could bring advantages here?

author: moffy
author_rank: Super Contributor
timestamp: September 18, 2022, 05:20:15 am
content: Quote from: Richard_S on September 18, 2022, 04:44:17 amTransconductance amplifiers are great because you can modify 'gm' open loop but because of their very nature their distortion is good but not exceptional, think Gilbert cell and how distortion rises rapidly with signal level. I am not sure if I will build my idea, neither Mouser or Digikey have any stock, and that doesn't look to change in the near future, though the AD5543 looks to be a great chip. It is an expensive solution, and more in the nature of a concept, but who knows what another day will bring forth?

author: Richard_S
author_rank: Contributor
timestamp: September 18, 2022, 07:42:00 am
content: Indeed, there's so many things to do and to try and so little time to do them I fear Moffy. Well, if you ever do give it a go, then I for one will be fascinated at the outcome.

author: David Hess
author_rank: Super Contributor
timestamp: September 18, 2022, 11:04:48 am
content: PMI published a variation of the Wien Bridge oscillator which only requires one potentiometer for frequency tuning. I linked to it a couple months ago.