Anda di halaman 1dari 13

Faculty of Electrical Engineering and Information

Technology
Professorship of Measurement and Sensor Technology

Smart sensor systems

Practical on
Digital Frequency Measurement

Literature:

1. Profos, P./ Pfeifer, T.: Grundlagen der Metechnik, Oldenbourg Verlag Mnchen
Wien 1997
2. Schrfer, E.: Elektrische Metechnik, Carl Hanser Verlag Mnchen Wien 2004
3. Schrfer, E.: Signalverarbeitung,Carl Hanser Verlag Mnchen Wien 1992
4. Best, R.: Digitale Mewertverarbeitung,Oldenbourg Verlag Mnchen Wien 1991
5. Best, R.: Digitale Signalverarbeitung und -simulation, vde-verlag gmbh Berlin
Offenbach, AT Verlag Aarau/Schweiz, 1993
6. v. Grningen, D.: Digitale Signalverarbeitung, AT Verlag Aarau/Schweiz 1993
7. Kammeyer K./ Kroschel, K.: Digitale Signalverarbeitung, Filterung und Spek-
tralanalyse mit MATLAB-bungen, B.G. Teubner Verlag Stuttgart/Leipzig
2002
8. Reinhard Lerch: Elektrische Messtechnik, analoge, digitale und computergesttzte,
Verfahren, Springer-Verlag , 2005

Revised on May 17, 2015


Digital Frequency Measurement

Objective:
Digital frequency measurement and period duration measurement in time domain

• Determination of the measuring variation and of the dynamic parameters of


this measuring method

Frequency determination by FFT

• Investigation of spectral resolution and windowing


• Interpolation considering discrete frequencies

1. Digital presentation and determination of the


frequency in time domain
A typical feature of frequency-analogue measuring methods is the conversion of the
quantity to be measured into the information parameter frequency or cycle duration
respectively, e.g. frequency of a harmonic voltage (alternating current):

• A capacitor can be a frequency determinant element of an oscillator circuit.


• A quartz thermometer gives a frequency signal that is dependent on the am-
bient temperature.
• Measuring methods using the doppler effect are based on the conversion of
the measured quantity into the difference frequency that is available for the
evaluation after the mix of transmission frequency and receiving frequency.

More frequency-analogue measuring methods can be listed.Time and frequency mea-


surement are tightly connected. If impulses of signals with afrequency f which are
equidistant related to time are added up during a time interval T using a counter,
then the number of counts N equals to: N = f T

This principle makes it possible to measure frequencies. By using digital frequency


measurement, the measured signal has to be first converted into a box-car pulse by
a Schmitt trigger (comparator) which is used as a pulse shaper. During a defined
measurement time TN , these pulses are added by an up-counter which shows the
meter reading N . The time TN is set by a reference clock that is a divider with
the ratio n as well as by a toggle flip-flop. Figure-1 shows the circuit for digital
frequency measurement and in such way the measured frequency can be calculated
as follows:
fT akt
fmess = N.fN = .N (1)
n
The counter has to be reset at the beginning at every new measurement cycle.
The measurement circuit, shown in Figure-1 as a block diagram, is a basis for
the experimental determination and the digital indication of the quantity under
measurement, i.e., the frequency.
Measurement deviations are basically caused by the used method because the cor-
relation between the measured quantity and the frequency is not exactly known.
Another measurement variation can result from errors that belong to the accuracy

Smart Sensor Systems Page 2


Digital Frequency Measurement

Figure 1: Block diagram of a measuring arrangement for digital frequency measure-


ment

of frequency determination. In addition to that, the incremental counting causes a


digital error of ± 1 impulse. This error is given the priority to be treated in this
experiment. The relative deviation that is caused during a frequency measurement
given by:

The sampling frequency fT akt is the clock reference frequency, see block diagram
in Figure-1, which is used to sample the measured signal fsample . The purpose
of the sampling is the analogue-to-digital conversion ADC of the measured signal
which is stored in a Digital Storage Oscilloscope (DSO). For the preparation of the
experiment, it is shown in Figure-2 a recorded example of a measured signal.

Figure 2: Application interface of a PC-program FFTANA

Page 3 Smart Sensor Systems


Digital Frequency Measurement

