Fast Method for Frequency Measurement by Rational Approximations with Application in Mechatronics

In Automatic Control, Mechatronics and Robotics technical tasks is desirable to have information about certain parameters to control, supervision or fault detection in a system. This information can be estimates by direct measurement of particular variables or using special devices capable of observing the state of system under control. If the first option is selected a physical sensor is required.


Introduction
In Automatic Control, Mechatronics and Robotics technical tasks is desirable to have information about certain parameters to control, supervision or fault detection in a system. This information can be estimates by direct measurement of particular variables or using special devices capable of observing the state of system under control. If the first option is selected a physical sensor is required.
One commonly selected option are the Frequency Domain Sensors (FDS), this devices converts the desired parameter into a square wave with a frequency or period proportional to physical quantity under measurement. In order to reduce time to obtain information for control a system with sufficient quality and good reliability, a high performance method for frequency measurement is desirable.
Historically, many analog and digital frequency measurement techniques have been proposed. In a basic digital measurement technique, the zero crossings of a signal are detected and a square wave is formed, representing transitions between the binary logic levels low and high. Selected digital logic state is detected and counted, and a measure of frequency is determined by the number of complete cycles occurring in the square waveform during a fixed time interval, determined by the counter's time base [1]. This method can be classified as the classical method and their main error source is the ±1 error count derived from the relative timing of gate and signal, which means that the resolution is 1 Hz during a 1s gate time for all input signal frequencies [2]. For allow high resolution frequency measurements gate time larger than 1s should be selected.
In reciprocal counting measurement techniques, the gate time is determined by electronic detection of two kinds of same phase difference situations between two pulsed signals with www.intechopen.com Modern Metrology Concerns 202 different frequencies [3], or by electronic detection of two coincident pulses of two regular independent pulse trains [5 -6]. In these methods the quantization error (±1 count error) can be overcome satisfactorily [2][3]6]. But, in [3] a high distinguishability analog circuit for phase coincidence detection is required and in [5] the relative methodical error is pulse width dependent for random selection of stop measurement pulse coincidence and, is experimentally probed that relative methodical error can be reduced by two o three orders of magnitude than frequency meters based on classical method [6].
Continuous time stamping principle change the scenario in frequency measurement, because in each measurement has not a defined start (= start trigger event), and a stop (= stop trigger event) plus a dead-time between measurements to read out and clear registers, do interpolation measurements and prepare for next measurement [2]. In this technique Linear regression using the least-squares line fitting is used because for a onesecond frequency measurement in a fast processing counter could contain hundreds o thousands of paced time-stamped events, no just a start event plus a stop event [2]. But fast digital circuits are needed to implement this technique.
However, a fast method for frequency measurement base pulse coincidence principle and rational approximations was proposed and, was shown that under a novel numerical condition for detect the stop trigger event measurement resolution is improved. Instrumental errors are caused only by the reproducibility of the reference frequency and relative measurement error is comparable to the reproducibility of reference oscillator. [7]. Simple digital circuits are needed to practical implementation of this technique.

Frequency measurement based on the pulse coincidence principle
In the past, pulse coincidence principle has been used for frequency measurement of electrical signals [4][5][6]. In this measurement method, a desired frequency is measured by comparing it with a standard frequency. The zero crossings of both frequencies are detected, and a narrow pulse is generated at each crossing. Then, two regular independent pulse trains are generated. The desired and standard trains of narrow pulses are compared for coincidence. This is made with an AND-gate, and then a coincidence pulse train is generated. Coincident pulses can be used as triggers to start and stop a pair of digital counters (start and stop events). See Figure 1.
The standard and desired pulse trains are applied to other counters and a measure of the desired frequency is obtained by multiplying the known standard frequency by the ratio between the desired count and the standard count obtained in the two digital counters [5]. And basically, measurement error reduction depends on the ability to detect a pair of best coincidences consecutively between a large number of these, for a given measurement time. In other works, measurement error reduction depends on reduction of comparison error of time intervals n 0 T 0 and n X T X by selection of adequate coincidence pulses [6].
Consider f x as the desired or unknown frequency and f o as the standard frequency, and 1 xx Tf  and 1 oo Tf  are they periods respectively. In Figure 1, S X (t) and S 0 (t) are the unknown and standard trains of narrows pulses,  is the pulse width on both trains and, S X (t) &S 0 (t) is the irregular pulse coincidence train. Then, n 0 and n X are integer numbers and represent the amount of whole periods between selected measurement start and stop events (see figure 1).
where t m is the measurement time.
It is experimentally known, that for a standard frequency Hz for 6 11 0 X f  Hz under same measurement conditions [6].

