Adding a logo to your KiCAD PCB
For PCB design I use the open-source schematic and PCB design software KiCAD. Its a great program and has gotten a lot better recently. It is unlimited in size, components and number of layers and has lots of the features of very expensive professional PCB layout software.
But… there are times when its not so obvious how to do what seems like simple tasks. One task I needed to do recently was to add a logo onto the silkscreen and the back copper layer of a PCB. This is a quick post collecting my experiences and the a procedure to do this.
Edit 27/6/2020: I realised this was a very heavily visited page on this website! I would now use the awesome svg2shenzhen add-on to Inkscape to create any layer KiCAD module from any SVG file. This is covered in detail in an article in this issue of Hackspace Magazine (free to download!)
Edit 1/12/2020: Link to module scaler site has been removed as it was taken over by a scam site. Please use above svg2shenzhen link above.
The steps involved are:
- Sort out your logo
- Add a white boundary around the logo
- Export as a .png or .bmp
- Use the bitmap2Component section of KiCAD to convert into a .mod file
- Resize the image, using an on-line conversion tool
- Remove the ‘bug’ section from the .mod code
- Use the library in your PCB design and import the module
I’ll go through them in more detail:
The first thing to do is sort out your logo. I use Inkscape or CorelDraw to create .svg images. You can also use any image file.
Add a white background to your image. There MUST be a white border all around your image. (This is required to sort out a bug later in the process….)
Export this as a .png or .bmp.
Open the ‘Bitmap2Component’ part of the KiCAD suite of utilities. This will open the Bitmap to Component converter.
This is the Bitmap2Component utility.
Load your logo bitmap/image file. In this example I have the open source hardware image. Its really big, hence you can only see a bit of it. It is best to use a large image and then scale it down, rather than use a small image where you will loose some of the detail.
Ensure this is set to ‘Negative’ and that the threshold level is correct (this is the level it converts to black or white). A negative image is required – the output will be anything WHITE in the image.
Save as a .mod module library. Save it somewhere where you will find it again.
Then we need to scale the image to the size required on your PCB. You will need to measure the size required, as you cannot scale this within KiCAD PCB. Luckily some clever folk have done an on-line KiCAD module scaler, which can be found here (Link now broken – Not now available). In this case I am making the image to be 0.4 inches (around 10mm). Here you can also choose which layer you would like the component to be on. I used both back copper (layer 0) and front silkscreen (layer 21).
Note 1/12/2020: These instructions are now redudant and the component scaler is no longer available through the link I had. Please use information at the top of this page.
Scroll to the bottom of the page, browse for your module library. You will also need the new width (in inches) and a name for your new module library (I tend to use the same name but with “_small” added).
Save as another module (.mod) library file.
Now lets have a look at it. You need to add this library to your PCB (go to preferences -> libraries and then use the ‘Add’ function). As you can see in this screen shot, there are two lines on the left and top edges. This is a problem with the ‘Bitmap2Component’ conversion software.
Click on the ‘Add module’ icon, as we want to add the new logo module.
Find it within the module list.
Urgh! What are those nasty lines doing?…..
Its been reported as a bug, but not yet fixed (13/12/12). So now what do you do?
The answer to this took me a bit of searching but, as usual, someone on the interweb (specifically this post) had done it before me. Basically the algorithm is ‘seeing’ the edge and creating a polygon. Using a white border around the logo means that this polygon is separate from the other polygon and so we can delete it.
All modules are text files with lists of the shapes and the co-ordinates between the points. So go to where your .mod file is saved and open the file with some kind of text editor:
Open up the .mod file as with a text editor.
The first polygon is the offending bit of code (highlighted in red). Delete the whole polygon section (from the DP line, including all the Dl lines, to just above the next DP line) and save it (I use the same name).
You can see (honest!) that each polygon starts with the line DP x x x x x x. There are then a load of Dl x x commands. Basically DP means Draw Polygon and the Dl are all the points within the polygon. The first polygon (DP) is the error section. We have to delete it and then save the file.
Now go back to your PCB and re-open the module:
The top logo is the one with the error, the bottom is the nice clean one without the lines. Yey!
You can see that the ‘bug’ lines have gone and you now have a nice logo to add to your board. Hope that helps you – I certainly had a couple of hours of head scratching.
I found a good youtube video explaining most of this after I had finished doing it and I was writing this post.
Update 3/7/14: There is another program to create KiCad modules from logos here: http://img2mod.wayneandlayne.com/
problem with the conversion error is that you cannot always erase that first polygon. in my case there was 10 polygons, first one was 98% of the file and next few are just few patches.
to get import correctly, one should simply use negative of the logo as an input BMP. then everything works fine. if needed use built in option to invert image in the BMP import wizard. hope this helps.
Thanks for the info.
i’ll check out that method (which sounds a lot easier) when I next need to do a logo.
Cheers,
Matt
Hi
The problem with the first polygon only appears if the image has no border. In this case the first polygon will be connected to the useful image data and you get the problem. To solve this (if inverting the image is not enough) you can add a border line all around the image (4-5 pixels will do), and then removing the first polygon will get you rid of the border and the eventual crappy lines without removing part of the real logo.
Walter
I confirm the creation of a negative image before using bitmap2Component to avoid the “invert bug”.
In addition to your (very good) tutorial, do you know how to import a logo with a 1:1 scale? In that case which DPI is expected?
Hi,
I’m afraid that I dont know that off the top of my head. To get a good resolution I have used a large initial image and the resized using the bitmap scaler online.
When I tried to have the logo at the sized I wanted it in the end (10mm I think) then the resolution was pretty terrible. I think this is due to the parameters in the Bitmap2Component part of KiCAD, although I am not sure if it is adjustable.
Not sure if that helps…
Matt
I have to insert a logo in the title block, both in the diagram and in the PCB, but I can not remember how I did it! I created different PCBs from different schemes, and in the squaring of the design there is this logo, but I can not remember the steps: I have the original JPG logo and I also tried to use the BITMAP converter but then I do not know how to import it into the final design . Does anyone know how to do it? Maybe with detailed steps, thanks
That module scaler is a phishing site and is totally harmful. I would appreciate not adding phishing links to your posts
Very sorry about the link. This has now been removed.
I wrote this article 8 years agao and it seems that site has been taken over by scammers.
Please use the svg2shenzhen inkscape add on as mentioned at the top of the artile.