Difference between revisions of "Workshop: Introduction to electronics"

From Design and Build Lab
Jump to navigation Jump to search
(Ohm’s Law)
(Ohm’s Law)
Line 147: Line 147:
  
 
<math>V = IR_{min}</math>
 
<math>V = IR_{min}</math>
 +
 +
<nowiki><math> I = \frac{V}{R_{min}} </math></nowiki>
  
 
<nowiki><math> I = \frac{V}{R_{min}} </math></nowiki>
 
<nowiki><math> I = \frac{V}{R_{min}} </math></nowiki>

Revision as of 16:04, 26 March 2019

(Generally, this workshop is offered at least once a week on a rotating basis. Check the Lab calendar for up-to-date availability!)

Introduction

Welcome to Basic Electronics! This workshop is designed as a primer on the field of electronic circuits. You will be introduced to the fundamental concepts of electrical engineering, including both signal flow and basic circuit analysis. Breadboards are introduced, and you will then experiment with simple components and build several simple circuits. Finally, you will learn the basics of soldering, and assemble a permanent first prototype of your circuit!

What concepts are we going to cover?

  • Electricity and Ohm’s Law
  • Introduction to components
  • Schematics and circuit analysis
  • Prototyping a circuit
  • Making a permanent first build

In what context are we going to be covering them?

  • Breadboards
  • Soldering stations
  • Printed Circuit Boards (PCBs)

What am I expected to know before taking this Workshop?

Nothing! This course is designed as an absolute introductory primer in the field of electronics.

Where can I go from here?

DaBL has a series of Workshops designed to the teach the fundamentals of modern low-power electronics. This Workshop is the first step in that process. After mastering this material, there are two paths which can be taken, either separately or concurrently:

  • Hardware electrical engineering: building and understanding electrical devices
  • Microcontrollers: using tiny computers to interact with your environment

There are also several supplemental Workshops which we encourage you to take if you want a more well-rounded overview of the field, and for those who want more exposure to software/hardware interaction.

Let’s get started!

Welcome to the world of electrons

Today you will be learning the basics of electronic circuit theory, which includes circuit analysis, breadboarding, and soldering. What is a circuit, anyway? A circuit is simply a set of electronic parts which are interconnected to manipulate electricity. Both of these are circuits:

Schematic Printed circuit board

The first is a circuit schematic, which is an illustrative representation of how the various parts of the circuit are connected; the second is a printed circuit board (or PCB), on which all the various parts of the circuit are physically connected. These parts, incidentally, are called components. You will be learning about and working with several different components today.

Electricity flows

When engineers talk about DC circuits (which is the kind you’ll be analyzing and building today), three quantities are used to describe them: voltage, current, and resistance. The easiest way to understand these quantities is to use the analogy of a radiator system in a house. In the basement, there is a radiator hot water tank from which water is pumped to the top floor; the water then flows through a radiator on each floor and back down into the hot water tank. The entire system is a closed loop, and water only flows in one direction.

Current: measured in amps, represented by the unit A

Current represents the amount of charge per second moving through a specific location in the circuit, and it is the easiest quantity to understand in this analogy: the amount of water per second passing through a specific location in the system.

Voltage: measured in volts, represented by the unit V

Voltage is also called electric potential, and it represents the amount of energy per charge. In the analogy, it’s similar to the potential energy of the water. The higher the floor you push the water to, the more potential energy it has; when it returns to the tank, it is back to the original amount of potential energy.

Resistance: measured in Ohms, represented by the unit Ω

When a component opposes electron flow, it exhibits resistance. Resistance can be thought of as a narrowing of the pipe in the analogy; imagine that the pipes which transport the water to the radiators are of some diameter, and the pipes of the radiators themselves are much narrower. This ultimately causes a decrease in the current.

Incidentally, the hot water tank itself can be analogized to ground, where there is both a place to source the water/electrons from, and a place to sink the water/electrons into. This concept will be discussed in subsequent courses.

Activity 1: Completing the circuit

A circuit is said to be complete when current can flow in a loop through it. If we were to break one of the pipes in our home radiator analogy, water would no longer be able to flow back to the tank, and the system comes to a (soggy) halt. The same goes for electrical circuits: if you don’t complete the loop, don’t expect a working project! With that in mind, it’s time to connect up your first circuit.

Breadboards are the best

We’ll be using three components (a 9V battery, an LED, and a resistor), plus a very special piece of equipment: the breadboard. The breadboard is an incredibly handy tool used to rapidly assemble and modify a circuit; to prototype without the need to solder. A series of isolated metal rails are mounted inside a plastic housing, which can be accessed through holes on the breadboard's front face. The rails themselves allow you to electrically connect components, and the holes in the plastic housing hold the components in place. Take a look at the top face and the internal connections:

