Electrical

From iRobotics Tech Wiki

Understanding Electricity

Electricity is the fundamental manner in which energy is stored, controlled, and delivered to different parts of the robot. Which the mechanical parts of the robot transfer that energy through the final drive and manipulators to the physical world, the mechanical workings rely on the electrical system to control exactly how much energy is removed from storage and put into the robot.

Electricity, as we care about it, is simply the flow of electrons through a wire. It takes work to get them to flow, and as such, their flow can in turn do work.

Ben Franklin, back in the day, thought that these "electricity-carrying" particles were positively charged, and did a bunch of math under that assumption which other people later used. Of course, we later also discovered he was wrong, but being engineers, were too lazy to change the math, and simply established a new convention: "Current" is the flow of electricity through a wire, and actually goes the opposite direction of the electrons. Ben Franklin didn't know any better, but students of Electrical Engineering still curse his name every time they get a sign error while doing math on semiconductors.

File:Electron+Flow.jpg

Got it so far? Don't worry if not, knowledge of electrons and their workings is not directly applicable to robotics.

Remember that zinger about electron flow and work a few paragraphs ago? Well, the corollary to that is that all electrical energy has a source, and must also then be consumed by something. This is because you can't simply put energy into a system and expect it to just go in and never come out. There either needs to be a storage mechanism, or something to get rid of the energy (for us, this is as mechanical energy, possibly light energy, and always as heat energy).

A battery is what is used as a source of electrical energy in a robot. Chemical reactions create a buildup of electrons at one terminal of a battery, and a lack of the at the other terminal. Nature dislikes this imbalance, and will attempt to correct it as soon as she has an opportunity. We humans can create this opportunity, and in doing so harvest the release of energy that occurs from resolving the imbalance.

One obvious way to correct the imbalance is to just put a wire connecting the terminals. Why a metal wire? Because literally has a sea of free electrons which can move around with little resistance. The electrons will simply migrate to correct the imbalance. Prior to the wire, there was only air between the terminals, and air has extremely few free charged particles to carry a current. Irrelevant fun fact: Air usually has no free charge carrying particles, giving it a very high resistance. However, if you can use a big voltage to coax just a few electrons across an air gap, those electrons will collide with air particles, breaking them apart and creating charged particles, which in turn can support a larger current flow. More current means more air particle destruction which means more charged particles which means more current flow. You actually end up forming a plasma with the heated and destroyed air particles. This is the basis of operation of every spark plug in every car, and the mechanism which gives you a shock when you touch a doorknob after walking across a carpet on a dry day.

Back to our example. We connect a wire across the battery.

File:Circuit+Lab.png

Electrons are free to flow, the imbalance is corrected, Mother Nature is appeased!

However, she is TOO appeased. The wire presents almost no resistance to the electrons, so they flow around the circuit at something like two-thirds the speed of light. All at once. You know what happens when you jam a bunch of electrons through a battery at 2/3's the speed of light??? THIS HAPPENS:

File:Bad+Batt.jpg

Sploded batteries are not good. What was the problem? We had nothing to consume the energy we put into the system (except the battery itself, and batteries are not designed to dissipate power).

Instead, we put a motor in line this time:

File:Better+Circuit.png

Now, the electrons first have to push the motor to rotate before they return. They do it very quickly still, but their energy is being used toward generating mechanical power now. Mother nature is still appeased, and we are now utilizing the natural tenancies of the electrons to do mechanical work.

This diagram can be used to clarify a bit of terminology:

Voltage is different from Current. They are locked in an eternal dance, but they are far from the same thing. Voltage is the force which pushes electrons through the wire. However, just as I can push on a wall with nothing budging, there can be a voltage without any actual current.

Current is, as mentioned, the flow of "positive test charges" through a wire. AKA, this imaginary thing which goes the opposite direction of electrons.

Aside from a number which measures a Voltage's strength (in volts), we also use the terminology "positive" and "negative" when referring to voltage. These terms map to slightly different things depending on whether we are talking about a device which pushes electrons through a circuit (like a battery), or a device which uses energy in a circuit (like a motor).

