MustafaMulla29/rp2040-bldc-motor-controller

Hardware assembly metadata and PCB geometry for a controller board with a snap-off rotary-encoder section, plus four parallel 150 µF/50 V bulk electrolytic capacitors filtering the motor supply.

Version
2.0.40
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone MustafaMulla29/rp2040-bldc-motor-controller  # download the package files into ./rp2040-bldc-motor-controller
tsci add MustafaMulla29/rp2040-bldc-motor-controller    # add it to your project as @tsci/MustafaMulla29.rp2040-bldc-motor-controller

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

docs/encoder-board.md

# Motor encoder board and snap-off fabrication — 1 December 2026

The project now has its own encoder board for J20. It replaces the bought AS5047P-TS_EK_AB adapter board proposed in `full-assembly.md`: that board is listed as discontinued at DigiKey and "No Longer Available" at Newark, and Mouser showed 0 in stock with a 10-week lead time on 1 December 2026. The design is made alongside the controller as a snap-off piece, so nothing is hand-soldered. Nothing has been fabricated or tested.

## Where to see it on tscircuit.com

The package page opens the main product (`index/circuit.json`). The other boards are in the **Builds** picker above the PCB view:

- `encoder-board/circuit.json`: the encoder board on its own ([open](https://tscircuit.com/MustafaMulla29/rp2040-bldc-motor-controller?preview_file=dist%2Fencoder-board%2Fcircuit.json#pcb)).
- `fabrication-with-encoder/circuit.json.gz`: the controller with the encoder joined on as a snap-off piece, as it would be ordered ([open](https://tscircuit.com/MustafaMulla29/rp2040-bldc-motor-controller?preview_file=dist%2Ffabrication-with-encoder%2Fcircuit.json.gz#pcb)). The plain file is 6.6 MB, above the registry's per-file upload limit, so the package carries this gzip copy (`scripts/large-files.mjs`); it holds the same bytes.

The 3D view includes the encoder board, holder and magnet cap at the motor, as part of the connected assembly model.

## The board

`encoder-board.circuit.tsx` is a 24 × 38 mm board with an AS5047P-ATSM (JLCPCB C962063) on-axis magnetic sensor. The chip centre is the board origin and must sit on the motor shaft axis.

| J30 pin | Net | J20 pin on the controller |
| --- | --- | --- |
| 1 | EB_3V3 | 1, ENC_3V3 |
| 2 | EB_GND | 2, GND |
| 3 | EB_A | 3, ENC_A_EXT |
| 4 | EB_B | 4, ENC_B_EXT |
| 5 | EB_Z (chip pin I) | 5, ENC_Z_EXT |

J30 is the same part as J20 (S5B-PH-SM4-TB, C265104) with the same pin order, so a straight 5-way JST PH cable joins them, for example Pololu 5636 (40 cm; shorter lengths exist). The cable's pin 1 must go to pin 1.

Wiring follows the AS5047P datasheet, version 2-00 (pin table and notes on pages 3–4, Figure 10 for the supply):

- 3.3 V operation: VDD and VDD3V3 are tied together, with 100 nF; a 1 µF capacitor is added beside it.
- TEST is connected to ground.
- SPI is idle in use, so CSn has a 10 kΩ pull-up and CLK and MOSI have 10 kΩ pull-downs. MISO and the unused U, V and W outputs are left open, as the datasheet allows.
- A, B and I each pass through 27 Ω. The outputs are rated for 1 mA and 50 pF, so keep the cable at 40 cm or less.
- Six unpopulated pads (TP30–TP35: GND, 3V3, MOSI, MISO, CLK, CS) give spring-pin access to SPI.

The chip powers up at 1000 pulses per revolution. Lower settings (down to 25) need SPI and are lost at power-off unless burned once into the chip's OTP memory; no procedure for that is written yet. The supply limit, the 20 kHz per channel qualification target and the diagnostic-only firmware described in `encoder-and-rearm.md` are unchanged.

All parts except the AS5047P are already used on the controller. Part and net names (U30, R300…, J30, TP30…, `EB_…`) are distinct from the controller's.

## Fabrication with the controller

`scripts/build-fabrication-with-encoder.mjs` joins the two finished boards into one board file, `dist/fabrication-with-encoder/circuit.json`, with the encoder as a snap-off piece below the controller's bottom edge. `circuit/breakoff-geometry.ts` holds the positions. This follows the pattern of the breakaway sensor board in `abse/gameboy-advance-dual-rp2350`, where a release script adds the break-off to the finished board file.

- The inputs are the released controller (`dist/pcb/circuit.json`) and the encoder's own build (`dist/encoder-board/circuit.json`). The controller's records are copied through unchanged. The encoder's records are only moved into place and given an `enc_` id prefix.
- The result is one board with one outline around both pieces. Two 3 mm bridges at the encoder's top corners join them, with a routed slot between the bridges and two rows of four 0.5 mm perforations on each bridge.
- A frame around the whole board is not possible, because the POWER switch lever and the USB sockets overhang the controller's edges. The bottom edge between X = 1 and X = 25 has no part within 3 mm, apart from the keep-out circles of C95 and C96, which the bridges avoid.
- The row of perforations on the controller side lies just outside its edge, so the controller is not cut into. A small ridge remains after snapping and is filed off.
- Both pieces are 4-layer, 1.6 mm, because they are one physical board; the encoder is built that way on its own too. Its ground fill is kept 1 mm back from its edge, clear of the perforations.

Build and check:

```sh
bun run build:fabrication
```

`scripts/check-fabrication-with-encoder.mjs` then establishes that:

1. the file describes one board, is not a panel, and records no errors;
2. every controller record is unchanged, apart from its board record gaining the joined outline;
3. the encoder's pads, paste, vias, tracks, fill and holes are its own build moved into place;
4. every exported tscircuit check gives the same result on the joined board as the two boards give on their own;
5. there are two bridges of the stated width, one slot and 16 perforations, none of which cuts into the controller;
6. no id or net name is shared, and all vias are through vias.

**Why not a tscircuit `<panel>`.** A first version placed both boards in a `<panel>`. In `@tscircuit/core` 0.0.2320, `Group_doInitialStandaloneSubcircuitPcbDesignRuleChecks` then runs a panel-level routing check with a stand-in `pcb_board` whose `num_layers` is fixed at 2, and reports a false "Via in trace … does not connect its adjacent wire layers" error for each of the 322 inner-layer vias. A panel must be the root element and offers no switch for that check. A panel also dropped the encoder's ground fill and needed the outline expressed as a rectangle with cut-outs. Joining the finished files avoids all three.

### Factory files

`dist/fabrication-with-encoder/factory-files.zip` is the native export (`tsci export … -f gerbers`) of the joined file. Checked contents: four copper layers, masks, paste, silkscreen, plated and non-plated drill files, a parts list and a placement file.

- The outline file holds one outline around both pieces and the slot between the bridges.
- The non-plated drill file holds the 16 perforations (0.5 mm) and the encoder's four 2.7 mm mounting holes.
- The parts list and placement file hold the ten encoder parts; the six SPI pads are not placed.
- The export cannot verify JLCPCB placement rotation for any part. The controller has its own reviewed placement files; the encoder's ten parts do not. Check U30's pin 1 and J30's direction in the fabricator's placement preview before ordering.
- JLCPCB counts boards that can be separated as different designs, so the order is entered as two designs.

The controller's own release checks (`export:factory-review` and its evidence files) cover the controller alone and were not rerun for this joined file.

## Holder and magnet cap

`encoder-mount/mount.py` is a parametric model of a printed holder and a magnet cap; `assets/encoder-mount/` has the print files and `report.json`.

- The holder is a plate under the motor base, fixed with the motor's four M3 screws (16 × 19 mm pattern), with four posts for the encoder board and two side walls that act as a stand.
- The encoder board lies along X, so its cable leaves sideways and does not run under the three motor leads.
- The cap holds a 6 × 2.5 mm diametrically magnetised magnet 1.5 mm above the chip. Its 3 mm neck is glued onto the end of the shaft; 1.6 mm of plastic keeps the magnet off the steel shaft, and the wide part runs 0.6 mm below the motor base so it cannot rub.
- Use plastic or brass screws near the magnet.

**Motor data.** The seller's dimension drawing for the Readytosky RS2212 920KV (Amazon B075DD16LK, read on 1 December 2026) gives a 28 mm body (drawn as 27.8), 24 mm height without the M6 propeller shaft, 38 mm overall and four M3 holes on 19 mm and 16 mm pitches. It shows a flat base with no shaft standing proud of it. The model therefore sets `shaft.stickOut` to 0: the cap does not grip the shaft, it is glued to its end. The listing's "Shaft Diameter: 12 millimeters" does not match anything on the drawing and is not used.

**Not verified on a motor.** The drawing does not dimension the rear of the shaft. Check on the motor whether the shaft end is flush or recessed, what retains it (a clip or a screw would need a different cap), the size of the opening around it, and where the three leads leave the base relative to the screw pattern (the holder can be fitted either way round, but the encoder cable should end up on a different side from the leads). Set `shaft.stickOut` (negative if recessed) and rerun the script: cap length, board height, post length and stand height follow from it. The script's 23 checks cover clearances for the modelled numbers; they do not establish fit on a real motor. A glued 3 mm joint on a shaft that can reach 18,000 rpm also needs a spin test behind a guard before use.

## Assembly view

`encoder-mount/update_assembly.py` replaced the old encoder board, cradle, carrier, spacers, nuts, contacts and wires in `assets/connected-system.glb` with the new board, holder, cap, magnet, plug and five wires, and updated `assets/connected-system.provenance.json`. Everything else in that file is copied through unchanged. This is a stop-gap: the assembly is generated from `assembly/`, which is not in the published package. Port the change there before running `bun run assembly:build`, or it is overwritten.

## Open items

- The shaft end, its retainer and the lead exit checked on a motor, then a printed holder and cap tried on it.
- A written procedure for setting the pulse count, and a decision on OTP.
- The fabricator's review of the break-off (bridges, slot and perforations) and of the two-design order.
- A placement file for the joined board with reviewed rotations, built from the controller's reviewed file plus the ten encoder parts.
- The enclosure checks that read the assembly file were not rerun; the encoder parts are outside the enclosure.