You are on page 1of 24

Project 3

VIBRATION ATTENUATION OF CANTILEVERED


FLEXIBLE BEAMS FOR USE IN NEXT-GENERATION OF
MICROCANTILEVER-BASED BIOSENSING

GROUP 6
CHRISTOPHER BALINO
CHRISTOPHER BRENNAN
SAM GREEN
ERIC HOLTZMAN
OLIVER QUADROS



Mechatronic Systems
Northeastern University











April 29th, 2015
TABLE OF CONTENTS
TABLE OF CONTENTS ............................................................................................................................................ 2
TABLE OF FIGURES ................................................................................................................................................. 2
TABLE OF TABLES ................................................................................................................................................... 2
ABSTRACT ................................................................................................................................................................... 3
INTRODUCTION ........................................................................................................................................................ 4
THEORY ........................................................................................................................................................................ 5
RESULTS .................................................................................................................................................................... 10
DISCUSSION ............................................................................................................................................................. 16
CONCLUSION ........................................................................................................................................................... 18
APPENDIX ................................................................................................................................................................. 19

TABLE OF FIGURES
Figure 1: Diagram of Theoretical Model ......................................................................................................... 5
Figure 2: Experimental Setup .............................................................................................................................. 9
Figure 3: Uncontrolled Velocity Response of Cantilever Tip .............................................................. 10
Figure 4: Zoomed View of the Uncontrolled Velocity Response ....................................................... 11
Figure 5: Velocity Response of Cantilever Tip with Controller 1 ..................................................... 12
Figure 6: Velocity Response of Cantilever Tip with Controller 2 ..................................................... 13
Figure 7: Experimental Data Amplitude Spectrum of Uncontrolled Beam ............................... 14
Figure 8: Simulated Data Amplitude Spectrum of Uncontrolled Beam ....................................... 14
Figure 9: Simulated Uncontrolled Beam Strain ........................................................................................ 15
Figure 10: Simulated Beam Strain with Controller 1 ............................................................................. 15
Figure 11: Simulated Beam Strain with Controller 2 ............................................................................. 16
Figure 12: Simulink system diagram for use in MATLABonly simulation .................................. 19
Figure 13: MATLAB Code for Analysis and Simulation ......................................................................... 23
Figure 14: Simulink theoretical model for validation of MATLAB simulation ........................... 24
Figure 15: Simulink theoretical simulation data to verify MATLAB code. ................................... 24

TABLE OF TABLES
Table 1: Controller Parameters and Calculated Percent Reduction ................................................ 17
Table 2: Tabulated peak values from both physical and theoretical systems. ........................... 17


ABSTRACT
Microcantilevers, or small, projecting beams fixed only at one end, can be incorporated into
microelectromechanical systems (MEMS) for use in atomic force microscopy and biological
sensing. In such applications, it becomes necessary to precisely regulate the dynamics
occurring at the cantilever tip. The objective of this study was to implement a PID
controller on a cantilever system so as to minimize the firstmode vibrations. This
cantilever system consisted of a beam with a piezoelectric patch (PZT) attached near its
base. A stinger was used to induce a sinewave excitation on the system while a laser
Doppler vibrometer, force transducer, and strain gauge monitored the tip dynamics. The
PID controller, which was designed according to the ZieglerNichols method, regulated the
voltage into the PZT such that the strain from first mode vibrations was minimized. From
this method with an input frequency of 8.1 Hz, firstmode amplitude reductions of 43% and
56% were realized for controller gains P=33, I=0, D=0.1 and gains P=50, I=440, D=0.1
respectively. The experiment was next run without a controller and a sine chirp from 0 to
25 Hz. This allowed for an updated transfer function and system model to be created for
simulation. A new natural frequency of 7.9 Hz was found for the system. This system was
then stimulated with the same 8.1 Hz frequency from this experiment to compare the
systems. The same controller gains were then applied to this closed loop model of the
cantilever system, and from this model, firstmode amplitude reductions of 59% and 71%
were realized for controller gains P=33, I=0, D=0.1 and gains P=50, I=440, D=0.1
respectively. These discrepancies between the experimental and theoretical results can be
attributed to the increased complexity of the real system as well as signal noise.

