1. Field of the Invention
The invention generally relates to analog to digital conversion circuitry and more particularly to hysteresis techniques used in digital measurement systems.
2. Related Art
There are a number of digital audio media available today. This includes compact disks (CDs), digital audio tapes (DAT) and MP3s, to name the most common types. One problem with each of these media is that they use different sampling rates and thus different frequencies when providing audio data. It would be very expensive to build complete subsystems to handle each of the varying rates, so it has been common to use a device called a sample rate converter to transfer audio data from one digital sampling frequency rate to another. For example, a CD is sampled at 44.1 kHz while a DAT is sampled at 48 kHz. The backend of the system is to operate at only a single frequency, thus it is required to convert one of the signals to that desired frequency. For example, the DAT frequency sample rate of 48 kHz could be converted to a 44.1 kHz rate, which would then be utilized by a digital/analog converter system to provide the desired analog audio signal. Therefore, only a single set of backend circuitry would be required if the rates were converted to a common rate.
To this end, a number of sample rate converter integrated circuits have been developed which have the capability of converting between various input and output frequencies. An example of one of these is the Cirrus Logic CS8420. The basic operation of a sample rate converter is that the data is interpolated at an oversampling rate, then resampled at the desired output rate, and then decimated or filtered to produce the final resultant output. One of the requirements of this process is that the ratio between the input and output clocks be positively determined. For example, in the CS8420 there are 3 to 1 and 1 to 3 maximum ratios. Given this relatively limited ratio, the rate measurement circuitry was relatively simple to build. However, with the advent of the MP3 format and its high-end sampling frequency of 192 kHz, there is a requirement of a wider frequency ratio to be supported, such as approximately 8 to 1. The simple techniques used in the CS8420 to develop the frequency ratio would not be sufficient. In general, the problem developed because the ratio of the input and output frequencies was determined based on the digitization of the analog relationship between the two frequencies. Because of the digitization, quantization errors often appeared, as common in any analog to digital conversion process. Further, in some situations, it is also preferred that a hysteresis behavior be built into the quantization process to prevent the output value from frequently changing, thus enhancing the overall system stability. However, conventional hysteresis rules tend to increase the quantization error because any variation being held in the hysteresis region is basically additive to the quantization error. Given the increased ratio which is desired, the prior technique would have resulted in extremely large swings due to quantization and hysteresis errors as the ratios became large. These swings would have a deleterious effect on the output, so an improved technique is required.
In an adaptive digital hysteresis technique according to the present invention, two modes are used to develop the output value, rather than the conventional single rounding technique, to reduce the quantization errors. To determine which of two different schemes, referred to as floor and ceiling modes, to use, it is necessary to have appropriate trip points to select modes. In various embodiments, the floor and ceiling trip points are developed based on the value of the input signal. For example, if the input signal exceeds a given amount, floor mode is used, while if it is below a given amount ceiling mode is used. If in a given mode, further data values are received that do not meet or exceed the other trip point, operation continues in the existing mode. When the trip point for the other mode is exceeded and the next trip point for the current mode is not exceeded, then the mode is changed. Thus, the output values of the technique have a lower output error as compared to prior art rounding with hysteresis techniques. This improved hysteresis technique results in a lower error frequency ratio value in a sample rate converter so that large ratios can be used.
The present invention has other advantages and features which will be more readily apparent from the following detailed description of the invention and the appended claims, when taken in conjunction with the accompanying drawings, in which:
The above system is just one simple example for the purpose of illustrating embodiments according to the present invention. Variations are possible, such as different types or numbers of sources and different types of input or output. In other variations, the input and output are simple external connections for the source rate converter, with control settings to program the sample rate converter. One such example is used in professional audio equipment.
The upper 8-bits of the 13-bit counter 400 are provided to a floor input of a two (2) input multiplexer 410. The 8-bit value is also provided to a one adder so that the 8-bit value plus 1 is provided as the second or ceiling (ceil) input of the multiplexer 410. Thus, the 8-bit value from the counter 400 or the 8-bit value plus one are the two potential outputs of the multiplexer 410. The selection of the particular input is based on the output of the D flip-flop 406, which indicates the hysteresis rule that is in effect. The output of the multiplexer 410 is provided to the input of the 8-bit register 408 so that each time the counter 402 rolls over, the upper 8-bits of the counter 400, or potentially one more based on the hysteresis rule, is loaded into the register 408. This value in the register 408 is used by the rate estimator logic 300 as the ratio of the input and output sample rates.
To discuss embodiments according to the hysteresis technique of the present invention, a review of the prior art hysteresis techniques is helpful. Assume that an analog quantity is being digitized into a fixed point number that has a certain number of bits below the radix point. The output of the system is an integer value without those fractional digits and is generated by rounding the value to the closest integer. When the original value is fluctuating around, say, 3.5, the output integer will also frequently switch between 3 and 4. To prevent this switching, it is necessary to build a hysteresis rule which may be prescribed as follows:
where:
O[n]: output of the system at index n
M[n]: measured value at index n
Q[n]=round(M[n]) and
where the round function rounds positive numbers with a 0.5 fractional value or greater to the next highest integer and truncated otherwise.
The maximum output error with this scheme is (1.5−delta). For example, if O[n] is 3, then the maximum M[n] is 4.4999.
Hysteresis techniques according to the present invention have two modes of operation:
Floor mode: O[n]=floor(M[n])
0Ceiling mode: O[n]=ceil(M[n])
where the floor function rounds positive numbers with a fractional value to the truncated integer and the ceil function rounds positive numbers with a fractional value to the next higher integer. It is understood that the rounding can occur at other than integer values of significance if desired.
By properly switching between the two modes, the same hysteresis can be introduced with a smaller maximum error. Switching from one mode to another mode occurs when the M[n] value passes a trip point of the other mode. There are two trip points.
Floor trip point : M[n]=N+delta
Ceiling trip point: M[n]=N+1−delta
where N is an arbitrary integer that is the integer portion of M[n] and delta is the fractional value.
Switching from the ceiling mode to the floor mode occurs when the M[n] value reaches or passes the floor trip point from either direction. The same applies for the floor-to-ceiling mode switching.
The maximum output error with this scheme is (1−delta). Typically, delta is set to the unit in last place or ulp of M[n]. The hysteresis range remains the same as M[n] changes values. In both schemes, the output is changed to a new value just by hitting the threshold, but it requires another change in M[n] equal to or greater than 1 to pass through the hysteresis region.
As an example, assume a delta value of 0.1 and an M[n] value of 5.1. Because this meets the floor trip point of 5.1 based on N=5 and delta=0.1, floor mode is set and O[n]=5. If the value of M[n+1]=6.1, then the value is equal to the next floor trip point of 6.1 and floor mode is set, resulting in O[n+1]=6 due to the operation of floor mode. If M[n+1] is 5.7, then floor mode remains active and O[n+1]=5. If M[n+1] is 4.5, then ceiling mode is entered since this value is past the ceiling mode trip point of 4.9 and then O[n+1]=5. Now, if M[n+2]=5.2, floor mode is entered since the value is past the floor mode trip point of 5.1 and O[n+2]=5. If M[n+3]=6.2, then floor mode is still used but O[n+3]=6.
With the circuit of
In some applications, such as those relating to specific sample rate conversion algorithms, there can be an additional requirement that O[n] must be smaller or greater than M[n]. For the simplicity of explanation, only the “smaller” case is discussed here. One possible prior art hysteresis rule for this case is:
where Q[n]=floor(M[n])−2.
The “−2” term in Q[n] instead of “−1” is necessary because there is a case where O[n]=M[n] with Q[n]=floor(M[n])−1. As an example, when O[n]=3 and M[n+1]=3, then this situation leads to O[n+1]=M[n+1]=3. With this scheme, the maximum output error is (4−delta), for example, when O[n]=3 and M[n+1]=6.999. The hysteresis range is ±2.
On the other hand, the hysteresis technique according to the present invention for this “smaller” case is as follows.
Floor mode: O[n]=floor(M[n])−1
Ceiling mode: O[n]=ceil(M[n])−1
Floor trip point: M[n]=N+delta
Ceiling trip point: M[n]=N+1−delta
The circuit of
The hysteresis technique according to the present invention for the “larger” case is as follows.
Floor mode: O[n]=floor(M[n])+1
Ceiling mode: O[n]=ceil(M[n])+1
Floor trip point: M[n]=N+delta
Ceiling trip point: M[n]=N+1−delta
The maximum output error with this scheme is also (2−delta), with a hysteresis range of ±1.
The circuit of
Thus, a hysteresis technique is provided which improves the output of the sample rate converter by reducing errors in the measured input and output frequency ratio value due to quantization errors
While this hysteresis technique has been illustrated being used with a sample rate converter, it can be used other places where a lower output error is desired for a quantized value based on the conversion or measure of analog values.
Although the invention has been described in considerable detail with reference to certain embodiments, other embodiments are possible. As will be understood by those of skill in the art, the invention may be embodied in other specific forms without departing from the essential characteristics thereof Accordingly, the present invention is intended to embrace all such alternatives, modifications and variations as fall within the spirit and scope of the appended claims and equivalents.