Electronics Design

Electronics Design Using KiCAD

Group Assignment Page

This week’s group assignment covers the usage of tools such as power supply, multimeter, oscilloscope and logic analyzer.

How to Set Up KiCAD?

Download KiCAD

To download KiCAD, we go to their website and download the latest installment.

Clone and Install Fab Repository

After downloading KiCAD, we need to install the Fab library, so we can work with the specific parts that we have available in the lab. To do this, we go to the Fab Electronics Library for KiCAD repository. We can clone this repository with Git, so any updates done can easily be adapted to.

To add this library to KiCAD, we can follow the instructions outlined in the repository:

  1. Clone or download this repository. You may rename the directory to fab.

  2. Store it in a safe place such as ~/kicad/libraries or C:/kicad/libraries.

  3. Run KiCad or open a KiCad .pro file.

  4. Go to “Preferences / Manage Symbol Libraries” and add fab.kicad_sym as symbol library.

  5. Go to “Preferences / Manage Footprint Libraries” and add fab.pretty as footprint library.

Designing in the Shematic Editor

Adding

After we install our library, we can start designing our part. We create a new project and make sure to check “create a new folder for the project.”

The place symbol command allows us to place electronic parts into our designs. We make sure to choose our parts from the Fab Library. First, we add the XIAO board.

adding xiao board part

Using the add power symbol command, we should add a power input and ground to the XIAO board. At this point, we should also pay attention to the type of grid we are using. For now, we will stick with the default one (1.27mm).

adding power symbols adding power symbols

Then, we add the LED and resistor pieces from the same Fab Library

adding LED adding resistor

We can connect these parts together with the XIAO board using wires. We can also put custom names to parts by right clicking and edit main fields/ edit value.

connected circuit

Calculating the Resistance

We need to calculate the value that we give to the resistor. For this, we need to know the specifics of the LED that we are going to use. We can check the LED’s data sheet through the right click menu. But at this case, it was just a generic LED datasheet, so we checked the Fab database. Through there, we found the details in the product page.

We learned that the recommended forward current in 30 mA. The information that we need is the “forward current” and “forward voltage”.

forward current forward voltage

Then, we start our calculations. In KiCAD, we can add text through the add text command on the right menu. What we need to find is the required resistance. For this, we use the formula “V=I*R”, where V is voltage (volts), I is current (amps), and R is resistance (ohm). We need to convert the mA values to A for this to work.

We find 43 ohm as the required resitance. We dont have exactly 43 ohms in the inventory but we can use 49.9 instead, as the closest one.

calculations calculations

Adding Buttons and Modularizing

Next, we added a button. We use the same process for adding a part. But this time, we will not connect it straight to the board in the schematic, but modularize it. For this we can use the net label command on the menu. We put the button cable somewhere else and label it. This is how we can modularize schematics.

button

No Connection Flags

If there are pins that are not connected, we add “no connection” flags to them, so the electronics rules checker does not see them as errors. These are displayed as small blue crosses.

Adding PWR_FLAGS

We can run the electronics rule check now, but it fails. Because there is no power input to the circuit. For this, we need to add power flags to the 3.3V output and ground. We add it though the add power symbols. After this, the rule check is succesfull.

rule check fail power flags

Adding NeoPixel

After completing the tutorial, I decided to try adding the neopixel component. After adding it through the Fab Library, I checked out it’s datasheet.

neopixel pinout neopixel pinout

I assumed I should hook it up to one of the analog pins, because I want to send a range of data, not only on or off. So I chose D3 as it’s data pin. Since it requires 5V, I hooked it up to the 5V power pin. I ran electrical rules check but got two errors.

neopixel connection neopixel error

I deleted the pwr flag connected to neopixel ground, one of the errors went away. The other error said DOUT pin not connected. According to the schematic, it doesn’t have to be connected, so I added a “no connection” flag, which solved the problem.

neopixel error

But when I tried to update it in the PCB board editor, it said no footprint. So I went back to the place symbol menu and relized I had not selected a footprint. The error got solved when I added this.

neopixel connection neopixel error

Adding Potentiometer

My idea was to make the neopixel be controlled by a potentiometer and map it to the RGB values. So when I turn the knob, I can move through the RGB spectrum. After looking at the data sheet, I connected one end to 5v, one end to GROUND and one end to an analog pin.

potentiometer

Using the PCB Board Editor

Update PCB from Schematic

The next step is to use the “PCB Board Editor” workspace. After opening the file, we should execute the “update PCB from schematic” command. If there are no errors, our schematic is imported.

We need to flip the board, since we are making a shield for the XIAO, and it makes sense to place the components to the other side of the board. We select board, press f. The pins turns blue. In this context, F means front and B means back.