INTRODUCTION
Vibration analysis and control has long been an issue in the field of engineering,
particularly with machinery and structural systems. The study of vibrations is of great
importance when designing any system (including mechanical, structural, etc.) in order to
ensure that the design meets all required specifications. An example case study was the
Tacoma Narrows Bridge, built in 1940 only to be destroyed a year later due to intense
winds1. The design of this bridge was deeply flawed as its vibration modes were excited by
small gusts of wind, thus leading to its collapse once the resonance condition was reached
for an extended period of time.
This case study is obviously an extreme case demonstrating the importance of vibration
control, but the principle remains the same. Smart structures are increasingly becoming a
heavilyresearched topic in engineering. These smart systems are essentially structures
with sensors and actuators comprised of smart materials (the most prominent being Lead
Zirconate Titanate or PZT) as well as a control system2. These PZTs have the ability to sense
and respond to certain behaviors on these structures, and either minimize or maximize
certain physical characteristics of the system3. PZTs have many advantages such as their
flexibility, ease of implementation, and relative low costs. Smart structures have a vast
array of applications from active vibration control to energy harvesting and biosensing4.
Cantilever beams are of particular interest because of their ability to be applied in many
different environments, including microcantilevers for biosensing. Microcantilevers are
ideal for biosensing applications because of their superior dynamic response, higher
reliability and precision, and their small size5. The goal of this project was to study the
vibration characteristics of a cantilever beam, excited at the fixed end, and use a
piezoelectric transducer (PZT) to dampen the vibration at the free end. This was done by
first exciting the cantilever at its first natural frequency and using a PID (Proportional
IntegralDerivative) controller in a closedloop control system. Experimental data was
taken at both the fixed (excited) end and free (vibrating) end with a strain gauge and Laser
Doppler Vibrometer, respectively. This data was then used to tune the PID controller gains
to optimal values according to the ZieglerNichols Method.


1 Karman, T., Collapse of the Tacoma Narrows Bridge, Resonance, 10 (8), 97102, (2005).
2 Dong, X., Meng, G., Peng, J., Vibration control of piezoelectric smart structures based on system

identification technique: Numerical simulation and experimental study, Journal of Sound and Vibration, 297
(35), 680693, (2006).
3 Xinke, G., Haimin, T., Active Vibration Control of a Cantilever Beam Using Bonded Piezoelectric Sensors and

Actuators, Electronic Measurements and Instruments, 2007. ICEMI 07. 8th International Conference on. 4854
88, (2007).
4 Aphale, S., "Characterization and Enhancement of Sensing Properties of Piezoelectric Materials with

Applications to Vibration Suppression", Clemson University, (2009).


5 Hansen, K., Thundat, T., Microcantilever Biosensors, Methods, 37 (1), 5764, (2005).
THEORY
The microcantileverbased sensor is comprised of a projecting beam with a piezoelectric
patch attached to its base. Since the beam is fixed at one end, the forces experienced by the
system vary as a function of distance. As a result, the cantilevers motion must be
characterized using the distributed parameter method, which describes systems as a
function of time and one or more spatial variables6. For reference, a diagram of the
theoretical model is depicted in Figure 1 with thickness t, width W and length L given as
dimensions for the piezo patch and beam respectively.

Beam x
L
Piezo
t b
W
t p
W
Lp


Figure 1: Diagram of Theoretical Model

The equations of motion were derived using the finite element method, which breaks the
system into simpler parts and approximates a solution by solving the individual boundary
value problems7. Here, the cantilever was divided into two sections to account for the
sections with and without the piezo patch. From Hamiltons principle, a particle will follow
the path that minimizes its action according to equation 1 below:

, , (1)

where S is the resulting path and L is the Lagrangian given as the difference between the
kinetic and potential energies for the variable q. An extension of this principle, called the
principle of virtual work, states that the work of the applied forces on a particle is zero for
all possible movements of that particle from static equilibrium8. That is a particle disturbed
from static equilibrium will return to static equilibrium and due to path independence the
work done on that particle will be zero. Therefore, since the cantilever starts from static


6 Bilbao, Stefan and Julius O. Smith. DiscreteTime Lumped Models. Center for Computer Research in Music

