Designing spiral or helix [SOLVED]

Hi Joan , I’m starting to become more familiar with the editor, I managed to replace batch many words “F.Cu” (in less than one minute) …también I created with the same code another spiral to the Bottom “B.Cu”
the question is when I want to turn the spiral in the opposite direction, what script should I write?
Thank you very very much

look in the py script up there & scroll to the end of it… there are the values you need to change:


if __name__ == ‘__main__’:
Center = [115.0,105.0] # x/y coordinates of the centre of the pcb sheet
Radius = 4.55 # start radius in mm
Sides = 36.0
StartAngle = 180.0 # degrees
TrackWidth = 0.2
TrackDistance = 0.3
Turns = 8
Spin = 1 # ccw = +1, cw = -1
Layer = “1cu”
Net = “1”
print FNC_spiral (Center,

2 Likes

First of all, I too would like to express my thanks for drafting the report on this serious topic.
I was absent these days and now returning again this PCB design … Well, I see that I will be little room in the center, please, would like to see if you can send me a script code with more turns toward the center: 11 in total .
The separate (limit PCB and first Turn) is 1.5 mm.
The value of separation is 0.2 mm “turns”
values remain 0.2 thickness / diameter of 15.5 mm PCB
You are a partner of excellence :smiley:

Just change the Turns value in the python script from 8 to 11, run it, safe it’s output in a txt file as per above guide and put it into your kicad_pcb file.
I know you can do it.

::smiley:Thanks Joan Sparky I have done it.!!!

To change spin; change negative to opossite and positive to opossite?
:sweat_smile:

The line you’re interested in:

Spin = 1 # ccw = +1, cw = -1

Spin = 1 is the code, anything behind # (hash) is a comment and usually refers to the code before the hash and will not be interpreted as code

So, to make it spin clock wise you have to set:

Spin = -1 # ccw = +1, cw = -1

1 Like

image

How could I design a spiral inductor with increasing track width as shown in the figure?

adjust the radius and track width every segment or turn in the code?

1 Like

Okay. I see in the code that I can change the track width. I have other things to consider first before designing the inductor. I will ask here again when I start with the inductor.

Thanks a lot :slight_smile:

Hi @Joan_Sparky,

I would like to design a self-resonator that consists of two superimposed copper spirals printed on both sides of a substrate as shown below.


As I am new to both KiCad and Python, I find myself struggling with programming to obtain the correct layout. Also as you can see, the wanted spirals are not “true” spirals. It rather looks like rounded arcs bonded by a constant straight track. Would you please guide me into how to modify your previous script to adjust the wanted layout ?
Many thanks in advance

spiki might be of use to you.

1 Like

Hi @MitjaN,

Thank you for sharing the link!

(Yes, I am aware this is a 5 year old thread)

I sort of like the spiki program.
Here a picture of a real-world application.
The product is a mass produced one-time Key generator, so every cent counts.
The screws in the back are used as some kind of electrical interface, probaby for programming the device in the factory.
The inductors on the screw terminals help in preventing ESD damage and such, together with the spark gaps below it. I find it a real beautiful design. Dave probably would have recognized it also if he wasn’t talking all the time and focusing on making his video’s.

Very spiral alike objects can be made out of half circles by cheating.
Example:
Assume you have concentric half circles with odd diameters (1, 3, 5, 7mm) on the left, and with even (2,4,6mm) on the right, then the end match up perfectly by shifting the left set 1/2mm up or downwards.

Having a separate application for Spiki (how does that PyQT stuff work?) seems a bit much. Having such a spiral inductor generator as a Footprint Wizard in KiCad itself seems to be more useful to me.

I’m also pretty green considering Python, and was surprised by:

useNLopt = True
try:  # check if nlopt is available
    import nlopt
except ImportError:
    useNLopt = False

which suggests spiki should compile / run without the inductor estimation stuff…

1 Like

That concentric circles trick is great! Thanks.
FYI I had to shift the left set up/down 1.0 mm

That being said, the python script from Joan is a great solution if you need more control over your geometry.

Hi together,

came to this problem as well today and found a very pragmatic approach. Since I use Inkscape to create PCB Art from time to time I had the idea to use the spiral tool of inkscape to generate a nice spiral.

  • Use Inkscape to generate the spiral (by size, turns)
  • export as .dxf
  • create new part and import .dxf to layer cmts.User (set linewdth!)
  • import again to layer dwgs.User, mirror, put above
  • add vias (pads with number “~”) in center to connect top and bottom layer
  • add pads to start and end
  • save and open .mod file in text editor
  • replace “cmts.User” by “F.Cu” and “dwgs.User” by “B.Cu”
  • done!


3 Likes

H together,
it is nice to learn how to make a spiral, but I’m getting interested in the oval coil shape
who can help me to know what I should modify and how to get it

Great suggestion from Knochi. If you don’t want to use a Python script, this is actually quite practical.

The only limitation is that you can’t go to inner layers from a footprint. I found a workaround : the .dxf file can be imported directly in Pcbnew. The process is actually quite simple :slight_smile:

  • go to File --> Import --> Import Graphics
  • select your file, specify the trace width, select Cmts.User for layer
  • then go to Edit --> Edit text & Graphics properties
  • in the dialog box, check the “PCB graphics items” box, check the “Filter items by layer” box, and select “Cmts.User” in the dropdown menu
  • under action, check the “set to specified values” box, then select which layer you want to spiral to move to in the dropdown menu

Here you go, you have it in just a few clicks, no text editing at all. :slight_smile:

(edit : I’d share a screenshot for convenience, but I haven’t found how to upload it here)

1 Like

The link to KiCAD_CopperSpiral_v3.py KiCAD_CopperSpiral_v3.py (6.3 KB)
seems to be broken. I do get an XML error. Is there a ‘good’ link to the file?

I scanned the above posts and didn’t notice any comments about the Simple approach (perhaps I just missed it…)

Without using a Plugin:

• Create the Spiral in Inkscape/other, Save as .PNG
• Load the .PNG into Kicad’s Bitmap_To_Component Convertor. Export to User layer (that creates a Footprint (.mod) file
• Place the Footprint into a PCB
-Double-click and Edit the Library Footprint > Change the User layer to a Desired Layer

Screenshot shows the Footprint before and after the layer change edit (now on B_Cu)…

I used your code & run with online compiler. I also added the row
Spin = -1
I get the result as below. Could u please explain it.

" A module you have imported isn’t available at the moment. It will be available soon."

This is the run code:
import sys, os
import shutil
import math
import itertools
from copy import deepcopy

0 1 2 3 4 5 6

LIST_elmt = [" (“,” (start “,”) (end “,”) “,” (layer “,”) “,”))“]
#LIST_elmt = [” (gr_line (start 131.571908 182.314571) (end 112.874456 120.68499) (angle 90) (layer Dwgs.User) (width 0.1))“]
#LIST_elmt = [” (segment (start 118.7 106.7) (end 119.4 106.7) (width 0.25) (layer B.Cu) (net 0))"]
DICT_elmt = {“seg” : [“segment”, "(width ", "(net "],
“arc” : [“gr_arc”, "(angle ", "(width "],
“lne” : [“gr_line”, "(angle ", "(width "],
}
DICT_lyr = { “dwg” : “Dwgs.User”,
“cmt” : “Cmts.User”,
“cut” : “Edge.Cuts”,
“fcu” : “F.Cu”,
“bcu” : “B.Cu”,
}

def FNC_string (element,
STR_start, #1
STR_end, #2
Angle, #4
layer, #5
width,
):
STR_line = “”
“”"
0 1 2 3 4 5
LIST_elmt = [" (“,” (start “,”) (end “,”) “,” (layer “,”) (width “,”))“]
“””
for i in range(len(LIST_elmt)):
STR_line += LIST_elmt[i]
if i == 0:
STR_line += DICT_elmt[element][0]
if i == 1:
STR_line += STR_start
if i == 2:
STR_line += STR_end
if i == 3:
if element == “seg”:
STR_line += DICT_elmt[element][1]
STR_angle = “{:.1f}”.format(width)
else:
STR_line += DICT_elmt[element][1]
if element == “lne”:
STR_angle = “90”
else:
STR_angle = str(Angle)
STR_line += STR_angle + “)”
if i == 4:
STR_line += DICT_lyr[layer]
if i == 5:
if element == “seg”:
STR_line += DICT_elmt[element][2]
STR_line += str(Angle)
else:
STR_line += DICT_elmt[element][2]
STR_line += “{:.2f}”.format(width)
STR_line += “\n”
return STR_line

def FNC_polygon (element,
STR_start, #1
STR_end, #2
Angle, #4
layer, #5
width,
):
STR_line = “”
“”"
0 1 2 3 4 5
LIST_elmt = [" (“,” (start “,”) (end “,”) “,” (layer “,”) (width “,”))“]
“””
for i in range(len(LIST_elmt)):
STR_line += LIST_elmt[i]
if i == 0:
STR_line += DICT_elmt[element][0]
if i == 1:
STR_line += STR_start
if i == 2:
STR_line += STR_end
if i == 3:
if element == “seg”:
STR_line += DICT_elmt[element][1]
STR_angle = “{:.1f}”.format(width)
else:
STR_line += DICT_elmt[element][1]
if element == “lne”:
STR_angle = “90”
else:
STR_angle = str(Angle)
STR_line += STR_angle + “)”
if i == 4:
STR_line += DICT_lyr[layer]
if i == 5:
if element == “seg”:
STR_line += DICT_elmt[element][2]
STR_line += str(Angle)
else:
STR_line += DICT_elmt[element][2]
STR_line += “{:.2f}”.format(width)
STR_line += “\n”
return STR_line

def FNC_spiral (cntr, # (x,y)
radius,
sides,
startangle,
tw, # track width
td, # track distance
turns,
layer,
net,
):

STR_data = ""
baseX = cntr[0]
baseY = cntr[1]
segangle = 360 / sides
segradius = td / sides

for i in range(turns * sides):
    # central rings for HV and SNS
    startX = baseX + (radius + segradius * i) * math.sin(math.radians(segangle*(i) + startangle))
    startY = baseY + (radius + segradius * i) * math.cos(math.radians(segangle*(i) + startangle))
    endX = baseX + (radius + segradius * (i+1.0)) * math.sin(math.radians(segangle*(i+1.0) + startangle))
    endY = baseY + (radius + segradius * (i+1.0)) * math.cos(math.radians(segangle*(i+1.0) + startangle))
    STR_data += FNC_string ("seg", #type of line
                            "{:.6f}".format(startX) + " " + "{:.6f}".format(startY), # start point
                            "{:.6f}".format(endX) + " " + "{:.6f}".format(endY), # end point
                            net, # angle or net value
                            layer, # layer on pcb
                            tw, # track width
                            )
return STR_data

if name == ‘main’:

Center = [105.0,105.0] # x/y coordinates of the centre of the pcb sheet
Radius = 1 # start radius in mm
Sides = 24
StartAngle = 0.0 # degrees
TrackWidth = 0.4
TrackDistance = 0.9
Turns = 8
Spin = -1 # ccw = +1,cw = -1
Layer = "fcu"
Net = "1"

print FNC_spiral (Center,
                  Radius,
                  Sides,
                  StartAngle,
                  TrackWidth,
                  TrackDistance,
                  Turns,
                  Spin,
                  Layer,
                  Net,
                  )