Basic Electronics And Microcontrollers

From XPUB & Lens-Based wiki

During the first Trimester (october - december 2010) I will be teaching a course in Basic Electronics and the use & programming of Microcontrollers. The theory-lessons will take place on wednesday afternoons, and additionally there will be some Electronics Hacking Days (see the Calendar)

Basic Electronics

In order to hack existing circuits, or to design and build your own, some understanding of the fundamental principles of electronics and circuit-design are required.
Although the trial-and-error approach (i.e. Circuit-Bending can be fun and rewarding, it can also be frustrating (connecting the wrong points together will usually destroy a circuit), and dangerous (never touch a circuit that may have voltages higher than ±25V going on!).[1]
Even after successfully 'bending' a circuit you wil not have learned how the circuit works, really, or why it behaves differently if you connect this point to that point ant touch it there. "It just does".

So, let me explain a bit about electronic circuits. It will be useful knowledge, I think.

What is Electricity?

The word 'Electronic' actually means "having to do, or working with electrons". In that same context, 'Electricity' is "the behaviour of electrons". This is the case for devices like an Electron microscope or a Photo multiplicator tube that are designed to detect the arrival of a single electron, but aslo for phenomena like lightning where uncountable bazillions of electrons are exchanged, in a flash, between charged thunderclouds or, most spectacularly, between the clouds and the Earth.

Electricity is a form of energy, and as such comes in two distinct states; Potential energy, i.e. electric potential, a.k.a. wikipedia:Voltage voltage (electrons wanting to move) and kinetic energy, i.e. electric current (electrons moving). Potential energy will get converted into kinetic energy whenever possible. In other words; if an electric current can flow, it will. In this conversion, some or all of the energy becomes available to do 'work'. An electric current has the power to do something. Converting kinetic energy back into potential energy is also possible, but then this requires 'effort' (the opposite of 'work', in this context). In order to (re-)charge a source of potential energy, power is required.

The process of the conversion from potential to kinetic energy, the relationship between voltage, current and resistance (i.e. the difficulty of the conversion) is given by Ohm's Law:
Ohm1.png or Ohm2.png or Ohm3.png where V, the potential, or voltage, is expressed in Volt (V), the current I in Ampère (A), and the resistance R in Ohm (Ω)

Basically, this states that the potential converted (the voltage 'lost') in a given resistance is equal to the current times the resistance,
the current flowing through a given resistance is equal to the potential-difference across the resistance (the voltage 'lost' in the resistance) divided by the resistance, or
the resistance is equal to the voltage-difference across that resistance divided by the current. All three versions are different perspectives on the same situation, and are equivalent.

In practical terms, say that the resistance is infinite. Then Ohm2.png states that the current will be zero, irrespective of the voltage. This is an 'open circuit'; no current can flow, because the resistance to current is infinite. All the potential energy is contained, and no kinetic energy exists. Inversely, if the resistance is 0Ω, Ohm2.png dictates that the current should be infinitely high. This is a 'short circuit', a situation best avoided, because all the potential energy is converted into kinetic energy, instantly, and this is usually not a good idea.
For any resistance-value in between these two extremes, some potential energy is converted into kinetic energy. Exactly how much energy is converted can be calculated if any two values of V, R and I are known.

The amount of power that is involved in these electric currents is given by Joule's Law:
Joule1.png where P, the power, is expressed in Watt (W)

Substituting Ohm's equation in Joule's equation lets us calculate the power when the resistance and either I or V are given:
Joule2.png or Joule3.png


Water-circuits

This is all rather abstract, so let me introduce a favourite analogy that I will use throughout this course:
Think of water-systems instead of electric systems. To most people, electricity & electrons are very abstract concepts. Hard to visualise and grasp. But everybody will be immediately familiar with water and how it behaves, from lifelong personal experience.
In these water-systems that I will be introducing throughout the course, potential energy, voltage, is analogous to the pressure of the water and kinetic energy, current, is analogous to the flow of water.

Imagine an artificial lake, high up in a remote mountain gorge somewhere, with a dam straddling the gorge. The water in the lake wants to flow downhill, because of gravity, but it can't, because of the dam. If the dam were a solid wall of concrete, all of the water in the lake would be contained. More specifically, all of the potential energy of the water would be contained. The water can't flow anywhere. This is the 'open circuit' equivalent.
But this is pointless. That is not why the dam is there. In fact, the dam has a hole at the bottom, with a pipeline leading all the way down to the mouth of the valley, where there is a building containing turbines & generators & such. Some water can escape from the lake, through the hole in the dam, and flow into the pipe. On the way down, this water's potential energy is traded for kinetic energy, and by the time it arrives in the generator-building, the water is moving fast and with considerable momentum. The 'work' that this water may do is traded for the 'effort' needed to push the turbine-blades and turn the generator. The generator converts this kinetic (rotational) energy back into potential (electric) energy, and there will be a voltage available at the terminals of the generator. The flow of the water is resisted when it meets the blades of the turbine. In fact, the amount of resistance of the turbine is directly related to the amount of 'effort' required to turn the generator, which in turn is dependent on the amount of electric power the generator has to deliver.[2]
The water, having spent most of its kinetic energy, will gently flow out of the generator-building, into streams & rivers and eventually into the sea. For the water, the sea is the point of lowest potential energy from where it cannot flow further down. The 'zero potential' level.

Imagine that it doesn't rain for quite a while. Eventually the lake will run dry. All of the potential energy in the lake will have been converted into kinetic energy, and the source of potential energy will have been depleted. Like an empty battery.
But of course in reality it does rain, and any rain or snow that falls in the surrounding mountains above the level of the lake must have an even higher potential energy than the water in the lake. This energy actually comes from the sun, evaporating water from the land & sea, forming clouds high up in the air. The wind (also a result of the energy from the sun) will drive these clouds against our mountain-range, where the clouds are pushed upward into colder strata of the atmosphere. The clouds will condensate into water-droplets or snowflakes falling on the mountains and re-filling the lake.

Now imagine a catastrophic collapse of the dam. The dam breaks and no longer offers any resistance to the potential energy of the water in the lake. All of the water will suddenly come crashing down the mountain, with all of its potential energy converted into kinetic energy, wiping out any obstacles it finds in its path, and doing massive damage until it eventually raches the sea. This would be a 'short circuit' situation. Not a good thing to have happen, then.

This is an example of a 'water circuit', since you can visualise it always being the same water getting evaporated from its level of lowest potential into clouds (the level of highest potential in this circuit), then raining down into the lake, flowing down the pipeline to drive the generators, and flowing back to its level of lowest potential. Over & over again.

As a thought-experiment, this mountain lake example demonstrates the conversion of potential into kinetic energy (and back), the concept of resistance to flow (or current), the ideas of 'work' vs.' effort' and power. It describes the 'open circuit' and 'short circuit' equivalents, and the fundamental concept of a circuit, so called because the 'agents' involved (ie. water or electrons) travel round and round in a loop, over & over again, until the ultimate source of potential energy (in this case the sun), is depleted.

Electronic Circuits

Soldering Circuits

Media:01-Soldering.pdf

Basic Electronic Components

Media:02-Electronic_Components.pdf

Datasheets

Microcontrollers

A microcontroller

Footnotes

  1. A Photo-flash is a prime example. They usually work on 1 or 2 AA-size batteries, so you'd think they are harmless when touched, right? Wrong! the circuit inside contains a converter wich makes a very high voltage, usually somewhere around 400V! And worse, it has a capacitor that stores a considerable charge at that high voltage. Very nasty & painful when touched. Use extreme caution!
  2. The pipeline from the dam to the generator-building offers some resistance to the water as well, because of friction with the inner wall of the pipe. But if the pipe's diameter is big enough, this resistance is negligible compared to the resistance of the turbine.