2. Measurement in frequency domain


For frequency measurement in time domain, the number of cycles of the measured
signal are counted and then divided by the measurement time. Therefore the indi-
cated frequency is the average value of all the frequencies that occur in the course
of the measuring time. However, time domain representation is not suitable for fast
alternating signals (especially not for periodic signals). To analyze such signals, it
is more interesting to measure the frequency-dependence of the amplitude of the
signal and for that the Fourier transformation is used.

The Fourier transformation is the transition from time domain to frequency domain.
And it is often used as a tool in signal processing because it makes it possible to find
the recurring periodic signals and to determine the spectral distribution of a given
signal x(t). Therefore it is a standard method for revealing periodic structures in
data and functions. The analysis of signals is not the only application of the Fourier
transformation but it is also used in filter masks in the efficient convolution, in the
analysis and manipulation of vision frequency and in decompression. The Fourier
transform is subdivided into:

• Continuous Fourier Transformation (CFT)


• Discreet Fourier Transformation (DFT)
• Fast Fourier Transformation (FFT)

2.1 The Continuous Fourier Transformation (CFT)


The Continuous Fourier Transform is an integral mathematical operation that makes
representation in frequency domain for an original function in time domain. The
function in the frequency domain in most cases is a complex with real and imaginary
part. The transformed function therefore is decomposed to spectral lines which
constitute the original function in time domain. It is defined by the following Fourier
integral:

Hence the Continuous Fourier Transform of a function/signal results in a periodic


function. The original functions can also be in frequency domain and for that the
inverse Fourier transform is used:

The inverse feature of the algorithm also enables the generation of signals. Both
transformations together form the Fourier transformation pair.

Smart Sensor Systems Page 4


Digital Frequency Measurement

2.2 The Discrete Fourier Transformation (DFT)


The Discrete Fourier Transform is an algorithm with which the Fourier transform of
a finite and discrete-time signal can be calculated. But at first we want to look at
the Fourier transform of an infinite, discrete (sampled) signal. The sampling of the
continuous signal leads to signal values that exist at discrete and equidistant time
points. The sampling time TA represents the time between two successive moments.
The following transformations are set up:

From that the Fourier transformed function of a sampled signal can be given as:

In the generalized form the coefficient TA written in front of the sum is left out.
A Fourier transformed sequence (of a discrete-time signals) is periodic, as well the
corresponding spectrum. The spectrum results from the sum of the spectra of Dirac
impulses that are time displaced and weighted by the values of the sampled signal.
Since there is generally a finite number of signal values (function values) the DFT
was developed. There the discrete signal values are located within a defined space
of time. The sampling of the signal delivers a finite number of sampling values (N
values). When proceeding from the Fourier transform of an infinite discrete signal
to the DFT the frequency is not a continuous variable anymore,A but a discrete
frequency k∆ω The spectrum is only calculated for a finite number of (radiant)
frequencies.

The discrete Fourier transformed function of a signal x(t) is calculated thus:

The exponential function e−jk∆ωnTA is a periodic function as well as the spectrum


of the Fourier transformed function of a discrete-time signal. The cycle is just
equivalent to the sampling frequency.
2π 1
ωp = wherefp = = fA (2)
TA TA
The DFT-algorithm works in such the data set that is read in during a time interval
N TA would continue. For a periodic signal, it is sufficient to read the data only one

Page 5 Smart Sensor Systems


Digital Frequency Measurement

period and transform to get the full spectral information. The distance between two
adjacent frequency values/spectral lines is calculated as:

2π 1
∆ω = where∆f = (3)
N TA N TA

For the spectral resolution therefore the whole measuring time (N TA ) is decisive. If
the measuring time increases to infinite values then the spectral lines move closer
so that the distance between them becomes zero, which means that the line spec-
trum changes into a continuous spectrum. If the Nyquist theorem is fulfilled then
the spectrum of the discrete signal is identical with the spectrum of the continuous
π π 1 1
signal in the base interval − <ω< or − fA < f < fA respectively.
TA TA 2 2
The Nyquist theorem says that the sampling frequency has to be at least twice as
high as the maximum frequency of the signal. If the sampling frequency is high
enough then the spectra of continuous signals can be replaced by the spectra of the
sampled signals. If the Nyquist theorem is violated then the original signal will be
distorted (aliasing in time domain).