In the case of a battery, current flows OUT of the POSITIVE terminal and INTO the NEGATIVE terminal.

In the case of a motor, current flows INTO the POSITIVE terminal and OUT of the negative terminal.

The reasoning behind this reversal actually is based in the sign of the work done by the electricity through the device. In one case, positive work is done. In the other, negative work is done. Take ECE330 for a better explanation.

The nice thing about this convention occurs when creating circuits. To get a motor to run forwards, you connect positive to positive, and negative to negative. Current flows in the proper directions, and happy things happen.

Side note: for robotics applications, conventions state that positive is usually Red, negative is usually Black.

Side side note: COLORS ARE NOT STANDARDIZED. The above rule applies to ROBOTICS. Not to everything. In fact, in household wiring, this convention is reversed. Just because you can see a wire's color does not mean you know it's purpose.

However, there is still one problem. This circuit only works for us if we like our robot to always drive forward and always raise its arm and never ever do anything else until its battery dies. Not a very useful robot. Let's try putting a device inline which can either allow current to flow, or stop it outright. A switch!

File:Switch+Circuit.png

Then some really smart guy in history realized if we turn the switch on and off really fast, we can make the motor go slower or faster depending on how long we kept our switch "on" We decided to hire a freshman to turn the switch on and off really really fast:

File:Poor+Freshman.png

Then the university got mad at us. So we programmed a microcontroller to do it for us instead:

File:Microcontroller+Switch.png

And then we devised a super special switch mechanism (also controlled from the microcontroller) which could change which way current flowed through the motor, which would change the direction it rotates:

File:PWM+Circuit.png

And then we were well on our way to making electronics for a robot. And so are you :) .

Debugging

Debugging an electronic circuit is a fundamental skill for any electrical engineer. No matter how good you think you are, you will inevitably do things wrong. This is generally acceptable, as long as you can identify what you did wrong in retrospect, and then have the ability to correct the problem. Also, don't kill anyone in the process.

Actually, the hardest step in the process is figuring out what you did wrong. Debugging is not a skill which is algorithmic and, as such, is nearly impossible to teach with a textbook.

Here are a few basic steps I have naturally developed and generally go through while debugging:

  1. DOCUMENT EVERYTHING. Having through diagrams of what you intended to do, labeled and well-organized wires, and clear communication between teammates will give you the opportunity to check your work as you go, and give you superior backward-tractability when something does go wrong. Documentation is key to any scientific or engineering endeavor.
  2. Start by looking for obvious things. Is the power switch off? Is there voltage at the power inputs to the malfunctioning device? Is the device mechanically constrained? Are there warning lights?
  3. Assuming it's not obvious, go back to the design documents and analyze them, making sure everything is as you expect. The goal of this step is to ensure that your intentions for reality are in fact logical and should

result in the proper operation.

  1. Design documents in hand, start at the source of power or the source of the signal driving whatever is broken. Is the signal good at the place where it is sourced from?
  2. Begin to trace downstream, checking to make sure that the signals and values are as expected as you move toward the output.
  3. As you trace downstream, debug each debugging action you take. Are you sure you are putting the probes on the right testpoints? Are you sure you expect to see 5V on this line? Is is possible to see anything else? Are these other readings actually indicative of an error?
  4. As soon as you get a bad signal, begin using a sort of "binary search" pattern to find the exact location of the problem. You know the issue must now lie between the bad signal you just measured, and the last good signal you measured.

Remember that, at this stage, you are looking both for things which could be a flaw in construction (eg, broken wire), as well as things that could be an error in translating your design documents into reality (eg, positive wire connected directly to ground)

Only as a very last resort should you just tear apart everything you did and start from scratch.

Remember that these rules are not hard-and-fast. every situation is different, and requires a unique approach. Take the time to develop your debugging skills both with this club and in your lab classes. They will serve you well in an engineering career (or any career for that matter).

Avoid this mentality:

File:BreakpointBasedDebugging.jpg

Search for causes, do not fixate on what is going wrong.