Beginning Embedded Electronics - 1.2

Lecture 1 - Background and Power Supply


Page 2


There are some down sides to a protection diode:


  • All diodes have a voltage drop, meaning 9V on one side will drop to about 8.5V on the other. So your 9V wall wart just became 8.5V.
  • Diodes have a current rating. If you try to suck 1A (1 amp) through a 0.1A (one hundred mili-amp) rated diode, the diode will quickly heat up and fail. For reverse protection, we recommend a 1A 1N4001 diode. These are dirt cheap and very common.


     Note that diodes are polarized. They have a direction that you need to pay attention to. Many diodes have a band indicating the cathode. What's a cathode? Go google. All you really need to know is that the line on the schematic part is the same as the line on the diode. If you can't remember which is which, remember 'arrow is for anode'. Cheesy, yes.

      So if you want to install this 'reverse protection diode', the 9V from your wall wart goes into the end of the diode without the band (the anode). The banded end (cathode) goes into your switch. Your switch then goes into the input. Throw the switch and you should see 5V on the output using your multimeter. Nifty. But I am tired of using my multimeter each time to check the 5V output. There must be a better way! Time to wire in the power LED.

      Light emitting diodes (LEDs) are bits of silicon that light up when current flows through them. Go google for the science. As a general rule of thumb, LEDs can have 20mA max current flowing through them before they begin to fail.


      So if you hooked up your LED like in the above schematic, it would light up very bright for a split second and then burn out. That's cause the LED is a diode and the current will flow from the anode (arrow) to the cathode (line) to ground - uncontrolled! The silicon will flow current at something like 1 amp for a split second and burn up. To limit this current flow to 20mA, we need Ohm's law. Yea, the book worms in the room suddenly perked up:

V = IR (this is Ohm's law)

If we have 5V, and we only want 20mA flowing through the LED:

5V = 0.02 * R

R = 250 Ohm

      Now this is not completely true because the LED has a forward voltage drop, but don't worry too much about that. Hooking up LEDs is very common with micros. All you need to remember is that you're going to need to limit the current. The most basic way to do this is with a resistor. 220 Ohms will work (LED will be brighter), 330Ohm is also good (LED a bit dimmer), 1K (1000) will work as well. 220, 330, and 1K are more common resistor values.

       I highly recommend you get your hands dirty. Hook up an LED to a 1k resistor, then a 330, then a 220, 100, 50, then finally blow the thing up by hooking it with no resistor. That was fun right? Good. You had a back-up right? Once the bit of silicon inside the LED is burned out, it is no good and the LED can be thrown away.


     Our final power supply circuit. It seems like a lot of work, but once you set this up on your breadboard, you might never take it off. This is the basis for all things micro. The input voltage may change, the output voltage may change (to 3.3V for example), but the basics are all there. Flip the switch and you should have a nice 5V rail and an LED letting you know that everything is a-ok. If the LED does not light up, that means that something else on the 5V rail is sucking so much current that the LED cannot light up. This is a very strong indicator something is wrong. If you turn on your system and the Power LED does not turn on, immediately turn off the system and check your wiring.

      You may be wondering if the resistor/LED order matters. It does not. The resistor can come first and then the LED or as shown. Either configuration will correctly limit current through the LED.

      If you think you may have blown up your LED then your LED will never turn on. You may want to check your power system with a multimeter instead.

      Good, you've made it this far. Now for some technical info about ripple/noise and why it's bad.

      If you've got major ripple on your power rail, say 500mV or more, this can cause your micro to latchup. This means that it was running fine at 4.8V, but at 4.3V it's not happy and will go into an unknown state. When the rail returns to 4.8V (because the ripple is bouncing the rail up and down), the micro goes from unknown to possibly latching up or freezing up. This is pretty rare these days because the chip manufacturers have done a good job of internally protecting against this, but in general, ripple is bad.

      Say you've got 500mV of ripple on your system and you're doing analog to digital conversions off of a
temperature sensor. The temp sensor has an output pin that will output an analog voltage that will vary 100mV for every 1 degree C. So at 25 degrees C (room temperature) the sensor will output 2500mV or 2.5V. If your micro is doing analog-to-digital conversions on this signal, it has to compare what it 'thinks' is a solid power rail of 5V against this changing analog signal from the temperature sensor. Well if your 5V 'solid' rail has 500mV of ripple, the micro doesn't know this, and will report a regular 2.5V reading as varying between ~3.0V (3000mV
= 30C) and ~2.0V (2000mV = 20C). This is wildly bad. You need a good 'clean' power rail if you are doing anything with analog signals.