and Acoustics (CCRMA). Stanford University, (2014).


7 J. Chaskalovic, Finite Elements Methods for Engineering Sciences, Springer Verlag, (2008).
8 Torby, Bruce. "Energy Methods". Advanced Dynamics for Engineers. HRW Series in Mechanical Engineering.

United States of America: CBS College, (1984).


equilibrium, the motion of the two sections can be described from the principle of virtual
work given as

0 (2)

where the operator denotes a functional derivative and Wnc denotes work from non
conservative forces. From here, the equations of motion for each section can be written as

0 (3)

and

0 (4)

Further, the eight boundary conditions, two geometric and two natural for each section,
can be derived by evaluating these equations at the endpoints 0, Lp, and L. Using the
assumed mode method, the equivalent mass and stiffness of the cantilever beam can be
estimated from a chosen mode shape that is consistent with the boundary conditions9.
These assumed mode shapes are solutions to the eigenvalue problem for the cantilever
beam and can be given as the following eigenfunctions:
sin cos sinh cosh (5)
and
sin cos sinh cosh (6)

where 1 and 2 are eigenfunction constants and A1D2 are eigenfunction coefficients. Note
that the values of the eigenfunction coefficients depend on the given boundary conditions,
yet the eigenfunction constants are independent of these conditions since they relate to the
natural frequencies of the system10. From here, 2 can be written in terms of 1 as
/

(7)

which gives the relation between natural frequency (Hz) and the 1 values as
/

(8)

Through orthonormalization of the discontinuous cantilever, the eigenvalue problem can


be solved for the multidegreeoffreedom system given by
(9)

9 Tribology Group. Rotordynamics Laboratory. Texas A&M Univerisity. (2015).
10 Gere, J. M. and Timoshenko, S. P., 1997, Mechanics of Materials, PWS Publishing Company. (2011).
thus yielding the eigenvectors x1 and x2, which can be put into state space as according to:
0 1
(10.1)

0
(10.2)

0 (10.3)
0 (10.4)
for mass M=1 , stiffness K=12 , and input force F 11.
Further, the viscous damping for the system can be calculated from these parameters
through the following relation:

(11)

Additionally, orthonormalization allows for the equation of motion for the first mode to be
written as

2 (12)

where q is the strain measured by the strain gage and F is the input piezo voltage. This
equation of motion yields a transfer function for the first mode that can be found by simply
measuring the first mode frequency, , and the damping ratio of the system, .
During experiment 2, both the damping ratio and first modal frequency were realized by
measuring the force, velocity, and acceleration of the structures tip upon a linear sine chirp
excitation from 0200 Hz. The recorded data was then analyzed using MATLABs Fast
Fourier Transform algorithm and used to calculate the autopower spectra. The four
autopower spectra were calculated using Eq. 13 through 16 as given below:

(13)

(14)

(15)

(16)

where denotes the input FFT (force data or piezo voltage), denotes the output FFT
(velocity or acceleration data) and * denotes the complex conjugate.


11 SM Khot, Nitesh P Yelve, Rajat Tomar, Sameer Desai and S Vittal. Active Vibration Control of Cantilever Beam

by using PID based output feedback controller. Journal of Vibration Control. (2011).
The calculated autopower spectra were then used to calculate the frequency response
functions given by Eq. 17 and Eq. 18 below:

(17)

(18)

The coherence was then determined with Eq. 19 below:

(19)

The frequency response functions were used to determine the resonance frequencies of the
structure. Both and were graphed and the most intense peaks within the usable
range of frequency data was taken as the resonance frequencies of the structure. The
damping ratio was then determined using the halfpower bandwidth method around the
fundamental frequency.
The damping ratio is given by:

(20)

where and were taken as the 3db frequency values on the positive and negative side
of the fundamental frequency ( ), respectively.
Furthermore during project 2 the theoretical model anticipated that the first three modal
frequencies occur at f1= 9.475 Hz, f2=56.74 Hz, and f3= 152.7 Hz while the experimental
results from experiment 2 gave the first three modal frequencies at f1= 7.70.3 Hz,
f2=46.00.4 Hz, and f3= 1200.4 Hz. To account for this discrepancy, the eigenfunction
coefficients of the theoretical model, given by Eq. 5 and Eq. 6, were modified to better
match the experimental results. Plugging these new values into Eq. 12 and taking the
Laplace Transform yielded the modified transfer function between strain and input
piezoelectric force as