pcb board editor

Placing Components and Drawing Edges

In the PCB board editor, there are many layers we can use to draw different parts of the design. For the actual shape of the board, we use “edge cut”. Edge cut allows us to make any shape we want out of the board.

The faint blue lines between, called a rats nest, shows connections between the components. We can move the components around, rotate them with “R” and place them wherever we like. Don’t forget to switch to “1mm” grid when doing this.

pcb board editor

Editing Net Classes and Adding Connections

Before adding connections between our placed parts, we need to edit pre-defined sizes. These are limiting values that depend on our manufacturing method. We wrote the values according to CNC milling, which is the method that we are going to use.

We go to edit pre-defined sizes thorugh the upper menu and select net classes. We changed the first three values: “clearance”, “track width” and “via size” to the values below.

edit net classes

Now we can start adding connections. We can change the grid to 0.1mm to allow for more flexibility. We then switch to “Front Copper Layer” to add the connections.

We can use the connect tool and connect the components manually. We can go a certain point an hit F to connect the rest auromativally. Or if we select a pad and click shit+F that completes the whole route automatically.

It is very important to edit net classes before we start drawing, because it will not update by itself.

At this point, I experimented with different connection configurations. Since it was my first time doing this, it was very hard to actually find a connection setup that did not interrupt each other’s paths. It was like a game of escaping a maze.

experimenting connections experimenting connections

Most of the configurations I tried did not work at all. Finally, I found a placement that allowed me to connect everything together.

working connections

The final step is to run “design rules checker”. However, I had an issue here: The footprint of the neopixed LED doesn not seem to be in accordance with our milling rules.

design rules issue

Questions and Issues

  1. Why does the footprint cause issues in the design rules checker? Should I have used a different one?

  2. What part is the “header connector”? There are many of them in the Fab Library, which of those should I have connected?

  3. Is the potentiometer and neopixel LED connected correctly?

Exporting Gerber Files

After receiving answers to these questions from Kris, I was ready to export. Before exporting, I decided to make some changes in my circuit board.

My last design featured a neo-pixel LED, however I realized after talking to Kris that we did not have it in the FabLab inventory. I accidentally used something from the default KiCad libraries.

I found the neopixel LED that was present in the lab, but couldn’t figure out how to wire it. I will have to ask it later in this week’s review. Anyway, I decided to not use the neo-pixel for this assignment.

My updated design consists of LEDs(x2), resistors(x2), button(x1) and potentiometer(x1). I also changed their orientation to make the paths simpler.

old design new design

new design

To export our design as a gerber file, we follow these steps:

  1. Choose the “Plot” option on the top bar
  2. Choose gerber as the output format, and select directory
  3. Select the layers we want to export
  4. Include layers: Front copper layer
  5. Plot on all layers: Edge cut
  6. Uncheck footprint values and reference designators since we’re doing it ourselves
  7. Don’t generate gerber job file
  8. Use extended x2
  9. Uncheck include netlist
  10. Hit plot

At this point, I got an error saying “width correction constrained”. I closed the windows, did it again, and it solved itself.

plot window

For drilling the holes, we do the following:

  1. Choose “generate drill files”
  2. Change drill file format to Gerberx2
  3. Click “generate drill files” again
generating drill files

This will create two files: “plated through holes” and “non-plated through holes”. Plated through holes are taken into account in the milling process in Coppercam. Non-plated through holes are used for mechanical purpoeses. So the only file we need is the PTH file.

We can now close the window and go to gerber viewer in KiCad, and do the following:

  1. File>Open gerber plot files
  2. Open f_cu gbr and pth gbr

At this point, I realized that the gerber file I created had only consisted of the lines between the components. This would work fine, but the milling process would take longer since it would have to mill the whole surface but the connection lines.

wrong gerber file

In order to fix this, I learned that I would have to create a “ground plane” in KiCad. This way, I could avoid unneccessary connection lines for connecting to ground since the whole surface would be ground. This would also save a lot in milling times.

To do this, I went back to the PCB editor and added a “copper zone”. I selected the front copper layer and “PWR_GND”. Then, we just have to draw an outline for the copper zone.

creating ground copper zone creating ground copper zone

I went back and re-did the same steps, and exported my gerber files.

This page includes documentation of work completed during Fab Academy Academic Overlay 2023 at Aalto University New Media MA Program. Due to the academic overlay's structure, electronics design week was preceding electronics production week. To read more about how this board that I designed in electronics design week was manufactured and tested, see Electronics Production week from the link below.

Electronics Production Week

Source Files

Week 8- Electronics Design