You are on page 1of 16

EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 1/16

EXPERIMENT 2: FREE-FALLING BODIES &


OPTOELECTRONIC SENSORS
INTRODUCTION
As you have seen from the previous assignments, many different factors affect how much data, and in
general the quality of the data being collected. The most important of these factors are the sampling rate and the
total number of samples recorded, though the sampling rate is the more important of the two. It is not just in
MATLAB® that setting the sample rate is arbitrarily done, but it is also done the same way with any other data
acquisition software. The deciding factor in determining what the sampling rate should be is the rate at which
the data will change during the course of the exercise. In this experiment, we must also take into account what
the resolution, or how fine a detailed picture we can take, as well as the hardware limitations of higher sampling
rates.

E2-1 BACKGROUND: PARTICLE DYNAMICS


In this experiment we will use an array of optoelectronic devices as proximity sensors to record the
motion of a free-falling ball dropped onto a massive aluminum surface. The time histories of the ball position
during approach and separation will be recorded with the aid of a National Instruments NI-6034E data
acquisition system. The coefficient of restitution, e, of the ball can then be determined by comparing the speed
of approach to the speed of separation. Let us first have a quick review on basic particle dynamics.

Figure E2-1-1. A free-falling body.

As shown in Fig. E2-1-1, a ball of mass m initially at an elevation y(0) = y0 is ejected upward with an
initial velocity v(0) = v0 into a Newtonian viscous medium with a damping constant b. (Note: If b equals zero,
the medium is called inviscid.) According to Newton’s law of viscosity, the instantaneous viscous force vector
r
(also called damping force), fb ( t ) , is acting against the motion of the ball and can be expressed as:
r r
Eq. (E2-1-1) fb = −bv ( t )
r
where v ( t ) is instantaneous velocity vector of the ball. Define the upward direction as the positive y-direction
with $j as its unit vector. Then, according to Newton’s second law, we have:

r v ⎧⎪− mgjˆ for inviscid case


Eq. (E2-1-2) f ( t ) = ma ( t ) = ⎨
⎪⎩− mgjˆ − bv ( t ) ˆj for viscous case
ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE
EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 2/16

v
bg bg
Here instantaneous acceleration vector of the ball, a t = a t $j , is :

⎧− g for inviscid case


dv ( t ) ⎪
Eq. (E2-1-3) a (t ) = =⎨ b
dt ⎪⎩− g − m v ( t ) for viscous case

where g is the gravitational constant. Note: A positive (or a negative) a(t) means an acceleration (or a
deceleration) along the positive y-direction. To find the velocity, we have:
⎧inviscid case: dv ( t ) = − gdt → v ( t ) = − gt + C1
⎪⎪
dv ( t ) m
⎨ viscous case: − = dt → − ln ⎡⎣ mg + bv ( t ) ⎤⎦ = t + C1
⎪ b
g + v (t ) b
⎪⎩ m
⎧v0 for inviscid case

Since, v ( t ) t =0 = v ( 0 ) = v0 , we have: C1 = ⎨ m
⎪⎩− b ln ( mg + bv0 ) for viscous case

bg bg
v
Hence, the velocity vector v t = v t $j becomes:

⎧ − gt + v0 for inviscid case



Eq. (E2-1-4) v (t ) = ⎨ m ⎛m ⎞ −bt m
⎪ − b g + ⎜ b g + v0 ⎟ e for viscous case
⎩ ⎝ ⎠
Here, again, a positive (or a negative) v(t) implies the ball moving in the upward (or downward) y-direction.
Substituting Eq. (E2-1-4) into Eq. (E2-1-3), we have:
⎧− g for inviscid case
dv ( t ) ⎪
Eq. (E2-1-5) a (t ) = =⎨ ⎛ b ⎞ −bt m
dt −
⎪ ⎜m g + v0 ⎟e for viscous case
⎩ ⎝ ⎠
Now, integrating the velocity, we have:
⎧ 1 2
⎪− 2 gt + v0t + C2 for inviscid case

y ( t ) = ∫ v ( t ) dt + y ( 0 ) = ⎨
t

⎡ 2
⎤ bt
⎪− ⎛⎜ m ⎞⎟ gt − ⎢⎛⎜ m ⎞⎟ g + ⎛⎜ m ⎞⎟ v0 ⎥ e − m + C2
0
for viscous case
⎩⎪ ⎝ b ⎠ ⎢⎣⎝ b ⎠ ⎝ b ⎠ ⎥⎦