The calculated spectral sequence of N dots generally shows symmetric features there-
fore it would be sufficient to calculate just half the amount of spectral values. For
calculating all N coefficients (spectral lines) ZM = N 2 complex multiplications are
necessary. The same partial products are calculated several times (redundant oper-
ations). By the elimination of redundancy the computational algorithm decreases
considerably, so that we speak about Fast Fourier Transform.

2.3 The Fast Fourier Transformation (FFT)


The FFT is an algorithm for the fast calculation of the values from the DFT. The
FFT is identical with the DFT, but requires far less mathematical operations, so that
the FFT is a version of the DFT and it can be performed with much less computation
effort on a digital computer. For interpreting the results the knowledge of the
features of the DFT is necessary. While the DFT needs N 2 complex multiplications
and additions to transform N values, the FFT requires only N/2log2 (N ) of these
operations. The effort you need for calculation is reduced from

ZDF T = N 2 to ZF F T = N/2.log2 (N )

The FFT can be applied under the condition that the sequence of data that shall be
transformed contains a number N of values, whereas N has to be an integer number
calculated with this term: (two to the nth power) N = 2n E. g.: For N = 28 = 256
values the DFT requires ZDF T = 65536 multiplications, whereas the FFT just needs
ZF F T = 1024 ones. The effort to calculate when using the FFT is just about 1/50
when using the DFT. Further there are fewer errors that occur when rounding up
or down intermediate results.

Smart Sensor Systems Page 6


Digital Frequency Measurement

2.4 Influence of the window function


The application of the DFT and the FFT respectively aims at a finite number of
measured values. This can be interpreted in this way: The sampled values of the
function in time domain are viewed through a window, whereas the values that
lie out of the window are zeros. The Fourier transformed function of a sampled
periodic function from time domain that is regarded through a window shaped like
a rectangle is the product of a complex exponential function and a function with
the form sinN x/sinx.

The function sinN x/sinx has one main lobe and many minor lobes. The curve
enveloping the spectral lines shows the maximum amplitude of the main lobe for
f = 0 (regarding non-periodic signals) and the maximum amplitude of the main
lobe for f = f0 (regarding periodic signals). The amplitudes of the side lobes are
lower than the one of the main lobe. The roots of the enveloping curve lie where
the roots of the function sinN x/sinx are situated.
Z
A non-periodic time signal: fZ = (Z = ±1, ±2, ±3, ...)
N TA
Z
A periodic time signal: fZ = f0 + (Z = ±1, ±2, ±3, ...)
N TA
When the fundamental cycle duration T0 is known then the measurement time N TA
has to be chosen in that way that it is an i-fold of the cycle duration T0 , while i is
an integer.

N TA = iT0

In this case the DFT gives the maximum amplitude (spectral line) exactly at f = f0
and the other spectral lines are superposed by the roots of the enveloping curve. In
this way all other possible spectral lines can be extinguished. But if the width of
the window N TA (measuring time) is not an i-fold integer of the cycle duration then
considerable discontinuities in the form of side lines will occur. Wrong spectral lines
appear. This effect is called Leakage effect.

The solution of the leakage problem therefore concentrates on the application of


suitable window functions which let slowly abate the sharp edge of the rectangu-
lar window. For this the following types of windows are employed among other
ones: triangular window, Hanning-window, Hamming-window, Blackman-window.
For judging the individual window functions the following criteria will help:

1) highest minor lobe


amplitude of the highest minor lobe
a=
amplitude of the main lobe
a is the ratio of the amplitude of the highest minor lobe and the amplitude of the
main lobe.

Page 7 Smart Sensor Systems


Digital Frequency Measurement

2) maximum sampling error


amplitude of the windows − F T at 1/2∆f
b=
amplitude of the main lobe
The ratio b shows the maximum measuring error of an amplitude

3) width of the main lobe


For the characterization of the width of the main lobe the 3-dB threshold frequency
has to be determined. At this very frequency the amplitude of the main lobe reaches
3dB.
amplitude of the windows − F T at f = 0
c=
amplitude of the windows − F T at f3

Type of window Highest minor lobe-a Maximum sampling error-b Width of the main lobe-c