(21)
. .

Lastly, before designing a controller, the effective mass and effective stiffness can be
calculated from the experimental data. Using the following equations these values can be
calculated based off of a known frequency of 7.9 Hz.

(22)

(23)

6.4750 , 2.6 (24)


As shown later in the report, a natural frequency of 7.9 Hz was used because this was the
newly found frequency of the system. Note that this is different from the value from
experiment 2 (7.7 Hz), and the experiment 3 input frequency of (8.1 Hz). This difference
will be talked about later in the Discussion of the report.
From here, the goal was to reduce the firstmode vibrations at the tip using a PID
controller.
A PID controller is a control loop feedback mechanism designed to regulate system inputs
such that the error between a system state and the commanded set point becomes
minimized. The general form of a PID controller is given by

(25)

where , , and are the proportional, integral, and derivative gains, respectively. Each
of these gains is tuned to contribute to the system input based on the error dynamics of the
system. The P gain produces actions that are proportional to the current error in the
system, the D gain produces actions based on the trends of error in the system, and the I
gain produces actions based on the accumulated error in the system.
Note that a PID controller implemented on the cantilever system would attempt to regulate
the voltage of the PZT such that the strain induced by vibrations becomes minimized.


Figure 2: Experimental Setup
The particular PID gains used to minimize first mode vibrations were experimentally
determined using the ZieglerNichols method. The results from these gains were then
compared against the results of the simulated closed loop system subject to the same gains.
The ZieglerNichols method for PID tuning involved adjusting the proportional gain, with
derivative gain and integral gain set to zero, until the closed loop system became
marginally stable at the ultimate gain Ku. Once marginally stable, the oscillation period Tu
was calculated and used to adjust the P, I, and D gains accordingly for the specified control
type12. Note that a stinger was used to induce a sinewave excitation on the system and
that stability was evaluated using a laser Doppler Vibrometer, force transducer, and strain
gauge as shown by the experimental setup given in Figure 2. As explained in the Results
section, an appreciable firstmode vibration reduction was realized from the Ziegler
Nichols method, and the magnitude of this reduction was successfully compared against
the results of the theoretical model subject to the same gains.

RESULTS


Figure 3: Uncontrolled Velocity Response of Cantilever Tip


12 Ziegler,
J.G and Nichols, N. B. (1942). Optimum settings for automatic controllers. Transactions of the
ASME 64. pp. 759768

Figure 4: Zoomed View of the Uncontrolled Velocity Response

Figure 3 displays the velocity response of the cantilever beam tip when the base is being
vibrated at the first fundamental frequency of 8.1 Hz. Figure 4 displays a zoomed view of
the same data. This data was recorded in order to compare the uncontrolled response of
the cantilever to the controlled response with the same disturbance input. The positive and
negative peaks of the velocity data were found in order to quantitatively compare
controlled versus uncontrolled performance. The peaks are marked in the data with orange
and green xs.
The first PID controller was developed through onthefly tuning in the lab and is given
here:
33 0.1 (26)
This first controller was implemented in the feedback loop and the velocity response of the
cantilever beam tip was again recorded for the same disturbance input. The velocity data is
displayed in Figure 5. The positive and negative peaks were again found. The reduction in
amplitude was then calculated by subtracting the average peak height of the controlled
data from the uncontrolled data. It was found that controller 1 reduced the amplitude
response by 43%.


Figure 5: Velocity Response of Cantilever Tip with Controller 1

The first PID controller was then improved through onthefly tuning and a second PID
controller was developed. This PID controller is given here:

50 0.1 (27)

The second PID controller was then implemented in the feedback loop and the velocity
response of the cantilever beam tip was again recorded for the same disturbance input. The
velocity data is displayed in Figure 6. The positive and negative peaks were again found
and the amplitude reduction was again calculated. It was found that controller 2 reduced
the amplitude response by 56%.


