6
Sine-wave synthesis using Walsh functions W.A. Evans, FIEE Indexing terms: Simulation, Signal processing, Computer simulation Abstract: An investigation of the synthesis of sine waves from a truncated series of Walsh waves of ascending sequency is described. Computer simu- lation of the model is carried out in establishing potential circuit performance. A prototype circuit has been built and tested to add validity to the theoretical results. 1 Introduction The digital generation of approximated sine waves includes table look-up methods [1, 2, 3], solution of the second-harmonic difference equation [1], filtering of a square wave in a nonrecursive transversal filter [5] and recursive digital filter methods [6]. The latter involves the use of at least one digital multiplier. In this paper the use of Walsh functions for the generation of sine waves is investigated through a simulation study. A prototype has been built based on the results of the theoretical investi- gation. Digital techniques for sine and arbitrary wave generation are now gaining wider acceptance as new advances in technology combined with computer-aided design reduce the costs of additional complexity. The Walsh-function approach offers an economy of hardware that merits serious consideration which should prove attractive to the aspiring custom LSI chip designer. 2 Walsh functions Walsh functions form a complete set of two-valued orthonormal functions with values +1. The orthonormal property is graphically illustrated in Fig. 1 and when used in the expansion of an arbitrary function it is conve- nient to relate the order n of a Walsh function to the number of zero crossings over which it is defined. The literature abounds with different definitions of Walsh functions. Harmuth [7] used a complicated recursive relationship having the virtue of ordering the Walsh func- tions such that increasing n corresponds to increasing zero crossings where half the number of zero crossings in the interval 6 is the waveform sequency t T (1) and T is the time base. It follows that sequency, mea- sured in zero crossings per second (zc/s) is a somewhat more general form of frequency removing the restriction that they be equally spaced. Paper 5O8OG (El, E10),firstreceived 25th February and in revised form 22nd September 1986 The author is with the Department of Electrical and Electronic Engin- eering, University College of Swansea, Singleton Park, Swansea, SA2 8PP, United Kingdom Wai (3.9)- • 1 Wal(5,G)-f - - — -1 -1 Wal(3,e)Wal(5. * '2 Wal(3,e)Wal(5.8) / / / \ -'2 4 0 *'t* *'2 -tflFtfb" Wal(3,0) -1 Wal(3.0) -1 Wal(3,G)Wal(3,e) •A, Wal(3,e)Wal(3,e)de Fig. 1 Orthogonal property of Walsh waves For the purposes of this work a more useful definition of Walsh functions is in terms of Rademacher functions. Lackey and Meltzer [8] have provided a simplified defi- nition based on this approach which preserves the order- ing of the Walsh functions so that the corresponding sal and cal functions have the sequency as part of the argu- ment. Proof of the methods employed has been provided by Da vies [9] with additions by Van Till [10]. IEE PROCEEDINGS, Vol. 134, Pt. G, No. 1, FEBRUARY 1987

Sine-wave synthesis using walsh functions

  • Upload
    wa

  • View
    212

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Sine-wave synthesis using walsh functions

Sine-wave synthesis using Walsh functions

W.A. Evans, FIEE

Indexing terms: Simulation, Signal processing, Computer simulation

Abstract: An investigation of the synthesis of sinewaves from a truncated series of Walsh waves ofascending sequency is described. Computer simu-lation of the model is carried out in establishingpotential circuit performance. A prototype circuithas been built and tested to add validity to thetheoretical results.

1 Introduction

The digital generation of approximated sine wavesincludes table look-up methods [1, 2, 3], solution of thesecond-harmonic difference equation [1], filtering of asquare wave in a nonrecursive transversal filter [5] andrecursive digital filter methods [6]. The latter involvesthe use of at least one digital multiplier. In this paper theuse of Walsh functions for the generation of sine waves isinvestigated through a simulation study. A prototype hasbeen built based on the results of the theoretical investi-gation. Digital techniques for sine and arbitrary wavegeneration are now gaining wider acceptance as newadvances in technology combined with computer-aideddesign reduce the costs of additional complexity. TheWalsh-function approach offers an economy of hardwarethat merits serious consideration which should proveattractive to the aspiring custom LSI chip designer.

2 Walsh functions

Walsh functions form a complete set of two-valuedorthonormal functions with values + 1 . The orthonormalproperty is graphically illustrated in Fig. 1 and whenused in the expansion of an arbitrary function it is conve-nient to relate the order n of a Walsh function to thenumber of zero crossings over which it is defined. Theliterature abounds with different definitions of Walshfunctions. Harmuth [7] used a complicated recursiverelationship having the virtue of ordering the Walsh func-tions such that increasing n corresponds to increasingzero crossings where half the number of zero crossings inthe interval 6 is the waveform sequency

tT

(1)

and T is the time base. It follows that sequency, mea-sured in zero crossings per second (zc/s) is a somewhatmore general form of frequency removing the restrictionthat they be equally spaced.

Paper 5O8OG (El, E10), first received 25th February and in revised form22nd September 1986The author is with the Department of Electrical and Electronic Engin-eering, University College of Swansea, Singleton Park, Swansea, SA28PP, United Kingdom

Wai (3.9)-• 1

Wal(5,G)-f - - —

-1

-1

Wal(3,e)Wal(5.

* '2Wal(3,e)Wal(5.8)

/ / / \- '2 4 0 *'t* *'2

-tflFtfb"

Wal(3,0)

-1

— Wal(3.0)-1

Wal(3,G)Wal(3,e)

•A,

Wal(3,e)Wal(3,e)de

Fig. 1 Orthogonal property of Walsh waves

For the purposes of this work a more useful definitionof Walsh functions is in terms of Rademacher functions.Lackey and Meltzer [8] have provided a simplified defi-nition based on this approach which preserves the order-ing of the Walsh functions so that the corresponding saland cal functions have the sequency as part of the argu-ment. Proof of the methods employed has been providedby Da vies [9] with additions by Van Till [10].

IEE PROCEEDINGS, Vol. 134, Pt. G, No. 1, FEBRUARY 1987

Page 2: Sine-wave synthesis using walsh functions

Rademacher functions are defined by the relationship Table 1: Determination of mean square error e

Rn(6) = sgn (2"7r0) (2)

where n is a nonnegative integer value.They are orthonormal in ± 1, but they do not form a

complete set. They are simply a series of rectangularwaves of descending period as may be found at theoutputs of successive stages of a synchronous binarycounter, i.e. only those square waves with 2" sign chargesin the half-open interval.

Sequency-ordered Walsh functions may be defined interms of Rademacher functions according to the relation-ship

Wai (n, 6>)= UtoRtf)

where n is a binary number of the form

n = b m b m - x . . . b x

a n d

(3)

(4)

gi = bi®bi+i (5)

For the purposes of the above the EXCLUSIVE ORoperation is to the binary variable 0, 1 as the operationof multiplication is to the variable + 1 , — 1.

As an example, the generation of Wai (13, 6) proceedsas follows:

13,o = 1101, = 1011,'10

i.e.

Wai (13, 6) =

Approximation model

(6)

An arbitrary function f(6) may be expanded as a Walshseries according to the relation

/(0)= (7)

where n is an integer.A truncated series leads to an approximation for/(0).

An estimate of the accuracy of the sine-wave approx-imation is provided by the mean square error e given by

1(8)

where eqn. 8 is derived in Appendix 9.Table 1 has been constructed using eqn. 8. The coeffi-

cient Cr is zero for all values of r other than those enteredin Table 1 over the range considered. An unexpectedresult emerges with the points forming groups of length Lwhere L = 2N (N integer) such that within each groupthere is a small variation in error. Convergence is rapidenough to suggest the Walsh-wave synthesis is a usefulmethod for approximate sine-wave generation.

A simulation study was adopted with the object ofproviding essential circuit data for design purposes aswell as estimating the theoretical performance of thecircuit. Fig. 2 is the basis of' the system model wherebinary voltages are used to represent the functions Wai(n, 9) multiplying each one by its respective coefficientCn. Each branch of the summing network thus providesa current which is the product of the input voltage func-tion and the conductance coefficient: thus, a means of'weighting' the Walsh functions is incorporated. The cur-

1

5

9

13

17

21

25

29

2

n1.6

0.272

In0.840

In0.08

~2n~0.056

2rt0.276

2n0.288

2n

0.4050849

0.064845

0.001874

0.017873

0.0001621

0.0000794

0.0019294

0.0021009

0.4052849

0.4701299

0.4720039

0.4898769

0.4900390

0.4901184

0.4920498

0.4941487

0.09447

0.0298701

0.0279961

0.0101231

0.0099610

0.0098816

0.0079522

0.0058513

Wai (0,9)

Wal(1,e)

of(6)

Wal(n,9)

WaKn.G)

Fig. 2 Basis of a system model

rents are summed by the operational amplifier resultingin the approximated output.

Circuit performance is assessed from a knowledge ofthe level and distribution of the unwanted harmonics.The distortion factor provides a useful measure of theharmonic contamination where

distortion factor =[ I (sf + C!YI2~\

x 100% (9)

where S, is the magnitude of the sine component of theith harmonic, C,- is the magnitude of the cosine com-ponent of the ith harmonic, and St and Cy are the sineand cosine components of the fundamental frequencyrespectively.

The simulation system was structured so that it couldbe adopted for the determination of the design param-eters required for the synthesis of most real functions.The programming language used was FORTRAN.

Operation of the simulation program begins byplacing sample data values of the function to be synthe-sised in an array. These are passed to a subprogramwhich performs a fast Walsh transform on the samplevalues with the result that the coefficients of the Walshseries that represent the function emerge from the sub-program. The coefficients are sequency ordered so thatno problems should arise in identifying them. A secondsubprogram is used to generate Walsh functions and the

IEE PROCEEDINGS, Vol. 134, Pt. G, No. 1, FEBRUARY 1987

Page 3: Sine-wave synthesis using walsh functions

result of forming the product of a Walsh function and thecorresponding sequency coefficient is stored in an accu-mulation array. The products constitute weighted Walshfunctions. Use is made of a fast Fourier transform sub-routine [11] to analyse the contents of the accumulatorarray so that the approximated signal may also be rep-resented in terms of its corresponding frequency spec-trum. The spectral distribution after each attempt atsignal restructuring is available: further use being madeof the Fourier coefficients to calculate the distortionfactor. Fig. 3 is a graphical representation of the stepsundertaken by the program for a series truncated to fourterms only.

A graph-plotting routine is incorporated so that accu-rate representations of each approximation may beobtained. When the program is completed the data foreach plot is collectively available in a graphic file. Recon-struction of the signal waveform is a sequential oper-ation; the number of terms in each approximation isincreased with each increment of the loop. The loopingoperation occurs for every sample point of data.

4 Simulation results

A total of 256 samples were employed for the input arrayresulting in a maximum of 63 terms in the Walsh series.The distortion factor curve against number of terms isshown in Fig. 5. The 2N groupings referred to earlier arepronounced with the level of each group about the samevalue. Fig. 4 indicates that for a given approximation allterms up to and including the term occurring at the tran-sition between groups are needed for the best approx-imations. It follows that the number of terms neededshould always be a power of two.

The graph plotting and fast Fourier transform rou-tines have been used in the construction of the resultantapproximated sine waves and their spectra depicted inFigs. 5 and 6. Well behaved sine-wave approximationsresult where the staircase waveform profile exhibits

equally spaced steps. This is reflected in the correspond-ing harmonic content of the waveform. The first term hasthe same spectral response as a square wave. The addi-tion of a second term results in the cancellation of severalharmonics with those that remain arranged in pairs. Thepresence of a third term in the series has the effect ofreintroducing some previously cancelled harmonics — a

5 or

40

r. 30

= 20

1 0

nnniTTTtntTt itmtmtmtmu0 10 20 30 40 50

number of termsFig. 4 Distortion of characteristic

60 70

pattern to be repeated for higher intermediate terms. Thespectrum for further terms in the series results in theelimination of many of the harmonics with a cancellationpattern emerging related to the number of dominantterms employed. Where the number of terms N employedis a power of 2, the harmonics present are given by

4N/c - 1 and 4N/c + 1

where k — 1, 2, 3 etc.The staircase approximation to a sine wave for this

case leads to the maximum elimination of harmonics forthe number of steps present in the approximation [3].

Table 2 is a summary of data provided by the programessential for the translation of the circuit model of Fig. 2

time domain

) = 255sin2TTe

Walsh domain

W f(G) = 163 sa l ( 1,6) - 68 s a l ( 3 , 9 ) - 1 3 sa l ( 5 , 6 ) - 32 sal ( 7,9)

255

Aw-163

3ZO 4Z. 6Z.

-255T-68

-13

sequency ,zc Is

I-32

251

IFourier domain

•f.

-2f.

"3f.

-Af,

"5f.

"6f .-7fo

F[163sal(1,9)] F[ -68sal (3,0)] F[-13sal(5,0)] F[-32sal(7,0)]

.207

—.69 -69«

-41 —

- 2 9

- 3 5

•5

- 1 1 -

- 4 '

.1

. 8 -12 -

- 2 9 ~

.8

-12

Fig. 3 Principle of superposition applied to Walsh-Fourier transforms

IEE PROCEEDINGS, Vol. 134, Pt. G, No. 1, FEBRUARY 1987

Page 4: Sine-wave synthesis using walsh functions

into a practical circuit. All resistor values are normalisedto 10 kQ and it is further assumed that all Walsh func-

Fig. 8 shows the time and frequency outputs of thesynthesised waveform when four Walsh waves are

= 0aEo

-1

a.o

-1

— . . .

• 1 r

— 3 0

-1 -1

_10 32 64

n umber of sample

fir

Fig. 5 First eight approximationsa Number of terms = 1 e Number of terms = 5b Number of terms = 2 / Number of terms = 6c Number of terms = 3 g Number of terms = 7d Number of terms = 4 h Number of terms = 8

tions are provided from a 75 Q, source impedance of atypical CMOS gate.

5 Practical circuit

The design of a practical circuit can follow any one of anumber of strategies. In this design example it wasdecided to confine the synthesis to a maximum of eightterms only. Table 3 has been constructed using eqn. 6.

The Walsh function generator is shown in Fig. 7. Asynchronous binary counter is used to provide the Rade-macher waves. Effects of unequal path delays in the com-binatorial logic are minimised by using a biphase clockwhere the logic outputs are clocked into D flip-flops. Thisapproach has the virtue of provision of a Walsh waveand its inverse at the D flip-flop outputs.

-1

number of sampleh

employed. These have been included purely for illustra-tive purposes: resistor values were chosen to be within2% of the values given in Table 2 (equivalent tospecifying coefficient accuracy to little better than 5 bits)resulting in spurious odd harmonics. Suppressing theseharmonics to more than 70 dB below the fundamentalcalls for resistor tolerances of at least 0.02% of tablevalues. An even harmonic can be discerned between the31st and 33rd harmonic and is a result of the presence ofthe clock fundamental frequency. Given these imperfec-tions the circuit behaviour is in accord with theoreticalpredictions.

It is instructive to compare the results of this workwith those obtained by Davies [5] using a transversalfilter. For an equal number of steps in the approximatedsinewave the amount of circuitry needed is about thesame. For an improved approximation in the case of

IEE PROCEEDINGS, Vol. 134, Pt. G, No. 1, FEBRUARY 1987

Page 5: Sine-wave synthesis using walsh functions

. I

_-10dB

1 - 2 0u * -30

-409 13 1517 21 25 2931 33

-10dB

" 2 0

-30

-A0

5 9 13 17 21 2 5 29 31 33

co0

Fig. 6 Spectral distribution of first eight terms

Sec Fig. 5 for key

Table 2: Data on circuit model in Fig. 2Data values per cycle = 64Base resistance = 0.1 * 105 Q

Walsh functionrequired

159

13172125293337414549535761

Sign

normalinvertedinvertedinvertedinvertednormalinvertedinvertedinvertednormalnormalnormalinvertednormalinvertedinverted

Weighting resistance, Q

0.149517 *1O 5

0.371571 x 105

0.189822 x 1 0 6

0.781876 *1O 7

0.800716 x i o 6

0.193416 x i o 7

0.384128 x i o 6

0.158672 *1O 6

0.324434 x 107

0.783362 x i o 7

0.393853 x i o 8

0.163135 x i o 8

0.160606 x i o 7

0.387843 x 107

0.770868 x 106

0.318865 x i o 6

Summing amp feedback resistance for unity gain0.803560 X 1 0 4 QSumming amp noninverting input resistance for unit gain0.401780 X 1 0 4 Q

Table 3: Rademacher composition of Walsh functions

Walsh function Rademacher compositionsequency

159

1317212529

fj ®/?2©/?3

/?1 ®/? 3 ®/? 4

R ^ R © R/?, ® fl4® R5

/?, ® fl3 ®/?5

/?1®/?2©/?5

Wat(1,9)

7AC163

clockinput

Fig. 7 Walsh-function generator

IEE PROCEEDINGS, Vol. 134, Pt. G, No. 1, FEBRUARY 1987

Page 6: Sine-wave synthesis using walsh functions

Fig. 8 Time- and frequency-domain oscillograms of an approximatedsine wave using four Walsh waves

Walsh waves it is merely a question of adding in thehigher sequency terms with no change in weighting(resistor input values) of the Walsh functions alreadypresent in the approximation. In the case of the trans-versal filter an improved approximation involves anadjustment of the weighting and a change in the corre-sponding resistor values. It follows that higher frequencyof operation can be traded for the number of steps in theapproximation without the need to change resistorvalues. This would not be the case in the work of Davies.

6 Conclusion

A circuit has been described which approximates a sine-wave from a series of Walsh waves. A simulation studyhas established essential data for design purposes. Appli-cations are most likely found in special-purpose instru-mentation where the availability of orthogonal Walshwaves is useful for hardware signal-processing operationsas well as the generation of basic signals.

7 Acknowledgments

I am indebted to former students, W. Walmsley and J.Lewis who carried out some of the detailed programdevelopment.

8 References

1 TIERNEY, J., RADER, CM., and GOLD, B.: 'A digital frequencysynthesizer', IEEE Trans., 1971, AU-19, (1), p. 18

2 JAWARD, S.M., and PAYNE, P.A.: 'A novel technique for pro-grammed generation of multifrequency sinusoids'. IERE Conf. Proc.38, 1977, p. 41

3 EVANS, W.A., and TOWERS, M.S.: 'Hybrid technique in wave-form generation and synthesis', IEE Proc. G, Electron. Circuits &Syst., 1980,127, (3), pp. 119-128

4 EVANS, W.A., GREY, W.A., and DAVIES, E.M.: 'Digital wave-form synthesis', Radio & Electron. Eng., 1975,45, (6), pp. 284-292

5 DAVIES, A.C.: 'Digital generation of low-frequency sine waves',IEEE Trans., 1969, IM-18, (2), p. 97

6 MITRU, S.K., and FURUNO, K.: 'Design of digital sine-cosinegenerator'. Proceedings of Florence Conference on Digital SignalProcessing, Universita di Fuenza, Florence, Italy, 1975, p. 142

7 HARMUTH, H.F.: 'Transmission of information by orthogonalfunctions' (Springer, New York, 1969)

8 LACKEY, R.B., and MELTZER, D.: 'A simplified definition ofWalsh functions', IEEE Trans., 1971, C-20, p. 211

9 DAVIES, A.C.: 'On the definitions and generation of Walsh func-tions', ibid., 1972, C-21, p. 187

10 VAN TILL, J.W.J.: 'On the definition and generation of Walshfunctions, ibid., 1973, C-22, p. 702

11 Nottingham Algorithms Group: 'Subroutine CO6AA5'. Document571, 1973

9 Appendix

The minimum mean square error for an arbitrary func-tion f(6) approximated by a Walsh series is given by

where2n

Kr = Wai (r, 9)2 d6Jo

In the range 0 ^ 9 < 2n

Kr = 2n

For the sine approximation/^) = sin 0 so that

sin2 9d9 = n

(12)

(13)

Substituting eqns. 12 and 13 in eqn. 10

h n ~ r= 1

(14)r = 1

W.A. Evans read physics at Swansea Uni-versity College, receiving a BSc degree inpure science with honours in physics. Hewas awarded the Erisson scholarship topursue information engineering at Bir-mingham University, where he obtainedan MSc degree in 1958. Following indus-trial experience in Canada with FerrantiPackard, Toronto, and RCA ResearchLaboratories, Montreal, he was, for twoyears, a lecturer at the University College

of North Wales, Bangor, before returning to Swansea in 1968.Since that time he has been continuously engaged in researchwork in electronic instrumentation and is currently a Reader inthe Department of Electrical and Electronic Engineering atSwansea. He is a Fellow of the IEE and a Fellow of the Institu-tion of Electronics and Radio Engineers.

IEE PROCEEDINGS, Vol. 134, Pt. G, No. 1, FEBRUARY 1987