Week 6 - Electronics Design

Assignment

Individual assignment

redraw the echo hello-world board, add (at least) a button and LED (with current-limiting resistor) check the design rules, make it, and test it

Group assignment

use the test equipment in your lab to observe the operation of a microcontroller circuit board

Link to group page

Process

Installing and Learning Eagle

In order to make this assignment I had to learn from scratch all about electronic design, beginning with what it’s its purpose, what are the tools to deal with and which softwares to practice.

Upon instructor’s suggestion, I started by looking at electronic CAD software Eagle, which is by all measures the most popular tool used in this field and it’s easy to understand while using it.

However, owning an old macbook (late 2008) prevented me from installing the latest version, which made me wonder if I had to deal with different CADs until I found on Autodesk’s website a link for a legacy version (7.0) from when Eagle production company was not owned yet by Autodesk.

After installing it, I found out that I a big, full, real 0 of knowledge in this topic and was unable of accomplish the smallest task in Eagle since I couldn’t follow anything of its worklflow. Hence, I delved into a tutorial that could teach at least the basis of Eagle. The best resource that I found is a series of well-written and beginner-level tutorial by the popular electronic producer and divulgator website Sparkfun. Specificaly I started to read this tutorial about making schematics on Eagle which allowed me to both understand some Eagle fundamentals and to reach other tutorials in the same website about PCB terminology, electronics, physics and other topics related to this field.

All the major tools and operations regarding Eagle that I used for my assignment were learned from these tutorials. Another very important resource that I found on Sparkfun was the following chart, which I kept open most of the time to understand and keep always in mind the meaning of the various symbols in the schematics.

sparkfun symbol chart

After picking some basis, I started once again Eagle and proceeded to set up the first operations for my project. The first thing to do was to install the fab.lbr library, which contains the Eagle equivalent of all the electronics parts used inside our lab. This was necessary in order to design a board that could be fitted with the materials available to me and my peers. This task was accomplished by just downloading the library from this link and locating in the Eagle library folder. Another way to complete this operation is to add your own library folder through the Option -> Directories menu command. In the resulting window, you can either change the library folder or add another one folder to the text form.

directories window

Since Eagle already has in-built tons of libraries, and working with such a huge amount of parts can be confusing, a good way to ease the task is to logically remove the libraries from the list, making appear on the drawing process only those that you required. To do so, in the initial Control Panel, you have to check the circle next to the libraries and make it green you want them or gray if you don’t want them.

You can as well select or deselect them all together with the right-click menu commands ‘Use all’ and Use none.

selecting libraries

After that, I was ready to begin a new project and design a copy of the following board.

original layout

Schematics

There are many ways to draw a schematics, possibly one for each designer, and I figured out that no one is better than another as long as it is clearly readable and concise. Since I started as a true beginner I figured out that it was better for me to begin drawing parts and wires in the most complete and straightforward way, by connecting every single pin with its relative line. Even though this style of drawing is rigorous and correct, in the end the result is often a mess of lines and parts that are hard to discern. The following image is the result of my first schematic.

first schematic

It’s clear from it that even a simple circuit like mine might result in a complicated tangle when drawn too rigorously and not using some of the useful tools provided by Eagle.

After some more research on tips and tricks of drawing schematics and setting again my project several times, in the end I opted for a more abstract, but clear and functional design that represents better the common practice of drawing and reading schematics.

second schematic

For making it, I made use of the Name property of every object drawn in the schematics, which enables connections among different and separated lines on the whole design by simply assigning them the same name. That’s how I connected between them all the ‘VCC’ and ‘GND’ lines, as well as certain lines which would otherwise overlap with other ones, such as ‘MISO’ and ‘RST’. Furthermore, I used a couple of graphic symbols, such as the Power and Ground ones, taken from the Sparkfun custom library for Eagle, which features many useful symbol which are not supposed to be represted on the board but still make the schematics more readable and informative.

Board

