I need to place components in a circle of a certain diameter, with a certain pitch, and angled evenly.
Is possible to do it in KiCAD automatically?
I need to place components in a circle of a certain diameter, with a certain pitch, and angled evenly.
Is possible to do it in KiCAD automatically?
No, but you can do it "manually" for any size and number in PCBNew using the magic of polar coordinates. Say you wanted six LED's aligned to the circumference of a 40mm diameter circle:
M
over the stack of parts, use the arrow keys to position D1 such that r is 2.0 and theta is 0. Click to place D1.M
over the remaining parts, move D2 such that r is ~2.0 and theta is ~60. It will help to make the snap grid very small.M
and move D3 r = ~2.0 and theta = ~120.M
and move D4 r = 2.0 and theta = 180 or -180.M
and move D5 r = ~2.0 and theta = -120.M
and move D6 r = ~2.0 and theta = -60.E
over each LED and enter their rotation angles (0,60,120,180,240,300.) This is the result:Now drag a box around the whole group and move with M
.
To calculate Cartesian coordinates (polar button not clicked, for accurate X,Y positions) Trigonometry must be used. Negative theta values will also work here. Perhaps this will help with a python solution:
This may not be fast nor easy, but it's precise.
Note many calculators differ on how trig functions are entered. On the Windows 10 scientific calculator for instance, these must be entered in this order: 60 COS * 20 =
.
Nope, not without knowing some python. (you can write a script yourself which does it)
Otherwise you are left to do the same as the rest of us; Excel sheet, some excel math, and then a ton of manual work putting all the exact coordinates in the footprint data for each footprint.
If you want to look into writing a python script to solve the problem for you then here are some hints to get you started; All KiCad files (the .kicad_pcb file included) are plain-text files. If you open the .kicad_pcb file in a text editor (such as Notepad++ for instance) then you will be able to see the whole pcb layout described in plaintext, and it is easy to read..
If you scroll down into the text file (the .kicad_pcb file) you will start finding stuff like this;
(module MYCOMPANYNAME:MYMODULENAME (layer F.Cu) (tedit 5C925A16) (tstamp 5CAD3543)
(at 92.5 95.25)
(path /5D633F7C)
(attr smd)
(fp_text reference J3 (at 0 6.604) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value 87832-0406 (at 0 -7.112) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start -0.762 4.191) (end -1.27 4.191) (layer F.SilkS) (width 0.15))
(fp_line (start -1.016 3.81) (end -0.762 4.191) (layer F.SilkS) (width 0.15))
Pay attention to the line that says; (at 92.5 95.25), this is the position of the specific module MYMODULENAME.
If you know a bit of python then it is fairly easy to write a script which opens the .kicad_pcb file, finds the specific modules that you want to place in a circle, and writes the correct positions to these.
But this script would either have to be written specifically to your use case, or be written more generically, in which case it is a whole SW project on its own (:
A bit late to the party but there are ways to do what you want without math or python. All below assumes version 5.1 but similar tools existed in previous versions as well.)
Sadly this tool does not allow one to use any other origin than the main coordinate system. (this is why this is a bit more complex) It further is not an option if you have different footprints to align.
Put your first part correctly rotated with distance radius relative to the main coordinate origin (top left corner of the worksheet, example with 0 rotation at x= radius, y=0)
right click on it and select array tool. Switch to polar array and enter your intended settings (number of parts, should it rotate, ...) and press ok.
You will now have a circle of parts. Change their references manually to fit the schematic and possibly delete the duplicates that were originally placed by the update from schematic tool. Run that tool again but tell kicad to use the reference designator (re-associate by reference) to ensure both schematic and pcb are in sync.
A bit more work but does not require reassociating the footprints.
Place all your components where the first one should end up and rotated like you want them.
Place the auxiliary coordinate origin at your intended center.
Right click on the first one and select move exactly (crtl+m) Select rotate around drill and place origin (this selects the auxilary coordinate system) Enter the intended rotation for this part and click ok. Repeat for all other parts.