The top and bottom of the board contain a pair of horizontal rails each; the center of the board contains vertical columns of rails. (Note: this course will always reference the breadboard in landscape orientation!)

  • Typically, the top and bottom pairs of horizontal rails function as power rails - you’ll connect the leads of your battery here, and whenever you need to connect something to the battery, you plug into here.
  • The central sets of vertical columns are used to connect the various other components of your circuit; in this first case, your LED and resistor. Note the trough in the middle - it electrically separates the top and bottom columns.

Setting it up

Let’s set up your breadboard so that you can conveniently access power from either side. Grab your jumper pack and pull out two wire jumpers, each about two inches long. On the right end of the board, use one of the wires to connect the top blue rail to the bottom blue rail, and the other to connect the top red rail to the bottom red rail, like so:

Push those legs in all the way! Now you have access to power from both the top and bottom of the breadboard. You won’t always need to do this; in fact, you may encounter projects which require more than one source of power, in which case you most assuredly will not want to do this. But since we’ll only be using one source of power in this course (the 9V battery), wiring the same power to both the top and the bottom makes building the circuits easier.

Connecting the components

The first circuit you’re going to hook up only has the three aforementioned components: a 9V battery, a resistor, and an LED. A full explanation of their functionality is coming, but for now recognize that the goal is to get the LED to light up - without burning it out! To do so successfully, you’ll use your breadboard to connect:

1. the positive rail to the long leg of the LED 2. the short leg of the LED to one side of the resistor (it doesn’t matter which) 3. the other leg of the resistor to the negative rail 4. the 9V battery to the power rails

Your complete circuit should now look something like this:

and your LED should be lit! Here’s another important note: as long as you’re correctly following the internal connections of the breadboard, it’s up to you where on the breadboard you wire up your circuit. It also doesn’t matter which order you place your resistor and LED in: since there is only one path for the current to take, the current is the same everywhere, and it makes no difference which component comes first. So you could also connect your circuit in a different way and it would function exactly the same:

OR

Aside: Uh oh, something went wrong…

Problem: the LED is not lit.

Cause: your circuit is not complete; your LED is in backward; or your battery is dead.

Solution: trace your circuit to see if the current can flow in a loop; switch the direction of the LED; or swap the battery.

Problem: the green LED turned orange, then turned off. Something smells funny.

Cause: you’ve hooked up the LED directly across the battery, skipping the resistor. Congratulations - you’ve burnt out an LED!

Solution: unplug the battery, carefully pull out the dead LED (it will be hot), grab a new one, and fix your circuit.

Activity 2: Schematics and components

Taking pictures of a breadboard is useful for simple circuits, but with added complexity comes added difficulty in discerning exactly how things are wired. This approach, when scaled up, really isn’t useful. So when you want to represent a circuit visually, there is a standard way to draw the components and the connections between them: the schematic! A schematic is an illustrative representation of how components in a circuit are connected. Check out the schematic of the circuit you just built:

So much easier! Each one of those shapes is a component, and the lines in between are just the wires interconnecting them. Each type of component has a standardized schematic symbol with which it is associated, so you can quickly identify it in a schematic. Let’s (finally) get acquainted with some components and their associated symbols!

Voltage Source

A voltage source creates a potential difference; in the analogy, it is the pump pushing water up to the top floor of the house. There are many types of voltage sources; the most common is the battery. Batteries are represented in schematics as such:

You’ll notice that there are positive (+) and negative (-) signs on the battery. This means batteries have polarity, and therefore it is important to connect their pins in the correct direction, or current may flow the wrong way… or not at all!

It should also be noted that when analyzing circuits, conventional current flows from the positive terminal, through the circuit, to the negative terminal. This will be discussed further in subsequent courses.

LEDs

The LED is a special type of diode that emits light when current flows through it. “That’s great!”, you’ll say, “But what in the world is a diode?” A diode is a one-way voltage-controlled current gate. We won’t get into the semiconducting properties of the materials which make up diodes; you can simply think of them as a valve in the water analogy - one that only works if the pump pushes water high enough into the system. The diode insulates when there isn’t enough voltage across it; no current will flow through. When enough voltage is dropped across is (called the forward voltage), it opens up and allows current to flow through - it conducts. In the case of a light emitting diode, when the gate opens and current is flowing, part of the energy of that flowing current is converted into photons; light!

Because LEDs (and by extension all diodes) act as one-way gates, they have definite polarity! The left side of the schematic symbol is the positive lead, called the anode; the right side is the negative pin, known as the cathode. On most LEDs you will encounter, the anode is connected to the longer leg, and the cathode is connected to the shorter leg.

