bennymeg / Fabrication-Toolkit

An JLC PCB Fabrication Plugin for KiCad
Apache License 2.0
307 stars 53 forks source link

Rotation wrong on bottom of board for JLCPCB #51

Closed revk closed 1 year ago

revk commented 1 year ago

The positions.csv is generated with Mid X, Mid Y, and Rotation "as viewed from top". This seems to be how KiCad works.

E.g. this is two 0603 resistors with rotation of 10 degrees.

Screenshot 2023-04-13 at 10 20 07

KiCad 3D view shows clearly.

a b

As you can see the 10 degree rotations is "as viewed from top".

The positions.csv file looks like this... showing both as 10 degrees.

Designator,Mid X,Mid Y,Rotation,Layer
R1,3.0,5.0,10.0,top
R2,7.0,5.0,10.0,bottom

However, when loaded on JLCPCB the rotation on the bottom is wrong, e.g

Screenshot 2023-04-13 at 10 13 08 Screenshot 2023-04-13 at 10 13 18

Clearly JLC are expecting the rotation "as viewed from above the component".

The positions.csv file needed is

Designator,Mid X,Mid Y,Rotation,Layer
R1,3.0,5.0,10.0,top
R2,7.0,5.0,350.0,bottom

This works as expected.

Screenshot 2023-04-13 at 10 16 40

If a rotation offset is applied, it works as you would expect, just added to the rotation, and could be used as a -20 offset to "fix" the bottom layer in this case, but that only works if rotated 10 degrees. Rotate 20 and you need to change the JLCPCB Rotation Offset to -40 to fix it. This is why the offsets seemed not to work. It is not the offset that is wrong, it is that all rotations on the back of the board need to be inverted, so as to be "as viewed from above the component" and not "as viewed from top" in the way KiCad works.

I think if the JLCPCB Rotation Offset is applied first, when present, to correct for whatever orientation JLC have used for the part, but then all bottom side rotations are inverted, it will be consistent and avoid having to tweak the back of every board.

This was obviously not obvious as rotations 0, and 180 did not show the problem, and 90 or 270 only showed on polarised components. But even a simple 0603, with no need for any rotation offset, breaks if placed at 45 degrees, so I think this is a definite bug, and should be fixed even with the backwards compatibility issues it would cause.

bennymeg commented 1 year ago

Thank you for contributing!