6.

Electronics Design

Home

Assignments

group project
Use the test equipment in your lab to observe the operation of a microcontroller circuit board (in minimum, check operating voltage on the board with multimeter or voltmeter and use oscilloscope to check noise of operating voltage and interpret a data signal)
Document your work (in a group or individually)

individual project
redraw an echo hello-world board
add (at least) a button and LED (with current-limiting resistor)
check the design rules, make it, and test it
extra credit: simulate its operation

Download files

Download all the files from this week's adventure.

Download all files

Table of contents

Group assignment

We didn't get to do the group assignment as COVID-19 decided to come along and close down the Fab Lab.

Unfortunately I don't have a spare oscilloscope or logic analyser on me to analyse the microcontroller I have.

Introduction

My final year project idea is a SmartWindow which switches on depending on the weather and time of day outside, using either RGB LED strips or just a mix of warm white and cold white LED strips.

Let’s have three buttons that can control the RGB channels of an LED. Each time you press a button it increases how fast the color channel of the LED it is associated with blinks and therefore how bright it is.

Designing a PCB Board

Thinking and theory

Three buttons that each control an RGB channels of an LED

    Components needed for the circuits:
  • 3 x buttons (temporary switches)
  • 1 x RGB LED
  • 1 x switch
  • 7 resistors (for each element above)
  • 1 capacitor between VCC and GND to smooth out interference

Drawing up the layout of the board

From the start I knew I needed 3 LEDs and 3 buttons, and that they needed to wire them to inputs and outputs of the boards.

It’d be simple: connect one end of the LEDs to an INPUT, which would act as VCC and then connect the other end of the LED to a resistor which then goes to GND… easy. For the button I got confused…

alt_text

How to wire 3 buttons through with one common VCC source?

I got confused because we’d need to wire a circuit between VCC and 3 inputs (with a resistor, of course) so that the inputs stay in HIGH mode.

Then when you press a button the current “ends” its journey into GND… but the start of the current for all 3 circuits comes from the same VCC... Doesn’t it mean that when one button is pressed then the current from all the inputs gets “sucked” into GND as well, and therefore change to a LOW value?

That’s when I read this article and this article about pull-up and pull-down resistors. It was a very interesting read which helped me understand a lot how the circuit and chip works. It says that the I/Os in the chip also have an internal resistor, called input impedance. It usually has a very high resistance.

Below is a drawing of how the current travels through the circuit when the switch is closed or opened. On the

alt_text

A question… ?

I had a question, which went something like: “Why are pull-up resistors the most common one when it means you keep the state of the pin as HIGH all the time rather than keeping it as LOW? Doesn’t it consume more power?”

Oscar answered something like: “No, it actually doesn’t consume any power, it’s just the state of the pin that is HIGH. It has voltage going through, but it doesn’t actually use it for anything”.

Choosing the ATtiny1614

I chose the ATtiny because it has 9 I/Os which allowed me to have 3 for each button and 3 for the LED's RGB channels. Then I used another one for a switch, because why not.

ATtiny1614 Datasheet

alt_text

If you search “Ratings” it shows General Operating Ratings under the Electrical Characteristics header.

alt_text

You can see that it’s optimum range is from 4.5V to 5.5V, in other terms at 5V.

You can see it’d work with a voltage down to 1.8V, which would result in the MCU running at a speed of 5MHz. As we have a very simple circuit we could work with that, but because we might use the board later for more advanced functions, we’ll stick with 5V.

Note //
That’s also the power that provided by USB, and therefore it avoids from having to convert the power.

Digitising your design

Eeschema in Kicad

I followed the (loose) instructions on the local lab’s page

The tutorial runs you through everything from installing the libraries of components, to placing them in the Eschema and then connecting them in PCBeditor.

Laying out the ATtiny1614 and other components we’ll need

Adding symbols to the schematic.

alt_text

The Symbol window.

alt_text

Starting to wire the board together.

alt_text

Pressing the E key over a component shows its value. In the ATtiny1614 componenent you also have a link to its datasheet.

alt_text

In the datasheet there is all the information you could possibly about the chip. There are also the I/Os layout so you can connect them properly on Eeschema. On Eeschema the VCC is on top, the GND is at the bottom and the I/Os are on both side.