⎧ y0 for inviscid case



Since, y = y0 @ t = 0 → C2 = ⎨ ⎛m⎞ ⎛m⎞
2

⎪ y0 + ⎜ ⎟ v0 + ⎜ ⎟ g for viscous case


⎩ ⎝b⎠ ⎝b⎠
v
bg bg
hence, we have the position vector y t = y t $j with:

ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE


EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 3/16

⎧ 1 2
⎪ − 2 gt + v0t + y0 for inviscid case

Eq. (E2-1-6) y (t ) = ⎨

(⎤
)
2
⎪ − ⎜⎛ m ⎟⎞ gt + ⎢⎜⎛ m ⎟⎞ g + ⎜⎛ m ⎟⎞ v0 ⎥ 1 − e − m + y0
bt
for viscous case
⎩⎪ ⎝ b ⎠ ⎣⎢⎝ b ⎠ ⎝ b ⎠ ⎦⎥

We will consider two special cases in this experiment. The first, which is called the approaching case,
studies a ball falling freely from an elevation y0 with zero initial velocity (i.e., v0 = 0) onto a massive plate,
which can be assumed rigid. The second, which is termed the rebounding case, investigates the rebounding of a
ball from the rigid plate. In this case the ball has a zero initial elevation (i.e., y0 = 0) with an initial velocity
equal to the rebounding velocity. Using Eqs (2-1-4) to (2-1-6) we can summarize the solutions of these two
cases as follows:

(A) The Approaching Case (v0 = 0)


⎧⎪− g for inviscid case
Eq. (E2-1-7) a (t ) = ⎨ −bt
⎪⎩− ge m for viscous case

⎧ − gt for inviscid case



v (t ) = ⎨ m
Eq. (E2-1-8)
(
⎪⎩ − b g 1 − e
− bt
m
) for viscous case

⎧ 1 2
⎪− 2 gt + y0 for inviscid case

Eq. (E2-1-9) y (t ) = ⎨
( )
2
⎪− ⎛ m ⎞ gt + ⎛ m ⎞ g 1 − e −bt m + y
⎪⎩ ⎜⎝ b ⎟⎠ ⎜ ⎟ 0 for viscous case
⎝b⎠

(B) The Rebounding Case (y0 = 0)


⎧− g for inviscid case

Eq. (E2-1-10) a (t ) = ⎨ ⎛ b ⎞ −bt m
⎪ − ⎜ g + v0 ⎟ e for viscous case
⎩ ⎝ m ⎠

⎧ − gt + v0 for inviscid case



Eq. (E2-1-11) v (t ) = ⎨ m ⎛m ⎞ −bt m

⎪ b g + ⎜ g + v0 ⎟e for viscous case
⎩ ⎝b ⎠

⎧ 1 2
⎪ − 2 gt + v0t for inviscid case

Eq. (E2-1-12) y (t ) = ⎨

(⎤
)
2
⎪ − ⎜⎛ m ⎟⎞ gt + ⎢⎜⎛ m ⎟⎞ g + ⎜⎛ m ⎟⎞ v0 ⎥ 1 − e − M
Bt
for viscous case
⎩⎪ ⎝ b ⎠ ⎣⎢⎝ b ⎠ ⎝ b ⎠ ⎦⎥

Consider the inviscid approaching case. From Eq. (E2-1-9) we can determine the time ta required for
the ball, which is falling freely from an elevation ya, to hit the ground as:
ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE
EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 4/16

1
y ( ta ) = 0 = − gta2 + y0 , or
2
2 ya
Eq. (E2-1-13) t a =
g
From Eq. (E2-1-8), the corresponding particle velocity just before the ball hits the ground is then given by:
2 ya
va = v ( ta ) = − gta = − g , or
g

Eq. (E2-1-14) va = − 2 gya


Again, the negative sign indicates that the velocity vector points downward.

Next, consider the frictionless separation case. From Eq. (E2-1-11) we can determine the time tr
required for the ball, which is rebounding from a rigid floor with an initial velocity of vr, to reach the maximum
height as:
v ( tr ) = 0 = − gtr + vr , or

