Abstract:
Sine and cosine waves are simultaneously accumulated in accordance with the following equations in apparatus embodying the invention. 
     
       M sin θ=[M sin (θ-δθ)] cos δθ+[M cos 
     
      (θ-δθ)] sin δθ 
     
       M cos θ=[M cos (θ-δθ)] cos δθ-]M sin 
     
      (θ-δθ)] sin δθ 
     Here δθ is an incremental angle between successive steps of accumulation.

Description:
This invention relates to the generation, in sampled-data terms, of sine waves and cosine waves of the same frequency and in quadrature phase relationship with each other. 
     BACKGROUND OF THE INVENTION 
     It is sought to avoid the need for using large sine/cosine look-up tables stored in read-only memory (ROM) in order to specify the sine and cosine waves with high precision. Interpolation by linear methods from a ROM with a restricted number of entries does not provide sine and cosine waves with the requisite degree of harmonic purity needed in many applications. Several prior art sine and cosine wave approximation methods have insufficient freedom from harmonic distortion for use in these applications requiring high-precision sine or cosine waves or both. 
     Digital oscillator methods known in the prior art have strong tendencies to provide slightly underdamped or slightly overdamped oscillations, which departure from unity damping is unacceptable in these applications. For example, oscillators for generating sine-waves can be constructed utilizing the equation 
     
         y(n)=A y(n-1)+B y(n-2)+Cx(n-1) 
    
     where x(n)=1 for n=0 and x(n)=0 for all other n. These oscillators take advantage of the second derivative of sin ωt being -ω 2  times as large as sin ωt, the differential equations describing such analog signal behavior being used to generate difference equations in sampled-data terms, of the sort set forth in the preceding sentence. Another digital oscillator method that is known to the inventor, but is unacceptable in that oscillations tend to decay with time, is constructed as a filter for the unit impulse. The filter has a transfer function based on the z transform of the desired output function sin(ωnT), which transfer function equals 
     
         z.sup.-1 sin(ωT)/[1-2 z.sup.-1 cos(ωT)+z.sup.-2 ]. 
    
     SUMMARY OF THE INVENTION 
     An object of the invention is to provide a digital oscillator for generating sine or cosine waves or both with no more than five percent distortion and with pronounced tendency for unity damping factor on the oscillations, as the oscillations neither grow in amplitude nor decay over time. 
     An object of the invention is to generate at least one of sine wave and cosine wave terms in sampled-data form at regularly recurring sample times separated by periods more than sixteen times shorter than that of the waves, where storage of sine wave and cosine wave samples in read-only memory becomes less practical. 
     The area of special interest is the generation of sine and cosine waves where there are at least sixteen samples per cycle and where the number of bits of resolution per sample required to keep distortion satisfactorily low requires a read only memory to store the samples that is larger than the 4096-bit read only memories that can be manufactured at low cost both in money and in silicon-area terms. 
     To achieve these objects ,especially in the area of special interest, sampled-data sine and cosine waves of the same frequency and amplitude are simultaneously accumulated based on the elementary trigonometric relations set forth in the following equations (1) and (2) below: 
     
         sin(A+B)=sin A cos B+cos A sin B                           (1) 
    
     
         cos(A+B)=cos A cos B-sin A sin B                           (2) 
    
     Defining A as a preceding value of angle (θ-δθ) to be incremented by a small angle B=δθ to arrive at a current value of angle, equations (1) and (2) may be rewritten as equations (3) and (4) following. 
     
         sin θ=sin (θ-δθ) cos δθ+cos (θ-δθ) sin δθ               (3) 
    
     
         cos θ=cos (θ-δθ) cos δθ-sin (θ-δθ) sin δθ               (4) 
    
     Here δθ is considered the change in the angle θ between the regularly recurring sample times. Equations (3) and (4) define a representative one of the algorithms in which sin θ and cos θ may be simultaneously accumulated in accordance with the invention. 
     More generally, accumulation is governed by the following equations (5) and (6), derived from equations (3) and (4) by multiplying both sides of these equations by an arbitrary scaling factor M on a distributed basis, M being a real number. 
     
         M sin θ=[M sin(θ-δθ)]cos δθ+[M cos(θ-δθ)]sin δθ            (5) 
    
     
         M cos θ=[M cos(θ-δθ)]cos δθ-[M sin(θ-δθ)]sin δθ            (6) 
    
    
    
     BRIEF DESCRIPTION OF THE DRAWING 
     FIG. 1 is a schematic diagram of apparatus for simultaneously accumulating a sine wave M sin θ and a cosine wave M cos θ, which apparatus embodies the invention. 
     FIG. 2 is a modification of the FIG. 1 apparatus, which modified apparatus embodies the invention in a further one of its aspects. 
     FIG. 3 is a schematic diagram of apparatus for generating precision analog sine and cosine waves, embodying a still further aspect of the invention. 
     FIG. 4 is a schematic diagram of apparatus for generating amplitude-modulation signals in yet another aspect of the invention. 
    
    
     DETAILED DESCRIPTION 
     As shown in FIG. 1, a generator 10 supplies clock signals at sample rate f s  having a periodicity T s  =1/f s . The frequency of the sampled-data sine wave and cosine wave to be generated by the apparatus shown in the drawing is f.sub.θ having a periodicity T.sub.θ =1/f.sub.θ. 
     The incremental angle change δθ that occurs over each period T s  is 2 T s  /T.sub.θ, which equals 2 f.sub.θ /f s . So knowing f.sub.θ (or T.sub.θ), δθ is determined. Knowing δθ, values of sinδθ and cosδθ may be determined (e.g., by table look-up, the method of determining these values not being shown in the drawing) for loading into a sin δθ register 11 and into a cos δθ register 12, respectively. Respective initial values of M sin θ and of M cos θ, M sin θ 0  and M cos θ 0 , are loaded into initial-value registers 13 and 14, respectively. When M, f.sub.θ in terms of f s , and the initial values of the sine and cosine waves are invariant and so need not be programmable, registers 11-14 can be replaced by hard-wired binary numbers of appropriate value, of course. 
     A sample counter 15 receives f s  clocking signals at its count input port, for sequentially counting the number of T s  sample periods that transpire after a reset signal is applied to counter 15. Reset typically is to the all-zero condition. Counter 15 has sufficient count capacity to count to f s  /f.sub.θ-MIN, where f.sub.θ-MIN is the minimum frequency of sin θ and cos θ that is to be expected, supposing f s  is chosen to be a multiple of f.sub.θ. A decoder 16 responds to counter 15 reaching the count (T.sub.θ /T s ) associated with reset to reset counter 15 and to generate jam load control signals for controlling selection by multiplexers 17 and 18 to accumulation registers 19 and 20. (&#34;Jam loading&#34; of an accumulation register such as 19 or 20 refers to a value being inserted into that register other than that generated by normal accumulation procedure.) Responsive to its jam load control signal, multiplexer 17 selects the initial value M sin θ o  stored in register 13 (or hard-wired to multiplexer 17 where this is alternatively done) for loading into the input port of an accumulation register 9 for M sin θ signal. Responsive to its jam load control signal multiplexer 18 selects the initial value M cos θ o  stored in register 14 (or hard-wired to multiplexer 18 where this is alternatively done) for loading into the input port of an accumulation register 20 for M cos θ signal. 
     For all other counts than reset count from counter 15, decoder 16 does not generate jam load control signals for application to multiplexers 17 and 18. In the absence of jam load control signal being applied thereto, multiplexer 17 selects for loading into the input port of accumulation register 19 the sum output signal of an adder 21. In the absence of jam load control signal being applied thereto, multiplexer 18 selects for loading into the input port of accumulation register 20 the difference output signal of a subtractor 22. Accumulation registers 19 and 20 receive f s  clocking signals from source 10 thereof and respond to each clocking signal to update their contents responsive to the signals received at their respective input ports. 
     The accumulation registers 19 and 20 supply current values of M sin θ and M cos θ in sampled-data form. For a subsequent T s  sample period--i.e., for the next accumulation cycle--these are the M sin (θ-δθ) and M cos (θ-δθ) values. The M sin (θ-δθ) value for the next accumulation cycle is supplied as multiplicand signals for digital multipliers 23 and 24 to be multiplied by sin δθ and by cos δθ respectively supplied as multiplier signals from registers 11 and 12. Analogously, the M cos (θ-δθ) value for this next accumulation is supplied as multiplicand signals for digital multipliers 25 and 26 to be multiplied by sin δθ and cos δθ respectively. Adder 21 sums the M sin (θ-δθ) cos δθ product signal from digital multiplier 24 and the M cos (θ-δθ) sin δθ product from digital multiplier 25 to supply the next value of M sin θ to the accumulation register 19 via multiplexer 17. Subtractor 22 subtracts the M sin (θ-δθ) sin δθ product provided digital multiplier 23 from the M cos (θ-δθ) cos δθ product provided by digital multiplier 26, thereby to supply the next value of M cos θ to the accumulation register 20 via multiplexer 18. 
     The generation of sampled-data M sin θ and M cos θ in registers 19 and 20 continues in the same way until decoder 16 decodes a prescribed T.sub.θ /T s  count to generate a reset pulse for restarting the wave generation process at the beginning of a subsequent T.sub.θ period. While the sine wave and cosine wave generation processes could go forward without restarting, periodic restart cleans accumulation errors from the registers 19 and 20. Periodically restarting only once per T.sub.θ period introduces a correction that causes the M cos θ and M sin θ output signals to tend to be accompanied by direct terms and by harmonic terms. 
     FIG. 2 shows a modification of the FIG. 1 apparatus wherein periodic restarting is done twice per T.sub.θ period. Restarting at π radian intervals in θ suppresses the tendencies for restart to introduce into each of the M cos θ and M sin θ output signals a respective direct term and respective harmonic terms. Since accumulation errors tend to be somewhat smaller over shorter periods of time, other harmonic terms may be reduced in amplitude as well, by restarting at π rather than 2π radian intervals in θ. When this is done restart will occur not only every time sample counter 15 is reset, but also midway between the times counter 15 is reset. 
     In the FIG. 2 apparatus the jam load control signals for multiplexers 17 and 18 are generated at the output port of an OR gate 27. OR gate 27 generates a ONE at its output port, which ONE commands jam loading, responsive to a ONE generated by a decoder 28 when a T.sub.θ /2T s  count is reached by counter 15, or responsive to a ONE generated by the decoder 16 when T.sub.θ /T s  count is reached. Unless the values multiplexer 17 jams into M sin θ register 19 at θ=0 radians and θ=π radians are both zero, these values should be opposite in polarity. And, unless the values multiplexer 18 jams into M cos θ register 20 at θ=0 radians and at θ=π radians are both zero, these values also should be opposite in polarity. An arrangement to invert the polarities of M sin θ o  and of M cos θ o  as jammed into registers 19 and 20 is needed when θ is an odd multiple of π. 
     One way to do this is as follows, proceeding with distinguishing between the two types of jam load condition. A NAND gate 29 receives the output signals of the decoders 16 and 28 at respective ones of its input ports. When θ equals zero radians (or an even multiple of π radians) decoders 16 and 28 both issue ONEs, and NAND gate 29 output signal is a ZERO. When θ equals π radians (or an odd multiple thereof) decoder 16 issues a ONE, but decoder 28 issues a ZERO, so NAND gate 29 output signal is a ONE. 
     In the FIG. 2 apparatus a selective complementer 31 is interposed between the M sin θ initial value register 13 and multiplexer 17, and a selective complementer 32 is interposed between the M cos θ initial value register 14 and multiplexer 18. Each of the selective complementers 31 and 32 responds to a control signal supplied thereto from the output port of NAND gate 29. When NAND gate 29 supplies a ZERO as control signal, the output ports of selective complementers 31 and 32 supply the same numbers applied to their respective input ports without polarity reversal. When NAND gate 29 supplies a ONE as control signal, the output ports of the selective complementers 31 and 32 supply numbers of like amplitudes but of opposite polarities, respectively, to those applied to their input ports. A selective complementer for the two&#39;s complement numbering system conventionally used for signed arithmetic can be constructed from a bank of exclusive-OR gates for the control signal and each bit of the input signal to the selective complementer, followed by an adder adding the one&#39;s complement result to a number formed with ZEROs in all bit places except the least significant, which least significant bit place is occupied by the control signal from NAND gate 29. 
     Where T.sub.θ /T s  is an integral power of two, in another embodiment of the invention, decoder 28 can be replaced by a decoder that decodes only those bits less significant than the most significant to generate jam load control signals directly, and OR gate 27 can be dispensed with. 
     If cleansing of errors from accumulation registers 19 and 20 more frequently than twice per cycle is desired, decoder 28 may be replaced by decoder and logic circuitry to generate the jam load signals associated with respective restarts more frequently. Arrangements are then made to load initial value registers before each restart with respective ones of respective cycles of initial values. These cycles of values can be stored in a sine/cosine look-up-table ROM addressed by a counter counting the number of times jam load signals are applied to multiplexers 17 and 18. In effect, the invention is then used as an interpolator for use with sine/cosine look-up-table ROM, which interpolator permits appreciably longer intervals between stored values than is possible with linear interpolation methods or with polynomial interpolation methods when harmonic distortion must be kept low. 
     It is most convenient to arrange only for jam loading M sin θ o  and M cos θ o  values for θ o  equalling 0°, 90°, 180° or 270° because then neither of the initial value registers will be required to carry extended binary fractions. On the other hand providing initial value registers with the capability of carrying extended binary fractions is useful where a number of the sine/cosine wave generators of the invention are to be operated concurrently, but with phase offsets between them. The plurality of sine/cosine wave generators can share the same elements 10, 15, 16, 27, 28, 29. Their different initial values determine the phasing of their output waves. For example in an arrangement using three sine/cosine wave generators having initial value registers loaded with M sin θ o  and M cos θ o , with M sin (θ o  +120°) and M cos (θ o  +120°), and with M sin (θ o  +240°) and M cos (θ o  +240°) respectively, two sets of three-phase sinusoidal output signals are generated. By using these signals and their complements, twelve-phase sinusoidal signals are available with fixed 30° phasing between them. 
     FIG. 3 shows a digital sine and cosine wave generating apparatus 40 of the type shown in FIGURE 1 or of the type shown in FIG. 2 having a digital sine wave output signal therefrom converted to an analog sine wave output signal by a digital-to-analog converter 41. FIG. 3 also shows a digital cosine wave output signal from apparatus 40 being supplied to a digital-to-analog converter 42 for conversion to an analog cosine wave output signal. By making f s  at least 256 times as large as the period of the sine and cosine waves and using eight-bit resolution, distortion can be kept below 3%. By making f s  at least 1024 times as large as the period of the sine and cosine waves and using eight-bit resolution, distortion can be kept below 1%. Storage of the sine wave and cosine wave samples in read-only memory, rather than generating them by accumulation in accordance with the invention, would require unacceptably large memory. 
     FIG. 4 shows the digital sine and cosine wave generating apparatus 40 being used as a source of carrier signal in an amplitude modulator. A digitized sine or cosine wave from generating apparatus 40 is supplied as multiplicand to a digital multiplier 43, there to be multiplied by a relatively-low-frequency digital modulating signal from a source 44 thereof. If the digital modulating signal is superposed upon a direct-component pedestal so its polarity is unchanging, and if digital multiplier 43 operates as a two-quadrant multiplier, the product signal from multiplier 43 will be a double-sideband amplitude-modulation signal not having its carrier suppressed. If source 44 supplies digital modulating signal that is not superposed on a direct-component pedestal, and if digital multiplier 43 operates as a four-quadrant multiplier, the product signal from multiplier 43 will be a suppressed-carrier double-sideband amplitude-modulation signal. 
     It may be desirable, where a large selection of amplitudes are desired from a sine and cosine wave generator, such as those of FIGS. 1 and 2, to use binary place shifters in the output signal connections to make order-of-magnitude changes and to vary M only for fine adjustment of amplitude values. This better maintains accuracy in the calculations because registers 13, 14, 19 and 20 are kept more &#34;full&#34; i.e, with fewer more significant bit places left unchanging at zero. 
     One may also arrange instead to operate with constant M and to alter the amplitudes of the output signal(s) with further digital multiplication(s). This has the advantage that sine wave and cosine wave amplitudes may be individually adjusted. 
     Suppose one desires to modify the apparatus shown in FIG. 1 or 2 to provide a stop/start oscillator. In such case, decoder 16 can be used to selectively withhold f s  clock signals from sample counter is rather than to reset counter 15. Reset signal for the counter 15 is then furnished from another source and is used to command resumption of furnishing f s  clock signals to counter 15. 
     Modifications of any of the previously described arrangements are possible wherein one of the output signals is inverted in polarity. In some applications only one of the output signals will be used. FIGS. 1 and 2 show address 21,22 and multipliers 23-26 being of clocked types, with clock signals for their output latches being forwarded to them from the f s  clock signal generator 10. Where adders 21 and 22 are clocked type, M sin θ and M cos θ waves may be taken from their output ports for use in ensuing apparatus, rather than from the output ports of accumulation registers 19 and 20. One skilled in the art and acquainted with the foregoing disclosure will be enabled to design many variants of the invention, and this should be borne in mind when construing the scope of the claims which follow.