Overview
The Free Fall Detector is a precision timing circuit designed to measure the time of free fall using infrared (IR) sensors. The system uses an ESP32 microcontroller to detect when an object passes through two IR beam gates and calculates the elapsed time with microsecond accuracy.Circuit Design
Component List
- Microcontroller: ESP32 development board
- Sensors: 2x IR photogate sensors (transmitter/receiver pairs)
- Resistors: Pull-up resistors (10kΩ recommended) for sensor inputs
- Power Supply: 5V USB or regulated power supply
- Connectors: Jumper wires, breadboard or PCB
Pin Assignments
| Function | GPIO Pin | Configuration |
|---|---|---|
| Start Gate (IR Sensor 1) | GPIO 18 | INPUT_PULLUP |
| End Gate (IR Sensor 2) | GPIO 5 or 26 | INPUT_PULLUP |
Circuit Connections
Circuit Diagram Description
The circuit uses two IR photogate sensors positioned vertically at a known distance apart. Each sensor consists of an IR LED transmitter and a phototransistor receiver facing each other. When an object breaks the IR beam, the sensor output transitions from HIGH to LOW. The ESP32 internal pull-up resistors (configured via INPUT_PULLUP) keep the sensor pins at 3.3V when the beam is unbroken. When the beam is broken, the sensor pulls the pin to ground (LOW).Electrical Specifications
Input Specifications
- Input Voltage Range: 0V (LOW) to 3.3V (HIGH)
- Logic Threshold: ~1.65V (typical for ESP32)
- Input Impedance: ~45kΩ (with internal pull-up enabled)
- Maximum Input Current: 12mA per pin
Power Requirements
- ESP32 Operating Voltage: 3.3V (regulated internally from 5V VIN)
- IR Sensor Supply: 5V DC
- Total Current Consumption: ~100-200mA (depends on IR sensor current)
- Recommended Power Supply: 5V @ 500mA minimum
Timing Specifications
- Timing Resolution: 1 microsecond (using
micros()function) - Sampling Rate: 1ms polling interval (configurable)
- Maximum Measurable Time: ~70 minutes (before micros() overflow)
- Minimum Detectable Pulse: ~1ms (depends on polling implementation)
Firmware Implementation
Polling-Based Implementation (FreeRTOS)
This implementation uses FreeRTOS task scheduling for robust timing measurements:Interrupt-Based Implementation
For applications requiring maximum timing precision, an interrupt-driven approach can be used:Timing Measurement Approach
Microsecond Precision
The system achieves microsecond precision using the ESP32’smicros() function, which returns the number of microseconds since the ESP32 began running. This provides:
- Resolution: 1 microsecond
- Accuracy: ±1-2 microseconds (limited by crystal oscillator accuracy)
- Measurement Range: 0 to 4,294,967,295 microseconds (~71.6 minutes before overflow)
Edge Detection Methods
-
Polling Method:
- Samples sensor states every 1ms using FreeRTOS task delay
- Detects falling edge by comparing current vs. previous state
- Timestamp captured immediately when edge detected
- Suitable for most free fall experiments
-
Interrupt Method:
- Hardware interrupt triggered on FALLING edge
- Minimal latency (~1-2 microseconds)
- Critical section protection for thread-safe variable access
- Recommended for high-precision measurements
State Machine Logic
The firmware implements a simple state machine:- Waiting for Start: System monitors start gate sensor
- Start Detected: Records timestamp, transitions to waiting for end
- Waiting for End: System monitors end gate sensor (start gate ignored)
- End Detected: Records timestamp, calculates delta, returns to waiting for start
Assembly and Testing
Assembly Steps
- Mount IR Sensors: Position sensors vertically with adjustable height mechanism
- Wire Power: Connect 5V and GND to both sensors
- Connect Signals: Wire sensor outputs to ESP32 GPIO pins
- Add Pull-ups: If sensors don’t have built-in pull-ups, add 10kΩ resistors
- Upload Firmware: Flash the appropriate firmware to ESP32
- Test Alignment: Verify IR beams are properly aligned
Testing Procedure
- Power On: Apply 5V power to circuit
- Open Serial Monitor: Set baud rate to 115200
- Verify Sensors: Check that sensors output HIGH when beam is clear
- Test Start Gate: Break start beam, verify “INICIO” message
- Test End Gate: Break end beam, verify “FIN” and “DELTA” messages
- Calibration: Drop object of known mass, verify timing matches theoretical calculation
Expected Performance
For a typical free fall experiment with 1 meter separation:- Expected Time: ~452ms (theoretical free fall)
- Measurement Accuracy: ±2ms (depends on sensor response time)
- Repeatability: ±1ms (with proper alignment)
Applications
- Physics Education: Measure gravitational acceleration (g)
- Free Fall Experiments: Verify kinematic equations
- Velocity Measurements: Calculate instantaneous velocity
- Timing Gate: General-purpose timing for moving objects
- Photogate Timer: Scientific data collection
Troubleshooting
| Issue | Possible Cause | Solution |
|---|---|---|
| No start detection | IR beam misaligned | Adjust sensor alignment |
| Inconsistent readings | Ambient light interference | Add shielding or use modulated IR |
| No serial output | Baud rate mismatch | Verify 115200 baud |
| Always reads LOW | Sensor wired backwards | Check sensor polarity |
| Overflow errors | Timing > 71 minutes | Reset ESP32 periodically |
Source Code Location
The complete firmware implementations can be found in:source/FreeFall/Micro-procesador/FreeFallEpsfreeRTOSFunciona/FreeFallEpsfreeRTOSFunciona.ino(Polling method)source/FreeFall/Micro-procesador/FreeFallInt_Timer/FreeFallInt_Timer.ino(Interrupt method)