A New Recursive Quadrature Oscillator

Similar documents
Voltage. Oscillator. Voltage. Oscillator

Understanding Poles and Zeros

Positive Feedback and Oscillators

Lock - in Amplifier and Applications

7. Beats. sin( + λ) + sin( λ) = 2 cos(λ) sin( )

Design of op amp sine wave oscillators

Auto-Tuning Using Fourier Coefficients

PCM Encoding and Decoding:

ALGEBRA 2/TRIGONOMETRY

SWISS ARMY KNIFE INDICATOR John F. Ehlers

L and C connected together. To be able: To analyse some basic circuits.

Friday, January 29, :15 a.m. to 12:15 p.m., only

Implementation of Digital Signal Processing: Some Background on GFSK Modulation

Switch Mode Power Supply Topologies

EDEXCEL NATIONAL CERTIFICATE/DIPLOMA UNIT 5 - ELECTRICAL AND ELECTRONIC PRINCIPLES NQF LEVEL 3 OUTCOME 4 - ALTERNATING CURRENT

Introduction to FM-Stereo-RDS Modulation

The front end of the receiver performs the frequency translation, channel selection and amplification of the signal.

ANALYZER BASICS WHAT IS AN FFT SPECTRUM ANALYZER? 2-1

HYBRID FIR-IIR FILTERS By John F. Ehlers

Synchronization of sampling in distributed signal processing systems

SIGNAL PROCESSING & SIMULATION NEWSLETTER

Broadband Networks. Prof. Dr. Abhay Karandikar. Electrical Engineering Department. Indian Institute of Technology, Bombay. Lecture - 29.

FFT Algorithms. Chapter 6. Contents 6.1

A Sound Analysis and Synthesis System for Generating an Instrumental Piri Song

Example #1: Controller for Frequency Modulated Spectroscopy

Experiment # (4) AM Demodulator

Electrical Resonance

Abstract. Cycle Domain Simulator for Phase-Locked Loops

From Concept to Production in Secure Voice Communications

Lecture - 4 Diode Rectifier Circuits

Convolution. The Delta Function and Impulse Response

Transformerless UPS systems and the 9900 By: John Steele, EIT Engineering Manager

DIODE CIRCUITS LABORATORY. Fig. 8.1a Fig 8.1b

DDS. 16-bit Direct Digital Synthesizer / Periodic waveform generator Rev Key Design Features. Block Diagram. Generic Parameters.

Adding Sinusoids of the Same Frequency. Additive Synthesis. Spectrum. Music 270a: Modulation

Magnetic Field Modeling of Halbach Permanent Magnet Array

Appendix D Digital Modulation and GMSK

BASIC ELECTRONICS AC CIRCUIT ANALYSIS. December 2011

2 Session Two - Complex Numbers and Vectors

POWER SYSTEM HARMONICS. A Reference Guide to Causes, Effects and Corrective Measures AN ALLEN-BRADLEY SERIES OF ISSUES AND ANSWERS

SIGNAL GENERATORS and OSCILLOSCOPE CALIBRATION

Jitter Transfer Functions in Minutes

Optical Fibres. Introduction. Safety precautions. For your safety. For the safety of the apparatus

Graham s Guide to Synthesizers (part 1) Analogue Synthesis

Discrete-Time Signals and Systems

Op-Amp Simulation EE/CS 5720/6720. Read Chapter 5 in Johns & Martin before you begin this assignment.

CIRCUITS LABORATORY EXPERIMENT 3. AC Circuit Analysis

(Refer Slide Time: 01:11-01:27)

J.Instrum.Soc.India 30(1)29-34 PROGRAMMABLE CONTROL OF TEMPERATURE: A SIMPLE AND VERSATILE METHOD. N. Asha Bhat and K. S. Sangunni.

Section 3. Sensor to ADC Design Example

CHAPTER 5 Round-off errors

FREQUENCY CONTROLLED AC MOTOR DRIVE

THE BASICS OF PLL FREQUENCY SYNTHESIS

South Carolina College- and Career-Ready (SCCCR) Pre-Calculus

Computer Networks and Internets, 5e Chapter 6 Information Sources and Signals. Introduction

Non-Data Aided Carrier Offset Compensation for SDR Implementation

Second Order Systems

FREQUENCY RESPONSE ANALYZERS

FAST Fourier Transform (FFT) and Digital Filtering Using LabVIEW

Transistor Amplifiers

Understand the effects of clock jitter and phase noise on sampled systems A s higher resolution data converters that can

USB 3.0 CDR Model White Paper Revision 0.5

Bipolar Transistor Amplifiers

