RIPPLE COMPENSATION FOR A CLASS-D AMPLIFIER

This paper presents the first detailed mathematical analysis of the ripple compensation technique for reducing audio distortion in a class-D amplifier with negative feedback. The amplifier converts a relatively low-frequency audio signal to a high-frequency train of rectangular pulses whose widths are slowly modulated according to the audio signal (pulse-width modulation, PWM). Distortion manifests itself through unwanted audio-frequency harmonics that arise in the output due to nonlinearities inherent in the design. In this paper, we first develop a small-signal model, which describes the fate of small-amplitude perturbations to a constant input, and demonstrate how this traditional engineering tool may be extended to allow one to infer the most significant contributions to the full output in response to a general audio input. We then compute the audio output of the amplifier through a perturbation expansion based on the ratio between audio and switching frequencies. Our results explicitly demonstrate how the ripple compensation technique significantly linearizes the output, thereby reducing the distortion.

the structure of the calculations.However, given the prevalence and technological significance of PWM feedback loops (in class-D amplifiers [2], power converters [7], and current regulators [7,11], for example), RC has potentially wide-ranging application, and our techniques, therefore, have potential broad applicability in quantifying the distortion in more practical designs.
In section 2 below, we set out our mathematical model for a simple first-order class-D amplifier and explain how RC may be applied.These preliminaries are necessary to demonstrate the basis of the RC technique.The first-order design is sufficiently straightforward that its operation may be reduced, in section 3, to a single (nonlinear) difference equation allowing calculation of the successive switching times of the output wave.
In analyzing this difference equation, we begin, in section 4, following engineering practice, by calculating the equilibrium solution, which corresponds to the steadystate operating point of the device for a constant input.Then in section 5 we derive a small-signal transfer function, which describes the relationship between an infinitesimal time-dependent perturbation to this constant-input state and the corresponding perturbation to the output response.This transfer function shows that RC significantly linearizes the behavior of the device.Although it does not seem to be well known among engineers, the small-signal model in fact allows one to infer much (but not quite all) about the output in response to a general audio input.This stepfrom the small-signal model to a prediction of the major components of the output for a general input-significantly extends the usual interpretation of the small-signal model, and so should find broad engineering application.
Finally, in section 6 we analyze the full nonlinear difference equation governing the amplifier, using perturbation techniques (the small parameter being proportional to the ratio of audio to switching frequencies).This nonlinear calculation corroborates the predictions of the small-signal model and extends them, revealing additional distortion terms which are beyond the scope of the small-signal model.In particular, whereas the (extended) small-signal model predicts that RC introduces no nonlinearities whatsoever into the output, the full nonlinear calculation determines the correct dominant (but still remarkably small) nonlinearity.

Mathematical formulation.
In this section, we formulate a mathematical model for the design illustrated in Figure 1, which is arguably the simplest possible, chosen to illustrate most cleanly the dramatic effects of RC [12,14].
For simplicity, the supply voltage has been scaled to ±1; the input audio signal s(t) lies in the range −1 < s(t) < 1 for all t.Typically, s(t) contains audio in the range 20Hz-20kHz.The output g(t) is a high-frequency rectangular wave given by where T is the switching period, typically a few microseconds; for later convenience, we introduce the associated (angular) switching frequency Fig. 1.A first-order class-D amplifier with negative feedback and the option of RC.The input audio signal is s(t).The output is a rectangular wave generated by a comparator (the triangular block): this wave is g(t) = sgn(m(t) − v(t)), where the carrier wave v(t) is a high-frequency sawtooth wave, and where m(t) is the time integral of the scaled error signal, c(s(t) − g(t) − kv(t)).k = 0 represents no RC; k = 1 corresponds to RC.
A recipe will be given presently for calculating the modulated switching times A n , the goal being that the low-frequency components of g(t) should closely match s(t).
The rectangular wave g(t) is generated by comparing two signals and takes the values ±1 according to which of those two signals is the greater.The first of these signals is a sawtooth carrier wave, given by The second signal, m(t), satisfies for some positive constant c, and is a continuous function of time, although its slope can be discontinuous at switching instants.The constant k indicates whether RC is applied (k = 1) or not (k = 0).This comparison process tells us that and we see that the switching times A n are determined by the condition m(A n ) = v(A n ).Hence, in view of (2.1), this switching condition amounts to where we have introduced the duty cycles a n , which are such that (2.4) In view of the later need to integrate (2.2), we introduce f (t) such that (2.5) Voltage waveforms without (left) and with (right) RC.In each case, for simplicity, the input signal s(t) has been shown as constant, s(t) = 1 2 .

