static volatile int64_t clock_offset_us = 0;
static volatile int64_t last_beam_break_us = 0;
static volatile bool beam_break_event = false;
int64_t master_time_now_us(void)
{
return esp_timer_get_time() + clock_offset_us;
}
void on_sync_packet(const SyncPacket *pkt)
{
int64_t t_client_rx_us = esp_timer_get_time();
int64_t one_way_us = pkt->round_trip_us / 2;
clock_offset_us =
(pkt->master_tx_us + one_way_us) - t_client_rx_us;
}
void IRAM_ATTR beam_break_isr(void)
{
last_beam_break_us = master_time_now_us();
beam_break_event = true;
}
void process_lap_event(void)
{
if (!beam_break_event) return;
beam_break_event = false;
send_timestamp_to_master(last_beam_break_us);
}
Hover a sheet to preview it · click to open it full size.
| Subsystem | Implementation |
|---|---|
| Optical receiver | Three BPW34 photodiodes increase the effective laser capture area while feeding one transimpedance stage. |
| Current-to-voltage stage | OPA380 TIA with 10 kΩ feedback and compensation capacitor converts photodiode current into a measurable voltage. |
| Digital edge output | LM393 comparator with adjustable threshold and hysteresis suppresses chatter before the signal reaches the ESP32. |
| Power path | BQ24074 manages USB-C input, 1S LiPo charging, PowerPath system output, and status pins for the MCU. |
| 3.3 V rail | TPS63001 buck-boost keeps the ESP32 and analog circuitry powered across the LiPo discharge range. |
| Clock synchronization | Master/client ESP-NOW timestamp exchange estimates clock offset before lap-time calculation; local beam-break events are converted into the master time domain with RTT compensation. |
| Wireless controller | ESP32-C3-MINI-1U provides USB programming, GPIO interrupt capture, and an external u.FL antenna path for 2.4 GHz communication. |