# Data Aquisition and Capture

## Introduction

We consider the main issues concerning the digital or computer Acquisition of real world data.

```Theoretical issues.
Conversion of  continuous-time, continuous amplitude signals measured
in the physical world into discrete-time, discrete amplitude data (or numbers) in a computer.
(i)	Discrete time signal
(ii)	Amplitude quantisation
(iii)	Sampling rate```
```Analog interface.
(i)	Signal Conditioning.
(ii)	Analog signal scaling.
(iii)	Analog to digital converter.```
```Analog acquisition systems.
(ii)	Data buffering
(iii)	Data logging memory requirements.
(iv)	Single and multi-channel interfaces```

## Simulate sampling a Continuous Time Signal

Generate a 'continuous' time signal. Sample this sgnal at discrete time intervals and plot both signal together to see the relationship between them.

## Continuous time signal: Signal frequency < Nyquist

Generate continuous time sinusoid, frequency = 0.5 Hz

```f=.5; % Signal frequency
tmax=4;
fsc=10000;tc=1/fsc; %tc is the 'continuous time' sampling interval
t=0:tc:tmax; % Continuous time vector
x=cos(2*pi*f*t);
plot(t,x)
title('Continuous time signal , f = 0.5','fontsize', 15)
``` ## Sampled Signal

Sample the signal at 20 Hz

```fs=20;
T=1/fs;
t_discrete=0:T:tmax;
xd=cos(2*pi*f*t_discrete);
hold on
stem(t_discrete,xd,'r','markerfacecolor','r')
title('Sampled Signal,   fs=20 ;    f signal = 0.5','fontsize', 15)
``` ## Zoom in

```for i=0:100
xlim([0 .5+3.5*(100-i)/100]);
drawnow
end
hold off
``` ## Continuous time signal: Signal frequency> Nyquist

Aliased Signal:

The frequency of the continuous time signal is 19.5 Hz (remember the nyquist frequency is 10 Hz)

```f=19.5; % Signal frequency
tmax=4;
fsc=10000;tc=1/fsc; %tc is the 'continuous time' sampling interval
t=0:tc:tmax; % Continuous time vector
x=cos(2*pi*f*t);
plot(t,x)
title('Continuous time signal , f = 19.5','fontsize', 15)
``` ## Sampled Signal

Sample the signal at 20 Hz

```fs=20;
T=1/fs;
t_discrete=0:T:tmax;
xd=cos(2*pi*f*t_discrete);
hold on
stem(t_discrete,xd,'r','markerfacecolor','r')
title('Sampled Signal,   fs=20 ;    f signal = 19.5','fontsize', 15)
``` ## Zoom in

```for i=0:100
xlim([0 .5+3.5*(100-i)/100]);
drawnow
end
hold off
``` ## Quantised Sampled Sinusoid

```Q=0.1;   % Quantisation level
f=.082; % Signal frequency
tmax=20;
fsc=10000;tc=1/fsc; %tc is the 'continuous time' sampling interval
t=0:tc:tmax; % Continuous time vector
x=cos(2*pi*f*t);
plot(t,x);
% Sampled Signal
fs=1;
T=1/fs;
t_discrete=0:T:tmax;
xd=cos(2*pi*f*t_discrete);
set(gca,'xgrid','on','xtick',0:T:tmax,'ygrid','on','ytick',-1:Q:1)
hold on
plot(t_discrete,xd,'o','markerfacecolor','b')
title(['Sampled Signal,   f_s=' num2str(fs) ';    f_signal = ' num2str(f) ],'fontsize', 15)
``` ## Quantised Signal

```xdq=floor(xd/Q)*Q;
stem(t_discrete,xdq,'sr','markerfacecolor','r')
``` ## Zoom in

```axis([10 15 .3 1])
hold off
``` ## Quantisation Error

```subplot(2,1,1)
xd=cos(2*pi*f*t_discrete);
set(gca,'xgrid','on','xtick',0:tmax,'ygrid','on','ytick',-1:1/10:1)
hold on
plot(t_discrete,xd,'o','markerfacecolor','b')
title(['Sampled Signal,   f_s=' num2str(fs) ';    f_signal = ' num2str(f) ],'fontsize', 15)
xdq=floor(xd*10)/10;
stem(t_discrete,xdq,'sr','markerfacecolor','r')
``` ```subplot(2,1,2)
e=xd-xdq;
stem(t_discrete,e);grid on
title('Quantisation Error')
``` 