LibrePCB / librepcb-parts-generator

A collection of scripts to generate parts for the LibrePCB default library
MIT License
7 stars 14 forks source link

Incorrect pitch in some SO packages #101

Closed ii8 closed 1 year ago

ii8 commented 1 year ago

In some packages generated by generate_so.py the pitch of pads is inconsistent, some gaps are correct and others are too small or too wide. This is because the script calculates the correct coordinates of the pads and then rounds them seemingly arbitrarily so they end up wrong. Is there some reason for this or can I make a PR to remove the rounding? It looks like it was a deliberate choice but to me it looks wrong.

https://github.com/LibrePCB/librepcb-parts-generator/blob/4208cd49d8900be0d95c9bc663e455db7cbed829/generate_so.py#L72-L89

rnestler commented 1 year ago

Maybe @dbrgn can comment, since he authored it: https://github.com/LibrePCB/librepcb-parts-generator/commit/5db97430e116ea36aac331646b287daab2ee3fe1

But rounding to 3 decimal places should result in just 1um error, right? Or is there some kind of accumulating error?

ii8 commented 1 year ago

Hm, the error I'm seeing is bigger, one gap 0.64mm and then the next one 0.02mm bigger (looking at TSSOP28P65_970X640X120L100X30) So I was possibly hasty and the rounding code above might not be the cause of the problem.

ii8 commented 1 year ago

Yes, my mistake, that commit you linked actually fixes this issue, 3 decimal place rounding is needed because of packages that have pitch with two significant figures (if there is an even number of pins their position is offset by half the pitch which can have 3 decimal places if the pitch has only 2). So the problem is just that the libraries have not been updated from the fixed script.

Although I wonder if using decimal arithmetic would be better than binary floating point for these calculations to avoid having to figure out how to round it right.

rnestler commented 1 year ago

So the problem is just that the libraries have not been updated from the fixed script.

That is an issue though. We should definitely update them.

ubruhin commented 1 year ago

That is an issue though. We should definitely update them.

Done in https://github.com/LibrePCB-Libraries/LibrePCB_Base.lplib/pull/101

Thanks for reporting @ii8!