Ripple compensation.
The nature of the input to the integrator depends significantly upon whether or not RC is applied.
Without RC, this input switches twice during each switching period: it is which switches down by 2 at the (regularly spaced) unmodulated times t = nT and up by 2 at the modulated times t = A n (which are not in general regularly spaced, as they depend on s(t)).In typical operation, s(t) − g(t) is nearly constant between switching instants, since the switching frequency is much greater than any audio frequencies.One important source of distortion in the amplifier without RC arises because, as the duty cycle of the PWM signal varies, the shape of the comparator input m(t) also varies.The slow modulation to the shape of m(t) gives rise to an unwanted, additional low-frequency input to the comparator, which generates output distortion.We quantify this aspect of the amplifier operation below.
With RC, by contrast, the integrator input switches only once in each switching period, since the regular up-switching of g(t) and the regular down-switching of v(t) at times t = nT cancel exactly: the integrator input is then This input switches up by 2 at times t = A n and ramps downwards, nearly linearly, between switching instants.Now, crucially, the shape of the signal m(t) is almost the same between any two switching instants, regardless of s(t); this feature of RC is responsible for its significant reduction of the output distortion.Typical voltage waveforms, with and without RC, are shown in Figure 2.

Further preliminaries.
To avoid ambiguity, we record here the scalings that we adopt for the Fourier transform and its inverse, which will be used later: We also introduce the Dirac δ-function, such that whenever p(t) is continuous at t = t 0 .
3. Derivation of governing difference equations.In this section, we reduce the mathematical model given above in section 2 to a single, nonlinear difference equation for the duty cycle.
By successively integrating (2.2) over the time intervals A n < t < (n + 1)T and (n + 1)T < t < A n+1 , using (2.6) and (2.7), we obtain where we have written m n+1 = m((n + 1)T ).If we next use the switching condition (2. 3) to substitute for m(A n ) and m(A n+1 ) in these expressions and eliminate m n+1 , we obtain a single difference equation for the duty cycle: This difference equation forms the basis of the analysis in the remainder of this paper.We note that, regardless of whether or not there is RC, (3.1) is inherently nonlinear for a time-varying audio input (since f is then a nonlinear function).For more involved designs, the equivalent of (3.1) would be a vector difference equation (or, equivalently, a higher-order difference equation); cf.[13].

Behavior for constant input.
In this section, we calculate the behavior of the device for a constant input s(t) ≡ s 0 .This analysis provides the first clues to the effectiveness of RC in reducing audio distortion when s(t) is genuinely time-dependent.It also provides the basis for the small-signal model described in section 5.
We set s(t) = s 0 and, correspondingly, from (2.5), f (t) = s 0 t.Substitution in (3.1) then gives the difference equation This has the equilibrium solution a n = a, where (4.2) a = 1 2 (1 + s 0 ), irrespective of whether or not RC is applied.(This simple steady-state duty-cycle condition may alternatively be derived by noting that for a time-periodic response the mean input to the integrator over one cycle must be zero.)Linearization about the equilibrium point, with a n = a + Δa n , gives Thus Δa n = λ n Δa 0 , with λ = (α − cT )/(α + cT ).It follows that in the absence of RC the parameters must satisfy the condition (4.4) 0 < cT < 2 in order to ensure stable operation for all s 0 .RC requires no such constraint for stability.Nevertheless, we assume that (4.4) holds in all that follows, so that comparison can be made between the two cases.We note, furthermore, that without RC λ depends on s 0 , but that with RC λ is independent of s 0 .This result gives the first hint that the dynamics of the system are significantly different in the two cases.

