# Mechanical Clock

用 ESP32-S3 同时控制六个步进电机与霍尔传感器的机械时钟。

A mechanical HH:MM:SS clock with six Hall-referenced stepper motors, driven by a custom PLC-style non-blocking architecture on an ESP32-S3.

用 ESP32-S3 同时控制六个步进电机与霍尔传感器的机械时钟。

- id: bernhardfoelk-mechanical-clock
- author: bernhardfoelk
- repository: https://github.com/bernhardfoelk/mechanical_clock
- license: MIT
- shape: robot
- scenes: art
- boards: ESP32-S3
- browser_playable: no
- preview: Project screenshots
- html: https://esp32gallery.com/projects/bernhardfoelk-mechanical-clock/
- html_zh: https://esp32gallery.com/zh/projects/bernhardfoelk-mechanical-clock/
- json: https://esp32gallery.com/data/catalog/projects/bernhardfoelk-mechanical-clock.json

## Hardware

ESP32-S3. Verify the exact board revision, wiring and power requirements in the upstream build guide.

ESP32-S3；请在上游构建文档中核对具体板型、供电与接线。

## English

```
Six digit wheels, one per HH:MM:SS character, each turned by a NEMA 17 stepper through a TMC2209 and zeroed by its own Hall sensor. An ESP32-S3 runs the whole thing as non-blocking function blocks in the style of IEC-61131-3, with hand-written `Ton`/`Tof` timers instead of `delay()`, so no missed step pulses. A modulo wrapper around AccelStepper always advances through the shortest positive path, and homing approaches the switch at reference speed, backs off, then closes in at a tenth of that. UART diagnostics were abandoned for plain STEP/DIR with MS1/MS2 strapping at 1/64. Status is honest: one wheel of the six is running.
```

## 中文

```
六个数字轮，每个 HH:MM:SS 字符一个，各由一颗 NEMA 17 步进电机通过 TMC2209 驱动，再用自己的霍尔传感器找零点。ESP32-S3 上的程序按 IEC-61131-3 那套思路写成一个个非阻塞功能块，用自己的 Ton/Tof 延时和边沿检测代替 delay()，免得漏发脉冲。步进封装会把绝对角度换算成取模后的最短正向步数，数字轮永远不用倒转；回零分两段，先按参考速度找霍尔，退开一个角度再用十分之一速度贴上去。TMC2209 的 UART 诊断折腾过后放弃，改回 STEP/DIR 加 MS1/MS2 跳线做 1/64 细分。项目坦白：六个轮子目前只跑起来一个。
```