Basic numerical skills: EQUATIONS AND HOW TO SOLVE THEM. x + 5 = = (2-2) = = 5. x = 7-5. x + 0 = 20.

The Effective Number of Bits (ENOB) of my R&S Digital Oscilloscope Technical Paper

Understanding the Effect of Uncorrelated Phase Noise on Multi-channel RF Vector Signal Generators and Analysers

Measuring Impedance and Frequency Response of Guitar Pickups

Timing Errors and Jitter

METHODOLOGICAL CONSIDERATIONS OF DRIVE SYSTEM SIMULATION, WHEN COUPLING FINITE ELEMENT MACHINE MODELS WITH THE CIRCUIT SIMULATOR MODELS OF CONVERTERS.

PeakVue Analysis for Antifriction Bearing Fault Detection

VCO Phase noise. Characterizing Phase Noise

25. AM radio receiver

LM 358 Op Amp. If you have small signals and need a more useful reading we could amplify it using the op amp, this is commonly used in sensors.

FEGYVERNEKI SÁNDOR, PROBABILITY THEORY AND MATHEmATICAL

ANALYTICAL METHODS FOR ENGINEERS

12.4 UNDRIVEN, PARALLEL RLC CIRCUIT*

Harmonics and Noise in Photovoltaic (PV) Inverter and the Mitigation Strategies

Energy Saving systems for Induction motors.

APPLICATION NOTE AP050830

2.2 Magic with complex exponentials

Basic Op Amp Circuits

QAM Demodulation. Performance Conclusion. o o o o o. (Nyquist shaping, Clock & Carrier Recovery, AGC, Adaptive Equaliser) o o. Wireless Communications

AM Receiver. Prelab. baseband

Analog Representations of Sound

The Fourier Analysis Tool in Microsoft Excel

MEASUREMENT UNCERTAINTY IN VECTOR NETWORK ANALYZER

Em bedded DSP : I ntroduction to Digital Filters

Title : Analog Circuit for Sound Localization Applications

Active Vibration Isolation of an Unbalanced Machine Spindle

Measuring Line Edge Roughness: Fluctuations in Uncertainty

Interfacing Analog to Digital Data Converters

Introduction to Receivers

Performing Amplifier Measurements with the Vector Network Analyzer ZVB

LogicLab s.r.l Via della valle Carate Brianza (MI) Tel Fax

Controller Design in Frequency Domain

Second Order Linear Nonhomogeneous Differential Equations; Method of Undetermined Coefficients. y + p(t) y + q(t) y = g(t), g(t) 0.

Maximum Likelihood Estimation of ADC Parameters from Sine Wave Test Data. László Balogh, Balázs Fodor, Attila Sárhegyi, and István Kollár

FOURIER TRANSFORM BASED SIMPLE CHORD ANALYSIS. UIUC Physics 193 POM

Transcription:

A New Recursive Quadrature Oscillator Martin Vicanek 21. October 2015 1 Introduction Digital harmonic oscillators are standard devices used in sound synthesis, control systems, test and measurement equipment, heterodyning, frequency conversion, and many other DSP applications. A harmonic or sine wave oscillator generates a pure tone without any overtones. In additive synthesis, a number sine waves are added to generate timbre the Hammond organ is a prominent example of this principle. Methods for generating sine waves in the digital domain fall roughly into two categories: 1. Recursive oscillators, where the actual output value is computed from previous states 2. Direct evaluation as a function of a phase accumulator (= non bandlimited ramp) The scheme presented in this note belongs to the first category. There are many algorithms for recursive oscillators, with different characteristics in terms of accuracy (especially at low frequencies), stability, computational complexity, etc.[1, 2]. In this note I present a new quadrature oscillator as the only hyperstable, equi-amplitude quadrature oscillator that I am aware of. Recursive oscillators perform best at constant frequency. Modulation requires coefficient(s) updating and may often result in amplitude change. For 1

an equi-amplitude quadrature oscillator, the situation is less problematic. It is somewhat difficult to add phase modulation (it can be done for a quadrature oscillator, but it is not very efficient). 2 Recursion Scheme Let u n and v n denote the oscillator outputs. The goal is to provide recursion equations for a harmonic quadrature oscillation, i.e. u n = cos(nω), v n = sin(nω) (1) with a specified frequency ω in radians per sample. Given the state at some discrete point in time n, the next state may be found by a simple rotation. For reasons to become clear later, we will first advance from time n by half a sample to the intermediate time n + 1/2,: u n+1/2 = cu n sv n (2) v n+1/2 = su n + cv n (3) where we have used the abreviations c = cos(ω/2) and s = sin(ω/2). Advance another half step to time n + 1, u n+1 = cu n+1/2 sv n+1/2 (4) v n+1 = su n+1/2 + cv n+1/2 (5) Likewise, we may write down equations for the reverse transitions by half a sample frm n + 1 to n + 1/2, and from n + 1/2 to n: u n+1/2 = cu n+1 + sv n+1 (6) v n+1/2 = su n+1 + cv n+1 (7) u n = cu n+1/2 + sv n+1/2 (8) v n = su n+1/2 + cv n+1/2 (9) We will not make use of all eight equations (2)-(9), since they are redundant. It will be sufficient to use a selection of four, namely equations (2) and (6), 2