Now some notes and photos on breadboards:

      Go read Tom Igoe's breakdown of the breadboard. In short, the power rails (the red/blue rows) are connected internally. The columns within the main area of the board are interconnected. So you can insert a wire into one hole and it will be electrically connected to a neighboring hole (vertical connections for the numbered columns, and horizontal connections for the blue/red power rails).

      Historically, the blue rail or the horizontal row of holes next to the blue line is 'GND' or ground. You can connect all the ground pins of all your components to this rail. Similarly, the red rail is for VCC. In our case, this is 5 volts.

     Here you can see power from the barrel jack being delivered to the slide switch, and then to the input pin of the v-reg. When the switch is thrown to the on position, the yellow LED turns on.

I cheated a bit.

     Do you see that odd thing in the upper right corner of the picture? That is my wall wart plugged into a DC barrel jack. Most wall warts are terminated with a round connector called a 'barrel'. The outside metal sheath is ground, and the inside metal is 9V. The two metal contacts are isolated. The DC barrel jack accepts this wall wart barrel (wall wart barrel slides into the jack with some friction to hold it in place). I don't like hacking the ends off power supplies and inserting the bare wires into a breadboard. Having energized bare wires bothers me.

      If the wires get pulled out of the breadboard because you kicked out the power cord, you'll have some tense moments until you get the power brick unplugged. So I soldered some short leads to the barrel jack so that I can plug/unplug my power cable from the breadboard. Easier to transport.

       See the orange wire at the end of the barrel jack? That pin inside the DC barrel jack connects to the center of the wall wart barrel. The center of our wall wart barrel connectors are '+' or 'hot' or '9V', whatever you want to call it. So the end of the DC barrel jack is soldered to an orange wiring meaning it is '+'. This orange wire is then connected to the center pin of the power switch.

      All ground connections are connected together. You will see a small black wire underneath the DC barrel jack. This is the pin that connects to the outside sheath of the wall wart barrel. This is the ground connection on the wall wart. This small black wire connects the ground of the wall wart to the ground on the breadboard.

     I did not install a reverse protection diode. I *only* use center positive power supplies so I know I'm safe. If you do anything similar, check your wall wart carefully with a multimeter before doing any testing.

Note: Our breadboard will have 5V and 0V rails. The blue rail is GND (considered 0V). Red is VCC (or called
5V).

Note on LEDs: LEDs are a polar device meaning you've got to hook them up in the correct direction. Light emitting diodes (LED) have a cathode and an anode. How do you tell the difference? Imagine the schematic element:



      Do you see the arrow? Do you see the flat line? A is for arrow. A is for anode. The physical LED will have a flat side corresponding to the flat line (the cathode) in the schematic picture. And there you go! When connecting an LED, you know that diodes only pass current in one direction (from anode to cathode - in the direction of the arrow!) so the flat side of the LED needs to be connected to ground somehow (usually through a resistor first) and the other side (remember arrow) is the anode and needs to be connected to power for current to flow. If you hook it up backwards, it won't turn on, and you might damage the LED but probably not. Just verify that you've got 5V on the correct rail and then flip your LED around if need be.


     Note the polarization of the caps. The larger 100uF cap is directly connected to the Input and GND pins of the v-reg. The '-' sign is connected to the ground pin. The smaller 10uF is connected on the power rails. The '-' sign (in white) is connected to ground, the opposite leg is inserted into the '+' rail. The power LED is on!

Note: The center pin of the wall transformer is connected to the red wire on the rear of the barrel jack. This short wire is then routed by another wire to the slide switch. Do not connect this center pin/9V source to the power rail on your breadboard!

      The slide switch has three legs. The center pin is considered the 'common' pin. If the switch is thrown to the right, there is a connection from the center pin to the right pin. Slide it to the left and a connection to the left pin is made. When dealing with power, we want the raw voltage (9V in our case) delivered to the center pin of the switch. When I slide the switch to the left (as pictured above), current is allowed to flow from the center pin to the left pin and on to the voltage regulator. When I slide the switch to the right, the center pin is connected to the right pin (which is not connected to anything). In this state, current does not flow anywhere and the breadboard remains powered down. Voila! We have a power switch.


     This picture is key. When I initially wired up this circuit, I flipped the switch and the power LED didn't light. That was VERY bad indicating there is a massive short somewhere. Even the good guys screw up now and again. Whip out your trusty multimeter and start probing in continuity mode.

