Ray Kholodovsky - "Can I ask parts-engine a que...
"Can I ask parts-engine a question or is it only run automatically during compile?"
I'm mentally architecting my modules, starting with a simple one like "Power LED", which I want to use a calculation to set the LED brightness to a particular target based on the provided input voltage, and return an LED and a resistor of appropriate value.
We discussed all this here before: https://github.com/orgs/tscircuit/discussions/763
The question now, is when my calculator returns an exact value of 6250 ohms, can I ask parts-engine to find the nearest size that is under the basic list? Or do I have to bring in that list myself and handle all of that selection logic myself in my userland module?
GitHub
Math! Equations! Calculators! · tscircuit · Discussion #763
As we discussed here, we can do expressions and basic math right in TSX, cool! https://discord.com/channels/1233487248129921135/1353415621995397172/1413333949417259098 However, I think it might be ...
10 Replies
For example, in my led calc, I can see that 6.2k ohm is the closest match if I'm using 0603 components but not 0402; if 0402 I can bounce over to 5.6k which is the next closest match.
My system lets me do all this, the question is whether I can use any parts of tsci to do this for me, or if I have to bring over all this logic including the list of JLC basic resistors hardcoded into my userland code.
My system lets me do all this, the question is whether I can use any parts of tsci to do this for me, or if I have to bring over all this logic including the list of JLC basic resistors hardcoded into my userland code.

Or perhaps what I am asking is more akin to making an API call to https://jlcsearch.tscircuit.com/resistors/list?package=0402&is_basic=true&resistance=
?
there are a couple ways this can get done depending on your preference
- Enough specifications supplied + supported for the
<led />
component, in this case the parts engine will handle it. IIUC you have an RTarget that you want, so we would need to add that as a property/filter. We would also add a tolerance
- Supply a manufacturer part number directly and use your own script (or provide your own platformConfig.partsEngine
that extends the existing parts engine)
- Allow a coding agent like Claude
to use tsci search
and evaluate options, then place a mpn
on the <led />
for you
I think we should have a doc page for this, CC @RishabhEnough specifications suppliedFor the LED this will be completely constrained by us, my input parameters might be "led 0402 red" and that would select from our preferred list à la here, which would contain 5-10 items total. For the resistor, I want to only constrain it enough by saying "res 0402 from jlc basic or preferred, find the closest match to 6250 ohms" and this is the root of the question I am asking - there's no MPN that I care about to speak of, just find the closest match from the list, like the list I used here: https://github.com/CDFER/jlcpcb-parts-database?tab=readme-ov-file
GitHub
GitHub - CDFER/jlcpcb-parts-database: Automatically updated sqlite ...
Automatically updated sqlite database of JLCPCB parts, filtered to only include components in stock. Includes a CSV file of basic and preferred parts. - CDFER/jlcpcb-parts-database

yea we use the same underlying source as those guys (i think) so it should be possible
soooo many things are based on https://github.com/yaqwsx/jlcparts
GitHub
GitHub - yaqwsx/jlcparts: Better parametric search for components a...
Better parametric search for components available for JLC PCB assembly - yaqwsx/jlcparts
yep 100%
dude runs the internet
we sponsor him as well
xkcd: Dependency

Someday ImageMagick will finally break for good and we'll have a long period of scrambling as we try to reassemble civilization from the rubble.
100%
I don't know that he lives in Nebraska, but otherwise...