Skip to content

Basic Electronics

Kay Kasemir edited this page Mar 27, 2021 · 9 revisions

Basic Electronics

This is a basic overview of the essentials that you should know when dealing with robot electrics: Briefest intro to Voltage, Current, Resistance, how to use that knowledge to connect an LED, and how to control devices like LED strips that need more power from an Arduino or RoboRIO.

Voltage, Current, Resistance

Voltage is comparable to water pressure. It's what pushes electrons through wires. The most common voltage encountered in robots is 12V from the main battery. All the motors, the RoboRio, solenoids, etc. are connected to 12V. The other voltage is 5V. The digital outputs of an Arduino, the PMW signals from the RoboRio, many of the "control" signals are 5V.

Current is comparable to water flow. Measured in Ampere, it tells us how many electrons per second flow through a wire. Common values are around 10 Ampere for the robot's drive train motors, 1 Amp for a smaller lift motor, 0.020 A = 20mA for an LED, 5mA for some control signal.

Resistance is comparable to a restriction in a water pipe. Measured in Ohm Ω, it determines how many Ampere will flow for a given Voltage. Values can range from a few Ohm Ω to kilo kΩ or Megaohm MΩ.

Ohm's law tells us how they relate:

# Voltage needed to 'push' desired current through a given resistance
Voltage = Current * Resistance  

# Current that will result when you apply some voltage to a resistance
Current = Voltage / Resistance 

# Resistance you need, given a voltage, to get desired current
Resistance = Voltage / Current

Note how they are related: The same voltage can generate a small or large current based on the encountered resistance.

Safety moment: The resistivity of your body is such that voltages below 50V are generally considered safe. Higher voltages can drive a current through your body that causes muscles to react, and if that muscle is your heart, you have a problem.

But even 12V batteries like the ones used in a robot can cause trouble. A metal wrench is a very good conductor, meaning it has nearly zero resistance. If a metal wrench happens to fall onto the battery such that is shortens the battery terminals, the 12V of the battery drive a very high current through that wrench. The wrench will get very hot, glowing red hot, causing severe burns if you touched it.

LEDs

LEDs are (usually small) lights which need about 20mA. They are polarized, with usually one somewhat longer leg that connects to the positive voltage, and a shorter one for ground.

LEDs are very efficient, and as a result they have almost no resistance. So if you simply connected an LED to 5 Volts, the result would be a current of

5V/(almost 0 Ohm) = very high Amperage

Such a high current would cause the LED to briefly light up, then it pops and is dead.

So we usually add a resistor. The exact value is not too critical, it should be about

5V/0.020A = 250 Ohm

For the Arduino, there is an exception. The digital outputs of the Arduino provide 5 Volts when the program commands them "on" or "HIGH". But the Arduino already contains internal resistors to limit the current that the Arduino outputs can drive. So it's OK to directly connect an LED to a digital output of an Arduino, no additional resistor required.

LED Strips

As mentioned, it's OK to directly connect an LED to an Arduino output. In fact a single LED is about the only thing you can directly power with an Arduino output. If you tried to connect a whole LED strip, i.e. a strip that contains many LEDs, the Arduino would not have enough power to provide the required current. The LED strip would remain dark.

To control an LED strip (or another device that needs more power) from an Arduino or from a digital output of the RoboRIO, we need to add some simple electronics.

The LED strip is connected to 12 Volts. If we connected the ground side of the LED strip directly to ground, it would light up. Instead, we insert a Transistor as shown in the diagram below.

The current for the LED string goes from the 12 V power source through the LEDs in the LED strip, then into the 'Collector' C of the transistor, comes out of the 'Emitter' E of the transistor and into ground. The 'Base' B of the transistor now allows us to turn the current through the transistor on or off. If the base is at 0 V (i.e. Arduino digital output off), no current flows through the transistor. If the base is at 5 V (i.e. Arduino digital output on), a current flows through the transistor.

In fact the transistor is a "current control" device. It takes the current flowing into the base, amplifies that by a factor of about 100, and then allows that current to flow through collector and emitter. Like an LED, a transistor is very effective, almost no resistance. If we directly connected the base to 5 V, a very high current would flow into the base, the transistor would pop, smoke, and we would be very sad. So similar to an LED, a transistor needs a resistor at the base. For the LED strip example, exact values don't matter. Something like R=1000 Ohm = 1kΩ would work.

More

If you paid attention, you should wonder why we didn't need a resistor on the LED strip input. If the LEDs are directly connected to 12V, wouldn't they need a resistor of around 12V/0.020A=600 Ohm to limit the current through the LEDs? Yes, if plain LEDs were directly connected to 12V, with our without a transistor to switch them on/off, they would only light up once and then die. But LED strips and in fact many of the larger LEDs that you buy these days have resistors built-in, they are meant to be connected to 12V. To be sure, check the specifications of your LEDs.

There is a lot more to electronics, but this should help you understand most of what we need for robotics.

Clone this wiki locally