Category Archives: DSP Lessons

DSP Lessons

Encoding and modulation of digital signals

We know that digital signals are stored as binary numbers in memory cells. Let’s see how these digital signals can be transferred in other words – how they can be encoded in to electrical signal shape. When signal has to be sent it has to be modulated.

Pulse Code Modulation (PCM)

Probably simplest and most common modulation method is pulse code modulation (PCM).

PCM_pulse_code_modulation.JPG

In CPM coding information is modulated as voltage levels. If supply voltage is 5V, then binary”1″ is represented as +5V while 0 as 0V level. Only two voltage levels are used to modulate signal. Signal can be sent in parallel (bus mode) or serial mode. In parallel mode whole (let’s say 8 bit) signal can be sent at once via 8 wires, while in serial mode data has to be sampled in time. This transmission method is most popular in embedded systems, for instance, ADC sends converted data to DSP using CPM. Continue reading

DSP processors and their characteristics

The processing of the various signals is carried out through implements that are together called as DSP hardware. This includes the hardware that is used for transmission of signals, various devices that are used to enhance or filter the signals, analogue to digital and digital to analogue converters and other processing equipment such as computers.

Among the hardware mentioned above, digital signal processors are the ones in which the actual processing takes place. Usually the digital signal processors today have the following characteristics:

  • They are equipped to handle real time processing i.e. they can give the optimal performance even when streaming data is being fed into them.

  • The memories that are used to store programs are different from the ones used to store data.

  • They do not provide hardware that supports multitasking.

  • It can be used as a direct memory access device in supporting or host environments.

  • They take analogue signals as input, convert them into the digital form, process the signals and then, convert them back into the analogous form.

  • They make use of Direct Memory Access technique.

Schematic_Diagram_Signal_Processing_System.png

Continue reading

Digital Signal Processing – Applications

Digital signal processing is the technique used to analyse various digital signals and obtain information form the same. It is also used for transfer of information from one place to another and also involves conversion in between analogue and digital signals.

It finds its application in various areas ranging from broadcasting to medicine.

Let us have a look at some of the applications of the same.

Biomedical Applications: DSP is used extensively in the field of biomedicine. In it, the various signals that are generated by the different organs in the human body are measured in order to find information regarding the health of the same. For example, in case of electrocardiograms, the electric signals generated by the heart are measured. Similarly, the activity of the brain is monitored by electroencephalograms.

Automatic Control: These days, many gadgets are available that can perform their tasks automatically. These devices contain various components that can take inputs depending on the surrounding conditions. These are conveyed to the control unit of the device where they are processed and the necessary action is taken. For example, a device like the thermostat increases its resistance in proportion to temperature. This can be used to stem the current in a machine whenever the temperature rises. Continue reading

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

Signal power and energy calculation

One of frequently used signal characteristics are energy and power. In signal theory these therms require additional comments because they are a bit different from these what we are used to use in AC or DC systems.

What is power and energy? If wee connect R resistor to voltage U, then 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 lets say that we ad some signal s() instead of DC voltage. In this case the power will depend on time as signal is time dependant. The therm is called instantaneous power: p(s)=s(t)2/R

in order to calculate energy loss during time T wee need to integrate:

power_integrate.PNG

Sometimes its is more convenient to calculate average power during some time T:

avg_power_integrate.PNG

When talking 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 formulation and then wee can talk about signal power and energy in signal theory:

signal_power.PNG

Signal e3nergy may be finite and infinite. For instance finite signal will have finite length energy while its level wont go to infinite. Any periodical signal has infinite energy. If signal energy is infinite, then we can only talk about average power over all time axis:

avg_signal_power.PNG

Square root of average power gives root mean square (RMS) of signal:

RMS.PNG

Well for signals with period T you don’t have to calculate average power or RMS using lim function. This is enough to calculate average values during one period.

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.

signal sampling

Sampling is a process when continuous time signal is recorded every T seconds by multiplying by an impulse train.