and equations (5) and (9). Thus, equation (2) provides an expression for the intermediate state u n+1/2. Then equation (6) advances u another half step to the time n + 1. To propagate v from n to n + 1, subtract equation (9) from equation (5) to obtain v n+1 = v n + 2su n+1/2 (10) Note that the intermediate state u n+1/2 is only an internal temporary variable, a stepstone to leapfrog from v n to v n+1. We may save two multiplies if we work with the auxiliary quantity w n := u n+1/2 /c. Then equations (2), (10) and (6) become where the two constants k 1 and k 2 are w n = u n k 1 v n (11.1) v n+1 = v n + k 2 w n (11.2) u n+1 = w n k 1 v n+1 (11.3) k 1 = tan(ω/2), k 2 = 2 sin(ω/2) cos(ω/2) = sin ω = 2k 1 /(1 + k 2 1) (12) Equations (11.1)-(11.3) constitute the main result of this paper. With initial values chosen as u 0 = 1, v 0 = 0 (13) the result of the recursion is a quadrature harmonic oscillation as in equation (1). Figure 1 shows the block diagram corresponding to equations (11). Below is a sample-by-sample processing algorithm in pseudocode. // initialize u and v at start do{ u = 1; v = 0; } // update coefficients if frequency changes do{ update w; 3

k1 = tan(0.5*w); k2 = 2*k1/(1 + k1*k1); } // iterate filter for every sample do{ tmp = u - k1*v; v = v + k2*tmp; u = tmp - k1*v; } 3 Stability For a stability analysis we take the z-transform of equations (11.1)-(11.3), w(z) = u(z) k 1 v(z) zv(z) = v(z) + k 2 w(z) zu(z) = w(z) zk 1 v(z) (14) Eliminating w(z) and rearranging, we obtain the following homogeneous system of equations for u(z) and v(z): k 2 u + [(1 k 1 k 2 ) z]v = 0 (z 1)u + (z + 1)k 1 v = 0. (15) Nontrivial solutions exist where the determinant vanishes, z 2 2(1 k 1 k 2 )z + 1 = 0 (16) For 0 < k 1 k 2 < 2, the roots z 1,2 of equation (16) are complex conjugate and lie exactly on the unit circle. We may write with the frequency ω given by z 1,2 = e ±iω (17) cos ω = 1 k 1 k 2. (18) 4

Even if k 1 and k 2 are subject to quantization in a real implementation, the poles still lie exactly on the unit circle hence preventing exponential runaway: the presented oscillator is hyperstable, as opposed to the well-known coupled form quadrature oscillator. Futrhermore, by virtue of equation (15), ( ) u/v = ±i sin ω/k 2 = ±ik 1 / tan(ω/2) = ±i k 1 k 1, (19) 2k2 i.e. the eigenmodes exhibit a phase lag between u and v of exactly π/2, regardless of coefficient quantization. The ratio of the corresponding amplitudes is unity if k 2 = 2k 1 /(1 + k1) 2 (20) In practice, equation (20) will be valid only within machine precision, resulting in slightly different amplitudes. 4 Modulation An interesting question is how the system responds to frequency modulation, i.e. coefficient changes while running freely. Neglect for a moment roundoff errors introduced by finite precision arithmetics, then the trajectory in u-vspace will be an ellipse. A deviation from a circular trajectory occurs because equation (20) is fulfilled only to machine precision. Now if we change the values of k 1 and k 2, the system s trajectory will simply switch to another ellipse, possibly moving at a different speed. As long as equation (20) remains approximately valid, the new ellipse will be close to circular. If coefficients are changed frequently, the deviations may accumulate in the long run, ultimately resulting in an altered amplitude. Whether or not this is a concern depends on the application. For sound generation in a musical context, this is not an issue at all. 5