functioning and uncertainty limitations
Let us consider two trains of narrow pulses with period X T and 0 T with and pulse width  respectively, generated by detection of zero crossings of two sinusoidal signal of frequencies 0 f and X f . Suppose that 0 T is a known parameter and X T is unknown and, both pulse trains start in phase, i.e. a time shift is 0.
For an appropriate selection of the pulse width of two regular independent pulse trains, periodic perfect coincidences of these pulses are observed in time axis [13]. Repetition period of perfect coincidences is 0 X T , in Fig. 1a). A Practical view of coincidences process is presented in Fig 1 b).
For frequency measurement, the time intervals 00 nT and XX nT are compared, where 0 n is the amount of periods 0 T in the measurement time and X n is the amount of periods X T in the same time interval.
Measurement time can be defined by the time interval between the first one pulse of coincidence (start event) after beginning the measurement process, and by any other following pulse of coincidence (stop event). As it were mentioned in the previous section, 0 n and X n are the counts of pulses obtained in two digital counters.
According to [12], pulse coincidence occurs when 00 XX nT nT where  is the acceptable tolerance (reasonable error value between time intervals 00 nT and XX nT less to pulse with and dependent on the quality of electronic circuits used).
To find values of 0 n and X n which define the appropriated coincidence it is useful to expand 0 X TT as simple continued fractions. This is evident rewriting (3) Left side of equation (3) represents the approximation of 0 X TT using rational numbers and right side is an approximation condition.
For frequency measurement, in a view of 00 In (5), X f is the hypothetical true value of the unknown frequency and 00 X fn n is the frequency value obtained by the measurement. Then, dividing both parts of (5) in X f and taking to account 00 1 f T  , relative error of measurement (frequency offset)  can been expressed by We can see in equation (6) that relative error of measurement is limited by the ratio between the acceptable tolerance of the error of comparison between the time intervals 00 nT and XX nT and, the time interval 00 nT . Value of 00 nT is approximately the measurement time.

Numerical stop condition of measurement
In frequency measurement, 0 n and X n are independent counter counts obtained in two digital counters, so they are properly integer numbers. An integer numbers ratio, like the involved in the frequency value obtained by the measurement, is possible to investigate under number theory laws. Let note and briefly explain some of them, especially Euclidean algorithm.

Number theoretic preliminaries
Let us to assume without loss generality that 0 X TT  , from the division algorithm we can write where the i a is the ith partial quotients for each case and Each remained obtained in the division step of Euclidean algorithm be could be interpreted as a distance [11], defined by where i P and i Q are the numerator and denominator of the ith convergent of the continued fractions to 0 X TT defined recursively as [12] 12 for arbitrary 2 i  , and T can be expressed in terms of two consecutive remainders [11] using the following expression: A similar expression can be derived for X T Supposing that n is the number of steps in the Euclidean algorithm to obtain greatest common divisor of X T and 0 T . Then last remained 0 n t   and time interval is the greatest common divisor of both periods X T and 0 T , in the consecutive division expressed in equations (7) to (11). Because the greatest common divisor is: the last nonzero remainder in this sequence of divisions. Expressing (10) in terms of (15) and (16) it is evident in (17) than step n is total equality point for both time intervals 11 0.
In frequency measurement, this term expressed in several forms have a mathematical mean of least common multiple, and practical mean of time interval 0 X T (see Fig. 1) expressed by: is the condition for periodic perfect coincidences of pulses (see Fig. 1). Assuming to 0 X T the measurement time in frequency measurement, from (1) and Fig. 1 and each time intervals 00 nT and XX nT are equal to 0 X T . Then, Now, product of two numbers ab c  can be considered as the sum aaa a     in which the number of summands is equal to b or as the sum bbb b     in which the number of summands is equal to a .

Stop condition of measurement
For small measurement time (less than or equal a 1 s) is evident from equation (4) In both cases 11 0 r is a common divisor of both periods X T and 0 T .
This is the numeric condition that we propose to stop the measurement process and is easy to implement with basics digital circuits.
A novel fast method to frequency measurement with application in mechatronics and telecommunication is based on this numerical stop condition is presented in [7][8][9]. Resolution improvement in frequency domain sensors is allowed in automotive applications [10] with this method and is applied in precise optical scanning and structural health monitoring [19][20][21]

