# SandTable Controller v0.4 (custom PCB) ![render](renders/render-iso.png) A 2-layer, 80 × 63 mm board that replaces the Arduino Uno + CNC shield in the sand table. It uses the **same 4 mounting holes as an Uno**, so it fits the deck standoffs. **Status:** v0.4 is designed and checked in KiCad, with order files ready for PCBWay. It has not been built yet. v0.3 boards have been ordered; their files are kept in [`archive/v0.3/`](archive/v0.3/), and "Using a v0.3 board" below lists what to watch for on them. - **MCU:** ESP32-WROOM-32E (Wi-Fi), running FluidNC. USB-C programming through a CH340C with auto-reset, so no buttons need pressing. ESD protection on the USB data lines. - **Motors:** 2× DRV8825 StepStick sockets, each with a 100 µF bulk capacitor plus a 10 µF ceramic right at its power pins. The board fixes the drivers at 1/32 microstepping and keeps them awake: M0–M2, RESET and SLEEP are all tied to 3.3 V. A4988 drivers also fit (at 1/16) after bridging solder jumper JP1. - **Power:** 12 V barrel jack → 2.5 A resettable fuse → reverse-polarity diode → RECOM R-78E 5 V 1 A switching regulator → AP7361C 3.3 V low-dropout regulator. USB 5 V and regulator 5 V are diode-ORed, so USB alone powers the logic for flashing. The motors need the 12 V supply. - **Connectors:** JST-XH to match the motor cable plugs: - 2× motor (pin order matches the Arduino CNC shield: each coil on an adjacent pair) - home switch - hall sensor (5 V supply) - WS2812B LED data (buffered to 5 V) - 4-pin expansion header - **Inputs:** the home and hall inputs have a pull-up to 3.3 V, an RC filter and a clamp diode to 3.3 V, so a 5 V sensor or module can't overdrive the ESP32. - **Copper:** ground pour on both layers, stitched with about 350 vias. The ESP32 antenna sits over a copper-free area at the board edge. ## Changes in v0.4 From a design review of v0.3. None of these stop a v0.3 board from working; they add margin and make the board safe for other people's parts. | Area | v0.3 | v0.4 | |---|---|---| | 3.3 V regulator | AMS1117: needs about 4.4 V in, but only gets about 4.5 V after the OR diode, so the rail could sag during Wi-Fi bursts | AP7361C-33E: 0.09 V dropout at 300 mA, stable with ceramic capacitors. **Different pinout** (1 IN, 2 GND/tab, 3 OUT); never swap in a 1117-type part | | 5 V regulator | R-78E5.0-0.5 (0.5 A): not enough for the ESP32 plus an LED strip | R-78E5.0-1.0 (1 A, same footprint). The OR diode D2 is now a 3 A SS34 | | Driver supply | 100 µF capacitors 19 mm from the VMOT pins | Plus a 10 µF 50 V ceramic across VMOT and GND at each socket (C16, C17). They sit between the socket strips, under the module | | Driver pin 2 (FAULT on DRV8825, VDD on A4988) | Tied to 3.3 V: safe only on modules with a series resistor on FAULT | Solder jumper JP1, open by default. Bridge it only for A4988 modules | | Home / hall inputs | A 5 V sensor module with its own pull-up could push about 4 V into IO34 / IO35 | BAT54 clamp diodes to 3.3 V (D6, D7), after the 1 k series resistors | | 12 V input | No fuse | Bourns MF-MSMF250/16X-2 resettable fuse (2.5 A hold, 5 A trip) | | USB | No ESD protection | USBLC6-2SC6 on D+ / D− | | Motor traces | One at 0.3 mm, the rest 0.5 mm | All 0.5 mm (about 1.5 A each); the router may not narrow motor or 12 V traces | | Ground | 29 ground vias, 3–4 under the ESP32 | About 350 stitching vias, about 100 under the ESP32 | | Motor plug pin order | Coil pairs on pins 1–2 and 3–4 | Same pairs, in the driver's own order (as on the CNC shield). An axis may now turn the other way than on v0.3: see "Firmware" below | ## Checks (KiCad 9.0.7, `kicad-cli`) | Check | Result | |---|---| | ERC (schematic) | 0 violations | | DRC (board, all severities) against PCBWay's standard limits: 6/6 mil trace/space, 0.3 mm hole, 0.15 mm ring | 0 violations, 0 unconnected | | Schematic ↔ PCB parity | 0 differences | | Vias within 0.2 mm of a pad, holes inside a pad (checked from the board file) | 0 | | Pinouts of every active part checked against its datasheet or KiCad's library symbol | ESP32, CH340C, AP7361C, 74AHCT1G125, R-78E, USBLC6, MMBT3904, USB-C, driver sockets | | Fit in the sand table (v3 shell and deck) | Board corners 3 mm from the wall, clear of the deck bosses; jack and USB next to the cable notch | ## Ordering from PCBWay Everything for the order is in [`pcbway-order/`](pcbway-order/). [`ORDER.md`](pcbway-order/ORDER.md) there lists the exact settings to enter, which file goes in which upload box, and a note to paste for PCBWay. | File | What | |---|---| | `1-gerbers-…zip` | Board files: Gerbers plus separate plated and non-plated drill files | | `2-bom-…csv` | Parts list for turnkey assembly, with manufacturer part numbers | | `3-centroid-…csv` | Part positions in mm, origin at the board's bottom-left corner | | `assembly-top-…pdf`, `schematic-…pdf` | For PCBWay's engineers if they ask | The DRV8825 modules are not on the order; you plug in your own. The back of the board has PCBWay's "WayWayWay" marker, so their order number prints there instead of on the front. ## Before first power-up 1. **Driver type.** DRV8825: leave JP1 (under the theta driver socket, marked "A4988 ONLY") open. A4988: bridge JP1 with a blob of solder, or the A4988 has no logic supply. 2. **Driver direction.** Line up the module's VMOT, EN and DIR pins with the VMOT / EN / DIR labels on the board. A driver plugged in backwards is destroyed. 3. **Driver current.** On a DRV8825, current limit = 2 × Vref (with the usual 0.1 Ω sense resistors). - Start at about 70 % of the motor's rated current. For example, a 1.0 A motor needs Vref ≈ 0.35 V. - Measure Vref between the trim pot and GND with the 12 V supply connected. - Never plug or unplug a motor while the power is on. 4. **Home switch wiring.** Connect the switch's COM to HOME pin 3 (GND) and its NO contact to pin 2. 5. **Firmware.** - Flash FluidNC over USB with the FluidNC web installer. - Upload `fluidnc/config.yaml` as `config.yaml`. - In the config, X is theta in degrees and Y is rho in mm. `$H` homes rho. - If an axis turns the wrong way, add `:low` to its direction pin. ## Using a v0.3 board The v0.3 boards work; the v0.4 changes add margin. On a v0.3 board: - **Random resets or Wi-Fi dropouts**, mostly on USB power alone: the AMS1117 is short of headroom. Run from the 12 V supply, or replace U3 with a low-dropout regulator that has the **same pinout as an AMS1117** (pin 1 GND, pin 2 OUT and tab, pin 3 IN). ST's LDL1117S33R is sold as one; check its datasheet's pin table before buying. The AP7361C used on v0.4 has a different pinout and does not fit a v0.3 board. - **DRV8825 clones:** check that the module has a resistor in series with its FAULT pin, as Pololu's does. If not, clip or bend that pin (FAULT, between A2 and the last GND on the motor-pin row) so it doesn't plug in; a DRV8825 doesn't need it. - **LED strip:** the 5 V regulator gives 0.5 A in total, which leaves room for only 2–3 LEDs at full white. - **Hall sensor:** use a bare open-collector sensor (A3144 style), not a breakout module with its own pull-up to 5 V. - **Motor traces:** fine up to about 1.2 A per motor. ## ESP32 pin map | Function | GPIO | |---|---| | Theta (spin) STEP / DIR | IO18 / IO19 | | Rho (arm) STEP / DIR | IO27 / IO14 | | Driver enable (shared, low = on, pulled up so the drivers are off at boot) | IO13 | | Rho home switch | IO34 | | Theta hall sensor | IO35 | | LED strip data (through a 74AHCT1G125 buffer) | IO33 | | Status LED | IO2 | | Expansion header | IO32, IO25 | | Free, not connected | IO16, IO17 | ## Files | Path | What | |---|---| | `kicad/` | KiCad 9 project: schematic, board, and project-local symbol and footprint tables | | `sandtable-controller-schematic.pdf` | Schematic | | `pcbway-order/` | Everything to upload to PCBWay, plus `ORDER.md` with the settings | | `renders/` | 3D renders | | `sandtable-controller.step` | 3D model | | `fluidnc/config.yaml` | FluidNC machine config (a starting point, not yet run on hardware) | | `archive/v0.3/` | The v0.3 board as ordered: KiCad files, order files, schematic and the generator's `design.py` | | `tools/` | Python generator: `design.py` (parts, placement, nets, sourcing) → `route.py` (router, ground pour, stitching vias, board file), `sch.py` (schematic), `fab.py` (PCBWay order folder, renders, copy into this folder). `place_new.py` finds free spots for parts added in a revision | To regenerate everything, run `python3 tools/route.py && python3 tools/sch.py && python3 tools/fab.py`. The KiCad files are built in `~/kicad/sandtable-controller` because the KiCad snap can't read inside `~/snap/`. ## Notes - **5 V budget:** the 5 V regulator supplies 1 A. The ESP32 takes up to about 0.4 A during Wi-Fi bursts, which leaves about 0.6 A for an LED strip: roughly 10 WS2812B LEDs at full white, or more at lower brightness. On USB power alone, keep the strip off; USB gives 0.5 A in total. Use a separate 5 V supply for longer strips. - **Input voltage:** 12 V. The fuse is rated 16 V, so don't use a higher supply. - **Noise:** DRV8825s are louder than TMC2209s; expect some motor whine. TMC2209 modules in standalone mode might work in these sockets, but their pin layouts vary by brand, so check before trying one. - **LED strip:** FluidNC doesn't drive the WS2812B header. It's there for other firmware or an add-on later.