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.
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.
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.
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.
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)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');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")Fast, real-time software: robot and motion control, simulation engines.
#include <iostream>
int main() {
double driver = 20, driven = 40, rpmIn = 1200;
double ratio = driven / driver;
std::cout << "ratio " << ratio << ":1, output " << rpmIn / ratio << " rpm\n";
}Large applications and tools; also used in some engineering software and Android apps.
public class Gear {
public static void main(String[] args) {
double driver = 20, driven = 40, rpmIn = 1200;
double ratio = driven / driver;
System.out.printf("ratio %.2f:1, output %.0f rpm%n", ratio, rpmIn / ratio);
}
}Microcontrollers: read sensors, drive motors, run on small hardware.
// Read a potentiometer and set a motor speed with PWM
const int POT = A0, MOTOR = 9;
void setup() { pinMode(MOTOR, OUTPUT); }
void loop() {
int raw = analogRead(POT); // 0..1023
analogWrite(MOTOR, raw / 4); // 0..255
delay(10);
}PLC programming (IEC 61131-3): the text language that sits beside ladder logic.
(* IEC 61131-3 Structured Text, the same calculation in a PLC *)
VAR
driver : REAL := 20.0;
driven : REAL := 40.0;
rpmIn : REAL := 1200.0;
ratio, rpmOut : REAL;
END_VAR
ratio := driven / driver;
rpmOut := rpmIn / ratio;Numerical computing, control design and plotting; the standard in many universities.
driver = 20; driven = 40; rpmIn = 1200;
ratio = driven / driver;
fprintf('ratio %.2f:1, output %.0f rpm\n', ratio, rpmIn / ratio)Let’s build something
Looking for an intern or have a project idea? Get in touch.
kenith [at] kenith.net