Figure 6: Velocity Response of Cantilever Tip with Controller 2

Figure 7 displays the velocity amplitude response of the uncontrolled beam recorded from
a sine chirp force input at the beams base. This data was used to verify the first
fundamental frequency of the beam so that the modeled transfer function of the cantilever
beam could be updated from project 2.
The updated transfer function of the system is given here:

(28)
. .

Figure 8 displays the simulated data of the updated model. The two figures show strong
agreement between the actual and simulated frequency response of the cantilever beam.
This verified the model used and allowed for further analysis with this model to simulate
controller performance.

Figure 7: Experimental Data Amplitude Spectrum of Uncontrolled Beam


Figure 8: Simulated Data Amplitude Spectrum of Uncontrolled Beam
Figure 9 displays the simulated strain response of the uncontrolled beam with a sinusoidal
force input at 8.1 Hz. Figure 10 displays the simulated strain response with controller 1
implemented. There is an obvious reduction in amplitude response when controller 1 is
used. The peaks were again detected and used to calculate the simulated amplitude
reduction with the controller. It was found that controller 1 reduced the simulated
amplitude response by 59%.


Figure 9: Simulated Uncontrolled Beam Strain


Figure 10: Simulated Beam Strain with Controller 1
Figure 11 displays the simulated strain response with controller 2 implemented. It is clear
that the response is again reduced in this simulation. The peak amplitudes were again used
to calculate the simulated reduction and it was found that controller 2 reduced the
simulated amplitude response by 71%.


Figure 11: Simulated Beam Strain with Controller 2

The simulated amplitudes of the system with controllers are slightly better than the actual
system reductions as expected. For controller 1 the simulated reduction of 59% is better
than the actual reduction of 43%. For controller 2 the simulated reduction of 71% is better
than the actual reduction of 59%. These differences are due to the increased complexity of
the real system in addition to signal noise.

DISCUSSION
This experiment focused on the analysis of two different controllers as compared to the
response of an uncontrolled system. Figure 3, Figure 5, and Figure 6 represent the
responses to the physical system without a controller and with controller 1 and 2,
respectively. Both controllers were created through tuning during a live experiment. The
results of the experiment and the values for the individual gains for each controller are
shown below in Table 1. Onthefly tuning allowed for adjustments of controller gains
through visual feedback of system attributes such as noise, amplitude, and stability. Once
experimental data was collected for the uncontrolled system and the two controllers this
data was compared with simulated results of the same system and controllers.
Table 1: Controller Parameters and Calculated Percent Reduction
Controller1 Controller2
Kp 33 50
Ki 0 440
Kd 0.1 0.1
%Reduction 43% 56%

Before the conclusion of data collection, it was decided to repeat the methodology of
Experiment 2 by introducing a sine chirp as the forcing function of the system. This was
done because the disturbance was now created by the impedance head instead of the piezo
patch. This changes the system dynamics and therefore requires validation of the
previously found transfer function. Figure 7 represents the beam tip response to a sine
chirp from 025 Hz. Figure 8 represents the simulated system response to the same sine
chirp. Although it is clear that these graphs are similar it is important to note that this
analysis was done after the experiment and the natural frequency of the first mode was
found to actually be 7.9 Hz. This was different from the excitation frequency of 8.1 Hz that
had been used for all data collection. As a result, the actual first modal frequency of 7.9 Hz
was used as the natural frequency for all simulation models as well as development of the
transfer function of the system. The input force was still simulated at 8.1 Hz to allow for
proper comparison between the physical system and the simulated system response.
As shown in Table 2, the two controllers used in the experiment gave reductions of 43%
and 56% respectively. By analyzing the system response of the system transfer function is
possible to compare the simulated amplitude reduction for the PID controllers used. Using
the MATLAB code in combination with the Simulink model (Figure 12 in the appendix) the
percent reductions of the controllers in a theoretical system were found and are displayed
in Table 2. These controllers have a simulated amplitude reduction that is greater than that
recorded in the actual system. This is expected and is likely due to many factors such as
simplified modelling of the system, addition of signal noise, and some nonrigid movement
in the base of the system.
Table 2: Tabulated peak values from both physical and theoretical systems.
Theoretical/Simulation PhysicalExperiment
%Reduction %Reduction
Controller1 59% 43%
Controller2 71% 56%



