Week 07

This week we were supposed to explore the electronics equipment at the lab and redraw the Hello Board, add new parts to the design, make it and test it. Below are some notes from the lecture.

The Art of Electronics - Neil’s recommended electrinics guide.

Octopart - a search engine for parts.

Eagle - electronics design tool that used to be a German company, then got bought by a electroncis part distributor and now is a property of Autodesk.

KiCad - open source PCB design tool.

Microelectronics fabrication - Microfabrication is the process of fabricating miniature structures of micrometre scales and smaller.

Integrated circuit design - Integrated circuit design, or IC design, is a subset of electronics engineering, encompassing the particular logic and circuit design techniques required to design integrated circuits, or ICs. ICs consist of miniaturized electronic components built into an electrical network on a monolithic semiconductor substrate by photolithography.

Spice - circuit simulation.

Verilog - programming language for designing integrated circuits.

Exploring Test Equipment

The tool that I use the most in my electronics work is the multimeter. I mostly use it to check if there is connection between parts that have to be connected or the opposite, the connection is not there where there should be no short.

Multimeter

The red and black connector are the two main components of the multimeter. The multimeter can be used to measure things related to altering current (AC) and direct current (DC). Altered current is the current that we can access through the electricity sockets in the room. It is usually 230 or 220V and the altering part means that the electrons alter the direction, go there and back in the cable.

However we mostly use DC throughout the course. It comes in many standard flavours. Most of the time we use 5V and 3.3V. In car electronics the stantard voltage is 12V (24V in military vehicles). In DC direct means that the current always flows in one direction from + to -. However in physics the electrons actually flow in opposite direction, but it was discovered after the language of describing electronic circuits has gone too far already.

The multimeter has many modes. I will describe a few of them, the ones that I tend to use the most. To measure voltage, use mode 1. In order to try that out, connect the red and black probes to the terminals of a battery.

Mode 1 can be also used to check the direction of the current.

Usually the current flows from red probe to black. In that case the voltage is positive. If for some reason the current is reversed, the voltage measurement is negative.

Another feature of the multimeter that I use the most is the mode for checking shorts. It features the number 2 in the image. Use the button 3 to select how the multimeter should notify you. I usually go for the audio feedback or the beep. When there is connection between the red and black probes, the multimeter emits an annoying sound.

By using a combination of 2 and 3 one can get to modes that are used to measure resistance of a part in a circuit which is useful if a resistor has no label or one is experimenting with other resistive materials.

To measure currents as strong as 10 amperes, one should plug the black probe into the 10A socket. One should remember to return the mode switch to the OFF state after doing her job.

PCB Design With Eagle

YouTube tutorial about drawing Schematic.

YouTube tutorial about the Printed Circuit Board Layout part.

Summary: Add parts and form the connections in the Schematic View. Lay out parts and design board for production process in Board View.

Making the Hello Board

I chose Eagle as the primary software for designing the board, but leave KiCad as the advanced task for this assignment. Another reason for choosing Eagle first is that it is used by many and integrates with Fusion 360.

The following is the workflow that I intend to use.

  • Create new project in Eagle.
  • Draw the schematic.
  • Add extra components.
  • Create layout.
  • Create PNG.
  • Parse PNG in Mods to create toolpaths.
  • Mill the PCB.
  • Solder components.
  • Programm it.
  • Test it.

First step is to create a new project in Eagle for the Hello board. I named it hello. Import the fab.lbr by copying it into /path/to/eagle/lbr folder. Create a schematic drawing by right-clicking on the hello project and choosing New → Schematic. Save it with CTRL+S and call it hello.sch.

We have to tell Eagle that we want to use the fab.lbr library as the source for our components. To do that, go to Library → Open library manager click on Browse and select the fab.lbr file. For some reason I could not find it in the InUse and Available lists.

Adding components to our schematic sheet is the next step. To add components, one has to click on the Add icon in the toolbar. The ADD window will open.

Add Components Dialog in Eagle

Below is a list of components we need for the base design.

  • supply1/VCC
  • supply1/GND
  • fab/attiny44-ssu
  • fab/resonator
  • fab/res-us1206fab
  • fab/cap-unpolarizedfab
  • fab/avrispsmd
  • fab/ftdi-smd-header

I had problems with finding a proper header part for my design. In the Fab Academy tutorial the recommended SparkFun libraries link was broken, thus I installed the official SparkFun libraries and I failed to find the Header 6 part. I added the CONN_06/CONN_06SMD part instead and rewired the connections in the schematic. The new part has better visual representation fot the PCB layout view in Eagle.

