Making an Antenna in KiCad

Jon Neal

I recently had to make an antenna in KiCad for an RFID/NFC circuit board I am designing.

The chip I am using is the ST Micro CR95HF which so far seems to be pretty nice (cheap and well documented). ST Micro has an app note (AN3344) which handily goes through all of the steps required to design the antenna for this chip and they even provide a calculator for different antenna designs!

Wrong way to make an antenna

In KiCad make sure you don't start making the antenna as its own trace! In general when you start a trace in KiCad a net is assigned to it based on what you started the trace on (a pad or another trace). When you start a trace without having it attached to another feature it is assigned to net 0 (the default net). KiCad does not allow different nets to connect together. When you go to connect your antenna to an RF capacitor, for example, you won't be able to since both pads of the capacitor will have a different net number/name.

If you have already made this mistake there is one kludge you can use to fix it. KiCad files are very human readable and editable. You can use this to open the file in a text editor and manually edit the trace to assign it to a net.

First in pcbnew write down where your trace starts (X 181.5 and Y 84.5 in this example). Once you have this info open the .kicad_pcb file in a text editor. Near the top of the file will be a list the different nets in the format (net 1 "Net-(C1-Pad1)"). Figure the number of the net you want to assign to the antenna trace (net 1 in this example). Next search for the trace segment in this file. I did this by doing a search for the X coordinate (181.5). This pretty quickly led me to the trace: (segment (start 181.5 84.5) (end 181.5 65.5) (width 1) (layer F.Cu) (net 0)). To implement the fix all that is needed then is to change the net from 0 to 1 on this single segment.

The next time KiCad is opened you should be able to connect the antenna traces to the pads you want! I should mention as well that KiCad will assign this new net to the rest of the segments in the antenna. This little hack can work for any trace that this happened to by accident, but I would be careful in using this too much.

Right way to make an antenna

The recommended way to design an antenna in kicad is to actually make a module, also known as a footprint, of the antenna and then place this module manually in pcbnew. While it takes a little bit of effort to make it a module I think it is well worth it. If you want to move the antenna it is as easy as moving a footprint. It is also easy to replicate or use in another design if wanted.

To get the spacing of the antenna traces correct I used the grid size to make my life easier. I used a 1mm wide trace and one segment needed to be 40mm long. Since it needs to be an even mm number I switched the grid size to 1mm which makes it a lot easier to get the needed precision.

I started the trace by clicking on the grid and then zeroed out the coordinates in the bottom right by clicking the space bar. One important thing to note is that KiCad measures distances from the center of the trace. That means there is 0.5mm of margin on either side of the pointer. Since there will be 0.5mm on both ends of the trace I subtraced 2*0.5mm from the total distance I needed to go. It is then as easy as going in the right direction until the coordinates read 0 39.

Once I had done this for the entire outer rectangle of the antenna (remembering to account for the extra 0.5mm margin) I then had to start the inner traces. These needed to be 0.25mm from the outer rectangle. As such I switched to a 0.25mm grid, zeroed out the coordinates, and moved the trace until I saw one grid spacing between the new trace and the outer trace. Rinse and repeat for as many turns as needed!

My antenna ended up looking like this:
CR95HF antenna in KiCad (This screenshow was taken with a very recent build of KiCad and shows off the cleanness of the new OpenGL rendering mode called GAL).

Hopefully this will be useful to someone else. If you have any questions feel free to send me an email or a message on twitter.

Copyright 2019 - Thoughts and ramblings
Theme by Nathan Westfall using Foundations
Copyright 2019 - Thoughts and ramblings Built by Nathan Westfall using Foundations