vr
Eq. (E2-1-15) tr =
g
From Eq. (E2-1-12), the corresponding maximum elevation is given by:
2
1 1 ⎛v ⎞ v
yr = y ( tr ) = − gtr2 + vr tr = − g ⎜ r ⎟ + vr r , or
2 2 ⎝g⎠ g

1 vr2
Eq. (E2-1-16) yr =
2 g

When the ball falls in a viscous medium, one can prove easily that there exists a maximum velocity,
which is called the terminal velocity vt. Assuming the particle starts from rest, with the aid of Eq. (E2-1-8) we
can prove easily that:

(
⎡ m
) ⎤ ⎛ m ⎞ ⎛ m −bt ⎞ m m
vt = lim v ( t ) = lim ⎢ − g 1 − e m ⎥ = lim ⎜ − g ⎟ + lim ⎜ ge m ⎟ = − g + g lim e m , or
t →∞ t →∞
⎣ b
−bt

⎦ t →∞ ⎝ b ⎠ t →∞ ⎝ b ⎠ b b t →∞
− bt
( )
m
Eq. (E2-1-17) vt = − g
b
Again, the negative sign implies that the particle travels downward. It can also be shown easily from Eq. (E2-1-
8) that if the particle falls from rest, it takes approximately:
5m
Eq. (E2-1-18) tt = 5τ =
b
for the particle velocity to reach within 1% of the terminal velocity vt. Here,
m
Eq. (E2-1-19) τ =
b
ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE
EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 5/16

is called the time constant of this viscous free-falling system.

When two particles collide without loss of energy, the impact is said to be perfectly-elastic. If there is
a loss of energy, the collision is said to be plastic. The coefficient of restitution, e, is a measure of the elasticity
(or equivalently, the plasticity) of the collision; a value of 1 indicates perfectly-elastic collision whereas a value
of zero implies perfectly-plastic collision. The coefficient of restitution is defined by the following expression:
relative separating velocity v′ − v′
Eq. (E2-1-20) e = = 2 1
relative approaching velocity v2 − v1

where vi and vi′ (i = 1,2) are the approaching and separating velocities of the particle i (i = 1,2). In our
experiment, the velocities of the massive aluminum base, v2 and v2′ , can be taken as zero. Hence the relative
approaching and separating velocities are the approaching and rebounding velocities, va and vr, respectively.
Thus Eq. (E2-1-20) reduces to:

Eq. (E2-1-21) e =
( first ) rebounding velocity = vr
( first ) approaching velocity va

If the free-falling and rebounding processes are inviscid, then by combining Eqs (E2-1-14), (E2-1-16)
and (E2-1-21) one can verify easily that the initial drop height ya and the first rebound height yr can be related
by:

Eq. (E2-1-22) e =
( first ) rebounding height =
yr
( first ) approaching height ya

E2-2 OBJECTIVES
The objectives of this experiment are:
(1) To use optoelectronics-based emitter-detector sensors to record the motion of free-falling balls - using both
MATLAB and LabVIEW;
(2) To apply polynomial regression analysis to fit recorded data for position vs time and velocity vs time curves
and to compare the experimental results with those predicted by theory of particle dynamics.

E2-3 EXPERIMENTAL APPARATUS


In this experiment, we use eight pairs of LED’s and phototransistors to form eight optical paths for detecting the
positions of falling bodies. This experiment uses a made-in-house, free-falling device as shown in Fig. E2-3-1.
A ball is dropped at the top between the rails of the fixed and movable vertical ball guides. The distance
between the guides can be adjusted for different ball diameters by shifting the movable guide rail. The locking
screw at the base of the movable guide must be loosened using a slotted screwdriver. The movable guide track
is kept parallel to the stationary guide track by a special kind of four bar linkage called, not surprisingly, a
parallel-bar linkage. There are eight emitter-detector pairs mounted on the guide rails; the eight light emitters
made of infrared emitting diodes (wavelength λ = 940 nm) are on the movable guide while the light detectors
made of phototransistors (wavelength λ = 940 nm) are on the fixed guide. The lowest sensor pair, called Sensor
7, is 1¼” from the heavy aluminum base while the spacing between subsequent sensor pairs is 2”. The highest

ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE


EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 6/16

sensor pair, called Sensor 0, is 2¼” away from the top opening of the guide rails. Thus, the total height of the
guide rails is 17½”.