Also, it makes it much easier to bridge the design with reality if you look up an actual physical reference of the part that you are looking for. In my case I found some headers that are available at the Fab Lab BCN and tried to see the connection between them and the ones that can be found in the library.

Hello Board Eagle Schematic

To finish the base iteration of the Hello World PCB design, I switched to the layout design mode in Eagle. The problem there was to understand the correct workflow of things and where to set critical values. The following is how I did it.

  • Layed out the parts according to a reference design.
  • Resized the canvas to match the layout.
  • Used Rastnest to re-calculate shortest airwires.
  • Use route to route traces by hand. The wire will turn red as you route it into place.

It is importand to set design rules as nothing in the design should be smaller than 16mm or 16mil. In order to access the EAGLE Design Rules dialog, type drc in the command line field and hit ENTER. Go to Clearance and set everything to 16mil. In order for the traces to be 16mm, you can select existing traces, right-click on them (while using the group tool), selecting Properties and setting the Width value to 16 (millimeters).

Eagle Design Rules Dialog

In order to set the width for all the traces that will follow, select the Route tool (or type route and hit ENTER) and set the Width to 16 (millimeters) in the field visible in the top parameter bar of the window.

Changing the Width of Existing Traces

Following the reference design I also had to use a few tricks to get the job done. One if them was using 0ohm resistors to hop over routes that get in your way. I first checked if there are 0ohm available at Fab Lab BCN, there were, thus I did the following. I added a new resistor component in the schematic. I identified the connection that needs to hop over another one, which in my case is VCC jumping over ground while trying to reach the VCC pin of the FTDI jumper.

Using 0 Ohm Hop-Over Resistors

Another feature that can help is using the grid (type grid in the command line to open the panel). Select the On radio button in the Display section, set the Size to, say, 16 (millimeters) and hit OK. You should be able to see rectangles that you can snap your routes to in the EAGLE layout view now.

Grid Adjust

Run erc (in the schematic view) and drc (in the layout view) to check electronic rules and design rules when you feel like your design iteration is finished. I got two warnings when checking electronic rules: CTS and RTS pins did not have any connection. My question was if one should connect them to GND. Answer: no as we will not use them. DRC revealed a few unfinished connections and the wiring of the 0ohm resistor had to be adjusted.

Next step was to use additional components. I went with the following list of additional components.

  • fab/LEDFAB1206
  • 2x fab/RES-US1206FAB
  • fab/6MM_SWITCH
  • 2x supply1/GND
  • supply1/VCC

For the values I am going to use 500ohm for the LED resistor and 10Kohm for the button resistor. There are 2 new pins that are used: PA7 (6) that we are going to name LED; PA3 (10) that we are going to name BUTTON. The LED needs extra resistor to reduce the load, so the LED does not explode. For the button connection we also need to use a resistor, which is called a pull-up resitor. To understand the concept of a pull-up resistor I went on to read a tutorial from SparkFun.

The main difference between pull-up and pull-down resistor is that the pull-up resistor is connected to VCC, but pull-down to GND. The pull-up resistor adds extra load to the circuit between the input pin and VCC in order to avoid short when the button is open. The input pin still reads HIGH and does not explode because of the resistor. When the button is closed, the current flows from VCC through the resistor to GND and the input pin feels the difference and reads LOW.

What resistance in ohms to choose for the resistor? One should go with something between 10Kohm to 100Kohm. The input pin has another resistor there that is considered to be around 1Mohm. You can think of it as a voltage divider. The less the resistance of the pull-up resistor, the higher the voltage that is supposed to trigger HIGH. Generally it should be less than the resistance of the internal resistor.

If you want more precision in choosing the right pull-up resistor, use the formula I found on electronics-tutorials.ws. For TTL signals a range from 2.0V to 5.0V is considered as HIGH.

Use the formula below to calculate the maximum pull-up resistor value, here to reach 2V.

Pull-up resistor formula

It would be nice to get a voltage that is between 2V and 5V. How about 3.5V. When we place the numbers in the formula we get the following.

(5V - 3.5V) / 20µA * 10-6 = 1.5V / 0.00002A = 75Kohm

In the case of 10Kohm we are aiming for 4.8V.

(5V - 4.8V) / 20µA * 10-6 = 0.2V / 0.00002A = 10Kohm

I am still looking for a way to extract the ATTiny44 I/O pin sink current value. 20µA works well in this scenario, but I have no idea what the actual value of an ATTiny44 is.

It took some time and an additional 0ohm resistor to get the layout right and I got so far to have enough courage to add text. The trick with text is that it has to be vector text in order to take into account the design rules of the layout.

Final Schematic and Layout

