RESISTORS
These do exactly what they say. They resist the flow of electrons. These are necessary for several
reasons:
- they can control how much current goes down each wire
- they can control power usage
- they can control voltages (since current, resistance, and voltage are interrelated)
The last point is important as it is the basis of Ohm's law, V=IR.
Voltage = Current x Resistance. For example, suppose you take a resistor
and connect the two ends of a battery with it. You know that your battery is 9V (or whatever)
and you know the resistor is 3Kohm (determined by the color stripes on the resistor),
so 9V divided by 3Kohm is .003amps (3 milliamps). So why is this information useful?
Well now that you know the current, you can determine other useful things such
as power. P=IV. You will notice that if you increase resistance, you decrease current.
If you decrease current, you decrease power use. Put a 1ohm resistor between
the battery and it will get so hot it could burn because of the power use. Use a 100Kohm
resistor and almost no power at all will be used.
So about determining the value of a resistor, all resistors have the value labled on
them. You will notice colored stripes on the resistor. Each stripe means a certain number.
This has been explained a billion times online already so I won't, just google search
'resistor color tutorial.'
Click for a quick resistor color code reference chart.
POTENTIOMETERS (VARIABLE RESISTORS)
There are also neat things such as variable resistors (called potentiometers) that can
change resistance at your will. Quite often you can change the resistance by simply
turning a dial. A great way for experimenters to tweak, no? Most robot
sensors are actually resistors that change resistance based on some environmental effect.
Photoresistors are perfect examples. A change in
resistance changes the current crossing the sensor. A change in current causes a change in
voltage - voltage is what computers measure to detect the environment.
So how can you use resistors for you robot? Well LED's require resistors in series or
they burn out. Voltage Amplifiers will need them.
Almost every circuit you build will require them for some particular reason. Even if you
do not put a resistor in the circuit, theoretically your circuit will still have resistance
as all wires carry resistance.
CAPACITORS
Now suppose you want to control how the current in your circuit changes (or not changes)
over time. Now why would you? Well radio
signals require very fast current changes. Robot motors cause current fluctuations in your
circuit which you need to control. What do you do when batteries cannot supply current
as fast as you circuit drains them? How do you prevent sudden current spikes that
could fry your robot circuitry? The solution to this is capacitors.
Capacitors are somewhat complex in theory, but most people can get by on the basics which I will
explain here. Capacitors are like electron storage banks. If your circuit is running low,
it will deliver electrons to your circuit. If your circuit is in access (such as when your
robot motors are turned off), it will store electrons. In our water analogy, think of this as
a water tank with water always flowing in, but with drainage valves opening and closing.
Since capacitors take time to charge, and time to discharge, they can also be used for timing
circuits. Timing circuits can be used to generate signals such as
PWM or
be used to turn on/off motors in solar powered BEAM robots.
Quick note, some capacitors are polarized, meaning current can only flow one direction
through them. If a capacitor has a lead that is longer than the other, assume the longer lead
must always connect to positive.
How do capicitors charge over time? This Capacitor Charge Curve Chart should help. The discharge
rate would be the direct inverse. Theoretically (as made obvious by the graph)
a capacitor can never be fully charged or discharged,
but in reality this is never the case.
So how can you use capacitors in your robot?
Power surge/drainage management.
The problem with using robot components that drain a large
amount of power is sometimes your battery cannot handle the high drain rate. Motors and servos being perfect
examples. This would cause a system wide voltage drop, often reseting your microcontroller,
or at least causing it to not work properly. Just a side note, it is bad to use the same
power source for both your batteries and your motors. So don't do it.
Or suppose your robot motors are not operating at it's full
potential because the battery cannot supply enough current, the capacitor will make up for it.
The solution is to place a large electrolytic capacitor
between the source and ground of your power source. Get a capacitor that is rated at least twice the voltage
you expect to go through it. Have it rated at 1mF-10mF for every amp required. For example, if your 20V motors will use
3 amps, use a 3mF-30mF 50V rated capacitor. Exactly how much will depend on how
often you expect your motor to change speed and direction, as well as momentum of what
you are actuating. Just note that if your capacitor is too large,
it make take a long time to charge up when you first turn your robot on. If it is too small, it
will drain of electrons and your circuit will be left with a deficit. It is also bad
to allow a large capacitor to remain fully charged when you turn off your robot.
Things could accidently short and fry, such as curious kitties that get too close. So use a simple power on
LED in your motor circuit to drain the capacitor after your robot is turned off. If your capacitor
is not rated properly for voltage, then can explode with smoke. Fortunately they do not overheat if given
excessive amounts of current. So just make sure your capacitor is rated higher than your highest expected.
Capacitors can also be used to prevent power spikes that could potentially fry circuitry. Next to any
on/off switch or anything that that could affect power suddenly should have a capacitor across it.
Capacitors can eliminate switch bouncing. When you flip a mechanical switch, the switch actually bounces several
times within a microsecond range. Normally this is too small of a time for anyone to care (or even notice), but note that
a microcontroller can take hundreds of readings in a single microsecond. So if your robot was counting the
number of times a switch is flipped, a single flip can count as dozens. So how do you stop this?
Use a small ceramic capacitor! Just experiment until you find the power capacitance value.
Capacitors can improve efficiency and longevity of electric motors up to 100%. Place a small ceramic
capacitor of like 10uF across the two leads of your motor. This works really well with el-cheap-o
motors. Not much effect with high-end expensive motors however.
These capacitors will also signficantly reduce EMI (Electro Magnetic Interference) and system noise too.
TRANSISTORS
Transistors are probably the post important electrical component created. After all computers tend to have billions of them.
But not just computers, almost everything today that is remotely electrical probably has them. Your car, your
washing machine, your microwave. The list goes on.
But transistors are somewhat complicated in theory, and especially calculation. Plus it is my firm opinion that
they are outdated technology. So for robotics what you should use is something similar to a transistor called
a MOSFET, or Metal Oxide Semiconducting Field-Effect Transistor.
MOSFETs
The operational theory required to use
a MOSFET is not much different from a simple mechanical on/off switch. But instead of flipping a switch, you
apply a binary signal to it straight from your microcontroller. Apply a 0
(for zero volts) to the Gate (or Base) and it is turned off, apply a 1 (for usually 5V or more) and it is turned on. It is
somewhat like a water spicket. By turning a small valve, you can control huge flows of water through a pipe.
If a Transistor is turned on, current will flow from the Collector to the Emitter.
If the MOSFET is turned on, current will flow from the Drain to the Source. Yes, the names are counter intuitive.
What makes transistors more complex is that Collector to Emitter current is not just dependent on Base voltage but also
on Base current. All quite complicated . . . then you got Darlington Pairs which are just crazy and stuff . . .
MOSFET's are just simple on and off. There is however MOSFETS designed for various applications. But usually a PWM
optimized MOSFET would be what you want.
Another note on MOSFETS, they are more efficient with higher Gate voltages. So you probably do not want to just apply
a simple binary 5V. Instead you should amplify it with say an operational amplifier or even better, a
MOSFET Driver IC. All are quite cheap and easy to implement. I highly recommend amplifying the Gate voltage
because it would save on battery power, and significantly reduce overheating. Which reminds me of another point . . .
DONT FORGET TO PUT A HEAT SINK ON ALL POWER MOSFETS!!!!!!!
They heat up pretty quick and burn you when you touch them.
A typical MOSFET is rated for about 300F, but its quite easy for them to reach that temperature.
So what can you use a transistor for? Well it is required for an H-Bridge.
Also, the concept works for Photoresistors
and DC Motor Braking.
------------------------------------
DIODES
--diode tutorial coming soon!--
--zener diodes coming soon too--
RELAYS
--relay tutorial coming soon!--