Overview
The spring-mass system experiment explores elastic forces, simple harmonic motion, damping, and system transfer functions. This advanced experiment uses homography transformations to compensate for perspective distortion and camera movement.Physics Theory
Hooke’s Law and Simple Harmonic Motion
For a mass attached to a spring with constant : Restoring Force: Equation of Motion: Where:- is spring constant (N/m)
- is damping coefficient (N·s/m)
- is displacement from equilibrium (m)
Damped Oscillation
The solution is: Where:- is damping coefficient
- is damped frequency
- is natural frequency
- is damping ratio
System Parameters
Period: Frequency: Spring Constant: Quality Factor:Transfer Function
System response in Laplace domain: Poles: For underdamped ():Measurement Method
PhysisLab uses homography-based video tracking:- Reference Markers: Isosceles triangle with known dimensions
- Affine Transformation: Maps pixel coordinates to real-world meters
- Per-Frame Calibration: Compensates for camera/setup movement
- Mass Tracking: Separate color detection for oscillating mass
~/workspace/source/Masa-Resorte/analisis.py
Hardware Requirements
- Spring (known or unknown spring constant)
- Calibrated mass (measure with scale)
- 3× colored markers forming isosceles triangle (reference frame)
- 1× colored marker on oscillating mass (different color)
- Camera (30+ FPS recommended)
- Ruler or measuring tape
- Stable mounting
Experimental Procedure
Setup Physical System
Reference Triangle:
- Attach 3 colored markers forming isosceles triangle to rigid frame
- Measure base width and height accurately (in meters)
- Position triangle so it’s visible throughout oscillation
- Hang spring vertically in front of reference triangle
- Attach mass with colored marker
- Allow system to reach equilibrium
- Measure mass with scale (kg)
Camera Setup
- Position camera perpendicular to oscillation plane
- Ensure all 4 markers (3 reference + 1 mass) visible throughout
- Frame should include full range of oscillation
- Use tripod for stability (but homography handles small movements)
Record Video
- Start recording
- Displace mass vertically and release
- Record at least 10-15 oscillations
- Keep initial amplitude < 10 cm for linearity
- Stop recording
Interactive Configuration
Frame Selection:
- Navigate:
d/a(±1 frame),D/A(±10 frames),g(go to frame) - Mark:
i(inicio),f(fin) - Confirm:
ENTER
- Select ROI on one reference marker → auto HSV detection
- Select ROI on oscillating mass → auto HSV detection
Verify Marker Detection
- Script shows detected markers with labels:
- TL (Top-Left)
- TR (Top-Right)
- BL (Bottom-Left)
- BR (Bottom-Right)
- Press ENTER to confirm
Code Walkthrough
Homography Geometry
Detect and assign triangle markers (analisis.py:161-172):
Affine Transformation
Map image pixels to real-world coordinates (analisis.py:210-221):
Per-Frame Homography Update
Compensate for camera/setup movement (analisis.py:258-270):
Position Transformation
Convert pixel position to meters (analisis.py:224-228):
Damped Sinusoid Fitting
Fit to experimental data (analisis.py:346-401):
Transfer Function Analysis
Calculate system poles (analisis.py:409-426):
Data Analysis
Output Files
Data File:datos_masa_resorte.txt
fig1_cinematica.png- Displacement, velocity, acceleration vs timefig2_espacio_fases.png- Phase space portrait (y vs vy)fig3_espectro.png- Power spectral density (frequency analysis)fig4_bode.png- Bode plot (magnitude and phase)fig5_polos_ceros.png- Pole-zero diagram
Example Results
Visualization
Bode Diagram
Frequency response of the system (analisis.py:516-543):
Pole-Zero Diagram
Visualize system stability (analisis.py:545-577):
Phase Space Portrait
Verification and Validation
Independent Spring Constant Measurement
Verify k using static displacement:Energy Dissipation
Calculate energy loss per cycle:Tips for Best Results
Hardware Setup
Hardware Setup
- Use spring with linear response (avoid overstretching)
- Reference triangle should be rigid (cardboard/foam board)
- All markers should be same size for consistent detection
- Mass marker attached at center of mass
- Ensure vertical alignment (use plumb line)
Measurement Technique
Measurement Technique
- Keep amplitude < 10% of spring length for linearity
- Minimize lateral motion (pull straight down)
- Wait for transients to settle before starting video
- Record at least 10 complete oscillations
- Avoid exciting higher harmonics
Marker Detection
Marker Detection
- Use high-contrast colors
- Matte finish (avoid glossy/reflective)
- Markers large enough to detect clearly
- Uniform lighting across field of view
- Check all 4 markers visible in every frame
Calibration
Calibration
- Measure triangle dimensions multiple times
- Use digital calipers for accuracy
- Measure mass with calibrated scale
- Triangle should be in same plane as motion
Advanced Analysis
Extracting Spring Constant k
From the fitted parameters:Quality Factor
Measure of damping: Higher Q → less damping → more oscillations before decay.Logarithmic Decrement
For consecutive peaks:Troubleshooting
| Issue | Solution |
|---|---|
| Homography fails frequently | Larger/brighter markers, better lighting |
| Erratic position data | Reduce motion blur, increase camera FPS |
| Poor fit to data | Check for non-linear spring behavior, air currents |
| k value inconsistent | Verify mass measurement, check spring linearity |
| Lateral motion detected | Ensure vertical alignment, reduce initial amplitude |
Next Steps
Projectile Motion
Study 2D motion with parabolic trajectories
Data Analysis Guide
Deep dive into system response analysis