Duke Electric Vehicles
Duke Electric Vehicles
IMG_4033.JPG

Blog

Electronics Tutorial 0: Crash Course to Basic Electronics

Gerry Chen
Written: Jun. 16, 2018
Last Updated: Jun. 16, 2018

The world of electronics can be intimidating, especially without any formal classroom experience.  Rest assured, countless successful electronics tinkerers have excelled without formal training and you can too.  Whether your entire knowledge of electronics consists of "it turns on the lights" or you've been studying electrical engineering for years, designing electronic systems in practice boils down to a few fundamental concepts and a lot of learning on the fly.  In this tutorial, we'll talk about the fundamentals you need to know to start designing your own boards.

As a disclaimer, designing many of the electrical systems in a vehicle requires a working level of electronics knowledge.  If you are not already familiar and comfortable with the material in this lesson and would like to build an electric vehicle, it is recommended that you use prebuilt electronics components or seek the help of someone with more electronics experience.  Although it's certainly possible to design certain parts of a vehicle's electronics starting from little to no prior knowledge, I believe it would be a much more frustrating and less enjoyable experience.  In my personal opinion, taking a couple months to tinker with more beginner-friendly projects would make the transition to more complex circuit design much smoother and more rewarding.  That said, amazing feats are possible with sufficient determination and grit - feel free to reach out to us and we'll try our best to help you and your team reach your goals.

Voltage, Current, and Power

Voltage and current are the two things which define the state of a circuit.  Every circuit ever made is ultimately a way to manipulate these values to accomplish what the designer wants.  If you have some electrical knowledge, you can probably skip these next two sections and move on to capacitors/inductors.

Voltage

Voltage is a measure of the electrical potential at a specific POINT in a circuit.  Every point of every wire/trace has some electrical potential.  It is important to emphasize that voltage is measured as the difference between two points.  Read on if you're not very familiar with the concept of voltage.

Because electrical potential is often a difficult concept to grasp, first consider gravitational potential.  Placing a marble above your head gives that marble more energy.  The gravitational potential of a marble is defined by where it is - every single point in space has a gravitational potential associated with it (essentially how much energy that marble would have if you put it there).  Furthermore, that marble would like very much to fall down, and if you can devise a clever way to harness the energy, you can use the marble's desire to drop to do something useful.

Image source: http://www.linuxfriends.net/courses/solar/WebLecture/main/main.php?page=t2Note: positive ions are essentially a shortage of electrons

Image source: http://www.linuxfriends.net/courses/solar/WebLecture/main/main.php?page=t2

Note: positive ions are essentially a shortage of electrons

Electrical potential is very similar, except it's like the energy an electron has at some point.  If you have a battery, one side has lots and lots of extra electrons and the other side has not so many extra electrons.  You can imagine that an arbitrary electron would love to move from the crowded side with more electrons to the spacious side with less electrons, but without a wire connecting the two sides, there's simply no path to get there.  If you do create a circuit which provides the path to get from one side to the other, the electrons will help you do useful work as they move down to a lower energy place.  The difference in concentration of electrons defines the voltage difference between two points.  A 1 volt battery is like a marble that's 1 ft above the floor and a 2 volt battery is like a marble that's 2 ft above the floor.

You may notice that the marble could fall to the ground, but if you dug a hole, it could also conceivably keep falling lower.  How then, do you define gravitational potential?  According to physics convention, gravitational potential is defined as zero if the marble is infinitely far away from the earth and is negative for any finite distance to the center of the earth.  This isn't really useful in practice, and oftentimes we adhere to one of two systems: (1) height of the marble relative to the ground or (2) height difference between two marbles/locations.  The same goes for voltages - most times, we only care about the relative voltages between 2 points in a circuit.  Sometimes, though, we reference voltages to the electrical potential of the literal dirt in the ground and call this "earth ground" or "true ground".  As a fun fact, the third "optional" prong of an electrical outlet is a direct connection to true ground and, while often unnecessary for the proper operation of an appliance, is often included in high power appliances for safety reasons - your body and most objects typically have a voltage near earth ground (since your feet are touching the ground) and if the appliance started drifting away from true ground, there could be a huge voltage buildup over time.  Additionally, because of the way the three-phase power grid is designed, true ground is often necessary for power hungry appliances to avoid issues with load balancing and keeping the neutral line near ground.