Figure E2-3-2 shows the circuit for a typical emitter-detector pair. If there is no incident light on the
phototransistor, then no current will flow through the output circuit; thus the position of a ball between the
guide rails can be determined by measuring the voltage levels in the output side of the detector circuits. As the
ball falls between the guides, the optical paths between the emitter-detector pairs are interrupted sequentially,
causing changes in output voltages. Each of the detectors has been connected to one channel of the National
Instruments SCB-68-board so that the voltage change can be recorded with a PC. In this experiment, three balls
will be used. They are:
(1) a tennis ball, which is green-yellow and has a diameter of approximately 64.8 mm (or 2.55”), a mass of
approximately 54.8 g, and a relatively rigid surface with a felt-like texture;
(2) a racquet ball, which is blue and has a diameter of approximately 55.9 mm (or 2.2”), a mass of
approximately 40.2 g, and a moderately smooth surface which seems to be easily deformable;
(3) a ping-pong ball, which is white and has a diameter of approximately 38.1 mm (or 1.5”), a mass of
approximately 2.8 g, and an extremely smooth surface (Because of its light weight, this make ping-pong ball
buoyant easily).
Question: Why use infrared rather than visible light LED’s?
Answer: First of all, infrared LED’s give more illumination for less current (longer wavelength, lower
frequency). Secondly, fluorescent lights (like those in the laboratory) emit very little infrared (this is
contrary to the emission from incandescent bulbs). Thus there is little possibility of interference with
the signal from ambient fluorescent lighting.

Figure E2-3-1. The apparatus for free-falling motion detection.

ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE


EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 7/16

Figure E2-3-2. The optoelectronic emitter-detector circuit.

E2-4 EXPERIMENTAL PROCEDURE


• Power on the PC and power supply. The BK Precision Power Supply should indicate that it is supplying
a voltage of 10.3 volts and a current of 0.13 amps. All LED indicators on the board mounted on the
apparatus should light up. By passing your hand through each of the sensors, they go out. If they are
already out, please ask the Laboratory Technician or the Professor for assistance.

USING LABVIEW:
(1) Double-click on the icon Free Fall on the desktop to start LabVIEW for this experiment.
(2) The screen that pops-up before you is called the front panel. On this screen make sure that the channels
range from 0 to 7; the trigger channel is 0; and the trigger level is 1.
(3) Right click within the graph to clear the Free Fall graph on the front panel. Scroll down to Data
Operations then left click on Clear Chart.
(4) Place the tennis ball at the entrance of the ball guide.
(5) Left-click the Run button on the toolbar of the front panel. Figure 2-4-1 shows sample results of the
free falling experiment.
(6) Save the filename in a text format, for example ball.txt, that will permit future analysis.
(7) Immediately drop the tennis ball through the guides. Care should be taken to ensure that the ball is
dropped freely; that is, no initial velocity v0 is exerted when the ball is released.
(8) Repeat Steps (4) to (8) for the racquetball and the ping-pong ball.

ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE


EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 8/16

Figure E2-4-1. Sample results showing the NI-LabVIEW front panel of the free-fall.VI.

USING MATLAB:1
We can see in the appendix that the block diagram for the data acquisition using LabVIEW is quite complicated
and hard to follow. One of the benefits of the Data Acquisition Toolbox is that it is possible to see in detail the
finer points of data acquisition. From the front panel of the LabVIEW VI, we can define the requirements of
what the MATLAB counterpart should be able to do. As with the Skin Temperature Measurement activity, we
will look a little deeper into the way data is acquired.

i. The first part of any program is to ensure that there are no variables in the memory, and then initialize
any drivers needed for the software to communicate with the hardware. This is the analog input object –
it contains the drivers necessary for MATLAB® to interface with the software.

close all %Close any open figure/plots first


clc %Empty command window
ai = analoginput('nidaq',1);
set(ai,'InputType', 'SingleEnded');

ii. Once the analog input object is created, we will refer to the functional details of the LabVIEW
counterpart to define the parameters of the data acquisition.

ch =addchannel(ai, [0:7]);

1
An annotated copy of this data acquisition code is provided in the Appendix
ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE
EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 9/16

set(ai,'ChannelSkewMode', 'Minimum');
duration = 6;
ActualRate = 8000;
set(ai, 'SampleRate', ActualRate / 8);
TotalSamples = duration * ActualRate / 8;
set(ai,'SamplesPerTrigger', TotalSamples);