Simulation
In the simulation two pulse trains of unitary amplitude are generated using a computational algorithm sampling independent [7]. The value of reference frequency was accepted as s.
In this case, is evident that X T and 0 T are mutually prime numbers and have the common denominator Simulation results are partially presented in the Table 1 and, frequency relative error calculated (non absolute value) is presented in Fig. 2 for a simulation time of 0.2 s.
The simulation process star in 0 0 n  and 0 X n  , and the best approximation is selected (in this case) using the condition, 6 11 0 X n  . Table 1 represents an interesting fact. For thousands of data we have the same uncertainty range 13 10  , as for first and third rows. And only when X n takes a form of 1 with six zeros (in this case, second row of Table 1) we are getting up to 17 10  .
In Fig. 2, we can see a global convergence to zero of frequency relative error. An alternated convergence and a non monotone decreasing characteristic are evident. However, we can identify in the graphic a point where  is minimum for an approximated time of 0.17 s. is presented in Fig. 3. In this graphic, we can observe a convergence by the left and a divergence by the right around 0.17 s (first point in the Fig. 3).
This condition is repeated with time, and we can see five points where absolute value of  is minimum, for a simulation time of 1 s. In each mentioned points the condition expressed in (30) is fulfilled.  Table 1. Simulation results of frequency measurement process.

Jitter effect in frequency measurement
In order to evaluated the jitter effect on the non-electrically detectable stop event for frequency measurement method based on the direct comparison of two regular independent trains of narrow pulses and rational approximations. Deterministic and random components of jitter are modeled and, are added in both pulse trains one deterministic jitter component and random jitter in each case. Simulation results are presented when both pulse trains start in phase and when start with a phase shift.

Fast Method for Frequency Measurement by Rational Approximations with Application in Mechatronics 211
Timing jitter (henceforth referred to as jitter) is defined as short-term non-cumulative variations of the significant instants of a signal from their ideal positions in time [18].
For modeling, Total Jitter (TJ) consists of two components: Deterministic Jitter (DJ) and Random Jitter (RJ) [14]. In time domain, TJ is the sum of the RJ and DJ components [15]. RJ is characterized by a Gaussian distribution. It has been shown that it is theoretically unbounded in amplitude.
DJ consists of several components caused by different and mostly physically-based phenomena, such electronic interference, cross-talk and bandwidth limitation. All DJ subcomponents have a bounded peak-to-peak value that does not increase when more measurement samples are taken [15].
DCD and ISI are referred as data correlated jitter, while PJ and BUJ are referred as data uncorrelated jitter. RJ is unbounded and uncorrelated [15].

Random Jitter (RJ)
Random Jitter RJ is caused the common influence of a large number of very small independent contributor or various device-originated noise sources (such as thermal and flicker noise). By the central limit theorem, the distribution of a large number of uncorrelated noise sources approaches a probability Gaussian distribution and is given by [14]  where σ is the standard deviation of the jitter distribution or the RMS value, and J RJ is the probability that leading edge (or trailing edge) will occur at time x, where x is the deviation from the mean value of the time reference point (time point related to 50% amplitude point on pulse edge). In Fig. 4a), is shows the histogram for random jitter.

Periodic Jitter (PJ)
Periodic jitter denotes periodical timing deviation from the ideal position of a signal that repeat in time, is typically uncorrelated to the data rate or the clock frequency [14]. Electromagnetic interference and crosstalk from some clock line can cause periodic jitter.
The mathematic model of PJ consists of a sum of cosine functions with phase deviation, modulation frequency, and peak amplitude. The model is given by where PJ T denotes the total periodic jitter, n is the number of cosine components, a i is the amplitude in units of time in each tone, ω i is the angular frequency of the corresponding modulation, t is the time, and θ i is the corresponding phase [15].
Sinusoidal jitter in time domain produces a probability distribution function given by (defining time zero as the center of the distribution) where 2a is the peak-to-peak width of periodic jitter [14]. In Fig. 4b) is shows the histogram for sinusoidal periodic jitter with added random jitter.

Duty Cycle Distortion (DCD)
Duty Cycle Distortion is often also called pulse width distortion [14], is deviation in the duty cycle value from the ideal value, this equates to a deviation in bit time between a 1 bit (logic 1) and a 0 bit (logic 0). DCD can have several sources. The most ommon are threshold level offsets and differences in the rising and falling edge characteristics [14].
DCD yields a binomial distribution consisting of two sharp peaks of equal height, unless one separates rising and falling transitions in the measurement. Theoretically those peaks are Dirac delta functions, but in practice random jitter and limited measurement resolution always produce peaks of finite height and finite width. The analytic equation for DCD distribution is the sum of delta functions [14]: where 2a is the peak-to-peak width of the DCD. In Fig. 4c) is shows the histogram for duty cycle distortion with added random jitter.

