Mechanical Engineering

Interactive lab

Move the sliders and watch what changes. Everything runs in your browser.

Oscilloscope

Change the frequency and watch the wave. A higher frequency means more cycles in the same time.

Period

Double-slit experiment with electrons

Fire electrons one at a time at two narrow slits. Each electron lands at a single point, like a particle. Yet after thousands of electrons the dots build up bright and dark bands: an interference pattern, the signature of a wave.

The curve is the wave prediction. Turn on the detector that watches which slit each electron uses and the bands disappear. Real versions of this experiment have been done with single electrons since 1989, and it is a cornerstone of quantum mechanics: matter behaves like both a wave and a particle.

Electrons 0

Illustrative scale: the shapes follow the real physics, the units are not real.

Mass-spring vibration

Every spring and mass has a natural frequency. Change them, then pluck.

Natural frequency

Lissajous figures

Plot one signal against another. The ratio of the two frequencies sets the shape.

MATLAB examples

The same ideas as the demos, written as MATLAB code. Copy them into MATLAB or the free GNU Octave and run them.

Mass-spring-damper with ode45
m = 2;  k = 200;  zeta = 0.05;       % kg, N/m, damping ratio
wn = sqrt(k/m);                       % natural frequency (rad/s)
c  = 2*zeta*sqrt(k*m);                % damping coefficient
f  = @(t,y) [y(2); -(c*y(2) + k*y(1))/m];
[t,y] = ode45(f, [0 6], [1; 0]);      % released from rest at x = 1
plot(t, y(:,1)); xlabel('Time (s)'); ylabel('x (m)');
fn = wn/(2*pi)                        % natural frequency (Hz)
Frequency spectrum with fft
fs = 1000;  t = 0:1/fs:1-1/fs;        % 1 s sampled at 1 kHz
x  = sin(2*pi*50*t) + 0.5*sin(2*pi*120*t);
X  = abs(fft(x))/numel(x)*2;          % amplitude spectrum
f  = (0:numel(x)-1)*fs/numel(x);
n  = numel(x)/2;
plot(f(1:n), X(1:n)); xlabel('Frequency (Hz)'); ylabel('Amplitude');
Beam deflection (simply supported, centre load)
P = 1000;  L = 2;  E = 200e9;  I = 8e-6;   % N, m, Pa, m^4
delta = P*L^3/(48*E*I)                % mid-span deflection (m)
% x = linspace(0, L/2, 100);  for the left half:
% y = P*x.*(3*L^2 - 4*x.^2)/(48*E*I);

Programming languages

Engineers use several languages, each for a different job. Here is the same small calculation, a gear ratio, in each of them, with what the language is typically used for.

Data analysis, simulation, scripting and quick prototypes.

driver, driven, rpm_in = 20, 40, 1200
ratio = driven / driver
rpm_out = rpm_in / ratio
print(f"ratio {ratio:.2f}:1, output {rpm_out:.0f} rpm")

Let’s build something

Looking for an intern or have a project idea? Get in touch.

kenith [at] kenith.net