CONCLUSION
For this experiment, an aluminum cantilever beam was subjected to a sustained vibration
at its fixed end in the form of a sine wave at 8.1 Hz and a piezoelectric patch was used to
control the vibration of the beam at the free end. A Laser Doppler Vibrometer was used to
collect velocity data at the free end of the beam in order to quantify the vibration. The
piezoelectric patch was controlled using a PID controller, and a strain gauge was used in
the closed loop feedback system. In the previous laboratory experiment, the resonance
frequency was found to be 7.7 Hz but with this new experimental setup the excitation
frequency was set to 8.1 Hz. Upon further research, it was found that the actual resonance
frequency with the new setup was closer to 7.9 Hz but all of the systems were forced with a
frequency of 8.1 Hz. Two PID gain combinations were found that yielded a significant
decrease in vibration amplitude. The first controller had gains of KP=33, KD=0, and KI=0.1,
yielding a vibration amplitude reduction of 43% (compared to the simulated value of 59%).
The second controller had gains of KP=50, KI=440, and KD=0.1, yielding a 56% reduction
(compared to the simulated value of 71%). The simulated values were found from a
simplified transfer function of a beam with natural frequency of 7.9 Hz.


APPENDIX


Figure 12: Simulink system diagram for use in MATLABonly simulation

%Script to Analyze experimental Data and Run Simulation to verify
%Experimental Data. Includes AD-HOC Analysis and Commented Notes

%%
clear
close all
A=load('experiment002-cut.csv');
Time=A(:,1);
PZT=A(:,5); % Chirp (piezo-Voltage) %input 1 (x1)
Transducer=A(:,3); % Base force %input 2 (x2)
Accelerometer=A(:,2); % Base accel %output 1 (y1)
LaserVib=A(:,4); % Tip vel %output 2 (y2)
Strain=A(:,6); %Strain

PZT=PZT*200; %true voltage experienced by the PZT


Accel=Accelerometer*(10); %Acceleration in g
Force=Transducer*(1/.02216); %Force in N %Was 0.2216
Veloc=LaserVib*.1; %Velocity in m/sec (*.1)

figure('name','Uncontrolled Velocity vs. Time');


plot(Time,Veloc);
title('Uncontrolled Experimental Data: Velocity vs. Time');
xlabel('time(s)');
ylabel('Velocity (m/sec)');

[AToppks,AToplocs] = findpeaks(Veloc,Time,'MinPeakHeight',0.014);
[ABotpks,ABotlocs] = findpeaks(Veloc*-1,Time,'MinPeakHeight',0.014);

hold on
plot(AToplocs,AToppks,'x');
plot(ABotlocs,ABotpks*-1,'gx');
hold off

AtopAvg=mean(AToppks);
AbotAvg=mean(ABotpks);

%{
figure('name','Velocity Response vs. Force Response');
plot(Time,Veloc,Time,Force);
legend('Velocity','Force');
title('Uncontrolled Experimental Data: Velocity & Force vs. Time');
xlabel('time(s)');
ylabel('Velocity (m/sec) or Force (N)');

figure('name','Velocity Response vs. Acceleration Response');


plot(Time,Veloc,Time,Accel);
legend('Velocity','Acceleration');
title('Uncontrolled Experimental Data: Velocity & Acceleration vs. Time');
xlabel('time(s)');
ylabel('Velocity (m/sec) or Acceleration (m/sec^2)');
%}

B=load('experiment004-cut.csv');
TimeB=B(:,1);
PZTB=B(:,5); % Chirp (piezo-Voltage) %input 1 (x1)
TransducerB=B(:,3); % Base force %input 2 (x2)
AccelerometerB=B(:,2); % Base accel %output 1 (y1)
LaserVibB=B(:,4); % Tip vel %output 2 (y2)
StrainB=B(:,6); %Strain

PZTB=PZTB*200; %true voltage experienced by the PZT


AccelB=AccelerometerB*(10); %Acceleration in g
ForceB=TransducerB*(1/.02216); %Force in N %Was 0.2216
VelocB=LaserVibB*.1; %Velocity in m/sec (*.1)

