9.4.09
MIT Swap Meet!
That glorious nerd food trough of hardware, the MIT Flea (aka Swap Meet) is near the end of the season. Next one is Sunday, September 16th, 2012. It's at the intersection of Albany and Main Street in Cambridge. 9am until around 1:30pm. Shop 'til your geeky legs drop.
31.1.09
Another Fred Note – LEDs and Microcontrollers
(for you who need a refresher and you who are new)
Read: Forrest Mims III's Getting Started in Electronics pages 44-46, 66-69
Light Emitting diodes are very efficient electrical devices that turn small amounts of electrical current into light. Because they are so efficient, and because the light-generating material is so small, they do not tolerate large amounts of electrical current the way ordinary incandescent light bulbs, solenoids, and motors do. Light bulbs and motors are wasteful in that they produce a lot of heat as by-products of their normal operation (the light, after all, comes from a glowing piece of metal in an anaerobic (no oxygen) environment, so it doesn't burn), and as they dissipate excess current (up to a point).
We can take any lightbulb and drive it with its recommended voltage with no other devices in the circuit. We can usually go higher, making the bulb light much more brightly, though we do risk blowing the bulb, or at least shortening its life. A normal Christmas tree bulb, for example, running at 3 volts DC draws .18 amps. If I bump that up to 6 volts, it draws .30 amps and is too bright to look at, but is otherwise doing fine. If I go much higher, I'll blow the bulb. Why? The filament eventually gets hot enough to melt.
A typical LED on the other hand is made to run on about 20mA; that's .020 amps or 1/10 of the current used by the Christmas tree bulb. Also, an LED typically drops about 2 volts in its normal operation. So, if we power an LED with a 2 volt power supply, the device will have all the voltage it needs to light (to overcome the PN junction barrier) and will draw only as much current from the power supply as it needs. Most power supplies that we use however, are not 2 volt power supplies. So what do we do? The most common solution is to waste some current; add a series resistor to make sure that only 20mA runs through the circuit.
Our Atmega chip output pins supply (source) 5 volts. So if we power an LED from a pin on our microcontroller, we need to deal with the 3 volts that remains after the LED drops its 2 volts. If we don't do anything, that voltage will all turn to current and the LED will emit smoke and a horrible smell. Here's how we calculate the value of resistor we need:
From Ohm's law, we remember that V = I * R. In this case, our V is 5 volts. However, our LED will take care of 2 through the process of lighting, so what we have to deal with is really 3 volts.
3 volts = .02 amps * R ohms ----> 3 / .02 = R = 150 ohms
Resistors dissipate electrical current by creating heat, and are also rated in watts. Watts are an expression of how much work a device is doing. The small resistors we use in class are ¼ or ½ watt. The resistor that determines Hi or Low light level in a slide projector might be rated for 20 watts or even more, and is a big wire-wound ceramic monster.
Power (watts) = EMF (volts) * Current (amps) ---> power = 3 * .02 = .06 watts.
So a ¼ watt resistor will be fine in this case.
The general formula for figuring out the value of a series resistor is:
R = (Vin – Vled) / Iled (voltage in volts, current in amps, and resistance in ohms)
Very Important – Our microcontroller sources 5 volts, however, it also can only deliver these 5 volts at a certain amount of current. Microcontrollers are meant to be brains, not muscles. Typically we place devices between the microcontroller and the world to mediate the outputs. From the Atmega168 datasheet, each output pin can source 40mA of current. In addition, any combination of pins in the same register (A, B, C, D) can support a maximum of 100mA. So, if you use 5 of the D ports to drive LEDs, you reach this 100mA maximum when you drive each LED at 20mA. If you need to drive 8 LEDs, you could drive 4 on D ports and 4 on B ports. This becomes an issue when using lots of LEDs or ultrabright LEDs.
I will cover techniques for driving large current loads with the Atmega in another Fred Note. The short answer is: NPN transistors (2N2222a), MOSFETs, ULN2803 IC, SN754410 IC.
For those of you who want to speed ahead:
Log into your account on Machine Science and open the Machine Science Guides. Scroll down to #3, Electronic Projects. Then look for the heading Atmega-Based Projects (NEW!) Click the link Atmega Board. I suggest reading through it. This is roughly the basics of the material we will cover for the next 2 weeks – simple lighting with LEDs, tone generating, analog light readings, use of switches. The better you know this now, the faster we can get to the more interesting cases.
One especially useful feature of the Atmega Guide is a translation of the commands used for materials supporting the Microchip PIC processor to the Atmega168. This allows you to work with other curriculum units published by Machine Science and adapt them for the Atmega chip. Finally, in the Machine Science Guides, under Item 7, Quick Reference, the Atmega guide has the complete pin out of the chip.
Be sure to visit the Atmel home page (www.atmel.com). This will give you a good idea of how these chips are used. For example, there are zillions that are strictly for automotive use. Toasters, space heaters, blenders, cardiac pacemakers, etc. all use them as well. Here's a link to the Atmega168 chip we are using (www.atmel.com/dyn/products/Product_card.asp?part_id=3303). Download the chip summary, and for late night reading, the full document.
(for you who need a refresher and you who are new)
Read: Forrest Mims III's Getting Started in Electronics pages 44-46, 66-69
Light Emitting diodes are very efficient electrical devices that turn small amounts of electrical current into light. Because they are so efficient, and because the light-generating material is so small, they do not tolerate large amounts of electrical current the way ordinary incandescent light bulbs, solenoids, and motors do. Light bulbs and motors are wasteful in that they produce a lot of heat as by-products of their normal operation (the light, after all, comes from a glowing piece of metal in an anaerobic (no oxygen) environment, so it doesn't burn), and as they dissipate excess current (up to a point).
We can take any lightbulb and drive it with its recommended voltage with no other devices in the circuit. We can usually go higher, making the bulb light much more brightly, though we do risk blowing the bulb, or at least shortening its life. A normal Christmas tree bulb, for example, running at 3 volts DC draws .18 amps. If I bump that up to 6 volts, it draws .30 amps and is too bright to look at, but is otherwise doing fine. If I go much higher, I'll blow the bulb. Why? The filament eventually gets hot enough to melt.
A typical LED on the other hand is made to run on about 20mA; that's .020 amps or 1/10 of the current used by the Christmas tree bulb. Also, an LED typically drops about 2 volts in its normal operation. So, if we power an LED with a 2 volt power supply, the device will have all the voltage it needs to light (to overcome the PN junction barrier) and will draw only as much current from the power supply as it needs. Most power supplies that we use however, are not 2 volt power supplies. So what do we do? The most common solution is to waste some current; add a series resistor to make sure that only 20mA runs through the circuit.
Our Atmega chip output pins supply (source) 5 volts. So if we power an LED from a pin on our microcontroller, we need to deal with the 3 volts that remains after the LED drops its 2 volts. If we don't do anything, that voltage will all turn to current and the LED will emit smoke and a horrible smell. Here's how we calculate the value of resistor we need:
From Ohm's law, we remember that V = I * R. In this case, our V is 5 volts. However, our LED will take care of 2 through the process of lighting, so what we have to deal with is really 3 volts.
3 volts = .02 amps * R ohms ----> 3 / .02 = R = 150 ohms
Resistors dissipate electrical current by creating heat, and are also rated in watts. Watts are an expression of how much work a device is doing. The small resistors we use in class are ¼ or ½ watt. The resistor that determines Hi or Low light level in a slide projector might be rated for 20 watts or even more, and is a big wire-wound ceramic monster.
Power (watts) = EMF (volts) * Current (amps) ---> power = 3 * .02 = .06 watts.
So a ¼ watt resistor will be fine in this case.
The general formula for figuring out the value of a series resistor is:
R = (Vin – Vled) / Iled (voltage in volts, current in amps, and resistance in ohms)
Very Important – Our microcontroller sources 5 volts, however, it also can only deliver these 5 volts at a certain amount of current. Microcontrollers are meant to be brains, not muscles. Typically we place devices between the microcontroller and the world to mediate the outputs. From the Atmega168 datasheet, each output pin can source 40mA of current. In addition, any combination of pins in the same register (A, B, C, D) can support a maximum of 100mA. So, if you use 5 of the D ports to drive LEDs, you reach this 100mA maximum when you drive each LED at 20mA. If you need to drive 8 LEDs, you could drive 4 on D ports and 4 on B ports. This becomes an issue when using lots of LEDs or ultrabright LEDs.
I will cover techniques for driving large current loads with the Atmega in another Fred Note. The short answer is: NPN transistors (2N2222a), MOSFETs, ULN2803 IC, SN754410 IC.
For those of you who want to speed ahead:
Log into your account on Machine Science and open the Machine Science Guides. Scroll down to #3, Electronic Projects. Then look for the heading Atmega-Based Projects (NEW!) Click the link Atmega Board. I suggest reading through it. This is roughly the basics of the material we will cover for the next 2 weeks – simple lighting with LEDs, tone generating, analog light readings, use of switches. The better you know this now, the faster we can get to the more interesting cases.
One especially useful feature of the Atmega Guide is a translation of the commands used for materials supporting the Microchip PIC processor to the Atmega168. This allows you to work with other curriculum units published by Machine Science and adapt them for the Atmega chip. Finally, in the Machine Science Guides, under Item 7, Quick Reference, the Atmega guide has the complete pin out of the chip.
Be sure to visit the Atmel home page (www.atmel.com). This will give you a good idea of how these chips are used. For example, there are zillions that are strictly for automotive use. Toasters, space heaters, blenders, cardiac pacemakers, etc. all use them as well. Here's a link to the Atmega168 chip we are using (www.atmel.com/dyn/products/Product_card.asp?part_id=3303). Download the chip summary, and for late night reading, the full document.
Subscribe to:
Posts (Atom)