iii. The program should have the ability to record data prior to the ball passing through each sensor so that
we will have a basis of comparison. This is the pre-trigger.2

set(ai, 'TriggerDelayUnits', 'Samples')


set(ai, 'TriggerDelay', -200);

iv. A trigger is introduced so that we should be able to record the phenomenon, as it meets a criterion that
we set beforehand.

set(ai, 'TriggerChannel', ch(1));


set(ai, 'TriggerType','Software');
set(ai, 'TriggerCondition', 'Rising');
set(ai, 'TriggerConditionValue', 1);

v. Real-time display of data acquired during the procedure is a must. It is a waste of time if data is
collected but the phenomenon we are looking for is not in it. As an extra feature, the plot window will
pop up to full screen size.

scrsz = get(0, 'ScreenSize');


figure('Position',[1 scrsz(4) scrsz(3) scrsz(4)])
set(gcf,'doublebuffer','on')
subplot(811), P1 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(812), P2 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(813), P3 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(814), P4 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(815), P5 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(816), P6 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(817), P7 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(818), P8 = plot(zeros(TotalSamples,1));
xlabel('Samples'), axis([0 TotalSamples -5 5]);
subplot(811)
T = title([sprintf('Samples Acquired: '), num2str(ai.SamplesAcquired)]);
2
By default, the ‘TriggerDelayUnits’ is in seconds, but can be specified to be the number of samples. This does not mean that you
must wait 200 samples before you drop the ball – by dropping the ball, you set off the trigger to start recording. Note also that the
TriggerDelay is a negative value, indicating that the data acquisition occurs prior to the trigger going off.
ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE
EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 10/16

start(ai);
while strcmp(ai.Running, 'On')
while ai.SamplesAcquired < ai.SamplesPerTrigger
data = peekdata(ai, ai.SamplesAcquired);
set(P1,'ydata',data(:,1));
set(P2,'ydata',data(:,2));
set(P3,'ydata',data(:,3));
set(P4,'ydata',data(:,4));
set(P5,'ydata',data(:,5));
set(P6,'ydata',data(:,6));
set(P7,'ydata',data(:,7));
set(P8,'ydata',data(:,8));
set(T,'String',[sprintf('Samples Acquired: '),...
num2str(ai.SamplesAcquired)]);
drawnow
end
end

vi. Run the program by pressing either F5 or the run button located below the menu bar. When the plot
pops up showing the actual data from the data acquisition card, pay attention to the title. It changes with
time, indicating how many samples it has already acquired. You may drop the ball once it indicated that
200 samples have been collected. At the end of the data acquisition, the data is saved to an ASCII-
format tab-delimited file, for future analysis.

data = getdata(ai);
save 'freefall.dat' data -ASCII -tabs

vii. In this instance, the data file where the data is saved is called ‘freefall.dat’. Please remember to either
change the code to indicate a new file or copy the data file to another location before it gets rewritten.
Once the program is complete, the analog input object is no longer running and has to be cleared from
memory.3

delete (ai)
clear ai

viii. The first step of any program is to ensure that it runs as it is supposed to. You may experiment with
the sensors themselves, and see the change in voltage on the screen, as you pass objects across the path
of each, individual sensor. When you do this, note how the plot changes accordingly. You may also
change the sampling rate (the ActualRate variable), so that you may observe the effects of higher
sampling rates on the real-time plots. Below is a sample of results showing the real-time plot in
MATLAB®:

3
Please note that if the program does not run properly, and data is not collected, the memory should not be cleared immediately. If the
object is no longer in the workspace, the program can not be run again, since there is already an instance of it. It can not be stopped,
either, since the analog input object, and thus the drivers permitting the interface are no longer present for MATLAB® to use. To
clear this, you must close the MATLAB® program, and start it up again.
ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE
EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 11/16

Figure E2-4-1. Sample results showing the MATLAB® plot.