alt_text

Adding and calculating the resistance needed for the RGB LEDs

Datasheet of the RGB LED

Below is the amperage consumption of the individual LEDs in the RGB LED. You notice that the red led consume twice as much as the other two.

alt_text

Ohm’s Law says that V = I * R, where V is in Volts, I in Amps and R in Ohms. The figures from the datasheet are in mA and therefore need to be converted in Amps for the equation.

We want to calculate the Resistance needed, so we can flip the equation around to R = V / I.

RR LED = 5 / 0.05 = 100Ω
RB&G LED = 5 / 0.025 = 200Ω

Here we are. We need to use 100Ω resistors for the red leg, and 200Ω for both the green and blue legs of the LED.

Calculating the resistance needed for the buttons (not essential)

The general rule is to use a pull-up resistor (R1) that is an order of magnitude (1/10th) less than the input impedance (R2) of the input pin.

Quote from Pull-up Resistors - learn.sparkfun.com

alt_text

It doesn’t need an exact resistance as all it needs to do is avoid the circuit to short. A common value to use is 4.7KΩ.

If you use a resistance that is too high, the pin might take longer to register the change in value, and that is not good for circuits that need speed. If you use a resistance that is too low it will consume unnecessarily amount of power for such a simple task.

What is Common Anode and Common Cathode?

The one that is given on the Eeschema is a common anode one, which means that the three “feet” for the channels go to GND. I thought that if you wanted the channels to light then you’d need to connect it to ground with a switch… but that switch would then need to be controlled programmatically via the I/Os.

alt_text

I asked Oscar but he said that the pins by default act as VCC, but if you put them to LOW then it acts as a ground, so you only need to connect the cathode side of the LEDs to the I/Os to control the channels.

alt_text

UPDI is missing? Modify the FTDI component with fab.mob and fab.lib

There wasn't any Symbol or Footpring for the UPDI in the Fab Library. I asked Josep what was up, and he explained how to modify the FTDI component to create the UPDI. I screenrecorded the conversation we had.

Wiring everything up in Eeschema

I used the image below to figure which pins needed to connect where, at least for VCC, GND, TX, RX & the RESET pin.

alt_text

After wiring up all the components in Eeschema.

alt_text

I didn't realise that if you did it in different part of the window, and used the Labels it actually joined them. I thought it was just for clearing things up. It didn't bother me too much though as

alt_text

Send the board for layout and trace in PCBeditor

Understanding which elements connect with which

It took me a little while to understand why when you moved the elements, the white lines connect to different pads... I was confused because I thought "well... the resistor has to go this pad, and then to ground, why is it jumping around like there's different options?"

Then I understood that GND need to be connected EVERYWHERE on the board, and therefore the white line just automatically jumps to the closes GND available.

That being said, I started moving the parts around to recognise what was what, and see where it'd make sense to place the components.

alt_text

Shortcuts (U, E, M) & using the Route Tracks tool

There a few shortcuts that really saves time. While hovering above components tap:

  • E to Edit the component such as it's Reference and Value.
  • M to Move the element and click to Release
  • U to Select the entire wire you are hovering over
  • Delete (not Backspace) to Delete the element or a section of wire

Pre-defined sizes for track & Grid snap

In the drop-down menu at the top left that says Track you can enter pre-defined sizes. To play around, I decided to create different tracks, for different components. For example if it was connected to VCC or GND, then the tracks would be 0,6mm wide, as it handles, albeit little, power.

alt_text

I also created width of 0.4mm for normal traces and finally 0,3mm for traces that were connected to the ISP.

I later realised I shouldn't have done that.

Comparing size of physical components to the real size on screen (button and switch were too big)

When in Eeschema I looked for a button but couldn't find one in the Fab library, so got one from the Kicad one.

alt_text