Regarding the making of the board, to learn better the use of Eagle controls, I’ve chosen to recreate a 180° turned version of the Hello World board, so that I couldn’t just copy paste the image we’ve been provided (that’s why I called my project “dlrow-olleh”).

Essentially this was not a difficult task and the only things that I figured important to control were the grid dimension, which I reduced to 4 mills (this granted me much more freedom for placing the parts), and the routes width that I changed from 16 mil to 12 mil when I had to trace the routes under the microcontroller.

first board

Extending the board

As a part of the assignment, I had to add a switch and an LED (with its relative resistance) to the board. The board itself has a lot of empty spaces that I was able to use for this task but first I had to figure out which could be the best connections starting from the schematics.

Concerning the switch, I thought a good way for using it could have been connecting one pin to VCC and the other to a free input pin of the microntroller (so that it could read at any moment when the button would be pressed). PA2 seemed apt for this purporse.

Regarding the LED, I used green LED with 499ohm resistor. I got the example for this from a previous assignment, but it’s easy to explain this value through Ohm’s law: V = R * I.

I had not at my disposal the datasheet of the exact kind of LED I was using, but assuming that approximately all SMD LEDs work in the same way, I looked at similar specifications of green LED (like the one at this link) and figured that current that it needs to be fully bright is 3.3v and 20ma. Applying Ohm’s law to this values you get 165 ohm, which actually is not a common value and surely not held in our lab. To avoid a series of many resistors of different values, it’s best to use the closest upper value, which in Fab Lab is matched by 499ohm resistors. The green LED shines bright even with such values.

For my board, I aligned both LED and resistor to a GND line and an output pin from the microcontroller, specifically PB2.

The following is the resulting schematic.

extended schematic

As for the board, coincidentally there was enough space for both parts on both sides of the microcontroller, allowing me to put the relative pads and routes with ease. I overlapped a couple of traces so to save some milling and copper, but I’m sure that with a little more mental effort can be accomplished a much better result.

extended board

Once the board was finished I export a PNG file through the File -> Exoport -> Image command menu, ensuring that the resulting image would be rendered monochrome and with a resolution of 1000 DPI. Then I modified the PNG file with GIMP in order to reduce the size in pixels onle to the circuit area and to make a cutout file that I would use to take away the PCB from the working sheet.

layout file

Layout file

cutout file

Cutout file

Milling, soldering and testing

When I used Fab Modules to generate the milling file with my PNGs, I encountered an unexpected issue. According to the drill route view, many traces of my board were not cut very well and would result in several short-circuits.

bad route

This was indeed a problem.

To solve this problem, at first I considered tweaking the drill tip diameter calculated in the fab modules until I obtained a proper result.This indeed gave me what I wanted when I reduced the value to 0.35mm, but it’s a really dangerous practice and could result in several issues.

After discussing the issue with Pietro Rustici he suggested me to check again my settings inside Eagle, which most of the time are the source of bad boards. Specifically, he told me to look at the Tools -> DRC... menu, onto which are described all the design rules my board would follow. Having totally ignored this feature, to me it came really natural to see how my board was flawed and prompted to fix this. The most useful value to adjust was Clearance which I set to 0.4 mm (Pietro also suggested me to work with the metric system, because for us europeans working with inches can end in very bad situation if you’re not a little used to it). This value was the most optimal because this is (almost) exactly our drill tip diameter, so I would not incur in any milling route miscalculations if all the traces respected it.

After repositioning and resizing the routes, the resulting milling files were just fine and I was ready to mill.

milling

The first mill try resulted in a flawed board. Somehow, the cutout milling went over the outer traces and totally ruined them.

bad-milling

Perhaprs, this issue occured because initially I made a cutout image in which the inside box was black and the outside frame white, making the drilling tip cut from the inside. If you had not calculated a proper margin between the traces and the border this is indeed a risky practice, so I inverted the colours of the cutout file and made a new milling.

The new result was just fine, except for a corner that I chipped when I removed the PCB from its layer. This was really a minor problem, since the overhanging piece included almost nothing functional, but with a bit of glue I fixed the issue easily.