Data Dependent Jitter (DDJ)
Data dependent jitter describes timing errors that depend on the preceding sequence of data bits [14]. DDJ is a predominant form of DJ caused by bandwidth limitations of the system or electromagnetic reflections of the signal [16][17]. Since there is always only a limited number of different possible patterns in a data stream of limited length, data dependent timing errors always produce a discrete timing jitter, theoretically DDJ distribution is the sum of two o more delta functions [14]: N is number of distinct patterns, p i is the probability of the particular pattern occurring, and t i is the timing displacement of the edge following this pattern. In Fig.  4d is shows the histogram for data dependent jitter with added random jitter.
In the simulations, two pulse trains of unitary amplitude are generated. The value of reference frequency was accepted as s. The RJ model used is Gaussian distributed with RMS value 0.7 ps. The PJ model is a single-tone sinusoidal with frequency 5 MHz and peak-to-peak value of 10 ps, same peak-to-peak value is assumed in DDJ and DCD jitter models. A component of random jitter is added to the last tree models to generate the jitter models PJ+RJ, DDJ+RJ and DCD+RJ. Such jitter values are selected because of the most typical values for such pulse trains according to [15]. Then the jitter components modeled are applied to the time reference points of each narrow pulse on the two pulse trains. In

Jitter simulation results
In the first computational experiment is assumed the same magnitude of the jitter in the oscillator under measurement and references oscillator on all models. The experimental results when the two pulse trains started in phase are presented in Table 2, to a simulation time of 0.172 s. In the first row of each table are presented the results obtained without jitter models.
In third column is shown the total number of coincidences obtained with each model for the simulation time and, in the fourth column is shown the number of coincidence where appears the stop event associate to the best approximation in the frequency measurement process (the desired count is represented like 10 r [7]). Program code for computational experiment in Matlab is presented in [22].

Reference Oscillator
Oscillator under test

Experimental research
For experimental research a prototype of frequency meter was implemented, based on the block diagram shown in Fig 6. This prototype was implement in the FPGA EP3SL150F1152C2N using the development board STRATIX III EP3SL150 and the design software QUARTUS II. In Fig 7. is shown the circuit diagram to the FPGA based frequency measurement prototype used.
For practical frequency measurement, reference frequency was provided by using an Agilent 33250A arbitrary waveform generator and, was set to 7 11 0 o f  Hz. The hypothetical unknown frequency was provided by Tektronix AFG3101 Arbitrary function generator.
In Fig. 8a) is presented arbitrary selection from the experimental data set a period value associate to the hypothetical unknown frequency used in experimental research. As shown in Fig. 8a) the measured unknown frequency was adjusted on the rate of T x =989.97ns according to in-built equipment frequency counter. Then this unique pulse train frequency was counted by our experimental prototype of frequency meter. The count of pulses from unknown frequency train obtained with the digital counter Q in block diagram of Fig 6 under the condition (30) is show in Fig. 7 b). The measurement time by single experimentation never exceeds 1 s. It is evident from screenshot Fig. 7 b) that our prototype circuit has a higher resolution than Tektronix AFG3101 in-built frequency counter, but it shows the same rate of frequency. The character of coincidences between indications of experimental prototype and Tektronix AFG3101 generator was the same on all experimental data set. It permits us to make the next important practical conclusion.  The prototype circuit unfortunately still has multiply sources of noise and uncertainty. But it is a second plan aspect of circuit optimal design in a future work. The main proof of this prototype circuit is the proof of the possibility for a fast frequency measurement without losses of high resolution and rigorous link to actual situation with frequency jitter in a present pulse train.

Conclusions
In the offered model for fast frequency measurement, the result is fixed on the equality of intervals 00 nT and XX nT . Therefore the model is independent to the parameters of coincidence circuits, duration and the shape of coincidence pulses, and the parameters of "zero-crossing" pulses in both sequences.
Due to jitter effect some theoretically expected marginal coincidences may disappear or nontheoretically expected may appear. However, this phenomenon can not be observed in nonmarginal coincidences, for instance the expected coincidence under condition (30) and an appropriated pulse width τ.
For measuring systems which can be constructed on the basis of the specified model, systematic and instrumental errors have the same infinitesimal order. Instrumental errors are caused only by the reproducibility of the reference frequency.
For measurements of high values of frequency X f it is expedient to use higher values of reference frequency in order to have an equivalent reduction of measurement time.
Also it is important to note, that this theoretical method permits to measure unknown frequency value in a case, when unknown frequency exceeds the own value of a standard. For classical methods it is impossible completely.
In future work, there will be an improved version of the experimental prototype to reduce the influence of deterministic errors in measuring and evaluating new frequency estimators based on the Theory of Numbers.