Small-signal model for perturbations to steady-state operation.
Having calculated the steady-state response to a constant input, we next examine the dynamic response to small time-dependent input perturbations.Thus we suppose that Here, a is given by (4.2) and we introduce the notation (5.1) Ān = (n + a)T.
Substituting these expressions in (3.1) and linearizing in perturbation quantities gives what engineers generally refer to as the small-signal model : Recalling (4.3), we observe that with RC the coefficients in this small-signal model are independent of s 0 ; without RC, they are not.
To solve (5.3), we introduce an analytic function x such that (5.4) Clearly (5.4) does not specify x uniquely; we shall later choose x to have other convenient properties.We then note that, by Taylor series, where D denotes the derivative operator d/dt.Thus (5.3) may be written [9] as We shall ultimately need to solve (5.5) for x and then deduce the corresponding influence on the output.Mindful of the latter step, before solving (5.5), we consider perturbations to the output rectangular wave.We write the full output g(t) as a sum of top-hat (or window) functions [4,6]: It then follows that the output has Fourier transform (for ω = 0) But the steady-state response has Fourier transform (again for ω = 0) and so, by taking the difference between these two results, we find Next we linearize (5.7): for any fixed ω, we may replace leading to the linearized result that (5.9) The linearization in (5.8), which leads to (5.9), has a ready interpretation in the time domain, as we now describe.The output perturbation Δg(t) is in fact a train of narrow rectangular pulses: Δg(t) is generally zero, except for brief intervals between perturbed and unperturbed switching instants, during which it takes the values ±2.Inverting the Fourier transform in (5.9) shows that the approximation (5.8) leads to (5.10) which amounts to replacing the narrow rectangular pulses by δ-functions at the steadystate switching instants.The area associated with the nth δ-function in (5.10) is evidently 2T x( Ān ).This precisely matches the additional area under the corresponding rectangular pulse, as may be seen by noting that the additional area under g(t) due to the perturbed switching time is 2(A n − Ān ), which is equal to 2T x( Ān ) by (5.4).
We next use (5.9) to express Δĝ in terms of x: first we note from (5.1) and (5.9) that where the last step follows from Poisson resummation [10].It then follows, upon making the substitution t = (τ + a)T , that The goal now is to use (5.5) to determine x and then use (5.11) to derive the consequent perturbation to the output.In fact, we solve (5.5) under the more restrictive condition that (5.5) holds at all times, not just the sample times t = Ān .Then, replacing Ān by t in (5.5) and taking the Fourier transform of the result, we have (5.12) To tidy the expressions below, we write (5.12) as Hence, using (5.2) we have and so, from (5.11), (5.13) where T denotes the transfer function The transfer-function result in (5.13) and (5.14) is the culmination of the small-signal model.
There are two special cases of practical interest in which this result may be simplified, which we now examine in turn.
Single-frequency disturbance.The first case in which (5.13) may be simplified arises when the input disturbance is a single-frequency signal.Suppose Δs(t) = Ae iΩt (subject to the constraint that Ω/ω c − 1 2 is not an integer); then Δŝ(ω) = 2πAδ(ω−Ω).Note that the input frequency here is arbitrary (apart from the constraint noted): in particular, it need not be small compared to the switching frequency.Then, according to (5.13), Of particular interest is the response at the fundamental frequency.For ω near Ω, only the term for n = 0 is relevant and so to determine the fundamental response we have Thus the component of the output at the fundamental frequency is given by Δg(t) = T (Ω)Δs(t).
Audio (low-frequency) disturbances.The second case concerns a disturbance with all components in the audio band: specifically, we suppose that the disturbance to the input is band-limited, so that Then, by virtue of (5.2) and (5.12), x is similarly band-limited.If we consider lowfrequency components of the output (with |ω| < ω c /2), only the term n = 0 contributes to the sum in (5.13), and hence with these restrictions where the subscript "a" indicates the audio (low-frequency) components of the output.Since audio frequencies are in practice much smaller than the switching frequency, we gain insight into the behavior of the amplifier by expanding T (ω) for small ω.Unfortunately, while (5.14) provides a compact representation of T (ω), it is not in a particularly convenient form for small-ω expansion.To provide a more fruitful expression, we write, from (5.2), (5.11), and (5.12), (5. 16) , where γ = α + cT α − cT .
Then it follows that (5.17) where the β n (ξ, γ) are the Apostol-Bernoulli functions, defined through the generating function [1] (5.18) We may simplify (5.17) using the identity [1] (5.19) , and β 5 (γ) = 5γ(γ 3 + 11γ 2 + 11γ + 1) (γ − 1) 5  , it follows that for small ω, Then inversion of the Fourier transform in (5.15) gives Δs (t).(5.21) In practice, we expect terms in this series to diminish in size successively and the first few terms to provide a good approximation to the audio output.This follows because if Ω is a typical audio frequency, then parameters are generally chosen so that ΩT 1, while cT = O(1); the nth derivative term in (5.21) is then O((ΩT ) n /(cT ) n ), so terms on the right-hand side are of diminishing asymptotic size.

Reconstruction of the "full" output from the small-signal model.
For the second of the cases above, we now show how the small-signal model may be extended to predict the amplifier output in response to a fully nonlinear input.In doing so, we highlight the particular influence of ripple compensation.

With RC.
Since the coefficients in the expression (5.21) for the audio components of the output all become independent of s 0 when RC is used, we deduce the following linear relationship in that case: even for signals that are not small.In section 6, we shall directly calculate the output in response to a general audio input and show that the expression (5.22) provides an excellent approximation to the true audio output.It will turn out that in fact our deductions from the smallsignal model, leading to (5.22), systematically omit terms that are nonlinear in time derivatives of s(t) (such terms are removed by the linearization inherent in the smallsignal model).We quantify these missing terms in section 6.