glueing

After printing a bill of materials for easy reference (Eagle has a very useful menu command from File -> Export -> BOM), I soldered all the pieces in place with relative ease (I still have to practice it a lot) starting from the central parts and moving to the ouside, leaving the biggest ones (like the switch and the ISP connector) for last.

soldering

Since I’m incredibly slow and imprecise in using a soldering iron, I spent some extra time with a multimeter to check if I inadvertendtly made short-circuits or burned any component.

testing connections

Checking connections

testing resistance

Checking resistance values

With an oscilloscope, I also tested if the LED was properly aligned and not burned in the process.

testing led

Funnily, this test made me discover that someone in our lab swapped green and red LEDs from their drawers in our storage.

Result

This is the final result of my dlrow olleh board.

final-result

It seems to work just fine, but I should program it to test it properly as soon as possible. The following link is to a ZIP file including Eagle project, PNG and milling files, BOM and board view.

Dlrow Olleh Board files

Gist & Further development

I’m sure that for my final project I’ll have to design and mill some circuitery, even though as to now I’m totally ignorant about how to use what and which to adopt when. This means that I’ll have to personally read and study more about electronics projects and functioning, make more tests and have a larger understanding of the whole topic. It was more than pleasing to see that, although little, I made some improvements in my soldering skills.

Tools and software used

Update

09/03/2018

During the lesson review I started to program my board with the help of Dario’s programmer. The results of the AVR workline confirmed that the board was working fine and the controller responded ok to the uploading of new programs.

programming the board

On that moment, I wasn’t really witty on the world of programmers, programs and makefiles, so all that I did was to flash the programs with the makefiles provided as examples for the Hello Board by Neil Gershenfeld using the Crosspack suite (this bundle of software will be exposed more in detail in a future assignment). However, I wasn’t able to run (or plainly understand yet) the echo program, hence I started to write my own code that could make the LED blink when the button was pressed.

For writing this code I copied the example reported in the hadbook Make: AVR programming, but adapting it to my board was more difficult than expected.

Essentially, the avr.io library offers three important parameters that are used to handle and read the pin of a microcontroller:

  • DDR: this one is used to set up pins as input (by setting them to 0) or output (by setting them to 1);
  • PORT: for setting the outcome of pins used for output;
  • PIN: for reading the status of pins used for input;

These commands work for whole group of 8 pins, selected through a suffix related to their register. i.e., PA1 is part of group A, so if I want to set it as an output pin I should write the line:

DDRA = 0b00000000; //this command sets up also all the other A pins as outputs

If I want to set its status to 1 to use the write the command:

PORTA = 0b00000001; //this command sets up also all the other A pins to 1

And if want to set it back as an input pin and read its status and save it a tmp variable I’ve to write:

DDRA = 0b00000001; //this command leaves all the other A pins as outputs tmp = PINA;

Making my LED blink was an easy task (it also meant that all my connections were doing great), but actually make it respond to my switch was troublesome. That’s because of a design flaw I inadvertently adopted in my board, being it that I used the VCC line as a trigger for the switch. This implied that when the trigger was off, the status of the line connected to the relative pin was uncertain and unreliable (and in fact I wasn’t able to make it work in the conventional ways you would read a switch status).

However, I did something serendipitous and eventually was able to make the board work properly. What I did was to set pin connected to the switch as an output, and then read its status as if it was like an input pin.

It worked!

switch off Switch off

switch on

Switch on

I’m not sure of the technical reasons behind this, but what I suppose is that when you set up a pin an output, the controller activate a pull-up resistance to it (actively setting it to 0), making it stable and not susceptible to voltage fluctuations. Still, the controller doesn’t stop you from treating the pin as an input with the relative command, and by the time you apply to it the VCC voltage (as my switch does) it is able to read it as 1 state.

Followin is the code file that I used to make the board work:

Olleh dlrow bliking led C code