A digital solution to analogue oscillator problems

Electronics Technical ArticlesSouth-East European INDUSTRIAL Мarket - issue 3/2006

Bonnie C. Baker, Microchip Technology Inc.

A designer presented with the task of producing a 100Hz sine-wave signal will probably consult analogue cookbooks and/or the web for a quick and suitable solution. This can be a good way to start, but it ignores another, potentially powerful, solution. Designers are always under pressure to produce their designs quickly, but before leaping to use an analogue circuit, it may be beneficial to consider using a digital engine, such as a microcontroller or microprocessor.

A number of well-known circuits,

such as phase-shift, Wien-bridge, quadrature and Bubba oscillators, will produce a sinusoidal output. At first sight, because the design equations for these circuits are in the public domain, they seem to present the quickest and easiest solution

However, the older references for these circuits may have their problems. For example, the cookbook circuit may not work in a single-supply environment, or the circuit being considered may look good in theory, but not so good on the bench. The standard cookbooks kept by many designers are very out-of-date and may not take account of recent advances in electronic components.

Consider the example of a cookbook oscillator circuit that is built and performs satisfactorily. Everything is fine until a request comes to the designer for the frequency to be changed from 100Hz to 200Hz. One option is to return to the design and replace the resistors/capacitors in the circuit to achieve the change. Another way would be to switch the design strategy to a digital one, based on a microcontroller, to ensure that any further design changes could be made much more easily.

So how can an analogue sinusoidal signal be produced by a digital device?

It is, in fact, very easy. First, send a pulse-width-modulator signal to one of the controller’s output pins. This signal can be generated by firmware or by using a PWM peripheral inside the controller or processor. Then, change the PWM signal into a sine wave with an analogue, low-pass filter. Figure 1 show this type of design. In this circuit, a second-order, low-pass filter removes higher frequencies from the PWM signal.

The analogue solution

was an inflexible, hardware-centric design in which adjustments could only be made by changing components. The alternative, digital, design is programmable and can be made smaller and lower cost, as it requires almost no external components. Modifications can be made by simple re-programming. The frequency, or even the phase, can be changed while maintaining good results.

Digital replacements for analogue functions

are getting better and more numerous. The on-chip peripherals offered by today’s microcontrollers, such as comparators, PWMs and timers, are quickening these developments. Digital solutions are not suitable replacements for all analogue functions. Analogue circuits will still have a place in the signal chain, where analogue speed or precision is needed and to provide interfaces to the real-world. However, the next time an analogue function is needed, a quick look at potential digital alternatives could prove very worthwhile.

LATEST issue 4/2019

issue 4-2019