In PCBeditor you can set the Zoom ratio in a drop-down menu in the top-right. If the Zoom is 1, then if you place your component in front of the screen, it should be the same size. (For some reason I couldn't set the Zoom exactly to 1, but the closest was 1.38)

I compared the real life button to the one I picked, and noticed it was waaaay too big. I then searched in the Fab library and found a button called 6MM_SWITCH. This one worked.

Same problem with the RGB LED. I used the LEDRGBNEW in the Fab libary and it appeared enormous on the board. I used LEDRGBOLD instead and that was the right LED.

Traces going under the chip

For a cleaner and smaller board I made some traces go under the ATtiny1614. The problem with that was to solder the pins to the traces that goes under it... so I added little pads to ensure the connection, but also make sure it doesn't move.

alt_text

Drawing the outline / routing of the board

alt_text

Noticing the traces are too close and they join

alt_text

Making the traces for the entire board 0.4mm

alt_text

alt_text

Adding a jumper to solve all the problems

alt_text

Creating the files to the milling machine

Export to SVG with these settings

Installing Inkscape on Mac OS Mojave

It fails, but you can install with Homebrew and a few tweaks: https://github.com/caskformula/homebrew-caskformula/issues/83

Edit: It doesn’t work. (That’s the problem of instant documentation, you see.)

Import SVG in Photoshop (Inkscape didn’t work and Illustrator was buggy)

Create the black and white PNGs for mods

Making the RML file and milling the board

We’ve done this before, see Week 4 - Electronics Production

[INSERT THE VIDEO OF MILLING STARTING]

The board came out nicely.

alt_text

Soldering the board

Picking up the components

I check my schematics and write down the components I need.

    They are:
  • 1 x 0 Ω
  • 1 x 100 Ω
  • 2 x 200 Ω
  • 3 x 4.7K Ω
  • 1 x 10k Ω
  • 1 x 1μf
  • 1 x RGB LED
  • 3 x 6mm buttons
  • 1 x slide switch
  • 1 x UPDI (2x header conn)
  • 1 x FTDI (6x header conn)
  • 1 x ATtiny1614

alt_text

While looking for the components Daniel told me to take the 1000pF for the 1uF capacitor... Luckily I checked and it wasn’t right. 1uF is 1,000,000 pF. 1000 pF is 1 nF, which would have been at thousand times too little.

In what order?

They say from small to big, inside to out.

In order from smallest to biggest it goes: resistors, capacitor, LED, slide switch, ATtiny, UPDI, FTDI and buttons.

In order from center to outside it goes: ATtiny, capacitor, resistors, RGB, UPDI, slide switch and buttons.

I think the best bet is to start with the ATtiny, then the capacitor, then the LED and its resistors, then the resistors for the buttons, the resistor for the slide switch, then the slide switch itself, the UPDI and FTDI and finally the buttons.

They didn’t have 200Ω resistors (whaaaaat) so I used 499Ω.
They didn’t have 4.7k either so used 10K

alt_text

Checking how to solder the RGB LED

The RGB led has a corner that is chamfered which shows which way it needs to soldered on the board.

alt_text

Noticing the two holes missing to place the slide switch

The slide switch has two little pieces of plastic that comes out on the bottom which is suppose to go in the board. They are there so that when you slide the switch it doesn't put stress on the soldering, but on these two protruding plastic cylinders.

alt_text

Checking the continuity on the button

To find out which way to solder the button I used the Continuity mode on a multimeter to touch the different pads of the button. If they beep then they need to be soldered on the same side, for example both to GND.

alt_text

Bending the legs of the UPDI

The UPDI is simply two of the FTDI legs. The thing is, on my board it couldn’t lie down because then it couldn’t be plugged in. One solution is to bend the legs so the UPDI faces up. I decided to cut them partially instead. The result is a bendy UPDI which doesn’t seem very solid... but if you are careful I'm sure it'll work.

Finished board

I’m quite happy with the result. Not as much shininess as during Electronic Production week, but still good stuff. Plus I designed this one.

alt_text

Checking continuity between GND, VCC and I/Os

I checked the continuity between the all the GND on the board, especially on the chip and FTDI. Then did the same with the VCC, and then checked one by one that there no shorts between the pins of the chip itself.

alt_text

Programming the board

I forgot my board at the lab

Unfortunately, again, I forgot my board at the Fab Lab, so I haven't had time to test it. I have a Barduino 2.0 I'll be playing with in the following weeks though.

Have you?