[Book]
Main Page |Book|Search:
[Add to or Correct This Page]

CIRCUITS

You don't have to know a lot about how your circiut works to get started. You can get very far with just being able to read a couple of simple recipes. You can learn to make a rote translation from the electronic diagram called a "schematic" to the actual attaching of wires and save yourself a big detour into electrical theory. The circuits are so simple they are unlikely to provoke a lot of curiosity anyway. They can be simple because computers does the work that used to be done by circuits. You only need to make enough circuitry to transduce the energy into a signal that can be heard at all by the microcontroller. Then you can substitute software in the microcontroller for circuitry to make adjustments to the signal and use it for triggering other events.

You first have to track down a schematic or diagram of a circuit that will fit your needs. You can get pretty far with the which are provided below on this page. The Physical Computing Quick Reference provides these same circuits along with other handy reference items for these brands of microctrollers Basic Stamp, BX24, Basic Atom, PIC. If you are using some sensor or device not in these circuits, you can usually find the appropriate circuit in the application notes or instructions for that device. You may also come across more complicated circuits for things like lie detectors or light organs in books or on the web. You should avoid these and stick to circuits that are designed to work with the luxury of software on the microcontroller. There will be transducers that will require additional circuitry that is just outside the scope of this site. For example, on the input side the amplification circuitry necessary for strain guages, and on the output side timing circuitry necessary for dimming ac power might require that you buydevice or get he help of an electrical engineer to build it. The Art of Electronics by Horowitz and Hill is a good book for learning more about circuitry.

Short Circuit

The one circuit that you definately do not want to make is a short circuit. This is when the positive side of the power flows unimpeded directly to the negative side. Putting a paper clip between the two holes in a wall socket is a good example of a short circuit. With no work load to slow them down, the electrons go so fast that they will burn things down (unless you have a fuse box). If chocolate ice cream were free, I would probably die of it. SHORT CIRCUITS ARE VERY BAD. Please avoid touching the leads of of your power source directly to each other. Don't work on a conductive surfaces like a metal table because some the connections on the bottom of your circuits may touch. Trim all your wires so that the parts exposed to the world have insulation on them.

Translating Schematic Symbols Although you don't have to know how to write a circuit, you do know how to read one. After you have a schematic to work with, learn the meaning of the symbols and to learn about the actual components represented by the symbols. Keep the package that your compenents come in because you may need it to decypher which lead is which.

Transistors are like switches that can be thrown by a electricity instead of by your finger. Transistors usually have 3 leads, a Base, a Collector and an Emitter. When the base gets electricity, it connects the Collector with the Emitter (for an NPN transistor). You can't use a transistor for switching something which uses AC power (use a relay instead). Keep the packaging for your transistors because it may have a key for telling which leg is the Base, Collector and Emitter.

Volts, Amps, Ohms, Watts

You will run across all these statistics for describing electricity. I look at it like a bus driving off a cliff. The height of the cliff is the Volts. This is easy to remember because things at the top of the cliff (like all good electrons) will move towards the "GROUND." How many people are on the bus is the current measured in amps. The Ohms is like the wind resistance or shrubbery on the side of the cliff. Watts are the power of the impact at the bottom of the cliff. Volts is often a given for example 120V from a AC wall socket or +5 volts DC from a microcontroller. If you have a switch or a relay, they are only rated as being safe for a certain amount of amperage. To figure out how many amps in your circuit, you can use the formula Watts (size of disaster) = (Volts (how high the cliff) multiplied by Amps (how many people on the bus) so for example a 120 Watt light bulb using 120 Volts uses 1 amp. Ohm's law describes the relationship between resitance, current and voltage. This would be useful if we were designing curcuits (knowing that your microcontroller might be putting out 5V at 20 milliamps you could calculate the resistance needed) but we are not designing circuits so I won't go on. Because I have a naive way of thinking about these things I am encouraged by the fact that electricity actually flows in the opposite direction of all the diagrams that engineers use. Apparently Ben Frankliin figured that electrical particles probably flowed from positive to negative (from the top of the cliff to the bottom). By the time scientist could see that in fact electrons flowed to the positive, I guess they figured it didn't matter so much so they kept all the diagrams the same. This is what I am told. If many engineers choose to view it as the more intuitive positive to negative flow, it should give you liscence to adopt whatever model you like for all this stuff as long as it works.

Circuit Board

An experimentor board allows you to make and change circuits easily. You can stick wires into and out of the holes (a needlenose pliars helps) without soldering. After you perfect your circuit on the is easy to change prototyping board, you can solder all your connections in a very similar looking board. For convience, all the holes in a continuous line are connected to each other. For instance wires 1 and 2 would be connected as are wires 3 and 4. The order in which wires are placed within a given row does not matter, each row can be treated as a single hole. This allows you make a junction in a circuit where many leads are suposed to touch each other without having to twist a lot of wires together or jam them into a single hole. Because the middle ridge breaks up the line, 5 and 4 are not connected. Almost all your circuits have many wires connected to ground or +5V so the two long lines on the side are usually reserved for these. Different experimenter boards connect differently, so you might test for continuity between holes using your

Wire

It is best to use 22 AWG solid wire with the experimentor board because it is stiff enough to be easily fed into the holes on the board. This wire is not so good when you need to run multiple wires (say you have ten switches to wire up) or for long distances because it gets messy. For these and others purposes you may want to use a more flexable stranded wire like ribbon cable or telephone wire which cannot be forced into the experimenter's board very easily. To solve this problem you can; 1) solder solid wire to the ends of the soft stranded wire; 2) solder wire wrap ends sold at radio shack to the ends of the stranded wires or 3) (Best) solder "headers" not sold at radio shack but you can get from any electronics catalogue to the ends of the stranded wires. A couple of alligator clips or test leads (Radio Shack# 278-016A) can come in mighty handy when your wiring is at an experimental stage.

Soldering

If you have to solder you should; 1) be careful and get a friend to help you; 2) allow the iron to fully heat up; 3) heat the items you are soldering not the solder directly, allowing the heat to transfer from the iron to the wire and then from the wire to the solder; and 4) be sparing with the solder 5) Unplug the soldering iron.