Resistor

Resistors oppose the flow of electrons. Their schematic symbol varies depending on if you’re in the United States or somewhere else. This course will use the international version.

Resistors are not polarized; you can connect them in either direction, and they will function the same. Their nominal resistance is stated in Ohms (Ω).

If you look at a resistor, however, you’ll notice no print on the side; only colored bands. They are used to indicate the nominal resistance value! Take a look at resistor color coding for more information.

Going further

Because you now know that there are resistors with different values, you should also begin to realize that you can control the current of the circuit with them! The resistor you first used is 220Ω; what should happen if you replace it with a 10kΩ resistor? Try it.

Now what happens if we remove the resistor entirely, and just have the battery connected to the LED (as below)?

With the battery unplugged, plug the LED into the breadboard; then plug the battery leads into the rails, being careful not to touch the LED. When you are certain no more current is flowing, unplug the battery leads. Do not touch the LED. Wait a few minutes, and then pull the LED out and toss it in the trash.

Activity 3: Variable resistance and Ohm’s Law

The last circuit you made was interesting, but also entirely static: you plug it in and it lights up, but you can’t really do anything else with it. Let’s get some actual human interaction! We’ll use the ambient light in the room to change the brightness of the LED.

Photoresistors

The photoresistor or light-dependant-resistor (LDR) is a type of variable resistor. Variable resistors change their nominal resistance based on external changes. The photoresistor has a sensor on its top face which responds to light, and changes its resistance accordingly. The resistance is inversely proportional to the amount of light hitting it, i.e. more light equals less resistance.

Build the circuit to the right on your breadboard. Once you plug your battery in, what you should see is that as you change the amount of light hitting the top face of the photoresistor, the LED changes in brightness! This is because the changing resistance is ultimately changing the amount of current flowing through the circuit, and because the LED’s brightness is tied to the current running through it, you can change it just by waving your hand back and forth. But why does resistance change current?

Ohm’s Law

Based on what you’ve just seen, the three quantities of electricity which we introduced earlier - voltage, current, and resistance - are clearly tied together somehow. It turns out that they’re actually mathematically related - and that relation is very easy! The equation, called Ohm’s Law, will be one of the most important tools in your toolkit:

V is the variable for voltage, I is for current, and R is for resistance. If you know two of the variables, you can solve for the third! Let’s do a simple calculation. We actually know the total V for the system: 9V. The LDRs you are using have a minimum resistance of 3kΩ, so we also know R! All we need to do is solve for I.  

<math> I = \frac{V}{R_{min}} </math>

<math> I = \frac{V}{R_{min}} </math>

Why did the LED burn out? ADD CONTENT HERE.

Activity 4: Potentiometers, and series vs parallel

Photoresistors are but one of many variable resistors. The one you will more likely encounter is the potentiometer.

Potentiometers

A potentiometer (or “pot”) is another type of variable resistor. It has three legs. If you want to use the knob as a normal, fixed resistor, just connect the two outside legs. However, if you want a varying resistance, you’ll use the middle leg. The middle leg is the wiper: it is connected to the knob, and it slides between the outside legs. Connecting the wiper and one of the outside legs gives you a varying resistance when the knob is turned. It does not matter which outside leg you connect to; it will only change the behavior of the resistance with respect to the knob.

Series versus parallel

In the circuits you’ve built so far, there was only one path for current to flow through. In those circuits, all the components are said to be in series; that is, following one after another.

But what is happening here? Current is flowing into the potentiometer and splitting between two paths! These two paths (each of which go to another resistor, then an LED, and then meet back up) are said to be in parallel; that is, that they split off from one another and then recombine. And when you rotate the knob, you’re actually changing the ratio of resistance between each of the two paths. These two paths are in parallel, meaning the current will split between them.

You already know that changing the resistance of part of a circuit also changes the current; more resistance equals less current, and less resistance equals more current. So by extension, varying the resistance between two paths should change their currents as well. Congratulations: you’ve just made a current crossfader!

For a more detailed explanation of series and parallel, see resistors in series and parallel.

Activity 5: Soldering

So you’ve got a breadboarded prototype of your first circuit. How do you make it more solid so you don’t have to delicately carry around a rats nest of wires? Soldering is the more permanent solution to connecting electronic components, and involves melting an alloy (often this is tin/lead, but increasingly this is being replaced with non-leaded alloys) onto the interconnection between the parts. Solder sometimes contains flux, which is a cleaning agent used to [1] remove oxidation from the leads of the components, [2] prevent further oxidation during the connection process, and [3] help the liquid solder flow more easily by reducing its surface tension.

IMPORTANT SAFETY PRECAUTIONS