figure('name','Controller 2 Experimental Data');


plot(TimeB,VelocB);
title('Controller 2 Experimental Data: Velocity vs. Time');
xlabel('time(s)');
ylabel('Velocity (m/sec)');

[BToppks,BToplocs] = findpeaks(VelocB,TimeB,'MinPeakHeight',0.005);
[BBotpks,BBotlocs] = findpeaks(VelocB*-1,TimeB,'MinPeakHeight',0.005);

hold on
plot(BToplocs,BToppks,'x');
plot(BBotlocs,BBotpks*-1,'gx');
hold off

BtopAvg=mean(BToppks);
BbotAvg=mean(BBotpks);

%{
figure('name','Controller 2 Velocity Response vs. Force Response');
plot(TimeB,VelocB,TimeB,ForceB);
legend('Velocity','Force');
title('Controller 2 Experimental Data: Velocity & Force vs. Time');
xlabel('time(s)');
ylabel('Velocity (m/sec) or Force (N)');

figure('name','Controller 2 Velocity Response vs. Acceleration Response');


plot(TimeB,VelocB,TimeB,AccelB);
legend('Velocity','Acceleration');
title('Controller 2 Experimental Data: Velocity & Acceleration vs. Time');
xlabel('time(s)');
ylabel('Velocity (m/sec) or Acceleration (m/sec^2)');
%}

C=load('experiment005-cut.csv');
TimeC=C(:,1);
PZTC=C(:,5); % Chirp (piezo-Voltage) %input 1 (x1)
TransducerC=C(:,3); % Base force %input 2 (x2)
AccelerometerC=C(:,2); % Base accel %output 1 (y1)
LaserVibC=C(:,4); % Tip vel %output 2 (y2)
StrainC=C(:,6); %Strain

PZTC=PZTC*200; %true voltage experienced by the PZT


AccelC=AccelerometerC*(10); %Acceleration in g
ForceC=TransducerC*(1/.02216); %Force in N %Was 0.2216
VelocC=LaserVibC*.1; %Velocity in m/sec (*.1)

figure('name','Controller 1 Experimental Data');


plot(TimeC,VelocC);
title('Controller 1 Experimental Data: Velocity vs. Time');
xlabel('time(s)');
ylabel('Velocity (m/sec)');

[CToppks,CToplocs] = findpeaks(VelocC,TimeC,'MinPeakHeight',0.005);
[CBotpks,CBotlocs] = findpeaks(VelocC*-1,TimeC,'MinPeakHeight',0.005);

hold on
plot(CToplocs,CToppks,'x');
plot(CBotlocs,CBotpks*-1,'gx');
hold off

CtopAvg=mean(CToppks);
CbotAvg=mean(CBotpks);

Cont2TopDiff=1-(BtopAvg/AtopAvg);
Cont2BotDiff=1-(BbotAvg/AbotAvg);
Cont1TopDiff=1-(CtopAvg/AtopAvg);
Cont1BotDiff=1-(CbotAvg/AbotAvg);

%% Model Verification
D=load('experiment006-cut.csv');
TimeD=D(:,1);
PZTD=D(:,5); % Chirp (piezo-Voltage) %input 1 (x1)
TransducerD=D(:,3); % Base force %input 2 (x2)
AccelerometerD=D(:,2); % Base accel %output 1 (y1)
LaserVibD=D(:,4); % Tip vel %output 2 (y2)
StrainD=D(:,6); %Strain

PZTD=PZTD*200; %true voltage experienced by the PZT


AccelD=AccelerometerD*(10); %Acceleration in g
ForceD=TransducerD*(1/.2216); %Force in N
VelocD=LaserVibD*.1; %Velocity in m/sec (*.1)

FsD = 1000; % Sampling frequency


TD = 1/FsD; % Sample time
LD = length(TimeD); % Length of signal
tD = (0:LD-1)*TD; % Time vector

NFFTD = 2^nextpow2(LD); % Next power of 2 from length of y


YD = fft(VelocD,NFFTD)/LD;
fD = FsD/2*linspace(0,1,NFFTD/2+1);

