Professional Documents
Culture Documents
Application of Orthogonal Hybrid Function On Control Sysytem PDF
Application of Orthogonal Hybrid Function On Control Sysytem PDF
Project Report
On
“Application of Orthogonal Hybrid function for the
Analysis and Synthesis of Control System”
By
Aninda Chatterjee (Roll No-14)
MAY 2013
St. Thomas’ College of Engineering &
Technology
CERTIFICATE OF APPROVAL
The project entitled ‘Application of Orthogonal Hybrid Function for the Analysis and
Synthesis of Control System’submitted by Aritra Purkait ,Sangramjit Sarkar,Amitava
Paul, Aninda Chatterjee, Spandan Chatterjee ,Srideep Saha done under my supervision
and guidance is accepted for partial fulfillment of the requirement to award the
degree of Bachelor of Technology in Electrical Engineering of St. Thomas’ College of
Engineering & Technology under West Bengal University of Technology, Kolkata.
This is to certify that the work embodied in this project has not been
submitted elsewhere for any other degree.
We would also like to convey our sincerest gratitude and indebtedness to all
other faculty members and staff of the Department of Electrical Engineering,
St.Thomas’ College of Engineering and Technology, who guided us at appropriate
times, without which it would have been difficult on our project work.
2 Objective 4
4 Methodology 4
5 Block Diagram 6
6 MATLAB model 8
7 Circuit Diagram 10
9 Result Analysis 16
10 Problems Encountered 21
11 Limitations 22
12 Future Extension 23
13 Conclusion 23
14 References 24
15 Appendix
Component List 25
Code 26
Datasheets 31
Introduction: - Analysis and synthesis are two fundamental problems of control
engineering. Analysis is the process or technique by which we are able to find the
response of a system excited by given input. In simple words it the method to find
the response when the excitation and the mathematical model of the system are
known to us. On the other hand, synthesis or design is to identify the mathematical
model of the system from the input-output relationship.
Fig1-Analysis Problem: i/p & system are known but o/p is unknown
Fig2-Synthesis Problem: i/p & o/p are known but system is unknown
In orthodox method, there are different ways of system analysis and synthesis based
on different convenient mathematical tools. This project is based on a new way of
system analysis and that is-Hybrid Function (HF) method. This method has a lot
potential for successful system identification. Digital computing has revolutionized
the field of modern technology. Since HF based computation involves working with
samples instead of actual analog signal it proves to be very simple and numerically
accurate. In the circumstances where only certain sample values are available in lieu
of the actual waveshape of the signal HF method is quite advantageous to be used.
1|Page
An introduction to Hybrid Function:- Prior to Introduction to Hybrid function its
essential first to define the notion of orthogonal function sets.
A time function f(t) defined over the time interval [0, T ) may be represented by an
orthogonal function set S(t) as
n 0
c nS n(t )
where, Cn’s are the coefficients of different members of the orthogonal set.
The members of the function set S(t) are said to be orthogonal in the interval
0≤ t < T if for any positive integral values of n and m, we have
T
0
S m ( t ) S n ( t ) dt mn
where, δmn = 0 for m ≠ n and when m = n, δmn = a constant.
Some common examples of orthogonal function sets are sinusoidal function set. Its
usefulness is well justified by the idea given by Fourier that any periodic function can
be realized as summation of infinite no of sinusoids. But let’s have a look at some of
the other kinds of orthogonal function sets which are very useful in digital
computation.
2|Page
Fig3- A set of SHF with 4 members Fig4- A set of TF with 4 members
Now we are in a position to describe Hybrid Function (HF) and using it how we can
approximate any square integrable continuous time function f(t).
3|Page
Hence in general, if we consider a function f(t) in an interval t Є [0,T). Considering
(m+1) equidistant samples of the function with a sampling period h (i. e., T = mh), we
can write
An important and interesting is that the realization of any function f(t) requires only
sampling the signal at an equal intervals (and obviously obeying Nyquist Sampling
Theorem) i.e we don’t have to solve the integrals like Fourier series expansion to find
the co-efficient of the corresponding basis functions. This is one of the great
advantages of working with HF.
Objective: - Objective of this project is to analysis any LTI system using HF method.
To do this standard test signals like sine wave, step, ramp and others are used. In HF
method only knowing the samples of i/p to the plant and the plant transfer function
we can accurately calculate the samples of the o/p waveform. This is justified using
hardware model.
Methodology: - Main idea is to first realize the actual continuous time input signal
into HF domain. It is done by sampling the actual signal and then joining these
sample points to construct a piecewise linear waveform. This piecewise linearly
joined waveform is the HF approximation of the actual signal. This signal is fed to the
system and the response is observed in DSO. On the other hand, the samples of the
input waveform are stored in microcontroller memory and using these samples & the
transfer function of the system we can compute the samples of the response using
HF based algorithm as indicated in ref [10]. Using these computed samples we
attempt to reconstruct the response using HF mathematics and compare the results
graphically as well as numerically.
4|Page
Piecewise Plant Response Sampler (ADC)
Excitation
linear wave
Fig6-Practical model
The input signal may be any arbitrary random signal but for analysis standard test
signals like step, ramp, parabola, and sinusoidal are considered. Here First attempt is
made based on sinusoidal waveform because it has both positive and negative swing.
Since the input is of a known (sinusoidal wave) nature, instead of actually sampling
the wave at the initial stage the samples are pre-calculated for a 1Hz sine wave and
directly used to construct the SHF (Sample and Hold Function) or ZOH (Zero order
wave) as explained later.
System or Plant is initially taken as 1st order RC circuit for the sake of simplicity and
then it is further this way of analysis is extended for 2nd order RC circuit.
5|Page
Block Diagram:-
Sampler
(ADC) Load
1. Continuous Signal
A continuous signal is input into the system. It may be a known signal (sine
wave, triangular wave, square wave etc) or a random signal.
This signal can have both positive and negative value (e.g a sine wave).
2. Sampler(ADC)
The continuous waveform is converted into a digital waveform by quantizing
the input with a fixed time delay between each measurement.
The ADC present inside the microcontroller was used here. It can only
measure voltages lying between 0 – 5 V. So the input signal has to be
attenuated so that its peak to peak value is less than 5 V. Some amount of
positive voltage is injected into the signal so that the entire signal becomes
positive.
3. Controller
The controller controls the sampling rate of the ADC and stores the samples in
memory. It performs some signal processing operations and then outputs the
result through the DAC.
4. DAC
An 8 bit R-2R ladder DAC is used is used to convert the digital samples into
analog output.
6|Page
5. Linear Joiner
O/p of the DAC is piecewise linearly joined together to reconstruct an
approximate version of the original input signal (continuous wave). This
piecewise linearly joined waveform is the HF approximation of the actual
continuous time i/p signal.
6. Load
The piecewise linearly joined wave is fed to the load (1 st order circuit or 2nd
order RC circuit has been used in this experiment) and the response is viewed
using a Digital Storage Oscilloscope.
7. Sampler(ADC)
The output of the load is sampled using an ADC for hybrid function analysis.
Since the output of the Load will have both positive and negative
voltages, the output is attenuated and level shifted so that the whole signal
lies in the positive plane and its peak to peak value is less than 5V just like in
stage 2.
Voltage Sampler
Load Attenuator Level Shifter (ADC)
Linear Joiner: - this block requires special attention because it is actually the signal
reconstruction block which is the heart of this project. The philosophy of signal
reconstruction from the sampled versions of the input signal is explained here from
the HF point of view.
1st we have to approximate the continuous function by sample and hold functions. It
is done by sampling by using an ADC (when the samples are not given but the actual
continuous signal is available) and then converting into a ZOH (Zero Order Hold)
signal using a microcontroller & DAC. In the next stage the TRAINGULAR function
approximation is done with the help of integrator. After these two stages finally we
get the piecewise linear HF based approximation of the original wave.
7|Page
MATLAB-SIMULINK block diagram model for 1st order system: -
Since sampling time is chosen as 100ms and 10 samples of ZOH sine wave is taken to
create a 1Hz sine wave we need the value of the RC to set as 100ms hence the time
constant is 1/RC=0.1 as shown in the ‘Linear Interpolator’ block.
To accurately join any two consecutive corner points of the ZOH sine wave, it is
essential to integrate the voltage difference between the next and the present
sampling point. Hence a comparator block is used prior to the ‘Linear Interpolator
Block’.
The peak to peak voltage o/p from the microcontroller can be maximum 5 volt which
can’t be negative. Hence, at the final stage, the signal ground is shifted by -2.5 V to
ensure the voltage swing both below and above the ground line.
The ‘1st order Plant’ block is the system which is to be fed by the approximated
signal.
8|Page
MATLAB-SIMULINK block diagram model for 2nd order system: -
Rest of the things in this block is same except the transfer function. This transfer
function is constructed as cascading following stages. Note each of these stages is
observed as described in details later in circuit diagram section. Transfer Function1
and Transfer function2 are easily realized through simple 1st order RC circuits.
9|Page
Circuit Diagram: - The detailed circuit Diagram is shown below which
incorporates all the blocks described above.
At the leftmost of this diagram there is a differential amplifier with unity gain. It is
used to shift the voltage of the waveform input to the integrator. This waveform is
obtained by finding the differences of the corresponding samples of the actual
10 | P a g e
waveform in the microcontroller and passing it through a DAC in order to get the TF
realization of the actual continuous wave. The Integration time constant is set as 0.1
by setting product R2C2 as 0.1 as the sampling rate was 0.1sec. 3rd op-amp is the part
of the integrator which is used as a unity gain inverter. Now comes to the stage to
inputting the piecewise linear wave to the plant (in the diagram 1st order plant is
shown and 2nd order plant is shown later). To avoid loading effect the 4th op-amp
shown in the circuit diagram is used as a unity gain buffer. After getting the response,
to shift the voltage level of the response finally by 2.5 volt an adder (in the non-
inverting mode) is used.
Block diagram given in Fig. 10 can be helpful to understand this circuit diagram of the
2nd order plant. Initial gain block has been realized using the difference amplifier
where 4.7Kohm and 1kohm resistances are used to provide gain 4.7 of this gain
block. Two series RC circuits are used to implement the two transfer functions as
shown on the Fig.10. 2nd and 3rd op-amps are used as buffers for successful cascading
of the blocks.
11 | P a g e
12 | P a g e
Snapshot of hardware circuit:-
13 | P a g e
I/P and reconstructed waveform for MATLAB-SIMULINK model: -
Fig17 – ZOH original sine wave of frequency 1Hz Fig18 – ZOH shifted sine
Fig19 – Integrator o/p-Piecewise Linear wave Fig 20– Piecewise linear wave fed to RC ckt.
14 | P a g e
I/P and reconstructed waveform for hardware model: -
Fig23 - Response of 1st order plant for MATLAB- Fig24- Response of 1st order plant for
SIMULINK model hardware model
15 | P a g e
Response (O/P) of 2nd order plant: -
Fig25 - Response of 2nd rder plant for MATLAB- Fig26 - Response of 2nd order plant for
SIMULINK model hardware model
Result analysis: -
Fig27 –Plot of Responses of 1ST order plant using direct samples of the MATLAB-SIMULINK response (blue
trace)
&
samples computing using HF algorithm (red trace)
16 | P a g e
Fig28 –Plot of Responses of 2nd order plant using direct samples of the MATLAB-SIMULINK response (blue trace)
&
samples computing using HF algorithm (red trace)
The above two plots show the comparative study between the responses which are
obtained by joining the direct samples of the responses of the MATLAB-SIMULINK
model (i.e ideal model) and by computing those samples as described in ref [10]
using HF based algorithm. As these two different coloured (red and blue) plots
almost merge together (as thus it is difficult to distinguish them is some portions of
the plot) the error is marginal. Detailed error tables and corresponding error plots
are shown next.
In the error analysis it is found that the absolute error is within 10%.This can also be
reduced to a greater extent by enhancing the sampling rate.
17 | P a g e
Error table of 1st order plant for sampling at 0.1s-
18 | P a g e
Error table of 2nd order plant for sampling at 0.1s-
Sampling instants Direct Samples of o/p Samples of o/p y(t) Percentage error
(s) y(t) via HF
19 | P a g e
Comparative study of the performance of the actual hardware model and the HF
based algorithmic computation method-
Two curves of the 1st order responses are plotted and shown in the fig-29. One curve
of the response of the 1st order plant (shown by solid trace) is plotted by collecting the
actual samples values of the response using ADC. This set of values is tabulated below-
20 | P a g e
The other curve of response of 1st order plant is plotted by computing the samples of
the response using HF based algorithm.
Fig31 – Plot of Responses of 1st order plant using direct samples of the HARDWARE response (solid trace)
&
samples computing using HF algorithm (dotted trace)
Here the two curves deviate quite a lot and hence the error is appreciable. This is due
the hardware model. There are some problems encountered in hardware models
resolving those problems will lead to better result. Such problems are discussed in
the section ‘Problems encountered’ [(iii) and (iv)].
Problems Encountered
I. Since the whole circuit was constructed on a Bread board, various types of
problems were encountered over the course of the experiments. Most of the
problems were due to loose connections of the single strand wires used for
connecting the various stages of the circuit.
II. Initially, an Atmel AT89S52 microcontroller (8051 derivative) was used as the
controller. But at startup, it had to be reset since sometimes it started to
execute the program from the middle. This is a known problem with the 8051
architecture. And also at startup, it took some time to provide stable output
from the DAC. Due to these problems, we shifted to using an Atmel ATmega
8L microcontroller which has a much modern architecture and has none of the
above mentioned problems. Also, it has an integrated 6 channel, 10 bit ADC.
So we could eliminate the external ADC.
21 | P a g e
III. The output of the DAC is totally positive and so to make it resemble the
original input wave (which can have both positive and negative values), we
used a voltage level shifter to shift the level downwards by 2.5V. This was
done by using a 10k multi turn potentiometer connected to the inverting pin
of the first stage of the linear joiner. During the course of the experiment, we
found that the voltage shift that was set using the pot would drift upwards or
downwards by a small value. This introduced an error in the output of the
linear joiner.
IV. In the integrator stage of the linear joiner circuit, we had used an electrolytic
capacitor. Electrolytic capacitors have very large thermal drift. So the output
of the integrator would shift during the time the circuit was on. This was
remedied by using a Tantalum capacitor. Tantalum capacitors have much
lower temperature drift.
V. The output of the linear joiner sometimes used to drift upwards or
downwards on its own. At that time, we had connected the input of the
different stages of the circuit to the ground directly. This was causing an
imbalance in the input offset current. This problem was overcome by
grounding the input through a resistance. The value of the resistance was the
Thevenin equivalent of the resistances used in the circuit as seen by the input
pin.
The problems (iii) and (iv) are the probable reasons for appreciable error
encountered in fig-29.
Limitations
I. The main focus of the experiment was on the reconstruction of the signal and
not too much time was devoted to ensuring that the samples taken by the
ADC is free of noise. A primitive method of filtering out noise was used (using
capacitors as a low pass filter). Also since the circuit was constructed on a vero
board, noise from the electrical circuit in the room, static charge on our
fingers, was injected into it. If a professional grade PCB could be constructed
and other advanced methods of noise filtering could be used, then the
samples would have been much more accurate.
II. Due to the level shifts used in various parts of the circuit, errors creep in into
the final output.
III. The circuit gives quite accurate results for input signals which have both
positive and negative voltage swings (e.g sine wave). But for the signals which
lie totally in the positive half (e.g ramp), it is not that accurate.
22 | P a g e
Future extension: -
The entire process of analysis was primarily initiated based on a a sine wave i/p and
the detailed study ,corresponding error computation and plotting of the response of
actual hardware model were done based on the fact that a 1 st order plant is being
excited by a sine wave. Such detailed studies needed to carried out for 2nd order
hardware model and also by exciting the system using other waveforms such as
ramp, parabola, exponential, arbitrary waveform etc. The reconstruction circuit
including some parts of the entire scheme should have to be changed for such other
types of signals where the signal has no negative excursion and has only positive
values.
The second most important part of the project was aimed to perform the SYNTHESIS
studies using actual hardware model. This was not successfully done and also
excluded from this report due to lack of time at the end.
Conclusion: - Since digital technology has changed the face of the modern technical
era by its ease and efficiency, mathematical computation and related signal
processing for control system engineering and other branches of engineering &
technology in digital domain is of great discussion nowadays. In this context, its
worthwhile to mention HF based mathematics has immense potential to improve
this digital computation technique. It’s a versatile, simple, easy to understand and
implement theory. This project is an attempt to unravel these mathematical utilities
of HF theory by a practical hardware circuit model (1st order and 2nd order). This
attempt has been partially successful (due to the problems encountered and the
limitations discussed above) with encouraging results that will motivate us to do
further improvement and related research work in this field.
23 | P a g e
References:
[1] Deb, A., Sarkar, G., Bhattacharjee, M., and Sen, S., A new set of piecewise
constant orthogonal functions for the analysis of linear SISO systems with sample-
and-hold, J. Franklin Instt., vol. 335B, no. 2, pp. 333-358, 1998.
[2] Deb, A., Sarkar, G., and Sengupta A., Triangular orthogonal functions for the
analysis of continuous time systems, Anthem Press, London, 2011.
[3] Deb, A., Sarkar, G., Mandal, P., Biswas A., Ganguly A. and Biswas D., Transfer
function identification from impulse response via a new set of orthogonal hybrid
functions (HF), Applied Mathematics and Computation, Vol 218, Issue 9, pp. 4760-
4787, 1 Jan, 2012.
[4] Deb, A., Sarkar, G., Ganguly, A. and Biswas, A., Approximation, integration and
differentiation of time functions using a set of orthogonal hybrid functions (HF) and
their application to solution of first order differential equations, Applied
Mathematics and Computation, Vol 218, Issue 9, pp. 4731-4759, 1 Jan, 2012.
[5] Beauchamp, K. G., Walsh and related orthogonal functions with an introduction to
sequency theory, Academic Press, London, 1984.
[6] Uffenbeck, J., Microcomputers and microprocessors--The 8080, 8085 and Z-80
programming, Interfacing and Troubleshooting, 3rd edition, PHI, New Delhi, 2005.
[7] Mazidi, Muhammad Ali, The 8051 microcontroller and embedded systems, 2nd
edition, Pearson Education, 2008.
[9] Hanselman, D. and Littlefield, B., Mastering MATLAB 7, Pearson Education, Delhi,
2005.
[10] Deb, A., Ganguly, A., Sarkar, G., Biswas, A., Computation of Convolution via A
New Set of Orthogonal Hybrid Functions (HF) for Linear Control System Analysis and
Identification , presented at IEEE, INDICON 2012.
24 | P a g e
Appendix
Pin Configuration:
LM358
Atmega 8L
25 | P a g e
Code:-
void main()
{ DDRD = 0xFF; //Set all pins of port D as Output
DDRB = 0xFF; //Set all pins of port B as Output
/* _________________ D E C L A R A T I O N _________________ */
/* _________________ P R O G R A M _________________ */
output_result[0] = 127; //max level = 255, ground = 127, min level = 0
for(i=1; i<10; i++)
output_result[i] = output[i] - output[i-1] + 127;
//output_result[MAX-1] = 0;
/* ___________________ O U T P U T ____________________ */
while(1)
{
for(i=0;i<MAX;i++)
{ PORTD = output[i];
PORTB = output_result[i];
_delay_ms(100);
}
}
}
26 | P a g e
/*-------------------------------- PC side data collection program ----------------------------------------*/
/*------------------------------------ written in Arduino v1.0.4 ---------------------------------------------*/
/*------------------------------------------ www.arduino.cc ---------------------------------------------------*/
// adc0 used for measuring the voltage of the output of the LOAD
//adc1 used for measuring the voltage of the voltage offset provided to level shifter
int adc0, adc1, i = 0;
void setup()
{ Serial.begin(9600);
Serial.println("Starting Program");
delay(1000);
Serial.println(" ");
adc1 = analogRead(1);
Serial.print(adc1);
Serial.println(" ");
Serial.print("Analog value = ");
}
void loop()
{ delay(100);
adc0 = analogRead(0); //measure the value every 0.1 sec
if(i%10 == 0)
{ adc1 = analogRead(1); //reads the value of offset every 10 samples
Serial.print("Offfset = "); //this gives an idea of the external noise
Serial.print(adc1); //affecting the system
Serial.println(" ");
}
}
MATLAB Code:-
clc
T=4;
27 | P a g e
m=40;
h=T/m;
t=0:h:T;
g=10*exp(-t*10);
r=sin1(:,2); % sin1= Input samples of a sine wave input used in simulink model.
%sin1 is matrix of dimension with 2columns, 1st column
%contains the value of time samples an 2nd ol contains
%the values of the amplitude samples .
yd=y_sin1(:,2); % yd : The output samples obtained by directly sampling the continous o/p.
%y_sin1 : The samples of the o/p used in simulink model.
yd=yd' ;
for i=1:2*m;
if i<m+1;
R(i)=2*r(i+1)+r(i);
end
if i==m+1;
R(i)=r(2)+2*r(1);
end
if i>m+1;
R(i)=r(i-m+1)+4*r(i-m)+r(i-m-1);
end
end
R;
for i=2:m+1
y1=[];
y1(i-1)=g(1)*R(i-1);
y2=[];
for p=2:i
y2(p-1)=g(p)*R(m+i-p+1);
z=sum(y2);
y2=[];
y2(p-1)=z;
end
y(i-1)=(h/6)*(y1(i-1)+y2(i-1));
end
y=[0 y];
err=((yd-y )./yd);
err=err*100;
28 | P a g e
end
figure(1)
plot(t,y,'r')
hold on
plot (t,yd)
hold off
figure(2)
plot(t,abs(err),'r')
clear all
clc
T=4;
m=40;
h=T/m;
t=0:h:T;
g=10*exp(-t*10);
r=sin1(:,2); % sin1= Input samples of a sine wave input used in simulink model.
%sin1 is matrix of dimension with 2 columns, 1st column
%contains the value of time samples an 2nd col contains
%the values of the amplitude samples .
yd=y_sin1(:,2); % yd : The output samples obtained by directly sampling the continous o/p.
%y_sin1 : The saples of thr o/p used in simulink model.
yd=yd' ;
for i=1:2*m;
if i<m+1;
R(i)=2*r(i+1)+r(i);
end
if i==m+1;
R(i)=r(2)+2*r(1);
end
if i>m+1;
R(i)=r(i-m+1)+4*r(i-m)+r(i-m-1);
end
end
R;
for i=2:m+1
y1=[];
29 | P a g e
y1(i-1)=g(1)*R(i-1);
y2=[];
for p=2:i
y2(p-1)=g(p)*R(m+i-p+1);
z=sum(y2);
y2=[];
y2(p-1)=z;
end
y(i-1)=(h/6)*(y1(i-1)+y2(i-1));
end
y=[0 y];
plot(t,y,'r')
hold on
30 | P a g e
-1.37
-0.39
0.60
1.17
1.14
0.47
-0.57
-1.61];
m=length(y_s)-1;
h1=0.1;
T1=m*h;
t1=0:h1:T1;
plot(t1,y_s)
Component Datasheet:-
31 | P a g e
32 | P a g e