Soldering is hot! (Sometimes in excess of 500° Fahrenheit.) Solder contains carcinogens! (Specifically, lead.) The following should be kept in mind at all times when soldering:

  • keep the area around the iron clear of any objects
  • keep the cable connecting the iron to the base station clear so nothing gets snagged
  • be aware of your surroundings

A permanent prototype

You will be taking your most recently breadboarded circuit and making a permanent build of it on what is called a printed circuit board - more commonly known as a PCB. The PCB itself is a piece of fibreglass with custom copper paths - called traces - which are used to interconnect the various parts. It is just like your breadboard, except that is has been custom designed to contain your project and your project only! You will be pushing the legs of your components in through the top of the PCB, and soldering them to the copper pads on the bottom side.

The PCB also has a layer on top of the copper called the solder mask, which protects the internal traces from damage. On this board, it is purple. Usually on top of the solder mask, the PCB will also have a silk screen, which contains text and images helpful to anyone looking at the board. This is the circuit you’ll be soldering together:

You’ll notice that it’s just a combination of two of the circuits you’ve already built, with one addition: a switch. This switch has a single pole which can only connect to one other pole; it is said to only have one way to be thrown. Therefore, this is a Single Pole, Single Throw switch; SPST.

Soldering Step 1: Setting up your workstation and parts

In order to solder together your new device, you'll need the following:

  • Soldering iron and station
  • Soldering iron cradle (to hold the iron)
  • Tip-cleaning device (this will either be a wet sponge, or brass shavings)
  • A way to hold your PCB in place (likely you’ll either have a vise of “third hand”)
  • Wire cutters
  • PCB and the components
  • Solder!

Put your iron in its cradle, plug in the soldering station, and make sure the area around both of these devices is clear. Then turn on your station. It may have actual temperature control, or it may just have a knob. Either way, ask your instructor what temperature setting to use.

While your iron is heating up, make sure you have all the necessary components.

Then, grab about 12” of solder from the spool and wrap it gently around your non-dominant thumb, leaving about an inch or two pointing outward from the pad of your thumb.

You’re going to be pushing components in from the top of the PCB and soldering them to the bottom. Secure the PCB in your vise (or both alligator clips of your third hand). Pick up one of the 470Ω resistors and find its corresponding shape on the top of the PCB. Push its legs all the way into the board from the top face so that the resistor is sitting flush with the board. (Remember that they don’t have polarity so it doesn’t matter which way you insert them.) Then gently bend the legs so the resistor won’t fall out when you let go!

Soldering Step 2: Clean and tin, clean and tin…

Soldering depends on proper transference of heat, and heat transference depends on proper metal to metal contact. If there is anything in between, it will hinder the process. Oxidation will inevitably occur on any metal surface, and is especially likely on the tip the longer the iron remains on. So it is important to remove this oxidation regularly to keep the heat moving!

Pick up the soldering iron and hold it as you would hold a pencil. Cleaning the tip is as easy as simply rotating and dragging it across the brass shavings (or wet sponge).

The second part of this equation is to remember to add a very small amount of solder to the tip after you clean it; this is called tinning. You do this for the same reason you add oil to a pan when you are cooking: to increase the surface area of the fluid, and therefore more effectively transfer the heat into the two objects you are soldering together!

Soldering Step 3: Apply that heat!

It’s finally time! The goal with all your solder joints today is to use the solder to connect the leg of the component with the copper pad on the PCB. In order to do this, you’ll need to heat both the leg and the pad, and then get solder to flow over both of them. The most important point to remember here is that solder will flow toward the source of heat. So when you make your solder joints, you want to:

  • place the part of the tip with the “tin” you added onto both the component leg and the copper pad
  • apply more solder from the stash in your non-dominant hand on the opposite side of the leg to where the tip is.

Notice that the solder joints in the pictures above and below kind of look like Hershey kisses; this is what you are aiming for.

Take your time! Figuring out exactly how to do this is tricky at first, since this is basically an exercise in fine motor skills. You may have to add more “tin”, or move the initial application of the solder to somewhere a little closer to the tip. Ask your instructor for help if you are unsure.

When you are satisfied that all the component’s legs are secured on the PCB, use the wire cutters to snip off the excess leg.

Soldering step 4: Everything in its right place

Continue soldering components to your PCB; make sure to take note of the components which have polarity (LEDs and the battery); you don’t want to solder them in backward! You’ll find that soldering becomes easier the more you do it.

Congratulations; you have just made a permanent prototype of your first circuit! Test it out to make sure everything works.

Now turn off your iron, and return all the tools back to their rightful positions in the shop - but be mindful of the iron, cradle, and station. The iron needs to cool down before storing it. Let it sit for five to ten minutes, and then pack it up as well.