Week 06: Electronics design¶
Assignments:¶
-
Group assignment: 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 assignment: Redraw one of the echo hello-world boards or something equivalent, add (at least) a button and LED (with current-limiting resistor) or equivalent input and output, check the design rules, make it, test it.
What to learn:¶
-
Select and use software for circuit board design
-
Demonstrate workflows used in circuit board design
Have you?¶
-
Linked to the group assignment page
-
Documented what you have learned in electronics design
-
Explained problems and how you fixed them, if you make a board and it doesn’t work; fix the board (with jumper wires etc) until it does work.
-
Included original design files (Eagle, KiCad, - whatever)
-
Included a ‘hero shot’ of your board
-
Loaded a program and tested if your board works
Understanding electronics:¶
This week we will be learning about how to design and assemble a basic electronic circuit.
Units:¶
The units we will be working with are:
CURRENT | VOLTAGE | POWER |
---|---|---|
Amperes | Volts | Watts |
(I) | (V) | (P) |
A flow of electric charge. | A measure of the difference in electric potential between two points in space, a material, or an electric circuit. | The product of applied potential difference and current in a direct-current circuit. |
Electric current results when electric charges move - these may be negatively charged electrons or positive charge carriers | Batteries provide voltage | Power makes batteries run |
This image explains the relationship between the three:
The formula between the three is:
P = V*I
Other units:
mA means milliamperes
uA means micro amperes
kA means kiloamperes
MA means megamperes
Components we will be using:¶
The components are connected in a circuit through copper traces or wires which are conductive material that allow the current to flow. I drew a diagram with the symbols of the components I learnt about this week:
In inventory by the digi-key section we can see what are the different components we will be using for this week. The components we will be using are:
-
Wire: we will be using the ribbon cable which is a multi-conductor cable with connectors that will connect to it. You can use it as a ribbon with multiple wires or you can peel it off and use the different wires individually. It is measured in wire gauge (AWG) which it is a measurement of a wire, either its diameter or cross-sectional area. The gauge of a wire determines how much current can flow through the wire. The gauge also determines the resistance of the wire and its weight per unit of length. When dealing with wire gauge, the characteristics of a wire usually specified on a chart is the wire’s size (specified in AWG), diameter, area, feet per pound, ohms per 1000ft, and current capacity (in amps) which we will need when carrying high signals for motors.
-
Button: the button in the circuit symbol it is a switch, normally open and you push the switch to open it.
-
Slide switch: the switch, it can either be vertical or horizontal, it has 3 connections, based on moving the slide switch back and forth you can either connect one side or the other. For example in a power switch or configuration switch.
-
Resistor: current flows through it and we usually use it to limit current, it has two sides, it does not matter the orientation, you place them in the circuit and they do what they have to do. Its main purpose is to provide a precise amount of electrical resistance. Say for example we have a battery and a lighting diode, you would need to set a resistor between them to control the current. The current equals the voltage divided by the resistance:
I=V/R
Therefore resistance is measured by:
R = V/I
It is measured in ohms. For a resistor you usually look into the following values: - 10K(the value of the resistance) - 1%(how accurate it is) - 1/4W(power it can handle) - 1206 (size in thousands of an inch so 12x6)
There are two types of resistors: - THT which display their information (Ω) with coloured rings - SMD resistor which the numbers shown are the Ω value
We use 1206 series of resistors in fablabs because they are the smallest components you can solder by hand. To simplify resistor manufacture, handling, purchase & electronic circuit design, resistor values are arranged into standard resistor values conforming to the E series. Resistor tolerances are generally ±20%, ±10% ±5%, ±2% and ±1%.
- Capacitors: collect energy and release it whenever the capacitor is full, you can use it to get more current going into the circuit. For example some machines need more energy at the start. It is measured in Farad (F).
C = Q/V
Which means there is charge in the capacitor and there is voltage across it.
C V = Q
Or if you take the time change:
C V(with dot on top, rate of change of voltage) = I (current through the capacitor)
This style of unpolarized capacitors store charge and are used in filters.
Polarized capacitors are very different, low voltage, they are used as local power sources, they are called supercaps. We use them in things that don’t use a lot of current, they store energy in less time (like for an example a toy you want to charge to quickly play with).
-
Crystal have a physical material in it and when you put a field on it, it bends and when it bends it generates a voltage and by doing that you make a mechanical oscillator. It can do that with a very narrow resonance which means it is very accurate, they are used to tell time. What this means is that it provides a clock signal. Crystal symbols usually have two terminals and are measured in Hz(frequency)
-
Resonator is also used for more accurate timing and faster timing = clock signal. Resonators usually have three terminals and are measured in Hz(frequency). Quoting from Tessel, 2020 Waag student, “The resonator does not have orientation. It is good practice to place it as close to the IC as possible because distance traveled over the trace equals a time delay. And time is exactly what the resonator is about. You must also try to place the two legs of the capacitor at equal distance from the IC. Equal distance is equal travel time and improves accuracy.”
I later on understood that a resonator is a crystal but with 2 capacitors already incorporated so when you use a crystal in a board you always need to add 2 capacitors.
- Inductors: there is the inductance, there is current going through this and then there is a voltage drop from one side to the other, the voltage drop depends on the rate of change of the current. In the capacitor this is backwards, a dc signal can’t get through but an ac signal can. With an inductor an ac signal can’t get through but a dc signal can. We use them to block high frequency noise.
V = L di/dt
- Differences between AC and DC (types of electric current):
AC | DC | |
---|---|---|
Alternating current | Direct current | |
Unidirectional current | Bidirectional current | |
AC current flows back and forth | DC current goes one direction from VCC to GND | |
Changes at every instant of time | Constant in time | |
Does not deteriorate with distance | Starts deteriotating with distance | |
Convenient for long distance (transmission) | Convenient for short distance | |
high level voltage | low level voltage | |
for better transportation of the power | mostly for our types of electronics | |
For example house power outlet provides AC. Most electronic equipment works with DC. AC is converted to DC. The block on your laptop’s charger converts AC to DC.
-
Diodes: have all sorts of uses, they always have a line of something special on one side which is the cathode side (tells you what direction to point it). A common diode we will use is the light emitting diode. We connect a processor, through one of the pins to a resistor and then to a diode, if you don’t add the limit resistor and you connect this to the pin with enough capacity you will blow it up, the resistor is very important
-
Transistors: is an electronic device used to control the flow of an electric current, meaning it can amplify or rectify electrical signals or power. It consists of three layers of a semiconductor material, each capable of supporting a current.
Quoting from Electrotopic to understand the the differences between a resistor and a transistor: - “Resistor: only two terminals, an input and an output, the output depending on the input and resistance.” - “A transistor is like a resistor, except that the resistor can be controlled by a second input called base input; It should also be noted that the gate input of the transistors is the transmitter and the output is the collector (its backward reason). if a negative current is applied to the input of the base, the resistance increases, thus preventing the current from passing from the emitter to the collector, thus allowing a transistor to act as a switch. If a positive current is applied to the base and a second negative current source attached to the transmitter, the input will be amplified proportionally to the base current.”
-
Phototransistors: a type of transistor,semiconductor device that is able to sense light levels and alter the current flowing between emitter and collector according to the level of light it receives.
-
Regulators: resistors are used to limit very little current in a circuit but regulators are used when you have hundreds of mA needed in a circuit. Quoting from Instructables “When you are using resistors in a voltage divider configuration of say taking 9V down to 5V, your basically loosing that extra 4V to heat. In the case of a battery your are wasting about 1/3rd of the battery life to heat. Voltage regulators are able to use more of that access voltage towards the output and loose less of it to heat. Though it still burns off a good bit of that access power to heat. Just not as much as resistors do.” We use regulators to work with the processors, the regulator has an input voltage coming in and an output voltage coming out, it takes the battery voltage in and setting a particular output voltage for the battery out.
-
Op-amp: (likely that we do not use it). It has a minus input and a plus input to interface to a microphone for example, now increasingly you can use an amplifier built in in processor to replace it.
-
Microcontroller: quoting electrosome “is an integrated circuit (IC) which is small, low cost and self contained computer designed to handle a specific task in embedded systems, which is clock driven, register based, accepts input and provides output after processing it as per the instructions stored in the memory. A microcontroller needs a clock as it works by sequential logic which means that the state of the device changes in different timings decided by a clock signal (creates a much more simple system).
Electrosome also explains very good the different parts of a microcontroller;
-
Clock signal: it is a particular type of signal that oscilates between a high and a low state and is utilized like a metronome to coordinate actions of circuit. This video was very helpful to understand the part the clock plays in machining.
-
Battery: it is a power supply. It has two sides: -> represented as: plus VCC / V+ / +V -> represented as: minus GND (ground)
Battery is measured in Volt (V). Voltage is the difference between two points(+ and -). Voltage as quoted in electronicsandyou.com “is a type of “pressure” that drives charge through an electrical circuit.” The battery(energy source) creates voltage causing the current to flow (push electrons through a circuit (conducting loop), this allows to do work such as illuminating a light.
Batteries and power supplies:
- Header pins: are a type of electrical connector, the male pin headers, that are soldered to a circuit board, stick up to receive a connection from a female socket which would then be connected to other devices. Each pin of the male header is connected to a different component of the board and transmits the information of that component so you have to be careful when orienting correctly the header. The headers can have different amounts of pins which are represented in the form of 1x3 (1 row(side) of 6 pins). The header below would have XXX pins
Simple circuit types:¶
-
Circuit: it is a conducting close loop that electrons can travel through and create current (I). The simplest circuit is made with a battery and a resistor. The resistor acts as a obstacle for electrons, if you do not have this you have a short which means electrons electrons will run directly from VCC to GND and your battery will be empty in no time.
-
The simplest circuit: R(resistance) is in ohms for V(voltage) in volts and I(current) in amps. This is known as Ohm’s law. Typical resistors of the most frequently used type (metal-oxide film, metal film, or carbon film) come in values from 1 ohm(1Ω) to about 10 megohms(10MΩ). The battery provides the source of power and the resistor controls the movement of electrons so that the battery does not run out in one go.
-
Voltage in a simple circuit:
-
The current: we need a resistor to have the electron’s motion in control.
-
The simplest circuit with Ohm’s law to calculate one of three variables when you know the other two:
-
The simplest circuit, power: when the power is higher than the power specified in the specs of the component: the device burns. **We have to look at the data sheet of the resistor to check the power it can handle(in Watts).
-
The simplest circuit + LED: the problem with LED is that it is a none ohmic device, this means that LEDs do not resist electrons so they need a resistor placed before or behind it, if you do not put one it will burn the LED.
-
This means that the equation for the current flowing through the LED itself is not as simple as V = IR, you will have to look the LED data sheet and check the maximum current it can handle(under forward current) so you can calculate the resistor. You also need to check the minimum voltage for the LED to light up.
-
To calculate the resistor needed to work with an LED we can use an LED calculator:
The calculation is to substract the voltage drop of the LED frm the voltage of the power source and divide by the forward current of the LED: R = (V_source - V_led) / I_led. (Ohm’s law, but with the difference in voltages.) (9V battery, 2V voltage drop of the LED, 20mA -> (9V - 2V)/0.02 = 350 Ohm)
-
To control the LED we have to put a microprocessor(so you can program it) in between. You connect one of the pins of the microprocessor to the resistor then to the led and the to the ground
-
Power signal: by adding VCC and GND in the schematic design you show in which direction the electrons are going.
- The simplest circuit and switch: switches are used to open and close the circuit manually.
How to read a schematic?¶
-
Names: component names are usually a combination of one or two letters and a number, i.e: R1, R2
-
Values: help define exactly what a component is, i.e: 10K
-
Power in a schematic
-
You can show traces between components in you schematic design by drawing either lines or by giving the ends of two connections the exact same name with tags.
-
Junctions are the visual lines connecting components, when there is no dot there is no connection.
-
Net names: to make schematics more legible you put net names rather than routing a wire all over the schematic. Nets with the same name are assumed to be connected, even though there is not a visible wire connecting them. Names can either be written directly on top of the net, or they can be “tags”, hanging off the wire. They are usually given a name related to their purpose, for example, power nets might be labeled “VCC” or “5V”, while serial communication nets might be labeled “RX” or “TX”.
-
You can make schematic designs either in series or in parallel:
-
When you put a battery in series, you connect the minus to the plus of the battery and then you connect both = 18V When you put a battery in parallel you still have the 9V but you have the double amount of electrons, meaning you have more current. More current = more power.
References:¶
- The art of electronics: wonderful bible of everything you need to know about electronics.
Group assignment: Learning how to use measuring tools¶
We were given a recitation where we learnt some tips about debugging. Debugging is the process of detecting and removing errors in an electronic board.
-
Attitude, stay calm and positive!
-
Write down every step when debugging in order to know what you have tried already.
General principles:
-
Narrow down the problem: the problem could be in the pcb, wire, programmer, … try to debug one at a time (for example; try other person’s pcb that is working to check out your setup is working).
-
Specific problems cover specific parts of the PCB, for example when you have a chip and you can’t really program that chip it probably means the problem is between your connection between the microcontroller and the programmer header:
-
For example if you manage to program it but when you plug it to the computer nothing comes up it will probably be your USB connection:
-
If you manage to program it and hook it up to your laptop but your led lights are not working it probably means the problem is somewhere in this section:
You have to understand what every single component does from your board so, that way, when something goes wrong, you know which part of the board you will be focusing on.
There are different tools that can help us to measure different parts of a board and detect where the errors are coming from:
Multimeter¶
A multimeter takes a single point in time reading of a circuit, showing an average reading of this output in real-time. In the multimeter the red wire is positive(active current) and the black one is the negative (ground), they end up in metal pieces called terminals which measure electrical currents. You connect the wires to the circuit/ component you want to check. Henk told us the ground one should be connected first.
The multimeter can measure different things, and this also depends in the type of multimeter (some multimeters have more advanced measuring options). The two basic utilities of a multimeter we will be using are the top two (continuity and voltage) but you can also measure other variables explained below:
Checking continuity:¶
When you create your PCB board many things can happen when milling it, so before soldering it you should test its continuity with the multimeter.
Continuity is tested by sending a small current through the 2 terminals and reading the resistance on the current. To check continuity first:
-
Turn the dial on the multimeter to the continuity setting. Generally, the continuity mode will have a diode symbol, which is a triangle with a line on the right side. It may also have a symbol that looks like sound waves (check multimeter continuity mode). If it does not have these you can also check continuity with the lowest number in resistance mode (measured in ohms Ω). At the end of this assignment I check continuity with the multimeter at the lab.
-
To test the continuity setting’s calibration, touch the 2 terminals together and hold them in place.
-
If the number on the multimeter is less than 1/0 ohms the multimeter is working correctly. Some also beep to show it is working correctly.
-
To test continuity, all you have to do is stick 2 terminals on your multimeter against 2 ends of an electrical current, you will hear a small beep (indicating the current is flowing through the traces).
-
If no numbers display or it shows an error message, then you have a broken connection and the current is being interrupted.
Checking voltage:¶
In voltage you can check both AC and DC, checking it has power when you need power (basically meaning with the multimeter you check the VCC and GND pins to check you have the firevaults needed).
The steps are:
-
Rotate the wheel to the type of current you plan to measure (AC or DC).
-
The symbol for direct current (DC) is a V with 3 dots or a dash above it (to measure batteries and other low-voltage sources of power). Here we measured the voltage of a battery (displayed in V).
-
The symbol for alternating current (AC) is often a V with a line with a wave on top (to measure electronics, multiple currents, …)
-
In more advanced multimeters you can set also the voltage range (numbers around the wheel). For example, if we have a 12V battery, we test it using the 20V setting. The range has to be set to its maximum voltage of the circuit to be as accurate as possible. Some more modern multimeters do this for you (autorange), setting the proper range once you start the test.
-
Connect both terminals to the system/ component you want to test, starting with the black one. The multimeter’s display will change as the current flows through it.
-
If the range is too high, it will make it more difficult for the multimeter to detect a lower current.
-
If it is displayed negative probably you have your terminals the wrong way around.
-
If there is no number the circuit is not receiving power at all.
-
We also measured a JTAG board to see if the transistor was actually doing its job within the board. Placing the black terminal in the VCC we placed the red terminal first before the transistor. The voltage was 5.12V (voltage coming directly from the battery) but if you placed the red terminal after the transistor the voltage was 3.285V. The 3.3V voltage regulator (transistor) worked!
Checking current:¶
We check current in order to see if a circuit is working properly or to check how is current being consumed in the circuit.
To check the current I read this blog which explains it quite well. The process of checking current has to be done breaking the circuit so that the current flows to the multimeter (acting as if they were part of the circuit).
-
Say for example we have a circuit with a battery, resistor and and LED light.
-
We will break the circuit by removing the clip that connects the resistor and the LED with alligator clips. The LED will turn off.
-
Select the DC mode in your multimeter (it will read in mA)
-
“The resistance of the meter must be as low as possible. For measurements of around an amp, the resistance of a meter should be much less than an ohm. For example if a meter had a resistance of one ohm, and a current of one amp was flowing, then it would develop a voltage of one volt across it. For most measurements this would be unacceptably high.”
-
Touch the red terminal to the unconnected resistor lead and the negative terminal to the unconnected LED lead. The LED should turn on, because the multimeter has completed the circuit, allowing current to run through it. The multimeter screen will display the current in mA.
-
Then connect the multimeter in another connection point in the circuit (between the positive battery lead and the resistor, taking care to open the circuit at the point of measurement and to orient the multimeter leads with the positive lead at a more positive voltage point than the negative lead) You should get the same current as before as it is a one path circuit.
Checking resistance:¶
Continuity is the measurement of resistance when you send a small current within a closed circuit but you can also measure resistance of specific components with the multimeter. To do this you:
-
Move the wheel to ohm sign, check the k also in the screen (important for values)
-
Choose a component and attach the red and black terminal to each side of it.
-
Note that it is easier to check the resistance of component which are not already within a circuit.
Checking frequency:¶
I also read this blog which explains how and in which cases you would want to measure frequency (displayed in multimeters with the Hz option) but I did not test this at the Lab.
Digital tweezers:¶
Digital tweezers are compact and pocket-sized tweezers that are very handy to check components (especially at a FabLab where students mess up components and you need to sort them out in the right box later on). They are very handy to check resistors (these are easier to identify individually than when already assembled on a board).
-
It can also measure capacitor, inductance, voltage, frequency, and diode.
-
Simply ‘grab’ a resistor, capacitor, diode, or LED to test. It has a “scanning” mode where it will try to guess what type of component you have, or you can select the component type with the Function button and it will auto-range for you.
-
To purchase check here
Oscilloscope:¶
This machine allow you to measure a circuit’s voltage over time, taking many thousands of readings and plotting them on a screen. With this you can see what it is actually happening in your circuit more precisely than with a multimeter. Multimeter can measure voltage but it measures one snippet in time of the voltage at that particular second) but the oscilloscope can freeze that voltage and show it in front of you in a screen and tell it like a story (better view of what is going on in your pcb).
-
Basics of using it: cable connected to the oscilloscope which you can hook it up to a ground lead in your board and the other side of the cable hook it up to any voltage source that you have in your circuit to see the voltage going on in your circuit like shown below:
-
This video helped me understand further how it works.
-
The yellow probe is for the yellow cable and the blue probe is for the blue cable (used to measure a signal, you can measure more than one). We just measured one signal (voltage) with the yellow cable.
-
The basic buttons we use in the oscilloscope:
The graph shown in the screen shows time width(amount seconds, mili seconds,..) in the x-axis and voltage in the y-axis. You can change the scale of the x-axis and the y-axis with the buttons explained above.
You can record a signal with the Run/ stop signal button so you can move along it and check possible problems. The signal is always the same so you just have to record one small part of the signal to look for possible errors. Then you move with the horizontal back in time button or with the vertical back in voltage button shown above. You would this for example to zoom in processes that are too quick for human eye to see in the board (for example a LED light as shown in the example below).
- Trying out the oscilloscope: Henk showed us how connecting the yellow probe to an LED shows in the oscilloscope screen if we have a blinking LED(going on or OFF).
Logic Analyzer:¶
It is the same as the oscilloscope but it is not as precise in the signal itself as it measures voltages in the form of 0(low voltage) or 1(high voltage). It is less precise in the signal itself. It is measured digitally through a USB, getting bits of 0 and 1 and sending them to your computer to analyze on software (like PulseView and Logic). It mainly decodes very complex protocols to see the characters that are going through the line, it is used as a sniffer.
We checked a 16-channel logic analyzer connected to an Arduino:
In the software there are many communication protocol extensions that you can snif to decode the bits that are processed through the logic analyzer.
How to Debug Almost Anything Kit (By Henk)¶
How to debug almost anything kit: (simple, smart and cheap): - Logic Analyzer (about 6 or 7 euros), works with logic analyzer open source software. It is a sniffer of information that is travelling to your circuit and when you know the protocol and you can decode on the fly what it is saying.
-
Ts100 solder iron (really small and usb charger to power it). It is important to have the right connection cables.
-
Block battery which you can connect to the solder iron or to power the power bench supply.
-
Radio Communication receiver
-
Digital tweezer: you can grab components on board to measure the resistance, voltage, the inductance, diods, capacitance, frequency,…
-
Minigrabbers: to reach into pins.
Individual assignment:¶
To design electronics we can use Eagle(with the same educational license as Fusion 360) or Ki-Cad. When Henk explained Ki-Cad I thougt it was quite an intuitive program so I decided to go for this one. For this program we will use an ATtiny 44 which is the new generation and makes the schema much more simple. We will also be adding a LED with a button and a phototransistor.
Using KiCad (electronics design software to design the pcb board)¶
I found a really well explained diagram here which explains visually the following steps:
I downloaded KiCad from their website. KiCad is a cross platform and open source electronics design automation software. This software allows you to create schematic designs as well as pcb layouts.
- I first opened Fab Electronics Library for KiCAD here and downloaded the library. It has all the electronics components found in the official fab inventory. If you press Read me it will give you the following steps to install them:
Clone or download this repository. You may rename the directory to fab.
Store it in a safe place such as ~/kicad/libraries or C:/kicad/libraries.
I saved mine in my FABLAB folder under a KICAD folder.
Open KiCad
Go to "Preferences / Manage Symbol Libraries" and add fab.lib as symbol library.
Go to "Preferences / Manage Footprint Libraries" and add fab.pretty as footprint library.
Go to "Preferences / Configure Paths" and add variable named FAB that points to the installation directory of the fab library, such as ~/kicad/libraries/fab or C:/kicad/libraries/fab. This will enable the custom 3D shapes to be found. The 3D shapes project has just started and most of them have to be populated still.
-
I also then added all the schematic symbols from Ki-Cad library as well, following the same steps. For this one we choose Kind selector in finder and select all the .lib files.
-
I also added all the footprints from Ki-Cad library, following the same steps as for the fab footprints (selecting all the .pretty folders)
-
When you open Ki-Cad it looks something like this:
-
I create a new project: File > new > project.
-
This will generate a folder with your kicad, schematic and pcb file in your computer (in my case I saved it to the desktop)
-
I open the schematic design editor which has the following options:
-
Press the place symbol button on the right-hand bar > choose from library the different components of the board by looking at them in the diagram of our board.
-
There is a list of echoboards from the Fab Academy but we created our echoboard from the following list of components and their values Henk sent us.
-
My target is to redraw and assemble the components of the echoboard so I looked into the different components to learn how to place them (especially their orientation within the board):
Component | Information | Orientation |
---|---|---|
ATtiny 412 | Microcontroller_ATtiny412_SSFR | Yes |
UPDI header | Conn_UPDI_01x02_Male | ? |
FTDI header | Conn_FTDI_01x06_Male | Yes |
Capacitor 1uF | C_1206 | ? |
LED | LED_1206 | Yes |
Resistor 1 | 5k for the LED | No |
Phototransistor | PHOTOTRANSISTOR-NPN1206 | Yes (different corner should be pointing towards the resistor) |
Resistor 2 | 10k for the phototransistor | No |
Switch Button | BUTTON_B3SN | Yes |
- Shortcuts to make the placing easier:
M (press M in keyboard and a component with mouse to move component around)
R (press R in keyboard and a component with mouse to rotate component)
C (press C in keyboard and a component with mouse to copy component)
E (press E in keyboard and a component with mouse to assign a value to a component in text box)
-
I place the components:
-
Next we will use the Annotate shortcut to add labels to the information of our components.
-
We can also add extra values by right clicking on a component > Properties > Edit Value.
-
I edited the values of the two resistors as they have different values and also the capacitor:
-
Once we have place all the parts we need we will connect them. You can connect the components either with wires or with labels. I decide to wire the most simple connections, you put your cursor on top of the pin you want to connect with a wire and press W in your keyboard, then you move your cursor to the end of that wire and press K.
- I then connect the rest, more complex connections, with labels as I feel it makes the schematic much more clean this way. For now we will be using global labels as we are not using many components, if you had hundreds of components then a hierarchy would be needed. I click on the Global label button on the right hand side menu > click anywhere on the screen > the following window appears > you create a label “say for example, VCC” and assign it to a pin as shown below. I discovered that if you press enter/click again anywhere on your screen, after assigning the pin label, the global label windows automatically appears again (faster way of assigning them).
(Lines and labels mean the same thing = components connected)
-
Following the image Henk sent us I connected the rest of the components with their corresponding labels:
-
From this tutorial I learned the basics of using Ki-CAD. One of the things I learned is to not forget to place *no connection flag when you have unconnected pins. I placed them as following in the FTDI which is the only component which had unconnected pins.
-
I also learned to check my schematic design before moving to the PCB window with the electrical rules checker (identifies errors, the symbol is a ladybug).
-
I had two errors appearing, apparently with the connections of a GND and a VCC (they are shown with a green arrow appearing next to your component). I looked into Ki-CAD forum and ran into the same problem explained online:. “KiCad does check if every component is connected to supply lines as a missing supply is a common mistake to make. Getting the error “ErrType(3): Pin connected to some others pins but no pin to drive it” means that KiCad thinks that some supply pin is not properly connected. Either because there is a missing connection or because KiCad has not been told where the circuit is supplied. The problem is typically easily solved by adding a “PWR_FLAG” symbol to the schematic. An examination of the Electrical Type assigned to the symbols pins will explain why KiCad has PWR_FLAGs.”
-
I tried putting some power flags, as adviced in the blog, to the problematic areas but the errors would not go. I went to Tessel’s documentation from last year to check if she had had the same errors. She also struggled with this, quoting from her “Rutger also mentioned on his page that his instructor (Henk) told him that the power errors are not a problem. They are there because there is no power input. Usually you would add a battery as a power source. But on this board the FTDI is giving power. KiCad does not know that but we do therefore we can ignore the power errors from the ERC. )” So I decided to ignore them untill Nadieh helped me out showing me how she deleted the errors with her schematic (she had the same errors)
-
I placed the PWR_FLAG after pressing the “Place power port” button and run the electrical rules checker again. Errors had gone!
-
Next, I pressed the asign pcb footprints to symbols button to combine schematics (components) and assign footprints to them. It opens up the following assign footprint window:
-
This shows how each component we have placed is connected to a footprint (I downloaded the footprint library from the Fab Academy so this is done automatically). Henk showed us how to check the footprint (to double check it is okay) by selecting a component > clicking on view selected footprint
-
When I did this I noticed the view was empty for some of my components, so I might have done something wrong.
-
The components which had information values did appear when I checked the footprint so I guessed I had not chose the LED, Capacitor and Resistors correct when choosing my components.
-
I closed the footprint window and I go back to try to assign the correct components within the design. By clicking on the component, for example the capacitor I realise under its information properties it gives an unknown footprint.
-
I press the place symbol button and type “C 1206” to make sure it is the capacitor within the fabacademy folder I downloaded.
-
I check the information again to see it has a tracked footprint.
-
I do this with the other two resistors and the LED(choosing the 1206 option). I delete the previous ones and reconnect them again with wires and labels. I also press the annotate button again and change values.
-
I press the assign pcb footprints to symbol button again and wala! All footprints are added:
-
I doubled checked all open up correctly > and I press apply save changes and continue > close assign footprint window.
-
Back in the schematic editor one more step I watched in the tutorial mentioned above was to generate a netlist. Henk did not mention this step in his Ki-Cad tutorial so I guess it is not really neccessary. The process is explained here in detail. Basically what this does is generate a file in your Ki-Cad folder with all the information describing the connections within your components.connections between the different pins.
-
I press the generate netlist button and this window appears:
-
Press generate netlist > save file to folder with all Ki-CAD files for this assignment.
-
I later realised by Erwin that “In version 4 you had to generate a separate netlist. In version 5 this is integrated with the “update pcb from schematic” function.” First creating a netlist and then importing it in Pcbnew is the old way, and it is mainly maintained as an interface to external programs and scripts. So this step is not really neccessary!
-
Before opening PCB editor I save the schematic again (just in case) and press the PCB button from the main menu of Ki-CAD. The PCB editor looks like this:
-
Henk showed us how to put design rules so that the PCB editor knows the constraints of the milling machine we will use to cut the board. I press the board setup button.
-
In design rules I change the minimum track width to 0,39mm.
-
We open the net classes section. Here we will put under clearance 0,4mm (size of drill) and we set the track width to 0,39mm (a bit smaller than the drilling bit). The rest of the settings remain untouched. Via, for example, are drills that connect double sided boards. An error appeared and by looking at last years documentation I learn that I also have to change de dpair width to 0,39mm. Also be careful with commas and dots!!
-
Once done this I now have to bring the components into the PCB editor to draw the actual traces which the milling machine will mill in the copper. Go to Tools > update PCB from schematic, you can also do this with the shortcut button:
-
A window with all the components in green appears (it should not have warnings/ errors in red) > update PCB.
-
I should get the footprints (pads of the components and traces to join them in the board) but instead I get a blank page. Nothing appears. I can actually see that the page has loaded the components but they are nowhere in the window display:
-
I tried downloading again the program as there was nothing I tried worked. I did not have to reinstall the symbols, footprint libraries and configure paths again.
-
Updated again PCB board and still, nothing appeared.
-
Loes helped me out here. The solution was very simple! You basically change in preferences from Modern Toolset (Fallback) to Modern Toolset (Accelerated).
-
Now I have all the components in my PCB editor all together.
-
I now proceed to select components and move them around (this gives you the freedom to create PCB boards whatever shape you want). Usually you spread components around to check how the connections should be and then rearrange them in order for connection lines not to overlap (maybe rotating components, moving components, etc.)
-
I now start thinking how to assemble the different components. I know I want the FTDI to be at the top (because of the outline shape, I have in mind, it is the only place to place it). The rest I will try to assemble them as untangled as possible.
Some tips I read on Tessel’s documentation to place the components:
-
Make sure traces do not overlap. (Quite done)
-
You can run a trace under the resistor.
-
Timing: even the smallest trace of copper takes time. Place the resonator and the resistor as close as possible to the chip and make sure the two traces are the same length.
-
Make the board square for efficient cutting.
-
Consider rotating the components to make the traces.
-
I decide to change my resistors around the microcontroller to follow Tessel’s tips:
-
I also try rotating my components which you do like this:
-
Some lines can be left overlapped because the green line symbol will solve the overlapping white lines (which are called air wires) by replacing them with a trace(actual trace which will be milled in the PCB board). You have to make the traces one by one following the white lines (which are there to help follow the path, when you connect the components they go away). The following image was my first attempt to create traces, some lines would remain white and would not allow me to make traces over them so I guessed it had something to do with the arrangement of my board.
-
I deleted all the traces and tried so many different combinations in order to make the traces work. None of them worked.
-
I always came to a point where I could not join one of the traces:
-
Loes gave me a nice tip which was “For tracing: start with the important things, then the VCC and only last the GND”. I also watched this tutorial to understand if I was missing any step. I decided to go for a more simple layout. I tried do it with the tip Loes said and it worked! What I basically did was to try to do the connections very slowly and actually thinking about where the traces were crossing by or if they were stopping a connection.
-
For the outline (called edge cuts) I followed the tutorial mentioned before which indicated me that the outline was done by selecting the Edge cuts layer (an arrow has to appear next to it) and then with the “add graphic lines” button on the left hand-side menu draw the outline of your PCB.
-
I pressed the electrical rule checker and it gave me no errors.
-
Now that my board is traced I am ready to export. First it is advisable to check it in View > 3D viewer = you can see board design here. Looks fine.
-
I export the file to SVG
-
In the export window make sure to tick the following boxes:
-
It will generate two types of files: one with the interior traces and one with the outline traces. (Later on I discovered that you also have to untick the “Print board edges” but this is explained below).
-
The two files are now saved to my Individual Assignment Echo World folder:
Working with Photoshop, Mods and small cnc machine to mill the PCB board:¶
-
We can either open the interior line SVG in Gimp or in Photoshop to change the resolution of our SVG. When opening the file the following window will appear, change the width and height to mm and the resolution to 300 pixels/inch.
-
I save the file in PNG but I realise it is not saved in the format MODS reads PNG, and also in the interior trace file the outline is also visible, it looks something like this:
-
So what I learn is that when you open the svg (with mm changed and resolution to 300 pixels/inch), first I deleted the outline line and then > Layer > New Fill Layer > Solid Color > OK > Choose white:
-
Drag the the new white layer created below the drawing.
-
Now create a group and place both layers inside and press the button showed below and select Invert:
-
We can also double check the image size here:
-
This is the PNG I have:
-
I repeat the same process for the outline PNG:
-
About to start milling it I wonder if the UPDI and FTDI connections should not be more in the edge of my outline board (to make it easier for the components to connect), so I go back to Ki-cad and start the process all over again!
-
After spacing the components out and putting them near the edges I redraw the traces, run electrical checker, and export the 2 SVGs again. When exporting it I realise with Henk that by unticking “Print board edges” the outline does not appear in the interior traces SVG. So this is also an important step when exporting!
-
I open the two files in Photoshop, setting up mm and resolution to 300 and re-do the process for the interior traces file. This is the outcome:
-
I then realise I did wrong the outline traces file. Because it is not designated as white and black areas but rather just a white trace (MODs does not read this). I open it up in Photoshop and with the bucket I paint the inside white.
-
I open it in mods and check the toolpath view window and this appears:
-
Because the lines meet the boundaries of the PNG, MODS is unable to read the trace properly so I select the whole shape and scale it down very little so it does not affect the PCB to 98%.
-
This is my new outline trace:
-
I now open Mods and check if it has a continous line: it does!
-
I move to the computer connected to the small CNC machine and open first the interior traces PNG. For this process I follow the complete steps from the Electronics Design week. After doing all the steps I start to mill the PCB. I had to stop the tryout in the first minute because the mill started going out the copper board.
-
I realised the space for the milling was too tight for my design, after measuring the space left I decided I had to place a new copper board.
-
Unfortunately the second tryout also came out very bad, traces were not done completely.
-
I realised this was because the mill had broken and also because the copper board was not properly stuck.
-
I had to stick it again and push it till there were no spaces in between.
-
I learned that if you push the up and down button on the CNC machine it resets it.
-
Finally on the third tryout things worked out. Result:
Soldering the PCB board:¶
-
To solder, the most important thing is the orientation of the components. To understand the orientation and how to position it in the board I have to look into the datasheet of the component. The datasheet is a set of instructions for each electronic component.
-
I re-wrote the following components’ table and completed the orientation section to know for which ones I needed to pay more attention (read the datasheet):
Component | Information | Orientation |
---|---|---|
ATtiny 412 | Microcontroller_ATtiny412_SSFR | Yes |
UPDI header | Conn_UPDI_01x02_Male | Yes |
FTDI header | Conn_FTDI_01x06_Male | Yes |
Capacitor 1uF | C_1206 | No |
LED | LED_1206 | Yes |
Resistor 1 | 5k for the LED | No |
Phototransistor | PHOTOTRANSISTOR-NPN1206 | Yes (different corner should be pointing towards the resistor) |
Resistor 2 | 10k for the phototransistor | No |
Switch Button | BUTTON_B3SN | Yes |
-
Ready to start soldering:
-
I first started with the chip. I did not know how to orient it so I had to look at the datasheet. I first searched the Microcontroller_ATtiny412_SSFR in Digikey but there were too many options to choose from.
-
So what I did was go to the components section of the Fab lab Inventory and look for the Microcontroller_ATtiny412_SSFR. There was only one 412ATtiny so I assumed it was this one. The first column of the Fablab inventory are the serial numbers for Digikey. The serial number for this component was ATTINY412-SSFRCT-ND, I pasted the number in the Digikey search bar and I found it.
-
I opened the datasheet for the chip but it was too long and I did not know where to look for the information I needed. So I looked into help guides on how to read datasheets and I came across this very helpful one. Here I learned that “A pinout lists the part’s pins, their functions, and where they’re physically located on the part for various packages the part might be available in.” So I opened the datasheet and in the index I looked for the pinout diagram. This is what appeared:
-
I now opened the Ki-Cad and the diagram and compared them. I compared the VCC and GND position with the labels on the components in Ki-CAD.
-
The dot (which you can also see in the physical chip) will be the guiding side to place. It is next to the VCC, so I now know in which orientation to put it.
-
The next component I placed was the FTDI, this was quite a simple one, the short pins have go towards the inside of the board.
-
Then I placed the button. This was also a tricky one. I looked for the serial number and then looked for it in DigiKey. What helped me to understand its orientation was the bottom view of the button because it had a name written on it.
-
From here I then compared it with Ki-Cad and then soldered it.
-
The LED had the same procedure. In the data sheet cathode and anode have a specific side. You can then check Ki-CAD to see that the anode side is connected to the chip and the cathode side to the resistor.
-
The phototransistor has one side connected to the emitter and one side connected to the collector. I oriented the phototransistor because it had a small mark in the bottom right hand corner. Compared it to Ki-CAD schematic and soldered it in the right direction.
-
The UPDI, resistors and capacitor were very easy to place.
-
Philip pointed out I had soldered the wrong UDPI connector to the board. So I had to remove it carefully and place the correct one which I had to cut out because they were all together.
Checking the PCB board:¶
-
I checked the traces with the continuity mode on the multimeter and they all worked. I used the following multimeter which for continuity you have to turn the wheel till the ohm sign and then press select. I connected every trace with both terminals and they all beeped, which means they all worked.
-
One thing I would change from my board is the amount of extra space there is around the traces. I should have done the outline a bit smaller so it is not such a waste of copper. Other than that I am quite happy with the outcome of my first EchoHelloWorld board. By the way the outline shape is where I live, Gran Canaria!
The following was done in week 8 as we did not complete the whole assignment on this week so you will see it repeated in both weeks:
Loading a program and checking if the board works:¶
Debugging my hello echo board:¶
This week I learned the origin of debugging from here. This comes from american engineers calling small machine flaws “bugs” because “when the first computers were built during the early 1940s, people working on them found bugs in both the hardware of the machines and in the programs that ran them. In 1947, engineers working on the Mark II computer at Harvard University found a moth stuck in one of the components. They taped the insect in their logbook and labeled it “first actual case of bug being found.” This log book was probably not Hopper’s, but she and the rest of the Mark II team helped popularize the use of the term computer bug and the related phrase “debug.”“
I also learnt how your programming problems can be all about DEBUGGING, like me this week. Here is a quick checklist Neil did for debugging, there are all kinds of things that can go wrong both in hardware:
-
inspect, reflow solder joints
-
check component orientation, values
-
verify data sheets to make sure it is right
-
confirm connector orientation
-
measure supply voltages
-
probe I/O signals oscilloscope, logic analyzer
and software:
-
in code once your LED is blinking you can use your LED blinks to debug your code by putting in messages.
-
once you have a terminal connected you can have it print out messages(print statements)
-
you can also use embedded debuggers (gdb, ddd, Atmel Studio) that allow you to reach in and change the code as it is running.
Try to program my Hello Echo Board.
-
I have a UPDI(same than FTDI but with a two pin connector) and a Hello Echo Board. I still have to make a FTDI board.
-
My UPDI is working.
-
My Hello Echo Board it not working (LED blinks but it is not going into the system).
-
I assume the problem is within the UPDI connector and the chip. So the first thing I will do is check the traces with the multimeter, check that the traces that should connect to each other are connected but also check that the traces that should not be connected to each other are not connected.
-
For this I have to open my schematic because I can’t visually see all the traces (some are under each other). After opening Kicad, I check the paths and I discover that one of the UPDI pins has extra solder at the back of the pad. This extra solder connects to the paths behind the pin which makes that pin connect to the button when it shouldn’t, it should only connect to one of the legs of the chip. (Paths connected where they should NOT connect).
-
To solve it I try sucking the solder out:
-
This does not work so Henk helps me out and uses the hot gun till the component slowly moves out of place. After this he sucks out the solder iron, perfilates the path with a cutter to remove any excess solder and resolders the component again in the right place.
Connecting FTDI, UPDI and Echo board to my laptop:¶
-
In order to UNDERSTAND SOMETHING this week, I followed this tutorial on Setting up UPDI Programming Toolkit with Arduino, megaTinyCore and pyupdi. Basically what we will be doing is install Arduino, make a tiny core, and with pyupdi program my hello world.
-
How do we do this? For this I need a UPDI, FTDI and Hello echo board which I previously checked they were working and connect them as follows.
-
I had previously downloaded the Arduino IDE for my group assignment here
-
Basically when programming a board you need to set up a board and a programmer but the Arduino default does not have AtTinys so I also followed these steps from Adrian which explain how to set up and download the library of the AtTinys and Atmegas for the Arduino environment (this sets up the right environment for the UPDI to read my helloechoboard, and this is also explained in the tutorial above). From the megatinycore page I follow the following steps:
-
I open Arduino and install the board package through the board manager. The boards manager URL is:
http://drazzy.com/package_drazzy.com_index.json
-
For this I go to File -> Preferences, enter the above URL in “Additional Boards Manager URLs”.
-
Then go to Tools -> Boards -> Boards Manager…, wait till the list loads and type “megaTinyCore”, “megaTinyCore by Spence Konde” and click “Install”. For best results, choose the most recent version.
-
I then configure the Arduino IDE for the ATtiny412 (the processor I have in my hello board). Make sure also the clock speed is set up to 20MHz. .
-
It is important to have the FTDI-USB connected and choose the “Serial Port and 4.7k (pyupdi style) programmer. This new version has the UPDYI uploader already integrated in the Arduino environment (before you would have to download this from terminal as the previous tutorial explains).
-
I check my UPDI is connected to the computer in About this mac > system report.
-
And I now connect it by selecting it under Tools > Port
-
We will use the Arduino IDE to compile the code. In order to find the compiled files to send to the updydi tool which uploads the code to the board we will need to edit a the configuration file in order to send this files to a specific folder. To do this we have to go to Arduino > Preferences and click on the preferences files.
-
We can only edit this when Arduino is closed so we close Arduino and open the preference file. Once it is opened:
-
We will add “build.path=home directory”
-
and set it up to where my home directory is which I will know by opening terminal and typing:
cd
pwd (print working directory)
- This will show my home directory which is “/Users/paulalonso”
This is not just the home directory but where the Arduino files will be. I type my home directory in the preferences text file with a new directory called build.
- Save this and closed it. Go back to terminal and type
cd Documents/Arduino/
ls
-
This will show up a new folder for a libraries.
-
We need to make a build directory:
-
We now have the folder that will hold our Arduino compile file (hex file).
-
In the programing examples here, there are two options: the Arduino IDE option or the echo option (which is if you want to directly try command programming). I will go for the Arduino option.
//
// hello.t412.blink.3.ino
//
// tiny412 blink hello-world, 3-pin UPDI+VCC header
//
// Neil Gershenfeld 1/10/21
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge this project. Copyright is retained and
// must be preserved. The work is provided as is; no
// warranty is provided, and users accept all liability.
//
#define LED 4
void setup() {
pinMode(LED,OUTPUT);
}
void loop() {
digitalWrite(LED,HIGH);
delay(100);
digitalWrite(LED,LOW);
delay(100);
}
-
You basically copy this to test out your programming workflow and you define the LED by comparing the datasheet of the microcontroller with my kicad pcb diagram and checking what pin is connected to the LED. I also saved the file.
-
Then in the define section you define the LED which in my case would have to be the “PA6” or “2” pin. I define it and upload the program but the LED does not blink. I try all the different pins but none of them work.
-
I will try to make my button work and see if this works. The button is an input for the ATtiny412. For this I go to Nadieh’s documentation and copy her code directly as I have seen we both have the same chip orientation and for her it works, which means that if it does not work for me then I have something wrong on my board.
-
This did not work either. Henk helps me out and we try to see if maybe the button is the wrong way around? We check with the multimeter and we realise the problem is that one of the corners of the button has solder and this connects it with the ground path(which it shouldn’t).It would not stop beeping when pressing the button.
-
Henk took the solder out with quick braid and the solder heat;
-
But when realigning the trace with the cutter the trace got destroyed so it now has a nice bypass but it works:
-
After fixing this we uploaded the program again but it still did not work. So we followed the pyserial procedure
-
We checked again with the multimeter and realised that all the pins from the FTDI would connect to each other (they beeped), this meant the solder pads had got into the trace behind it.
-
When I took out the FTDI connector with the hot gun, traces came out, and we realised the pads from the FTDI connector were too close to the trace behind it. They have to be at least 0.4mm distance- How do we measure in Kicad to know they are so far apart?
-
Henk fixed this by taking out all the traces, connecting with solder the GND, RX and TX connections from the FTDI connector. For the VCC he made a bypass. He then connected all the FTDI pins with hot glue.
-
We tried programming again and the button worked, screen when opening the serial monitor:
-
We then checked the LED and realised the resistor had solder in between its two pads and it should not because it is a bridge to a path underneath it:
-
So we took it out, took the excess solder and solder it again.
-
The program was now working!
Files to this week’s assignments:¶
-
This is the Ki-CAD schematic file in PDF for my first hello echo world board | helloechosch
-
This is the traces PNG for my first hello echo world bord | helloechotraces
-
This is the interior PNG for my first hello echo world | helloechointerior