rushabhcodes/wireless-split-keyboard

Wireless Split Keyboard — custom routed nRF52840 split PCBs with a printable enclosure

Version
0.4.5
License
unset
Stars
0

Use with the tscircuit CLI

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

tsci clone rushabhcodes/wireless-split-keyboard  # download the package files into ./wireless-split-keyboard
tsci add rushabhcodes/wireless-split-keyboard    # add it to your project as @tsci/rushabhcodes.wireless-split-keyboard

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.

scripts/calculations.py

"""Bounded preliminary RF/power estimates. These are not field-solver or bench results."""
import json,math
from pathlib import Path
root=Path(__file__).resolve().parents[1]
# Hammerstad-style quasi-static, zero-thickness uncoated microstrip. The real
# 35um copper and solder mask need the fab calculator/field solver; no final
# RF trace width is asserted by this calculation.
h=.103;er=4.1

def z0(w):
 u=w/h;ee=(er+1)/2+(er-1)/2*(1/math.sqrt(1+12/u)+(.04*(1-u)**2 if u<1 else 0))
 return 60/math.sqrt(ee)*math.log(8/u+u/4) if u<=1 else 120*math.pi/(math.sqrt(ee)*(u+1.393+.667*math.log(u+1.444)))
a,b=.01,1
for _ in range(100):
 m=(a+b)/2
 if z0(m)>50:a=m
 else:b=m
power=[]
for role,load in [('central',.6),('peripheral',.15)]:
 # Load mA on 3V includes arbitrary scenario allowances, not measured ZMK data.
 for capacity in [150,300,500]:
  battery_ma=3.0*load/(3.7*.85)+.011+.004
  power.append({'role':role,'capacityMah':capacity,'assumed3VLoadMa':load,'regulatorEfficiency':.85,'batteryCurrentMa':battery_ma,'estimatedDays80pctUsable':capacity*.8/battery_ma/24})
report={'status':'PRELIMINARY ASSUMPTIONS — not measured or released',
 'rf':{'candidateFab':'4-layer 1+2+1 HDI, filled/capped 0.15/0.35 mm B-L3 microvias; stackup pending engineering review','source':'https://jlcpcb.com/pcb-fabrication/hdi-pcb','dielectricMm':h,'er':er,'copperMm':.035,'calculation':'Illustrative 0.103 mm outer dielectric only. Zero-thickness uncoated microstrip excludes copper thickness, etch taper, solder mask and nearby ground. NOT a fabrication width.','ideal50OhmWidthMm':(a+b)/2,'routedFeedWidthMm':.2,'required':'Fabricator field-solver GCPW or microstrip result, stackup approval and coupon verification before fabrication'},
 'regulator':{'feedbackReferenceV':.5,'topOhms':453000,'bottomOhms':91000,'nominalV':.5*(1+453000/91000),'maxRecommendedPanelV':3.3},
 'charger':{'isetFactorAOhm':300,'isetOhms':6040,'nominalChargeMa':300/6040*1000,'ilimOhms':24000,'nominalInputLimitMa':100,'batteryRegulationV':4.2,'battery':'Candidate Adafruit 1578 protected 500mAh, charge limit <=500mA. NTC must be attached externally.'},
 'batteryLife':{'assumptions':'Scenario 3V currents include MCU/radio, scan and display. 60Hz VCOM thread cost is NOT characterized; actual runtime may be much shorter. Assumed 85% regulator efficiency, 11uA regulator IQ, 4uA charger drain, 80% usable capacity, continuous operation.','scenarios':power}}
(root/'outputs/calculations.json').write_text(json.dumps(report,indent=2)+'\n')
print('Idealized 50ohm width',round((a+b)/2,5),'mm; nominal rail',report['regulator']['nominalV'],'V')