Without RC.
Matters are more complicated without RC, since the transfer function depends on s 0 .However, we may still infer much about the audio output from the small-signal model.We have in (5.15) an expression that may be expanded in powers of iω in the form From (5.20), we see that the functions F n satisfy If we now write (5.24) Φ n (γ) = F n (s 0 ), then the chain rule gives where we have used (4.3) and (5.16), and where the last step uses the identity (5.19).
Using the identity (A.3), which is derived in the appendix, we find F n (s 0 ) is correspondingly obtained using (4.3), (5.16), and (5.24).We take one of the constants of integration so that F 0 (0) = 0; the other constants are immaterial in view of the time derivatives taken below, in (5.25).
We may now reconstruct the full audio output g a (t), as predicted by the smallsignal model.By inverting the Fourier transform in (5.23), it follows that where the last step follows from repeated application of the chain rule and linearization.Thus we infer from the small-signal model that the audio output is (omitting terms that are nonlinear in time derivatives, and hence invisible to the small-signal analysis) where Hence the small-signal analysis predicts the following nonlinear audio output: (5.26) 6. Fully nonlinear audio output.Our mathematical analysis has so far concerned an input signal that is a constant plus an infinitesimal time-dependent perturbation.In this section, we instead calculate the fully nonlinear response to a general time-varying input signal s(t).This calculation will corroborate the small-signal results and will complete that analysis by providing the missing terms.The calculation of this section is a perturbation calculation based on the assumption that the audio signal varies slowly compared to the switching (which is generally the case).

Perturbation framework.
We suppose now that the audio input s(t) is time-varying, with a typical (angular) frequency Ω (we emphasize that there is no assumption that the input is sinusoidal, merely that Ω is representative of the audio frequencies present).We introduce the small parameter ≡ ΩT 1 and construct a perturbation solution for the audio output of the amplifier, following our earlier treatments of other class-D designs [4,5,6].
To emphasize the time scales of the various quantities involved in the analysis, we introduce a dimensionless time variable (6.1) σ = Ωt = t/T and write and hence, given (2.5), S(σ) = F (σ).We now introduce A(σ) such that sampled values are specified by (6.2) The governing equation for A is then the exact difference equation (3.1), which becomes, in the present notation, either with or without RC, We note that the discrete equation (6.3) holds for integer n.To make analytical headway, we seek a particular solution that also satisfies the corresponding equation at intermediate points.Thus we seek a solution to Since we have been unable to find a general solution to this equation for A(σ), we instead attempt to solve for successive terms in the perturbation series (6.5) by solving (6.4) at successive orders in .Using computer algebra to accomplish the details, we find the first couple of results to be the first is an analogue of the steady-state duty-cycle result (4.2).However, results for A(σ) are in themselves rather unedifying.To see their practical import, we next calculate the corresponding audio components of the output g(t).
We now apply Poisson resummation to the Fourier transform of the full output and adopt the notation in (6.2) to give Now we focus on the audio components of the output, specifically with |ω| < ω c /2; we make the reasonable assumption that these are dominated by the term n = 0 in (6.6).After Taylor-expanding the exponential involving A( t/T ) in (6.6), we have where we have used the result that the Fourier transform of p (t) is iω p(ω).Hence, by inverting the Fourier transform, we obtain where the constant is not determined by the analysis above (in view of the restriction to ω = 0 in expressions such as (6.6)).This constant may readily be obtained by noting that g(t) = −1 for all t when A(σ) = 0 for all σ; hence 6.2.Results with and without RC.We find, after substituting our solution for A(σ) in (6.7) and reverting to the original notation of the problem, that the audio component of the output satisfies (6.8) g a (t) ∼ g 0 (t) + g 1 (t) + 2 g 2 (t) + 3 g 3 (t), Table 1 Results for s(t) = 0.9 sin 2πf 1 t, with f 1 = 5kHz, giving the amplitudes of the fundamental, second, and third harmonics in the output.The missing entry indicates that, to the order we have calculated, our analytical results predict only second-harmonic distortion with RC (although higher harmonics arise later in the perturbation expansion of the output).where g 0 (t) = s(t), (6.9)

