Professional Documents
Culture Documents
Spring 2014
Week 2
Contents
1 Objective
2 Equipments
3 Experiment Procedure
3.1 Assignment 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Assignment 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Assignment 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
2
2
3
3
4
4
6
5 Conclusion
6 Appendix
List of Figures
1
2
3
4
5
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
5
6
7
4
4
List of Tables
1
2
Objective
1. To understand data formats and its conversion between fixed-point data and floating-point
data.
2. To evaluate the overall time-delay when implementing a digital controller on dSpace.
3. To investigate quantization error.
Equipments
Experiment Procedure
Overall, experimentation consisted of making of simulink model, converting the model into an
equivalent C code which could be loaded on the controller board and real time control of the
simulink model through control desk (GUI for DSpace board) software. This section talks about
the experimental procedure adopted for assignments and the next section talks about results and
analysis.
3.1
Assignment 1
A matlab code (shown in appendix) was written to make the conversion from the binary to decimal
and vice-versa in an automated manner. Two external m files were used namely f p dec2bin16.m
and f p bin2dec16.m to make the conversion possible.
3.2
Assignment 2
3.3
Assignment 3
1. The resolution of ADCH1 ADCH5 were calculated and found to be 3.0518X105 and 4.8828X104
respectively(without the gain of 10).
2. DACH1 was connected to both ADCH1 ADCH5 using two BNC cables and a T-joint connector.
3. Changes were made to the previous simulink model to abtain the following (fixed step).
4. Corresponding changes were made in Control Desk interface.
3
In this section, results for various assignments and corresponding analysis is presented.
4.1
Assignment 1
Decimal Numbers
0
100
1.56
-3.5
-135000
130000
Binary Number
0000000000000000
0101011000111111
0011111000111101
1100001011111111
1111110000011110
0111111111101111
Binary Numbers
0111010111101101
0100010101101100
1111010101111111
1000010111101001
Decimal Number
24272
5.4219
-22512
-9.0182e-05
10
X
[di ]21 )X2e15
i=1
For the maximum number we take the sign bit as positive(0), exponent part to be 11110(as
11111 is reserved for infinity) and fraction part to be 1111111111. The bias was found by
e=
4
X
[e4j ]X2j
j=0
4.2
Assignment 2
1. Two different set of data for two different sampling frequencies are shown below. Clearly
from the these curve we can see the delay between the original and the delayed signal. Also
it is evident that delay reduces due to by increasing the sampling frequency of the signal.
Close-ups for these figures is shown next which also suggests the dependency of delay on
sampling period.
Figure 3: Overall delay for two sampling period - 0.0001s and 0.00002s
4.3
Assignment 3
1. Below is shown the comparison curve for the two channel ouputs(ADCH 1 ADCH 5) with
the orignial sine wave for the first case when the amplitude is 0.001. Clearly we can see
from the curve below that the black curve which is the output of the 16 bit port (which has a
higher resultion of 3.0518X104 ) is able to follow the original plot(green curve) more closely as
compared to the 12-bit port(which has a resolution of 4.8828X103 ). The resolution basically
6
tells us the minimum value a ADC can pick up for quatisation. Since the amplitude for the
sine wave in this case is 0.001, the ADCH 5 is not able to pick anything(as this amplitude is
less than its resolution) and technically should be zero. The spikes seen in the red curve are
possible noises which is also corroborated by their random distribution.
2. In the next case when amplitude of the sine wave is 0.01, the ADCH 5 is able to follow the
original curve as it is able to quantize the input signal(as now the input signal is greater than
the 4.8828X103 value). Again we can see that ADCH 1 is better replication of the sine
wave since its resolution is less and thus is able to quantize to the values closer to the original
signal.
Conclusion
Fundamentals of a digtal controller and practical problems in the implementation were understood.
In particular the inherent properties of a digital controller namely number conversion, overall delay
and quantisation was understood. Moreover the dependency of these properties on the sampling
frequency of the controller and the magnitude of the signals involved were tackled with.
Appendix
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
ME 7292 Control System Labs
%
Week 2
%
Kirti Deo Mishra(# 98)
%
%
The following script coverts binary decimal and processes
%
the data from the control desk environment into meaning figures.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
% Assignment 1
% Decimal to Binary Conversion
% Array of decimal values to be converted to binary.
value1 = [0, 100, 1.56, 3.5, 135000, 130000] ;
% Initiating the reults array
results1 =[];
% Displaying results
disp(['Decimal Number ', '
for i=1:length(value1)
Binary Number'])
figure('color', [1 1 1])
plot(part2.X.Data, part2.Y(1,2).Data,'r',...
part2.X.Data, part2.Y(1,3).Data,'g')
grid on
xlabel('Time(s)')
ylabel('Signal')
legend('Original Signal', 'Delayed signal')
title('Overall time dalay 0.00002 sec sampling')
% Assignment 3
clc
lear all
% Loading Data files exported from the control desk
load assignment 3a.mat
load assignment 3b.mat
figure('color', [1 1 1])
plot(assignment 3a.X.Data, assignment 3a.Y(1,1).Data,'k',...
assignment 3a.X.Data, assignment 3a.Y(1,2).Data,'r',...
assignment 3a.X.Data, assignment 3a.Y(1,3).Data,'g')
xlabel('Time(s)')
ylabel('Signal')
legend('ADCH1(16 bits) signal', 'ADCH5(12 bits) signal', 'Original Signal')
grid on
title('Quantisation effect 0.001 amplitude')
figure('color', [1 1 1])
plot(assignment 3b.X.Data, assignment 3b.Y(1,1).Data,'k',...
assignment 3b.X.Data, assignment 3b.Y(1,2).Data,'r',...
assignment 3b.X.Data, assignment 3b.Y(1,3).Data,'g')
xlabel('Time(s)')
ylabel('Signal')
legend('ADCH1(16 bits) signal', 'ADCH5(12 bits) signal', 'Original Signal')
grid on
title('Quantisation effect 0.01 amplitude')
*************************
10