Circular buffers in DSP processors

I am not going to analyse what DSP processors are different from regular microcontrollers as there are many differences that allow to boost performance in many specific tasks like filtering, FFT, etc. One thing is obvious that DSP processors have to perform mathematical calculations rapidly enough to get predictive results. Better result we want – more processing power wee need. We know that MCU are performing two main tasks: data manipulation and mathematical operations. But fact is that it has to be done really fast. General purpose microcontrollers aren’t optimised to perform these tasks effectively as microcontroller has to as much universal as possible to fit in many areas. In other words flexibility reduces performance. DSP processors are more specialized microprocessors that ara optimised for tas that they usually do – multiplication and addition. Lets take most common DSP routine FIR digital filter implementation. It takes several samples of signal x[] and produces output signal y[] which is modified by multiplying appropriate samples by coefficients an . y[n] = a0x[n]+a1x[n-1]+…+akx[n-k]

Continue reading

Low frequency Butterworth and optimal Wiener ECG filters

Regular ad hoc filters don’t guarantee optimal signal filtering as there is no any criteria that evaluates filter characteristics. Usually filter parameters are calculated empirically and filtering is done by best results. In order to avoid such shortage there are optimal filters used where parameters are optimized by some criteria. The main idea of optimal filtering is to give bigger weight coefficients to signal spectra parts where signal noise has less power and true signal spectral components has bigger power. Lets project simple Butterworth filter that will be used as comparative filter to optimal Wiener DSP filter. Butterworth filter transfer characteristics:   Where N – indicates filter Tap number. I will skip description of butterworth filter for now as main idea is constructing optimal wiener filter. Butterworth filter characteristics are pretty plain:   Butterworth characteristics with bandpass of 70Hz Main disadvantage of Butterworth filter is that signal is distorted on filter output. If you want minimal signal distortions it is better to use optimal Wiener filter. Filter chart looks as follows:   As you can see to make this filter functional wee need additional conditions like signal model reference. Filter coefficients are calculated using MMSE. root mean square error. Lets…

Continue reading

Signal power and energy calculation

The most common signal characteristics are energy and power. In signal theory, these terms require additional comments because they are a bit different from these what we are using in AC or DC systems. What are power and energy? When we connect R resistor to voltage U, then the resistor will dissipate some power which is equal P=U2/R. During time T the energy loss on this resistor will be E= TU2/R. Now let us say that we add some signal s() instead of DC voltage. In this case, the power will depend on time as the signal is time dependent. The term is called instantaneous power: p(s)=s(t)2/R to calculate energy loss during time T we need to integrate: Sometimes it is more convenient to evaluate average power during some time T: When we talk about signal power, we don’t care about R load. Therm Signal power usually is used for comparing different signals. For this it is agreed to use R=1, then we exclude resistance from the formulation, and then we can talk about signal power and energy in signal theory: p(t) = s^{2}(t) Signal energy may be finite and infinite. For instance, a finite signal will have limited length…

Continue reading

Signal sampling mechanism

Sampling is a process when continuous time signal is represented by series of discrete samples while reconstruction is reverse process when these samples re recreating adequate continuous time signal. Bellow the overall process is illustrated. Sampling is a process when continuous time signal is recorded every T seconds by multiplying by an impulse train. If signal is sampled in frequency domain. For this we need signal transformed in to frequency domain. The frequency spectrum has to be band-limited. The impulse train after transformation becomes impulse train with scale in heigh 1/T. Multiplication in time domain becomes a convolution in frequency domain. After convolving the signal is scaled and shifted. The signal in frequency domain becomes periodical. In order to reconstruct the signal x(t) from sampled spectrum first we need to extract the original spectrum. For this ideal filter is needed to take single spectrum from spectrum signal train. Low pass filter fill cut other copies of spectrum. The filter should have cut off at f=±1/(2T) and Gain of T: After this reconstruction can be done. Ideal filter in frequency domain is a sinc function in time domain. This means that multiplying spectra by box in frequency domains means convolving with…

Continue reading

From analog to digital signal filtering

Signal filter is electrical equipment that attenuates the unwanted signal characteristic wave. Filters can be analog or digital. An analog filter processes analog signals. They are mainly arranged with capacitors and resistors. Digital signal filters process digital signals which are quantized. Digital filters are arranged with solid state components to process the signals. Let’s start from analog filters. Analog filter is a circuit which filters unwanted frequencies. Filtering is done by choosing circuit transfer function. Simplest analog low pass filter: The current in RC circuit can be calculated as follows: Then if we think about digital filtering, then Uin(t) and Uex(t) we can change to xn=x(nT) and yn=y(nT). Then we can rewrite equation: Then we get: yn=a0xn+a1xn-1-b1yn-1, Where a0=1/(1+T/RC), a1=-1/(1+T/RC), b1=-1/(1+T/RC). This equation now can be used to build digital filter. Filter can be described using response function. Response function of analog filter is reaction to step function while digital filter response function is response to step function in samples: u[n] = 1, if n>=0 u[n] = 0, otherwise According to method described in previous article we can calculate filter transfer function h(n); Results are in following table: Filter h at t/RC 0 0.5 1 1.5 2 Analog 1 0.779…

Continue reading

Frequency response of discrete system

In previous post we discussed about impulse response. Impulse response h(n) is digital system response in time domain. But there is another characterization of discrete system – frequency response H(ejω). Frequency response can be calculated form impulse response by formula: This means frequency response is systems transfer coefficient to every frequency value. Frequency response is a complex function. So this can be evaluated as:

Continue reading