Without
We see now that without RC (i.e., taking k = 0), nonlinearity in s arises in each term from g 1 onwards.This nonlinearity causes (undesirable) harmonic distortion in the output.Furthermore, we note that all contributions in g 0 , g 1 , and g 2 are predicted by our analysis of the small-signal model (cf.(5.26)), although the underlined term in g 3 cannot be found from that model, because it involves products of time derivatives (neither can some of the other terms in the mess we have denoted "further terms").
The significant benefit of RC (with k = 1) appears starkly in the results above: all terms in the full audio output are linear in s, until O( 3 ), where the first nonlinear term occurs.Recall that the output predicted by the small-signal model in this case is entirely linear in s, so any nonlinearity in the full output is beyond that model.

Simulation results.
To corroborate the analysis above, we have carried out simulations of the amplifier with and without RC, using (3.1) to calculate a sequence of output switching times.We then discard initial transients and use (5.6) to determine the corresponding output Fourier transform ĝ(ω) (with slight modifications because our simulation has finite duration).We are thus able to determine numerically the contributions to the output at various frequencies.We then compare these to the asymptotic predictions from (6.8)-(6.12).The amplifier parameters are chosen to be typical for the operation of this device: T −1 = 384kHz and c = 0.8/T .
We carry out two sets of simulations: in the first, s(t) = 0.9 sin 2πf 1 t, with f 1 = 5kHz, and we expect to see this fundamental and its harmonics in the output; in the second, s(t) = 0.5 sin 2πf 0 t + 0.4 sin 2πf 1 t, with f 0 = 1kHz and f 1 = 5kHz, and we expect to see in addition "intermodulation terms" with frequencies that are integer combinations of f 0 and f 1 .If we choose the "typical" frequency as 5kHz in each case, then our small parameter is = 2πf 1 T ≈ 0.08.
Results for the first simulation are summarized in Table 1, where we show the amplitude of the fundamental and the second and third harmonics.Without RC, the analytical results are quoted based on terms up to and including those in g 3 , including those not quoted explicitly in (6.12) (although we note that the terms in g 3 affect only the fourth decimal place of the analytical result).With RC, the harmonics are much smaller than without; said differently, there is less harmonic distortion.Again, we use terms up to and including g 3 for the analytical results; the only nonlinear term is then that underlined in (6.12), so there is not yet any third or higher harmonic present in the analytical result.
Results for the second simulation are summarized in Table 2, where we have included the main output frequency components in the range 1-10kHz.This provides a more exacting test of the nonlinear terms than does the first simulation.Both with and without RC, there is excellent agreement between analysis and numerics.Since the analytical results include terms up to g 3 , with RC the only nonlinearity is quadratic and hence the only frequency components generated in the range 1-10kHz are those with nonzero entries in Table 2.The impressive performance of RC in removing extraneous frequency components from the output is clear (that is, RC significantly reduces the so-called intermodulation distortion).[12,14] is a highly effective means of significantly reducing audio distortion in class-D amplifiers.Through achieving the highest possible loop gain across the audio band, the technique is able to suppress imperfections in the output stage.RC may also be used to improve the performance of other switching technologies, such as current and voltage control loops, DC-to-DC or DC-to-AC power converters, or high-precision motor drives.In this paper, we have presented the first detailed mathematical analysis of this technique, leading to an explicit expression for the fully nonlinear audio output of the amplifier.This expression quantifies in detail for the first time how RC significantly linearizes the amplifier output and thus fundamentally improves our understanding of the RC technique.

Conclusions. Ripple compensation (RC)
In the present design, the only system parameter involved in the coefficient of the leading output nonlinearity is the switching period, so the only way to design this term to be small is to choose as high a switching frequency as possible.In future work, we intend to apply our analysis to higher-order designs, in the expectation that it may be possible to tune the system parameters (in a more meaningful way than indefinitely increasing the switching frequency) to reduce the nonlinearity in the output.
Our work has proceeded by first reducing the mathematical model to a nonlinear difference equation for the duty cycle.This approach effectively "factors out" the fast dynamics associated with the switching and can be applied generally to switching systems.Of course, the idea of such a reduction to difference equations is clearly not new (see, for example, [13,16]), but in the literature the subsequent analysis usually focuses on determination of the steady-state operating point and investigation of its stability and bifurcations as the parameters of the problem are varied.By contrast, here our interest is in the response to slowly varying input, under the assumption of stable operation.
We close by noting that one aspect of particular significance in the present work is our extension of the standard small-signal model to yield the most significant components of the audio output in response to a general audio input signal.This aspect of our work has wide potential applicability beyond the present case.

Table 2
Results for s(t) = 0.5 sin 2πf 0 t + 0.4 sin 2πf 1 t, with f 0 = 1kHz and f 1 = 5kHz, giving the amplitudes of the output contributions at various frequencies.Missing entries indicate either terms absent from the analytical expression for the output to the order calculated or negligible numerical contributions.