Using a Multimeter

Like most things, your circuits will not work the first time. It is easier and safer to check at each small step whether the things that are supposed to be connected are indeed connected and the things that are supposed to get voltage are getting voltage and the correct voltage. A Multimeter will be your main debugging device when things do not work. It is analogous to the message box in some software authoring programs. Of the many functions on your meter, the two that you will be most intersted in are the Volts DC (0-10 scale) (not AC Volts which sometimes has a tilde for an icon) and the Resitance ¸ (or the more convienient continuity which sometimes has a musical note for an icon). Using the Volts you can check to see that +5 volts is passing at the expected points of the circuit by touching the black (-) lead of the meter to ground on your circuit and the red (+) lead to the points that you want to check. Your multimeter should read "5V" if you have digital readout or the needle should go half way (if you are using the 0-10 scale). If you get a negative reading, you have the +5 and Ground reversed.

Checking for continuity is even more useful. Continuity means that there is a good connection. If your multimeter doesn't have a thing called "continuity," you check for 0 resistance. First set the multimeter to one of resistance (ohms) scales. Continuity is more convenient because because it beeps and you don't have to look back at the multimeter's display. When you touch the probes of the meter together, the it should react by beeping (if you have a continuity setting) or showing 0 resistance. Now you can stick those probes at different points in the circuit that you expect to have good connections and see if they are in fact good. Don't leave your meter in the resistance mode because it uses up the battery.

[Connections to your microcontroller.]

You have to set your microctroller up with power and a programming cable before you can get started.

Digital Output

With digital output you are usually turning things on and off. Which circuit you use will depend on the power requirements of the thing you are controlling. The simplest way is to turn on an off a LED which is small enough that the microcontroller itself can power it.

You can use a transistor as a switch which is thrown when power is applied to its base. You only need to apply the microcontroller's 5 Volts and the transistor can switch far greater voltage. In this way the transistor is acting as an amplifier. THIS CIRCUIT WILL NOT WORK FOR AC POWER (LIKE THE POWER FROM A WALL SOCKET). You can only use this with DC circuits. You should also check the transistor's package to see that it meets your load's voltage and current requirements. A common mistake with this circuit is not comingling the ground of the stamp with the gound of your DC load. You need to combine these grounds for the circuit to work.

Finally if you want to turn something on that uses electicity from a wall socket AC power, you have to add a relay to the circuit. This adds another level of amplification and isolation from the microcontroller. transistor can switch the kind of power the relay needs and the relay can switch the kind of power your AC appliance needs. Check the package of the relay to see that it meets your AC load's voltage and current requirements. The LED and capacitor are only there to eat up the charge that the coil in the relay kicks back into the circuit when it turns off. There are 5V (TTL compatible) solid state relays that make all this easier. Please be very careful and fully test the circuit (you can hear the relays click) before you add the AC Power.

Digital Input

The intuitive part of this circuit is where the Stamp's pin either touches 5V or not depending on the position of the switch. The problem is that when the switch is open (not touching) the pin would be waiving in the breeze. We need to tie it down to a default position. We can take advantage of the fact that electricity always goes along the path of least resistance. While the switch is open, the current from the microcontroller's pin goes along the resistor towards the ground because it is the only game in town. The pin then feels LOW (0) (Ground). When the switch is closed the path towards +5V is unimpeeded by a resistor and so looks more appealling to the electrons. Now the pin feels HIGH (1) (5V).

 
‘ declare a variable called X:
dim x as byte

sub main()
	do
		‘ getPin command sets the I/O mode and reads
		‘ the value of the pin into the variable X:
		X = getPin(12)
		Debug.print “X = “; cstr(X)
	Loop
End sub 	

Analog Input

The easy (naive) way to look at this circuit is that the stamp sends out 5V and depending on how much resistance the variable resistor is providing, a certain percentage of that 5V comes back. (Actually the stamp is sending out some juice and then timing how long it takes the capacitor in the ciruit to discharge.) Depending on that percentage, the microcontroller gives you a number (0-225) that descibes the analog state of the variable resistor. All this happens really fast when you give your Stamp the POT command.

Analog Output

Your microcontroller does not itself have enough power to drive anything but tiny electrical components like a LED or a Piezo transducer. To power real electrical appliances you would have to amplify the signal coming from the stamp. For now, just try using the Pulseout command with and LED or Piezo.

[Add to or Correct This Page]|[Yes, this is a Wiki]