Before starting to mill, I realized that my design is 5mm bigger than the FR-4 board I wanted to use. I went back to EAGLE to make the design even more compact.

Later, when cutting traces, I noticed that the scale of the board is larger than it should be. It seems to be because of a bug in EAGLE–when exporting PCB as an image, it scales it up. I was waiting for the SRM-20 job to finish in order to be able to tell how much it was scaled up in order to be able to fix the problem in Gimp image editor.

If using EAGLE on Mac: there is a bug when exporting PCB as an image; it scales the drawing up by 2.

Below you can see the milling process with the failed iterations included. You can see the oversized PCB first, which was the result of the bug in Eagle for Mac. A few milling tasks failed because of the FR-4 being attached too close to the edge of the build plate of the SRM-20.

By the way, here is a nice tutorial explaining how one can add vias to make a double-sided board.

Exporting from Eagle

In order to export the board design from Eagle, one has to open the design in the board editor. You should open the layers panel and hide all layers except the Top and Dimensions one.

Layers in Eagle

Then go to File / Export / Image to export a monochrome 500dpi image at a location you chose on your disk.

Eagle Export Image dialog

The exported image should look like the one below.

Exported image from Eagle

From here you can consult the Photoshop section from the Computer-Aided Design week to prepare the source images for Mods.

Testing the Hello Board

For testing or essentially compiling existing C code and uploading the binary to the AtTiny44 we need the following source files.

We have the needed toolchain for compiling and uploading the code from the Electronics Production assignment week.

First step is to connect the newly created Hello Board to the computer by using a FTDI ←→ USB cable. Run the following code in terminal to check if your Hello Board shows up.

ls -l /dev/cu*

On Mac you should see the following output.

/dev/cu.Bluetooth-Incoming-Port
/dev/cu.usbserial-FTHBQ1K0

We are looking for the /dev/cu.usbserial-FTHBQ1K0. If you disconnect your Hello Board and run ls -l /dev/cu* again, you should see only one entry.

Both, the FTDI cable and the ISP programmer have to be connected to the board.

Start up Arduino. Go to Arduino → Preferences and look for the Additional Boards Manager URL’s. Enter the following URL there.

https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

This is going to enable Arduino Boards Manager to be able to find the ATtiny boards package. Go to Tools → Board → Boards Manager… And select the attiny package. At the time of writing this the version was 1.0.2.

Now you should be able to see the ATtiny24/44/64 entry under Tools → Boards. Select it! It is the ATtiny44 microcontroller that is the heart of our Hello Board.

Select the processor by going to Tools → Processor and selecting ATtiny44.

Select the clock by going to Tools → Clock and selecting External 20 MHz.

Burning the bootloader is the next thing you have to do. In order to do that, select your programmer from Tools → Programmer. I used AVRISP mkII since there is someting wrong with the FabTinyISP.

Now you are ready to program your board. I used the test code below, which turns the LED on once the button is pressed.

#define LED 7
#define BUTTON 2

void setup() {
  pinMode(LED, OUTPUT);
  pinMode(BUTTON, INPUT);
}

void loop() {
  if (digitalRead(BUTTON) == LOW) { // IF the button is NOT pressed
      digitalWrite(LED, HIGH);   // turn the LED on
  } else {
      digitalWrite(LED, LOW);   // turn the LED off
  }              
}

Compile and run. It works!

Conclusions

Learning Eagle was fun. Too bad that there are still bugs. Even after installing the latest update, it still was exporting a PNG image two times the actual size.

Unfortunatelly I did not manage to find enough time to try out KiCad, but as far as I know, the workflow is similar. What excites me, although I have no idea how to integrate it into my current projects, is the possibility to design PCB’s with up to 32 layers. In Eagle one can do only 16. On the other hand Eagle comes with the promise to integrate PCB designs into your Fusion 360 projects.

All in all I enjoyed the assignment as I started to see a way towards integrating the skills into my final project. The hello board with the ATtiny44 could be reused for my joystick shield almost without alteration. The only things I would need to add are the hoystick and a header to make it a HAT for a Raspberry Pi.

A few notes on soldering. Surprisingly I did not have any problem since I followed and mastered a pattern which is as follows.

  • Make sure that the soldering iron is clean
  • Use flux before applying solder
  • Before placing the SMD components, put a bit of solder on the tip of the soldering iron; then touch the place where one of the SMD pads should go; wait till a bit of solder flows onto the pad
  • Place the SMD component in place, you can apply a bit of pressure to keep it in place using tweezers
  • Touch the component AND the pad with soldering iron, see how the SMD component drops into the molten solder
  • Solder the other terminal(s)
  • Apply extra solder to the initial terminal

Files

Download all files.