1
\$\begingroup\$

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?

\$\endgroup\$
2
  • \$\begingroup\$ An other "no, but ..." option: Write code in your favorite programming language to generate your footprint as an SVG, then convert that to a KiCAD using svg2mod. \$\endgroup\$
    – hoijui
    Commented May 27, 2021 at 5:08
  • \$\begingroup\$ I did not test this, but yet an other way might be, to use KiCadStepUp, where you could import your footprint from KiCad into FreeCAD, edit it parametrically, and export it back into KiCAD. \$\endgroup\$
    – hoijui
    Commented May 27, 2021 at 5:19

3 Answers 3

3
\$\begingroup\$

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:

  • Move all six of the parts to the top-left corner of the page (0,0).
  • Press the "Polar Coordinates" button on the left bar. Notice that the bottom bar middle now reads in polar coordinates (radius r, angle theta.)
  • 360°/6 = 60° for each angle. Angle (\$\theta\$) convention in PCBNew is: 0° is the 3 o'clock position, 90° = noon, 180° = 9 o'clock, and after this it inverts (-180°), -90° at the 6 o'clock position, and back to -0.
  • \$r = \frac{1}{2}d\$ , so radius r = 20mm.
  • Unfortunately, part positions cannot be entered in polar notation. We will estimate using the polar read-out in the bottom statusbar.
  • Click 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.
  • Click 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.
  • Click M and move D3 r = ~2.0 and theta = ~120.
  • Click M and move D4 r = 2.0 and theta = 180 or -180.
  • Click M and move D5 r = ~2.0 and theta = -120.
  • Click M and move D6 r = ~2.0 and theta = -60.
  • Click E over each LED and enter their rotation angles (0,60,120,180,240,300.) This is the result:

KiCAD Polar Coordinates

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:

  • To convert polar (radius r, angle \$\theta\$) to Cartesian (x,y): \$\quad x=r\cdot \cos \left(\theta \right)\quad \:y=r\cdot \sin \left(\theta \right)\$
  • Element 1, 0°: \$\quad\cos\left(0\right)\cdot20 = 20\quad\sin\left(0\right)\cdot20 = 0\quad\$ (20,0), rotate the part 0°
  • Element 2, 60°: \$\quad\cos\left(60\right)\cdot20 = 10\quad\sin\left(60\right)\cdot20 = 17.32\quad\$ (10,17.32), rotate 60°
  • Element 3, 120°: \$\quad\cos\left(120\right)\cdot20 = -10\quad\sin\left(120\right)\cdot20 = 17.32\quad\$ (-10,17.32), rotate 120°
  • Element 4, 180°: \$\quad\cos\left(180\right)\cdot20 = -20\quad\sin\left(180\right)\cdot20 = 0\quad\$ (-20,0), rotate 180°
  • Element 5, 240°: \$\quad\cos\left(240\right)\cdot20 = -10\quad\sin\left(240\right)\cdot20 = -17.32\quad\$ (-10,-17.32), rotate 240°
  • Element 6, 300°: \$\quad\cos\left(300\right)\cdot20 = 10\quad\sin\left(300\right)\cdot20 = -17.32\quad\$ (10,-17.32), rotate 300°

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 =.

\$\endgroup\$
2
\$\begingroup\$

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 (:

\$\endgroup\$
0
1
\$\begingroup\$

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.)

Option 1 the array tool:

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.


Option 2: move exactly tool

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.