sampling.JPG

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.

freqsampl.JPG

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:

filtering.JPG

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 a sinc function in time domain. Because y(t) is a series of impulses, then reconstructed x(t) is a superposition of scaled and shifted sincs:

signal superposition

The fundamental result is that any band-limited signal can be completely discretized by equally spaced samples. And remember that sampling frequency has to be at least two times bigger than bandlimit of signal to avoid alias (overlap) of sampled signal spectra. Otherwise reconstruction of original signal becomes impossible.

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:

image002.gif

This means frequency response is systems transfer coefficient to every frequency value. Frequency response is a complex function. So this can be evaluated as:

image004.gif

where |H(ejω)| – is amplitude frequency response

image006.gif – phase frequency response.

There are two simple ways to calculate frequency response of discrete system:

First mentioned above – from impulse response;

Second – from discrete system equation:

image008.gif

Lets say we have digital filter described as:

y(n)=-a1·y(n-1)+b0·x(n)

then frequency response of digital filter would be:

image010.gif

Digital system equation

Back to DSP thread. Lets talk about digital system equation. Every digital system can be described using this equation.

The output of digital filter generally consist of previous inputs and previous outputs.

image002.gif

y(n-k) is considered as previous outputs;

x(n-p) – previous inputs;

ak and b­p – coefficients;

This equation is convenient to define discrete system and extract various characteristics. Number N defines discrete filter tap (Tap – A FIR “tap” is simply a coefficient/delay pair).

Lets say we have digital filter made of one tap.

y(n)=a·y(n-1)+b·x(n)

First we calculate filter response function – h(n):

Response function is calculated from system reaction to discrete impulse δ(n). So assume that x(n)= δ(n) and y(n)=h(n). Initial conditions: y(-1)=h(-1)=0.

Then:

h(n)=0 when n<0;

h(0)=a·h(-1)+b·δ(n)=b;

h(1)=a·h(0)+b·δ(1)=ab;

………….

h(n)= ban where n>0

Lets say we have a=0.7; b=1;

Then we get discrete system characteristics:

image004.gif

This equation in example describes IIR (Infinite Impulse Response) discrete systems, because there is a feedback element a·y(n-1).

There is another type of discrete filter – FIR (Finite Impulse Response)

Finite response filter equation is much simpler:

image006.gif

As you may noticed from equation – IIR filter have infinite number of response impulses while FIR filter have a finite number of impulses. IIR and FIR systems are different in their properties and realizations.

Discrete systems in series and parallel

Discrete systems in series

Let as say that we have two discrete systems and their impulse responses are h1(n) and h2(n). Then when these discrete systems are connected in series, then overall impulse response:

image003.gif

image002.gif

image005.gif

Where:

image007.gif

As you noticed there were changing made:

image009.gif

This is nothing more than convolution of impulse responses of both discrete systems:

image011.gif

Discrete systems in parallel

If we have two discrete systems connected in parallel:

image012.gif

As we see there is simple sum of output queues of each discrete system. So we can assume, that overall impulse response is as sum of systems connected in parallel:

image014.gif

What is a linear system?

Discrete system is nothing more than algorithm, where input is transformed to output. The output is transformed by operator L() which describes discrete system.
Lets see few most common operators of discrete systems.

Delay

This means that output queue is delayed by on sample.

delay.jpg

Multiplication

This operator takes each sample of input queue and multiplies by constant a.

multiply.jpg

Sum operator

Takes two or more sample queues and adds them in the output.

sum.jpg

Assuming we can say, that the system is linear if input sum reaction is equal to sum of inputs reactions:

linear.jpg

The system has stable parameters if:
y(n-k)=L(x(n-k)), this means that output delay should be the same as input.
It is obvious that delay, multiply and sum operators are linear and has stable parameters. We will need then for further lessons.

New on WinAVR Tutorial New on WinARM Tutorial