Quick note: I highly recommend you purchase a multimeter with a 'continuity' feature built in. This mode allows you to 'tone' out circuits. In this mode, if you touch the two probes together, you should hear a tone indicating that there is a direct connection between one probe and the other (obviously - you have them touching!). This feature is used countless times during trouble shooting. In the above example, by probing from one GND rail to another, I noticed that I could not get a tone. Therefore, there was a break in the circuit somewhere which lead me to realize the break is in the rails.

     If you've got a medium sized breadboard such as the one shown above, you'll notice something horribly odd. The various holes of the power rails are not connected!


There is a reason why the power rails are broken. If you have a breadboard with multiple and different power rails, you cannot share them on the same row of holes. So modern breadboards break the rails up so that you can isolate different parts of your circuit. For example, if you were building a really complex design you may need to have 5V and 3.3V on the same board. Because the rails are isolated from each other, you could just use various strips around your breadboard to be designed at 5V, 2.8V, etc. For the purposes of this tutorial (and for almost all breadboarding) we assume that you'll only be using 5V and GND. Therefore, we need to use short jumper wires to interconnect all the isolated rails, forming one continuous 5V rail and one continuous GND rail.

      When I first wired up my power supply, I only had the long black/red jumpers on the right side of the board, but didn't have the small jumpers in the middle of the rails. Without these middle jumpers, only the bottom left rails (next to the 5V supply) actually have 5V and GND. Since the LED is connected to the upper left power and ground rails, the LED never got power! Therefore, you will probably need to use very short jumper wires (and some long ones on the end) to connect all the '+' rails (5V) together and all the '-' rails (GND) together.

     Some additional nit-picky notes about breadboarding:
  1. You won't listen to this rule. Neither did I initially. Use a few different colors of wire! It's really helpful to see where the power and gnd wires go if GND is black and 5V is red. I wired 200 connections using only orange. When things didn't work, it was hard to figure out where all the connections went.
  2. Don't worry about super-tight wires, and don't use huge loops. When cutting and stripping wire for breadboard connections, don't spend exorbitant amounts of time making the wire perfectly flat. It doesn't matter. That said, don't use 9" of wire when 1" will do. Make it clean.
  3. The 'making things clean' rule applies to LEDs, resistors, and crystals as well. Clip the legs! If you've got OCD like I do, it can be hard to permanently alter a part in this way. What if I need the legs to reach further away on a future project?! It's ok. Resistors cost $0.005 each. If in the future, you need a resistor with full legs to reach from point A to point B, just get a new one. It's not worth having lots of exposed legs that could bend and short to other exposed legs.
Now with your power supply built up, turn your multimeter to voltage and check your board voltage by probing from the Blue rail (0V or GND) and the red rail (5V or VCC).

Note: To use a multimeter you need to use both probes. Voltage refers to a potential. Using only one probe will get you nothing because you have to compare something against something else. In our world, we assume ground is 0V. So touch your black probe to any ground connection. Now you can measure the voltage on any other pin with the red probe. In the picture below, the black probe is touching the ground rail (0V), and the red probe is touching the 5V rail - thus we are viewing what voltage is exposed on the red probe compared to
ground. If we put both probes on the 5V rail, the multimeter would show 0V because there is no difference in voltage between the probes.

     Guess what happens when you push the black probe against the 5V rail and the red probe against the ground rail? The multimeter will show -5V. This is because the multimeter assumes the black probe is touching 0V. There is still a difference of 5V between the probes so the multimeter shows -5V.


     So you don't have 5.000V. Nothing in engineering is perfect. If you're within 100mV you're doing just fine. These cheap-o voltage regulators are cheap for a reason - and we don't need high-precision. 4.9V to 5.1V is just fine.

      Congratulations! You've built up your very first breadboard! Now leave this 5V power supply wired in your breadboard! You are going to use it many times...


Quick Note: PTCs are your friend! PTC = positive temperature coefficient. Beginners will often create shorts or accidentally hook things up backwards. A PTC (also known as a thermistor) is a device that will increase in resistance as current flows through it. These PTCs can be designed so that at a certain current flow (let's say 500mA), the resistance increases dramatically, thus limiting the current flow. Basically, the PTC acts as a resettable fuse! You will want to place this device in series, before your voltage regulator. If your circuit draws more than 500mA (if you short power to ground for instance), the PTC will heat up and limit the current to 250mA. Once you remove the short, the current will drop back down, the PTC will cool off and the circuit will start operating normally again. Very cool little component that has saved many of my designs from smoking.


This is how the PTC looks in circuit. The PTC is wired in line. As the current of the circuit flows through the
PTC, it will trip if the current is too large, cutting off the rest of the system.





No comments:

Post a Comment