E2-5 REPORT
The final report of this experiment is expected to include at least the following items:
(1) With the three sets of voltage-time data of the eight proximity sensors, tabulate the position vs time histories
of the three balls. Assume frictionless, use the 2nd-degree polynomial equation:
Eq. (E2-5-1) bg
y t = a0 + a1t + a2 t 2
and the least-square regression technique to fit the first approaching and the first separation curves of the three
balls. Estimate:
(i) the difference in time between the moment when a ball was released and the instant when the data
acquisition started for all the ball;
(ii) the initial heights, y0, when the balls were dropped and the first rebounding heights, y1, that the balls
had reached for all three balls, respectively (Note: Because of the hand position when the ball was
released, the initial height might not be the height of the ball guide.);
(iii) the first approaching and rebounding velocities, va and vr, of the three balls, respectively;
(iv) the coefficients of restitution, e, of the three balls using Eqs (E2-1-21) and (E2-1-22), respectively.
Determine if the collisions were elastic or plastic?

ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE


EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 12/16

(2) Plot and compare in the same graph the theoretically-predicted and experimentally-determined position vs
time histories for each ball.
(3) The theoretically-predicted velocities can be obtained by differentiating Eq. (E2-5-1). Plot and compare in
the same graph the theoretically-predicted and experimentally-determined velocity vs time histories of each
ball. Try to determine the velocities from experimental data using various techniques, such as those you
learned in Homework #7: Optoelectronic Sensors - High-Speed Measurement. Explain which
technique you think may be the most accurate.
(4) Determine what attributes of these three balls may have caused the differences in the time histories of
position and velocity among the three balls.
(5) Can you use the viscous model, as shown in Eqs (E2-1-7) to (E2-1-12), to estimate the viscous damping
constants, b, of the three balls. Once the b’s are obtained, determine if the inviscid model is still valid for
each ball. What would be the corresponding terminal velocities, vt, and how high would the track have to be
to allow the balls to reach 99% of their terminal velocities? What are the sources of friction and viscosity?
Can they be minimized? Can you propose a different mathematical model for the friction? If so, can you
calculate the values for the parameters of your new model?
(6) We see from the MATLAB® code that the input types from the sensors are of the single ended non-
referenced type. Why is this so? Is this better than using a differential input type? Is there a difference
between the two, and how does this affect the data acquisition?
(7) Though the sample rate for this experiment was set at 8000 samples per second, it can arbitrarily be set for
almost any value. However, for this experiment, there is a minimum sampling rate. What is it, and how is it
determined?4

E2-5 APPENDIX
The following is the block diagram of the free-fall.VI:

4
HINT: This involves the balls velocity and the distance between sensors
ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE
EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 13/16

Figure E2-5-1. Sample results showing the NI-LabVIEW block diagram of the free-fall.VI.

ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE


EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 14/16

%Free Fall Data Acquisition File


%This program is set up into several different components -
% [1] Set up data acquisition object
% [2] Acquire the pre-trigger data
% [3] Acquire normal data
% [4] Displaying data
% [5] Cleaning up

close all %Close any open figure/plots first


clear %Empty workspace of all variables
clc %Empty command window

%--------------------------------------------------------------------------
% 1. Set up the data acquisition
% Initialize handle for analog input - board is device 1 on computer
ai = analoginput('nidaq',1);

%Specify the type of input channel


set(ai,'InputType', 'SingleEnded');

%Setup hardware channels 0 - 7, first channel on NI boards is 0 not 1


ch = addchannel(ai, [0:7]);

%Set up sampling duration in seconds


duration = 4; %6 seconds

%Set channel skew mode - the time delay between scanning different
%channels - minimum would set it to smallest possible value supported
%by hardware
set(ai,'ChannelSkewMode', 'Minimum');
ChSkew = ai.ChannelSkew

%Set up sampling rate of card


ActualRate = 8000; %Minimum used for winsound example

%Because max sample rate of board is rated for one channel, divide the
%sample rate by the number of channels to be scanned, in this case - 8
set(ai, 'SampleRate', ActualRate / 8);

%The total number of samples would be the sampling rate times the duration
%of the sampling
TotalSamples = duration * ActualRate / 8;

%With the sampling rate, set the number of samples to take per trigger
set(ai,'SamplesPerTrigger', TotalSamples);

%Insert trigger here to start acquiring data - specify the channel where
%the trigger is to be used
set(ai, 'TriggerChannel', ch(1));
%0, the first channel for Nat'l Instr. boards. In this matrix for the
%channel the first index is for the first channel

%Set the type of trigger to be used - 'Software' defines the acceptable


%threshold for reference input
ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE
EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 15/16

set(ai, 'TriggerType','Software');

%Set the conditions which will trigger/start data logging - 'Rising' means
%having a positive slope as it passes through the value
set(ai, 'TriggerCondition', 'Rising');
set(ai, 'TriggerConditionValue', 1);