Current

Current is a measure of the flow of electrons through a circuit.  Current is not referenced between two points, but is rather measured through a point of a wire in a circuit.  In order to measure current, you must physically cut a wire and insert a device between the cuts (well actually there exist other ways to measure current by sensing magnetic fields, but we'll forget about those for now).  Current absolutely must be the same everywhere along an uninterrupted wire.  Read on if you're not very familiar with current.

If voltage is like the height of a marble, current is like measuring how many marbles are flowing down a marble track.  If you have a really narrow track that only lets one marble go at a time, the number of marbles that can cross the track in a fixed amount of time is relatively few, but if you have a super wide track where 20 marbles can roll side by side, then the number of marbles that can cross the track in the same amount of time increases by about 20 fold.  We can measure flow as (# of marbles)/second.  Similarly, we measure current as coulombs/second, also named amps (A for short).  1 coulomb is approximately 6.242×10^18 electrons.

An important point is that, since current is the flow of electrons, any point where wires join must have the same current going in as going out.  This is because, otherwise, there would be a buildup of electrons with nowhere to go or a shortage of electrons.  This would be like more marbles going into a swirly-whirlpool-thing that come out - where would the marbles go?!?  The charge would build up so fast that, for most circuit design, there is no situation in which the current in does not equal the current out (the exception being static electricity).  Similarly, connecting several devices in a line means the current through each one must be the same because the electrons can't just get sucked into the devices without ever coming out or vice-versa.

As you can imagine, marbles typically only flow if there's some height difference on the track.  Similarly, current typically only exists with some voltage differential in a circuit, and current typically flows from high voltage to low voltage (exceptions exist if the marbles start out with some velocity).  Lots of marbles rolling down a great height can produce more power than can either (a) fewer marbles down the same height or (b) the same number of marbles down a smaller height.  This gets us to the idea of power in an electrical circuit.

Power

Power is a measure of how quickly energy can be transferred.  In terms of electricity, it turns out power (P) is equal to voltage (V) times current (I)   (commit this to memory):

P = I*V

The unit for power is Watts (W) and, conveniently, 1 watt is defined as (1 volt)*(1 amp).  Energy is defined as the integral of energy with respect to time.  For the pre-calculus folk out there, energy is basically just the amount of power multiplied by the amount of time that power is being applied.  The SI unit for energy, the Joule (J), is defined as (1 watt)*(1 second).  Using less energy can mean using less power, using it for less time, or both.

In the context of electric vehicles, power can be equivalently expressed as force * speed (or torque * rotational speed if that's more useful).

1W = (1V) * (1A) = (1N) * (1m/s) = (1 Nm) * (1 rad/s)

Thus, if you want a motor to give more torque at a given speed, you need more power.  If you want a motor to run faster but give the same amount of torque, you need more power.  If you want to consume less power, you need to (a) drive slower, (b) use less torque, or (c) have a more efficient powertrain.

Resistance/Loads

Many devices are modeled as resistive loads.  Resistance (R) can be expressed as the voltage drop across an element divided by the current through the element.  Often, we express it equivalently (commit this to memory):

V = I*R

Resistance uses the unit "ohms" (Ω).

Intuitively, resistance is exactly what it sounds like - a resistance to the flow of electricity.  Smaller resistance means electrons can flow more easily and thus, less voltage potential is needed for the same current (or for the same voltage potential, more current will flow).

In electronics, it's often easier for us to comprehend voltage sources - a device which generates a constant voltage potential across it (i.e. a 3V battery generates a 3V voltage potential across its terminals).  Because current and resistance are inversely related, if we want to get more current/power out of a circuit, we want a very low resistance device.  If we want to conserve power, we want a large resistance.  This is why space heaters have thick coils while battery-powered hand warmers have this wires - the thicker the metal, the lower the resistance.  If you're familiar with speakers, you may also know that a 4ohm speaker requires a higher power amp than does an 8ohm speaker.

The following reformulations of the P = IV equation can be derived using the V = IR equation above:

P = IV = (V^2)/R = (I^2) * R

These 2 alternate expressions are also useful to commit to memory.  A silly rhyme my professor taught us goes:

twinkle twinkle little star,

Power equals I squared R!

Electronic devices called resistors are fixed resistance devices and are often used to help limit the amount of current traveling through a circuit for various reasons.  They cost a dime a dozen which makes them the backbone for much of board-level circuit design.

Capacitance and Inductance

I won't go into too much detail about these two because they aren't very intuitive and have limited use cases.  Basically, they don't like change and will do their best to make sure their state doesn't change.  A capacitor doesn't like a changing voltage and, as such, will absorb or release charge to try to keep the voltage across it constant.  It's kind of like a tiny tiny TINY rechargeable battery.  Usually, you'd put 1 or more capacitors across the ground and supply wires of a computing chip to make sure the voltage supply doesn't "ripple".  If the chip suddenly needs more power (equivalent resistance of the chip suddenly drops), the capacitor can supply a little bit of current to help prevent the voltage from dipping too much.  As a general rule of thumb, place a 0.1uF capacitor across the power pins of any IC and more (in parallel) if it's particularly sensitive or complex.  Placing large (eg 2400uF) capacitors across "noisy" devices (as many motor drive circuits are) is also a good idea.  Inductors are similar to capacitors except they resist changes in current instead of voltage - they will provide voltage potentials in order to prevent changes in current.  Inductors tend to be less common because, among other reasons, current spikes are typically less likely to break/interfere with the operation of a device than voltage spikes are.

Image source: https://www.quora.com/In-a-simple-5-V-linear-regulated-power-supply-how-do-you-calculate-the-values-and-ratings-of-each-of-the-components-in-this-circuitNote: dashed line is analogous to before a capacitor, and the red line is ana…

Image source: https://www.quora.com/In-a-simple-5-V-linear-regulated-power-supply-how-do-you-calculate-the-values-and-ratings-of-each-of-the-components-in-this-circuit

Note: dashed line is analogous to before a capacitor, and the red line is analogous to after.

MOSFETs

MOSFETs are a type of transistor and are by and large the most popular type of transistor in low to medium power applications (such as a prototype electric vehicle).  MOSFETs are essentially voltage controlled switches - applying a voltage potential between the "gate" and "source" pins will allow current to flow across the drain/source.  This way, a small or weak signal on the gate can drive very large loads.  MOSFETs are the backbone of digital electronic control/circuitry and, in my opinion, the most important things to understand after voltage/current/power and resistors.

image source: http://panamahitek.com/que-es-y-como-funciona-un-mosfet/Note: Though there are various different symbols for a MOSFET with subtly different meanings, these are usually the ones I use when drawing circuits by hand.

image source: http://panamahitek.com/que-es-y-como-funciona-un-mosfet/

Note: Though there are various different symbols for a MOSFET with subtly different meanings, these are usually the ones I use when drawing circuits by hand.

A MOSFET typically has 3 terminals (commit these to memory):

  1. source
  2. drain
  3. gate

There are 2 primary types of MOSFETs: n-channel and p-channel.  n-channel MOSFETs (N-FETs) are much more common due to slightly better efficiencies as a byproduct of some fancy chemistry/materials science, though P-FETs are sometimes used in bridge driver configurations and various converter topologies for reasons which will perhaps become apparent shortly.  For the next 5 paragraphs, I will only consider N type MOSFETs.

When the gate of the MOSFET is supplied voltage, the MOSFET acts like a closed switch and allows current to flow through the circuit.  Note that the resistor simply acts to limit the current going through the LED.

When the gate of the MOSFET is supplied voltage, the MOSFET acts like a closed switch and allows current to flow through the circuit.  Note that the resistor simply acts to limit the current going through the LED.

In an N-FET, the source is almost always connected to ground (commit to memory that the source is the "bottom" one in an N-FET and that the drain is the "top" one.  As an aside, this naming convention is because the electrons flow from the source to the drain - confusingly the opposite direction as the convention for current).  This is because the voltage supplied to the gate is referenced relative to the source.  That is to say, to turn the MOSFET on, you need to create a voltage differential between the gate and the source.  The problem is, your "logic" chip (be that an Arduino, Teensy, other MCU, or whatever) is pretty much always grounded and thus its outputs are relative to ground.  If the source of the MOSFET is floating at some unknown voltage, it's very difficult to generate a voltage which is some specified amount above the source voltage.  Therefore, the source is generally tied to ground and turning on the MOSFET is simply a matter of applying a voltage to the gate.

In the on state, a MOSFET acts like a closed switch/wire: with very little resistance and current can flow either direction.  In the off state, a MOSFET acts almost like an open switch/broken wire (no current can pass): current cannot flow from the drain to the source, but it can flow from the source to the drain (just remember this, I know it's strange).

To "Turn on" a MOSFET means, in most cases, to apply the full gate voltage required for the MOSFET to be in the on state (as opposed to a transition state).  For "logic level" MOSFETs, this threshold is generally on the order of 2-3V.  For "drive" MOSFETs or other large MOSFETs, the threshold is usually rated for somewhere around 12V or 24V.  If you browse digikey.com for MOSFETs, the larger of the 2 voltages listed as "Drive Voltage" is the threshold needed to turn the MOSFET fully on.  In this fully on state, the MOSFET is modeled as a resistor whose resistance is labeled as "RDS on" (so called because it's the resistance R across the Drain and Source when the MOSFET is on).  As you can see from some of the MOSFETs on Digikey, this RDS on is really small for most MOSFETs!  For simple applications like LEDs or buzzers or even small motors, this resistance can be ignored and you can treat an on-state MOSFET as a closed switch or a wire.  In high power or high efficiency applications, you must treat this resistance as a parasitic loss.

To "turn off" a MOSFET, you must pull the gate voltage back to ground (assuming the source is connected to ground).  It will stay floating at whatever voltage it feels like floating at if you leave it disconnected.  Oftentimes, people put a "pull-down" resistor between the gate and source.  A pull-down resistor is a large value resistor (i.e. 10k ohms) so that, if nothing is connected to the gate, its voltage will naturally get pulled down to 0.  If a voltage is connected to the gate (i.e. 5V), the voltage at the gate will be 5V but there will be a very small amount of parasitic current flowing through the resistor (5V/10kohms = 0.5mA  -> 2.5mW).  A larger value resistor will waste less power but will be slower at pulling the gate back down to ground.

When an NFET turns off, it mostly acts like an open switch/break in the wire, but not quite.  Due to the way nearly all MOSFETs are constructed, they actually resemble a diode when turned off.  A diode allows current to flow in only one direction, and that direction is "up" for an N-FET (i.e. from source to drain).  This is called "body diode conduction" or because the diode inside the MOSFET is formed from the so-called "body".  Sometimes this is convenient, sometimes it's an annoyance, and in "most" applications it plays no role (though you should still always consider it just in case).

NFETs vs PFETs

As stated earlier, NFETs are much more common because they're generally more efficient (lower RDSon), but sometimes PFETs are much more convenient to use.  This is often the case in situations where, for one reason or another, the MOSFET's gate cannot be referenced to ground.  In a bridge driver configuration, for example, the top MOSFETs make more sense to reference to VCC (source/supply voltage).  Fortunately, this is exactly how PFETs operate: they turn on when the gate is pulled to a voltage below the source (negative with respect to the source).  Usually, a pull up resistor is used to keep the PFET off and a "helper" logic-level NFET pulls the PFET's gate to ground at the command of the controller.  This is sometimes useful in drive applications, but more often than not, a "gate driver" chip already exists which can drive NFETs for you, even in a bridge configuration by using a "charge pump".  Digikey has an entire category consisting of >1000 ICs dedicated to driving MOSFETs specifically in the half and full bridge configurations, and another >8000 component category for general gate drivers.  Nonetheless, it's useful to know about PFETs anyway.

Design Example

Now that we have some groundwork, let's take a look at a particular application of resistors and MOSFETs.

Using the example circuit in the MOSFET section, I've added some values for the voltage source and resistor:

schemeit-project (1).png

Referencing to ground, the voltage at the top (above the LED) is 5V from the battery.  Most LEDs produce a voltage drop of around 1.8-3V depending on the color (but regardless of current).  We'll assume it's a red LED and causes a voltage drop of 1.8V when it's on.  When the LED is on, that makes the voltage between the LED and resistor to be 3.2V.  Since the MOSFET is essentially a wire, it has no voltage drop across it so the voltage between the resistor and MOSFET is around 0V.  That means the voltage drop across the resistor is 3.2V.  Since the resistor is 220ohms, the current through the resistor must be 3.2V/220ohms = 14.5mA.  Recall that the current through devices in a line (in series) is the same, so the current through the LED must also be 14.5mA.  Most small LEDs expect 5-20mA so this is an appropriately sized resistor.  If the resistor were too large, the current through the circuit/LED would be too small and the LED would be too dim.  If the resistor were too small, the current would be too large and would burn out the LED.  220 and 470 are common "current limiting" resistor values to put in series with an LED.

When the MOSFET is turned off, current is unable to flow through the circuit and the LED turns off.  To check if current could ever flow backwards up the MOSFET from source to drain, we just have to check if the voltage between the MOSFET and resistor could ever be lower than ground.  Simply put, it can't in this simple circuit and we can safely ignore the effects of body-diode conduction.

Controlling small fans, valves, DC motors, and many other devices can be done with a similar circuit except replacing the LED with the device of choice (and often omitting the resistor).  For example, the fan and 2 valves of our hydrogen fuel cell system are controlled this way.

Summary

First covered the basic ideas behind voltage, current, and power.  Voltage is the "potential" between two points, current is the flow of electrons through a wire/device, and power is the rate at which energy is transferred; equivalently P = IV.

Then, we covered resistance.  Resistance is the ratio of voltage drop across a device and the current through it.  Usually, this relationship is expressed equivalently as V = IR.  Resistors allow for manipulating voltage and current cheaply in many circuits and many devices are modeled as resistive loads (i.e. by the ratio of the voltage drop across them to the current through them at some instant in time).

We briefly mentioned capacitors and inductors which act to resist changes in voltage and current, respectively, making them great for filtering out noise and smoothing out signals.  Capacitors are especially widespread in helping to regulate the power supplies to ICs (integrated circuits) and other chips.

Finally, we talked about what MOSFETs are and how they work.  MOSFETs are the backbone of digital electronics and are, in my opinion, the most important device to understand after resistors.  MOSFETs can take a small logic-level signal from a micro-controller and control a potentially huge load that the micro-controller could never do itself.  MOSFETs can also be used to amplify signals, perform logic, and countless other tasks.  For N-FETs, the source is typically connected to ground and applying a voltage at the gate allows current to flow easily across the MOSFET in either direction with small losses due to RDSon.  Pulling the gate voltage back to ground restricts the flow of current from drain to source, but still allows flow from source to drain.

Hopefully, this electronics crash course was helpful and enabled you to design your own Arduino-controlled RC cars or what-have-you.  Next, we'll be looking at how to size large/major components for an electric vehicle in preparation for designing electrical boards later.

Feel free to reach out to us via this form or by emailing us at dukeecomarathon@gmail.com.

Duke EV1 Comment