% Plot single-sided amplitude spectrum.


figure('name','Actual Amplitude Spectrum of Uncontrolled Beam');
%plot(f,2*abs(Y(1:NFFT/2+1)))
plot(fD(1:(length(fD)/20)),2*abs(YD(1:(NFFTD/2+1)/20)))
title('Amplitude Spectrum of Uncontrolled Beam')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

sim('StrainOutputModel');

SimTime=StrainOut.time;
SimPiezo=PiezoVoltageIn.data;
SimStrain=StrainOut.data;

Fs = 1000; % Sampling frequency


T = 1/Fs; % Sample time
L = length(SimTime); % Length of signal
t = (0:L-1)*T; % Time vector
figure('name','Simulated Raw Strain Data');
plot(Fs*t,SimStrain);

NFFT = 2^nextpow2(L); % Next power of 2 from length of y


Y = fft(SimStrain,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);

% Plot single-sided amplitude spectrum.


figure('name','Simulated Chirp Amplitude of Beam');
%plot(f,2*abs(Y(1:NFFT/2+1)))
plot(f(1:(length(f)/20)),2*abs(Y(1:(NFFT/2+1)/20)))
title('Simulated Amplitude Spectrum of Uncontrolled Beam')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

%% Simulated Control (see how well it matches actual results)


s = tf('s');
%Pest1 = 1/(s^2+4.0715*s+2.5902*10^3); %8.1 Hz
Pest1 = 1/(s^2+3.9710*s+2.4638*10^3); %7.9 Hz

figure('name','UnControlled System Sine Response');


t = 0:0.001:5;
u = sin(2*pi*8.1*t); %8.1 Hz response
lsim(Pest1,u,t)
o = lsim(Pest1,u,t);

[PToppks,PToplocs] = findpeaks(o,t);
[PBotpks,PBotlocs] = findpeaks(o*-1,t);

hold on
plot(PToplocs,PToppks,'x');
plot(PBotlocs,PBotpks*-1,'gx');
hold off

PtopAvg=mean(PToppks)
PbotAvg=mean(PBotpks)

%% PID controller

%Controller 1
K1=33;
D1=0.1;
I1=0;

C1 = (D1*s^2+K1*s+I1)/s;
C1 = C1*20;

System1 = feedback(Pest1,C1);
figure('name','Simulated System Sine Response with Controller 1');
%t = 0:0.001:5;
%u = 0.5*sin(2*pi*8.1*t);
lsim(System1,u,t)
So1 = lsim(System1,u,t);

[SToppks1,SToplocs1] = findpeaks(So1,t);
[SBotpks1,SBotlocs1] = findpeaks(So1*-1,t);

hold on
plot(SToplocs1,SToppks1,'x');
plot(SBotlocs1,SBotpks1*-1,'gx');
hold off

StopAvg1=mean(SToppks1)
SbotAvg1=mean(SBotpks1)

ContTopDiff1=1-(StopAvg1/PtopAvg)
ContBotDiff1=1-(SbotAvg1/PbotAvg)

%Controller 2
K2=50;
D2=0.1;
I2=440;

C2 = (D2*s^2+K2*s+I2)/s;
C2 = C2*20;

System2 = feedback(Pest1,C2);

figure('name','Simulated System Sine Response with Controller 2');


%t = 0:0.001:5;
%u = 0.5*sin(2*pi*8.1*t);
lsim(System2,u,t)
So2 = lsim(System2,u,t);

[SToppks2,SToplocs2] = findpeaks(So2,t);
[SBotpks2,SBotlocs2] = findpeaks(So2*-1,t);

hold on
plot(SToplocs2,SToppks2,'x');
plot(SBotlocs2,SBotpks2*-1,'gx');
hold off

StopAvg2=mean(SToppks2)
SbotAvg2=mean(SBotpks2)

ContTopDiff2=1-(StopAvg2/PtopAvg)
ContBotDiff2=1-(SbotAvg2/PbotAvg)
Figure 13: MATLAB Code for Analysis and Simulation

Figure 14: Simulink theoretical model for validation of MATLAB simulation


Figure 15: Simulink theoretical simulation data to verify MATLAB code.

You might also like