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.

enclosure/dimensions.ts

import {oled} from "./oled-mechanics"
import placement from "../circuit/placement.json"
import boardJson from "./reference-board.json"
const rows = boardJson as any[]
export const board = rows.find(r=>r.type==="pcb_board")!
export const mountingHoles=rows.filter(r=>r.type==="pcb_hole"&&!r.pcb_component_id&&r.hole_diameter===3.2)
export function component(name:string){const s=rows.find(r=>r.type==="source_component"&&r.name===name);const p=rows.find(r=>r.type==="pcb_component"&&r.source_component_id===s?.source_component_id);if(!p)throw Error(`Missing ${name}`);return {...p,center:placement.pcb_placements.find(q=>q.selector===name)?.center??p.center}}
if(board.width!==91||board.height!==90||mountingHoles.length!==4)throw Error("Review enclosure for changed PCB")
export const design={
 // Original base, PCB supports and M3 hardware restored.
 wall:2.4,boardClearance:4.3,bottom:-9,floorTop:-6.6,seam:-6.6,
 roofBottom:17.6,top:19.6,lipClearance:.3,
 inserts:{m2:{length:3,diameter:3.6,holeDiameter:3.4},m3:{length:5.7,diameter:4.6,holeDiameter:4.2}},
 pcbMount:{radius:3.5,insertTop:-1.1,holeBottom:-7.7,screwLength:8},
 caseBolts:[[-60.8,-29.3],[35.8,-29.3],[-60.8,66.3],[35.8,66.3]] as [number,number][],
 flange:{radius:3.4,bottom:-6.45,top:-1.2,holeRadius:1.2,headRadius:2.1,headSeat:-7.6,screwLength:4},
 // Mounting flanges: the floor plate carries on 13 mm past the two side walls (POWER / USB side and
 // encoder side), flush with the underside, with two screw holes in each. This is the pattern of the
 // Hammond 1591 flanged boxes: a flange on two opposite ends, four holes in all. The 4.5 mm holes take
 // M4 or No. 8 pan-head screws (washer up to 9 mm); a 2.4 mm plate is too thin to countersink.
 // ("flange" above is the older name for the four case-screw lugs inside the lid.)
 mount:{width:13,holeOffset:6.5,holeRadius:2.25,holeEndInset:7.2,corner:4,washerRadius:4.5},
 // Alps RK09D1130C2P drawing: 6 mm shaft, ONE flat 4.5 mm across (1.5 mm from the
 // axis) over the top 12 mm, LM1 = 25 mm above the PCB surface -> tip z = 25.8,
 // flat from z = 13.8. Axis on the mounting-tab line (footprint datum).
 knob:{x:-51.762,y:50.700,openingRadius:4.15,shaftRadius:3.0,shaftFlat:1.5,shaftTop:25.8,flatBottom:13.8,lm1:25,
  stemRadius:3.75,boreRadius:3.1,boreFlat:1.58,
  // Three crush ribs grip the Alps 6 mm D-shaft (0.045-0.07 mm interference).
  gripRibs:[30,90,150],gripRibRadius:2.93,gripRibWidth:.6,gripRibStart:.9,gripRibEnd:24.8,leadInRadius:3.45,leadInDepth:.5,capRadius:6.5,capBottom:20.1,capTop:27.2,stemBottom:15.0,
  ribs:24,ribDepth:.45,pointerWidth:.9},
 motorOpening:{x:8.9021,y:54.4,width:36,depth:25.7},
 screen:{x:oled.x,y:oled.activeY,width:37.5,depth:20.0,glassTop:oled.panelTop,
  activeWidth:oled.activeWidth,activeHeight:oled.activeHeight,upperX:oled.x,upperWidth:38.3,upperDepth:20.8,
  holderWidth:44.54,holderDepth:29.72,holderTop:oled.holderTop,holderBottom:oled.holderBottom,
  rearOpeningWidth:38.6,rearOpeningDepth:24.7,flexExitWidth:13.5,
  locatingWidth:44.54,locatingDepth:29.72,panelClearance:.25,seatBottom:oled.seatBottom,
  padThickness:oled.adhesiveThickness,bossTop:oled.bossTop,
  insertBottom:oled.insertBottom,insertTop:oled.insertTop,insertHoleBottom:oled.insertHoleBottom,
  screwSeat:oled.screwSeat,screwLength:oled.screwLength,screwHeadHeight:oled.screwHeadHeight,
  panelY:oled.panelY,panelWidth:oled.panelWidth,panelDepth:oled.panelHeight,panelBottom:oled.panelBottom,
  adhesiveX:oled.adhesiveX,adhesiveWidth:oled.adhesiveWidth,adhesiveLength:oled.adhesiveLength,
  tailLength:oled.tailLength,stiffenerLength:oled.stiffenerLength,insertion:oled.insertion,screws:oled.holderScrews},
 // Removable screen door (lid insert). The panel, its seat and the rear retainer live in
 // this insert, so the lid is closed first and the stock 36 mm flex is mated from above
 // through the opening. The 45 degree seat lets the door drop straight in without falling
 // through. Two M2 x 4 screws enter from the top into M2 x 3 inserts in the lid: the same
 // hardware as the display retainer. Screw sites avoid the SPEED knob, buttons and J11.
 door:{
  low:{x0:-42.2,x1:7.6,y0:34.0,y1:65.3},      // main outline at the roof underside
  ear:{x0:-46.6,x1:-41,y0:57.9,y1:64.1},       // covers the upper-left retainer boss
  bevel:1,gap:.2,seatGap:.04,corner:.8,
  // 1 mm screw tabs that overlap the lid; each sits in a matching lid recess.
  tabs:[{x0:-54.7,x1:-45,y0:58.9,y1:65.7},{x0:6,x1:15.2,y0:34.1,y1:40.9}],
  tabThickness:1,tabCorner:1.2,
  screws:[[-51.3,62.3],[11.8,37.5]] as [number,number][],
  bossRadius:2.7,bossBottom:14.5,holeBottom:15.1,insertTop:18.5,
  screwLength:4,screwHeadHeight:1.3,screwHeadRadius:1.9,clearRadius:1.15,
  // Relief in front of the glass edge so the flex can curve instead of creasing at its bond.
  flexWidth:14,flexFront:32.4,flexBottom:16.5,
 },
 // POWER: SK-22D03-G080 at the left PCB edge (footprint 270 deg, centre x=-55.3).
 // Body face x=-58.73; the 8 mm lever (2 x 2 mm, z 2.5-4.5) passes through a slot
 // in the side wall and ends 2 mm proud of the outside, inside a shallow thumb
 // pocket (handheld-console style). Lever travel 2.03 mm: OFF toward +Y.
 power:{y:35.5,bodyFaceX:-58.73,bodyBackX:-51.87,leverTipX:-66.73,leverWidth:2.03,travel:2.03,
  leverBottom:2.5,leverTop:4.5,slotHalfWidth:2.38,slotTop:4.9,tongueTop:2.1,tongueClearance:.1,
  pocketDepth:1.5,pocketHalfDepth:6.5,pocketBottom:0,pocketTop:7,pocketRadius:2},
 // KH-6X6X9.5H (as on the dual-RP2350 handheld): round plunger dia ~3.2 mm, top at
 // z = 0.8 + 9.5 = 10.3; switch body top z = 4.3. Console-style captive cap: a
 // 3.7 mm socket slides 3 mm down over the plunger and rests on its top; flange
 // under the roof; visible 6 mm crowned cap 1.7 mm above the lid.
 button:{stemRadius:3.0,boreRadius:3.3,flangeRadius:3.8,pocketRadius:4.1,guideRadius:4.8,
  guideBottom:11.0,flangeBottom:16.3,flangeTop:17.1,tipBottom:7.3,top:21.3,switchTop:10.3,domeDrop:.6,
  plungerRadius:1.6,socketRadius:1.85,switchBodyTop:4.3},
 // BOOT and RESET have no cap. Each is pressed through a 2 mm hole with a straightened paperclip.
 // A solid guide under the hole ends 1 mm above the switch plunger and steers the wire onto it.
 pinhole:{radius:1.0,guideRadius:3.0,guideBottom:11.3,leadInRadius:1.5,leadInDepth:.5,wireDiameter:.9},
 led:{x:-49,y:32,radius:1.2},// J20 stays fixed. Grip the mating plug from its sides through a low port.
 encoder:{x:39.7,y:34.4,width:18,depth:28.4,bottom:-.6,top:8.8,tongueClearance:.15,
  fingerRadius:4,fingerY:[24.4,44.4],fingerZ:4.02},
} as const
export const body={x:board.center.x,y:board.center.y,innerWidth:board.width+2*design.boardClearance,innerDepth:board.height+2*design.boardClearance,width:board.width+2*(design.boardClearance+design.wall),depth:board.height+2*(design.boardClearance+design.wall)}
// Four mounting holes, two in each flange, 7.2 mm in from the front and rear edges.
export const mountHoles=[-1,1].flatMap(sx=>[-1,1].map(sy=>[body.x+sx*(body.width/2+design.mount.holeOffset),body.y+sy*(body.depth/2-design.mount.holeEndInset)] as [number,number]))
export const buttons=["SW1","SW2","SW3","SW5","SW6","SW7","SW8"].map(ref=>({ref,...component(ref).center,label:({SW1:"BOOT",SW2:"RESET",SW3:"ARM",SW5:"UP",SW6:"DOWN",SW7:"OK",SW8:"BACK"} as Record<string,string>)[ref]}))
// BOOT and RESET sit behind pinholes; the other five have printed caps.
export const pinholeRefs=["SW1","SW2"]
export const pinholeButtons=buttons.filter(b=>pinholeRefs.includes(b.ref))
export const capButtons=buttons.filter(b=>!pinholeRefs.includes(b.ref))
export const motorPorts=["J10","J11","J12"].map(ref=>({ref,x:component(ref).center.x+.0101,y:66.3351}))
// Shared access for the unchanged J19/J1 centres. Nominal cable bodies are 12 x 6 mm.
// The 12.5 mm centre spacing still limits simultaneous use of larger overmolds.
const usbYs=[component("J19").center.y,component("J1").center.y]
export const usbOpening={name:"USB",x:body.x-body.width/2,y:(Math.min(...usbYs)+Math.max(...usbYs))/2,
 width:14,depth:Math.max(...usbYs)-Math.min(...usbYs)+14,bottom:-1.6,top:6.8,along:"y",
 leadInDepth:1,leadInFlare:1}
export const portOpenings=[
 usbOpening,
 {name:"motor",x:8.9021,y:body.y+body.depth/2,width:36.8,depth:14,bottom:.2,top:14.6,along:"x"},
]
// Closed-top visual trial. Base slots remain; loaded thermal validation is pending.
// The four small top slots are acoustic openings for the buzzer.
export const roofVents: {x:number;y:number;width:number;depth:number;z:number}[]=[]
export const buzzerVents=Array.from({length:4},(_,i)=>({x:-48+i*2,y:-19,width:1,depth:6,z:19.6}))
export const baseVents=Array.from({length:8},(_,i)=>({x:-30+i*6,y:4,width:2,depth:16}))