Rectangular 0.224 (-13dB) 0.64 ±0.45∆f


Triangular 0.045 (-27dB) 0.84 ±0.64∆f
Hanning 0.025 (-32dB) 0.85 ±0.72∆f
Hamming 0.007 (-43dB) 0.82 ±0.65∆f
Blackman 0.001 (-58dB) 0.88 ±0.84∆f
Typical window functions and their characteristic values

Figure 3: Influence of the width of the measuring window on the resulting spectrum

Smart Sensor Systems Page 8


Digital Frequency Measurement

Preparation Tasks
The sampling frequency that was used for the sampling of the time signal in the
DSO has the values of 20MHz, 10MHz, 4MHz or 2MHz respectively. The number
of sampling values is 2048 in any case.

1. What are the cycle durations for the given sampling frequencies?
2. Compare the characteristic values in time and frequency domain. Name the
interactions between (grid points) sampling rate, width of the measuring win-
dow (time domain), the number of (usable) spectral lines, frequency resolution
and the maximum frequency (frequency domain).
3. For which frequency range is it physically meaningful to describe the calculated
amplitude density spectrum?
4. For a periodic rectangular pulse (a periodic box-car pulse) amounts to the
ratio of pulse duration to period duration = window width T = 1/f0 , a) 1: 10
and b) 1: 100. At which frequencies (reference frequency f0) the calculation
gives roots in the spectrum?
5. Calculate the expected number of samples per cycle for the signals 1-8 we want
to analyze (see 5 Experimental procedure).
Sampled signal 1-4: fsampling = 20MHz
Sampled signal 5-8: fsampling = 4MHz

Page 9 Smart Sensor Systems


Digital Frequency Measurement

