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.
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. 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).
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.
There is another program to create KiCad modules from logos here: http://img2mod.wayneandlayne.com/