%Now, to set up the plot to display the data in real time. When the program
%is running, we want the figure to open up full screen, so first we
%determine the size of the screen
scrsz = get(0, 'ScreenSize');

%Then we specify the position of the plot


figure('Position',[1 scrsz(4) scrsz(3) scrsz(4)])
% where the position refers to the position of the corners of the window
set(gcf,'doublebuffer','on') %Reduces plot flicker

subplot(811), P1 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(812), P2 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(813), P3 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(814), P4 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(815), P5 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(816), P6 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(817), P7 = plot(zeros(TotalSamples,1));
axis([0 TotalSamples -5 5]);
subplot(818), P8 = plot(zeros(TotalSamples,1));
xlabel('Samples'), axis([0 TotalSamples -5 5]);
subplot(811)
T = title([sprintf('Samples Acquired: '), num2str(ai.SamplesAcquired)]);
%Note that we're using a y-axis range of -5 to 5 because we expect the
%input to fall within that range only

%--------------------------------------------------------------------------
% 2. Acquiring pre-trigger data
%To acquire pre-trigger data, we have to pre-determine how many samples or
%how much time is used for the pre-tigger.

%To set the pre-trigger, we have to use the 'TriggerDelay' property with a
%negative value.
set(ai, 'TriggerDelayUnits', 'Samples')
set(ai, 'TriggerDelay', -200);
%In this case, we set a pre-tigger of 200 samples prior to the
%trigger to be recorded. However, this means that we have decreased the
%number of samples to be saved in memory after the trigger.

%log information to the file freefall.daq.


set(ai,'LogFileName','freefall.daq')
set(ai,'LoggingMode','Disk&Memory')

%--------------------------------------------------------------------------
ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE
EXPERIMENT 2: FREE-FALLING BODIES & OPTOELECTRONIC SENSORS Page 16/16

% 3. Acquiring normal data


start(ai);
%This condition it checks is whether the analog input object is running
%or not.
while strcmp(ai.Running, 'On')
while ai.SamplesAcquired < ai.SamplesPerTrigger
data = peekdata(ai, ai.SamplesAcquired); %The peekdata argument is:
% PEEKDATA(analoginput object, number of samples to acquire)
set(P1,'ydata',data(:,1));
set(P2,'ydata',data(:,2));
set(P3,'ydata',data(:,3));
set(P4,'ydata',data(:,4));
set(P5,'ydata',data(:,5));
set(P6,'ydata',data(:,6));
set(P7,'ydata',data(:,7));
set(P8,'ydata',data(:,8));
set(T,'String',[sprintf('Samples Acquired: '),...
num2str(ai.SamplesAcquired)]);
drawnow %the DRAWNOW command forces MATLAB to update the plot
% based on the new values
end
end
[dat1, time] = daqread('freefall.daq');
data = getdata(ai);
save 'freefall.dat' data -ASCII -tabs %This saves the data into an ASCII
%format file where the columns are tab delimited. To evaluate the data in
%MS Excel, open Excel, and click on 'Data' on the menubar. On the pulldown
%menu, click on the option to 'Import External Data' and then on the
%'Import Data'. A pop-up will appear asking where to import the data from.
%Navigate to the desktop where the file is located, and open it. If the
%file does not appear, make sure that you are looking at all file-types,
%not just all data sources. Then click on 'Finish' when you see the data,
%and it will appear on the worksheet that is currently open.

%--------------------------------------------------------------------------
% 4. Display the data
figure
dat = load('freefall.dat');
for i = 1:size(dat(:,1))
x(i) = (ai.TriggerDelay + i) / ai.SampleRate;
end
for i = 1:4
subplot(8,1,i), plot(x, dat(:,i));
ylabel('Voltage');
subplot(8,1,i+4), plot(x, dat(:,i+4));
ylabel('Voltage');
end
xlabel('Time (sec)')

%--------------------------------------------------------------------------
% 5. Cleaning up - The analog input object must be stopped before it can be
% started again, or else there will be problems re-running the program from
% the beginning if it is stopped in the middle. If this happens, you will have to
% exit and restart the MATLAB environment

delete (ai)
clear ai
ME 31100: FUNDAMENTALS OF MECHATRONICS STUDENT LABORATORY GUIDE

You might also like