Electronics design
Intro
Hello future student, perhaps you're new to electronics and Henk has sent you to my page as an example of someone who started this week with no prior knowledge. Perhaps you're struggling with Electronics design and wondering how to noob your way through this week. Well, before you do anything, watch these three videos:
- Basic Electronics for Beginners in 15 Steps
- How to Make a Circuit Board (Beginner's Guide)
- Aalto FabLab KiCad tutorial and use Nadieh's notes
Other useful resources
Tasks
Electronics concepts
Voltage (V, Volt)
Is measuring how much electrons would like to go from one place to another. Voltage is the amount of motivation electrons have to move.
The force getting them to move is Voltage. Push enough against those electrons and they will jump.
In the example below you'll see Angel falls. Think of this as a good representation of high voltage
. There is a lot of force behind the water / "electrons" moving to ground.
Niagara falls is more low voltage
, as it's a wide, short drop.
Current (I, Ampere)
The total amount of electrons in a circuit. Angel falls might be considered as having low current, whereas Niagara falls has lots of it.
NB. The sum of all voltage in a loop = 0. All of the voltage is used as it returns to the end of the circuit
DC - direct current. Always positive.
AC - alternating current. Its polarity switches positive to negative.
Power (P, Watt)
P = Voltage x Current (V x I)
Energy is Power over Time (eg. kWh)
NB. In a closed circuit, you don’t lose current (amps), you lose voltage.
Electronics components (some of them)
Resistors (R)
Current limiting. They create resistance for electrons.
If there is too much voltage being resisted, the energy will be dissipated in heat. The heat can/will destroy the circuit.
Two main types of resistors: pin and surface mount (SMD).
The rings on pin resistors will tell you its value. The first two rings are numbers > the next is the additional zeroes > last is the degree of accuracy (eg. 5% meaning the results will be between 95 and 100ohms)
For SMDs: the first two are the numbers, last one is the zeros
Resistors don't have polarities.
Resistance = voltage / current
Capacitor (C)
- Storage tank for electric fields.
- Store them and they will retain the charge.
- Often used in filters to block out the wrong kinds of currents. This also helps smooth out the signal that's delivered.
- They can be polarized or not.
Diode / LED (D)
- They act as a one way valve for electrons.
- “bridge rectifier”
- Can use to make an AC signal a DC signal.
Coil (L)
- A storage tank for magnetic fields.
- Short circuit for DC current.
- Typically used in relays and motors.
- Magnetism can be used to create motion (motors).
- Relay is a switch that’s controlled through the magnet
There can be quite a lot of energy stored in the coil, if you suddenly yank the power, there can be issues. But, a flyback diode can dissipate the magnetism -- it's like a bleed resistor for a capacitor. Somewhere to manage the release the stored energy in a coil or capacitor.
Transistor (Q)
- Amplifier and/or switch.
- Bipolar — small current can amplify a large current.
- JFET - P / N.
- MOSFET: metal oxide field effect transistor — small voltage can drive a large current.
- Most digital systems we use MOSFETs.
Microcontroller (U, IC)
- Inputs, outputs, memory, calculations (ALU).
- Essentially, “being a computer” by sending signals to other devices to do the different kinds of heavy lifting.
Measuring devices
Multimeter
- They measure voltage and current.
- The black cable should always be ground.
- For DC signals, the multimeter is perfect.
- For signals that alternate, multimeter is not the best tool — multimeter will average out readings.
Oscilloscope
X and Y axis visualizations of a current, shown on a screen that's divided into squares, whose values can be adjusted in order to help better visualize the current.
NB. Always connect the ground first with any measuring tool.
Side Quest: ffmpeg gif making
To make the gif: ffmpeg -i osc.MOV osc.gif
To make a gif that's less enormous: ffmpeg -i osc.MOV -vf "fps=10,scale=400:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=64[p];[s1][p]paletteuse=dither=bayer" -loop 0 osc.gif
I tried using gifsicle to decrease the file from 2mb, but it just made it 1.9mb: gifsicle -O3 --lossy=80 -o osc.gif osc-lossy.gif
Used ffmpeg to trim the loop and got it down to 996kb: ffmpeg -i osc.gif -ss 00:00:00 -t 00:00:02 osc4.gif
Above is a gif of the oscillator in work. It shows how long it takes before the signal starts again. From one point in the wave until the same measurement at the beginning of the next wave is how you measure its period.
Below are the knobs that you can use to control the view on the oscillator screen.
Logic analyzer
- Basically an oscilloscope for digital signals
- It's useful for showing the relationship between multiple signals.
Individual project
Using KiCad
Import Fab library into KiCAD:
KiCAD hotkeys (also available in the right-hand toolbar)
a
place another componentr
rotates the itemm
to move itw
draw wired
data sheetv
value
This Aalto FabLab KiCad tutorial is a useful resource for the beginning steps of KiCad.
Here are the basic, main steps when working in KiCad:
- Compile a list of parts
- Check if the EDA files are in KiCAD
- Check if they're available on DigiKey
- Download the data sheets
- Place parts in a schematic
- Search and make sure the parts have footprints
- Add headers (GND, VCC, etc)
- Add capacitors and resistors
- Give them footprints
When the circuit seems ready, open the Electrical Rules Checker
to see if there are any Violations. The two that showed for me were because the Power pins weren't set up (solved here) and I hadn't imported the Fab library correctly (make sure to read the instructions carefully).
From Henk about this week's assignment:
build around xiao rp2040 or esp32-s3 button led (external, so the button on the xiao don't count) and then either a SPEAKER 8OHM 250MW SENSOR PHOTO 940NM TOP VIEW 1206 and all the necessary resistors and capacitors You are free to add your own in or output device so go through documents of previous years students, go through datasheets and try to impress me with a functional and beautiful board
Name | Label |
---|---|
ESP32-C3 | Module_XIAO-ESP32C3 |
Button | Switch_Tactile_Omron |
LED | LED_1206 |
Phototransistor | PT15-21C/TR8 |
Resistors | R_1206 |
Here's the view of my schematics editor before I moved on to arranging the PCB:
At about this point in the week I realized I was confused, afraid to start anything, and very, very alone (not really). Eventually though, I had to make the jump and start putting stuff into the schematic.
The hard part of KiCad is not the program itself, but rather knowing what to do when it comes to electronics.
This video helped me realize that that I didn't know how to design a circuit (theoretically). I had some basic questions that needed answering.
For instance:
Why can we put a resistor ""after" an LED?
And by "after" I mean: (VCC --> LED --> Resistor --> GND).
This is what AI had to say:
A current flowing through a series circuit is the same at all points. The resistor limits the current for the entire circuit, including the LED, regardless of its position in the series. As long as the resistor is in series with the LED, it will limit the current effectively.
Instantaneous effect: In an electrical circuit, changes occur almost instantaneously throughout the entire circuit. When you connect the circuit, the current doesn't "flow through" the LED first and then the resistor. Instead, the circuit behaves as a complete system immediately.
Constant current: In a series circuit, the current is the same at all points. This is because there's only one path for the electrons to flow, like a single-lane road. The current doesn't accumulate or diminish as it passes through components.
Voltage distribution: What changes across the components is the voltage drop. The total voltage from the power source is distributed across all components in the circuit. The resistor creates a voltage drop, leaving less voltage available for the LED, thus limiting the current through the entire circuit.
Electron behavior: While individual electrons do move through the circuit, the overall effect is instantaneous. When you turn on a light switch, the light doesn't wait for electrons to travel from the switch to the bulb; it lights up immediately because the electric field changes throughout the circuit at once.
How does a circuit work?
What is ground? How does it work?
(eventually this one just makes sense)
Understanding phototransistors
Here's a nice Phototransistor tutorial.
Phototransistors are made up the following basic parts:
- C = Collector.
- E = Emitter. The direction of the arrow on the emitter distinguishes between an NPN and a PNP transistor.
- B = Base.
- The Collector provides the "source" of current.
- The Emitter is where the current "leaves" the transistor.
- The light shining on the phototransistor controls the amount of current flowing between the Collector and Emitter.
NB. Arrow direction determines the transistor type.
In our case, the arrow is pointing towards the emitter. This indicates an NPN transistor.
If the arrow was pointing towards the base, it would be a PNP transistor.
Calculating resistors
Phototransistor resistor
The resistor value affects the sensitivity of the phototransistor. A lower resistor value (higher current) will make it less sensitive to light changes, while a higher resistor value (lower current) will increase sensitivity.
Collect the following from the data sheet:
- Desired collector current (Ic) -- "desired" because the data sheet lists the MAX, but we don't want that
- Collector emitter saturation voltage (VCE(sat)) Voltage between the Collector and Emitter Vce
- VCC
This is the equation to calculate resistance needed:
R = (Vcc - VCE(sat)) / Ic
(3.3-0.4)/.001 = 2.9kΩ resistor
LED resistor
I also had to figure out how much resistance I needed with the LED. I chose to have an Orange LED. Color affects the calculation because different colors have different Forward Currents.
Use the information below to calculate what resistor to use:
Button resistor
Use the information in this table to help calculate what resistor to use with a button in the circuit.
Rating (Resistive Load):
The switch is rated for 1 to 50 mA at 3 to 24 VDC. This means it can safely handle currents within this range without damage.
Ensure that the current through the resistor stays within the switch's rated range (1–50 mA).
- Choose a Target Current within the safe operating range of the switch; eg. 1 mA
- Use Ohm's Law
- VCC is your supply voltage (3.3 V)
- I is your desired current (e.g., 1 mA)
Practical Recommendations from AI
Use a pull-up or pull-down resistor between 1 kΩ and 10 kΩ, as these values are commonly used and fall within safe operating ranges for most circuits.
Button
After speaking with Sam, I learned that my button needed a pull up or pull down resistor. Otherwise, when you push the button, the circuit could short.
From Vera's documentation:
"The ESP32C3 and a lot of other boards have internal pull-up/pull-down resistors meaning in the chip there’s already these resistors. You can use them if you declare that you want to use them in your code."
PCB layout editor
Design Rules
In order to make sure that the PCB actually works, it must follow some design rules. Those, we need to define in KiCad.
I also added Constraints settings that Vera used last year (the third photo). She made a pre-defined 0.8mm track size so that she can toggle between 0.4mm and 0.8mm. She had this to say:
From the local review I heard it’s best to use 0.4 to connect pins and 0.8 for tracks that are connected to power.
File > Board Setup > Constraints
Drawing traces
NB. f
- Finishes the track that's currently being drawn.
I imported the schematic to PCB and started laying out all of the parts. Nothing was fitting right. The pins in the PCB view weren't in the same position as in the PCB editor. The rats nest makes it quite hard to concentrate, so it helped to toggle on/off the F.Fab
layer in order to hide the names of the parts.
Rejigged the pins in my schematic because my traces were blocking one another. Added labels.
I moved my LED to a lower pin (on the left hand side) and my Phototransistor to a higher one. That enabled me some space to make the traces flow easier.
Design rules checker
Lots of errors. Some silkscreen errors that I could easily fix. Others were nested under the XIAO MCU, not easy (or necessary?) to remove, and so I left those.
F.Cu + Edge.cuts
KiCad Image Converter:
- bitmap trace the image in black and white
- save it as
.kicad_mod
file - save it in a
.pretty
library folder (I called my libraryHenk
) - add the new Footprint library to KiCad
- use
a
to add the file to the PCB editor
NB. The Fablab Aalto video, linked earlier, also explains this process.
Footprint Editor > import file > select the object > right click > properties > set Layer to Edge.Cuts > save in the correct library
Select a
when in the PCB viewer and add the newly made Edge.cut file from the Henk
library.
Hero shot
Here's a final 3D render for this week's work :)