4. Experimental set-up
Figure-4 shows the application interface of the program. Essentially the handling is
self explaining. The signal is stored for 2048 sampling values (index 1 to 2048 where
the index range can be adjusted by the help of the ZOOM-function. Sampling mo-
ment and normalized amplitude of a selected single value can be shown by moving
the cursor. Furthermore the sampling frequency fsampling (Abtastfrequenz) at which
the signal (Normsignal) has been digitized is shown.

The stored time signal is transformed into frequency domain by FFT. The ampli-
tude of the spectrum is shown just for positive frequencies. The spectrum can be
calculated and shown for the measured signal multiplied by various time windows
with which the measured signal is multiplied in time domain.

Figure 4: Spectrum of a sampled harmonic time signal

In the submenu OPTIONS you can choose window functions, width and position of
the window by setting the grids number and the cursor. The default setting is the
rectangular function for all 2048 values. Then, the normalized amplitudes of the
single spectral lines are measurable by making zoom of the appropriate range and
the positioning the cursor at the desired spectral line.

The interpolation method to calculate the frequency (interpolation according to


centroid method) is used by selecting the spectral lines that are intended to be
calculated e.g. marked with red in Figure-4, with the right mouse button. The
result appears for the approximated frequency on the lower edge of the screen. But
for that you have to switch off the function CURSOR in the menu OPTIONS.

Smart Sensor Systems Page 10


Digital Frequency Measurement

5. Experimental Procedure
To start the program FFTANA, you first have to call the program MATLAB in
Windows. After that you input FFTANA. To perform the wanted tasks of this
experiment, below are listed time signals in the form of data files, e.g. the file name
(sin10 0) contains a sampled sinusoidal harmonic with 10 time periods shown and
recorded in the screen.
Click on the LOAD bottom in the interface of the program to select a signal file and
run it. The data are found in the path: C : \matlab4 \ toolbox \ df m \ ...

1. sin2 0.mat 2. sin2 5.mat


3. sin10 0.mat 4. sin10 5.mat
5. sin369 0.mat 6. sin368 5.mat
7. sin922 0.mat 8. sin921 5.mat
9. rauschen.mat 10. rausch2.mat
11. saegz1 0.mat 12. gleichsp.mat

5.1 Measurement in time domain


1. Compare the number of the samples per period which were determined during
the experiment with the results in the preparation task 3.5 for the measuring
signals 1-8.
2. Determine the frequency of the measured signals 1-8 with using the cycle du-
ration in time domain. Note the following:

- The determination of the cycle duration is based on the measuring arrange-


ment shown in Figure-1. That means that the comparator switches when
crossing the zero of the harmonic signal. So the time measurement shall al-
ways start with the first positive value of the sampled signal after passing the
zero and end before the first positive value after the zero crossing, (positive
slope of the time signal = positive sign of the y-value). The frequency divider
is fixed to 1:1.
- Determine the frequency with the help of the duration of just one cycle and
also by using more cycles (10), (signals 4-8).
- Especially for the signals 5-8 you should measure the duration of a single
cycle several times (at least 3 times are sensible) at different moments.

(a) Calculate the frequencies of the measured signals using number of cycles
and the sampling frequency. Give the values of the measurement devia-
tions (absolute and relative error) of each frequency that you determined
in this experiment.
(b) Discuss the results! Under which condition can you actually determine a
frequency from the sampled signal?

Page 11 Smart Sensor Systems


Digital Frequency Measurement

5.2 Evaluation in frequency domain


A frequency determination in frequency domain is useful, if the original shape of
the sampled signal can not be represented in time domain anymore, e. g. when
the number of sampled values in one cycle of a harmonic signal is less than 10.
Especially when having signals that just exist for a short time (like the ones that
result from measuring methods based on the Doppler Effect) the frequency domain
is advantageous. Then a linear (flat)interpolation within the main lobe can be useful
for such frequency spectra. For such interpolation, the centroid method is used.

1. Transform the measuring signals 1-8 into frequency domain and discuss the
representation. The transformation always happens with a rectangular window
(idx 1-2048). Use the ZOOM function and if necessary print some examples
for further explanation (details about the zeros).
2. Load measuring signal 3 and find out the time interval for exactly one cycle
(idx j ...idx k). Open the submenu OPTION and set the idx-values. By
pushing OK you get back and see the time interval with detail showing the
single cycle. Transform this signal and discuss the result. Give reasons why
the spectral line with the maximum amplitude can lie on another frequency
than that determined easily in time domain. Repeat this task by setting other
time intervals you can choose on your own.
3. Load the measuring signal 12 (do not cut off the offset). Discuss the represen-
tation in time domain. Give the number of bits the A-D converter has to be
used when the measuring range for the sampling of the signal is 2V.
4. Show how the spectra of box-car pulses (rectangular) look like. The duration
of the pulses have to be set according to the preparation task 4 (OPTION).
Compare the roots with the calculated values.
5. Evaluate the spectra of box- car pulses according to task 4 for the follow-
ing pulse durations: six-, two- and one-fold of the sampling cycle duration!
Document what you find out.
6. Load measuring signal 6, make a window of 200 samples (from OPTIONS, e.g.
idx 100 to idx 300), show the spectrum with the ZOOM function. Calculate
the minima of the signal in the spectrum and decide whether an interpolation
within the main lobe of the spectrum is sensible. Calculate the measuring
frequency more exactly by using 6 spectral lines in your calculation (centroid
method). Compare the result with the frequency line that has the maximum
amplitude in the spectrum and with the evaluation in time domain.
7. The measuring signal 9 is a digitalized noise signal (white noise). Determine
the spectrum that is belonging to it and interpret the result.
8. Measuring signal 10 was measured as an output signal of an operational ampli-
fier, while the input quantity was white noise generated by a noise generator.
Determine the spectrum of the output signal, interpret it and compare it with
the result from task 7. How would the figure change if the signal was not
sampled just 2048 times, but with a measuring time (measuring window) that
is ten times longer, so that the signal is sampled 20,480 times now?

Smart Sensor Systems Page 12


Digital Frequency Measurement

Organizational Information:
A sufficient preparation of the experiment is basically required. All preparation
tasks have to answer in written. Each group should submit one written preparation
tasks. The sources of using literature have to be indicated (scientific style). The
practical takes place in your own responsibility under the technical instruction from
the tutor. A report, that includes a rework preparation, all graphs and measured
data, as well as a detailed analysis, should be submitted. The report should be
submitted to the tutor in handwritten or printed form not later than 14 days after
the practical. One report for each labor group is adequate. All equipment and
facilities are handled with care.

Page 13 Smart Sensor Systems

Anda mungkin juga menyukai