5 Roundoff Error A rigorous analysis of the effect of roundoff errors on the iteration equation (11) is beyond the scope of this note. Quantization is often modelled as additive noise, without taking into account a possible correlation to the signal itself. Such a model would result in a slow drift with the accumulated error increasing as the square root of the number of iterations. However, this behavior is not supported by empirical findings, which suggest that the system rather locks in into a limiting cycle. The oscillator has been run at 44.1 khz sample rate for days, with varying initial conditiona and coefficient values. In no case has there been an unbounded drift. Again, this is in harsh contrast with the coupled form oscillator, which shows systematic deviations already in the first few seconds, and ultimately terminates in an exponential runaway. 6

Appendix: Some Common Oscillators Table 1 lists some recursive oscillators with their respective properties. For each listed oscillator tyxpe we give the governing equations below. Biquad Oscillator The biquad oscillator is a direct form I realization, and is the most used oscillator form. With one multiply and one add it is a very economic scheme, however accuracy is bad at low frequencies. Recurrence Parameter Initialization Output u n+1 = ku n u n 1 k = 2 cos ω u 1 = 0 u 0 = sin ω u n = sin(nω) Reinsch Oscillator This is another CPU friendly oscillator, with good accuracy at low frequencies. It is the ideal static oscillator. Recurrence Parameter Initialization Output u n+1 = u n + v n k = 4 sin 2 ( 1ω) 2 u 0 = 0 v n+1 = v n ku n+1 v 0 = sin ω u n = sin(nω) v n = A cos[(n + 1 2 )ω] A = 2 sin( 1 2 ω) Digital Waveguide Oscillator Another one-multiply oscillator with quadrature output, however with bad accuracy at low frequencies. 7

Recurrence Parameter Initialization Output s n = k(u n + v n ) t n = s n + u n u n+1 = s n v n v n+1 = t n k = cos ω u 0 = 0 v 0 = 1 u n = A sin(nω) v n = cos(nω) A = tan( 1 2 ω) Quadrature Oscillator with Staggered Update Recurrence Parameter Initialization Output v n+1 = u n + kv n k = cos ω u 0 = 0 u n+1 = kv n+1 v n v 0 = 1 u n = A sin(nω) v n = cos(nω) A = sin ω Magic Circle Oscillator A popular almost quadrature oscillator. The outputs have equal amplitudes and a phase difference of 90 degrees plus half a sample. Recurrence Parameter Initialization Output u n+1 = u n kv n k = 2 sin( 1ω) 2 u 0 = cos( 1ω) 2 v n+1 = v n + ku n+1 v 0 = 0 u n = cos[(n 1 2 )ω] v n = sin(nω) Coupled Form Oscillator The standard quadrature, equal amplitudes oscillator. Unfortunaltely it is not numerically stable: if left run freely, amplitudes will grow or decay exponentially because the poles generally do not lie exactly on the unit circle. Therefore, some sort of automatic gain control has to be applied. Updating the parameters, i.e. frequency modulation, is somewhat CPU-demanding. 8

Recurrence Parameters Initialization Output u n+1 = k 1 u n k 2 v n v n+1 = k 2 u n + k 1 v n k 1 = cos ω k 2 = sin ω u 0 = 1 v 0 = 0 u 0 = cos(nω) v 0 = sin(nω) Present Work A stable quadrature oscillator with equal amplitudes, good accuracy at low frequencies, and reasonable CPU load. Recurrence Parameters Initialization Output w n = u n k 1 v n v n+1 = v n + k 2 w n k 1 = tan( 1 2 ω) k 2 = sin ω u 0 = 1 v 0 = 0 u 0 = cos(nω) v 0 = sin(nω) u n+1 = w n k 1 v n+1 References [1] P. Symons, Digital Waveform Generation, Cambridge University Press 2013, pp. 90-108. [2] Clay Turner, Recursive Discrete Time Sinusoidal Oscillators, IEEE Signal Processing Mag, May 2003, p103-111. [3] J. W. Gordon and J. O. Smith, A Sine Generation Algorithm for VLSI Applications, in Proc. Int. Computer Music Conf. (1985), pp. 165168. [4] J. O. Smith and P. R. Cook, The Second-Order Digital Waveguide Oscillator, in Proc. Int. Computer Music Conf. (1992), pp. 150153. 9

Figure 1: Block diagram of the oscillator corresponding to equations (11) Oscillator type Stable Biquad yes no yes no Reinisch no nearly yes yes Digital Waveguide no yes yes no Quad Staggered Update no yes yes no Magic Circle yes nearly yes yes Coupled Quad yes yes no yes This work yes yes yes yes Table 1: Some common oscillators and their properties Equal amplitudes Quadrature Lowfrequency accurate 10