Practical Arduino Cool Projects for Open Source Hardware- P4 potx

10 325 0
Practical Arduino Cool Projects for Open Source Hardware- P4 potx

Đang tải... (xem toàn văn)

Thông tin tài liệu

CHAPTER 1  INTRODUCTION There are at least three parameters that you need to consider when selecting diodes for use in your projects, these are: • Current-handling capability: Diodes can only pass a certain amount of current without damage. Small “signal” diodes like the venerable 1N4148/1N914 can cope with about 200mA, Rectifier diodes like the 1N400 are good for an amp or so; for higher ratings, you’ll find plenty of options at your favorite supplier. • Maximum reverse voltage: Diodes can only cope with a certain amount of reverse bias (voltage) before they are damaged. Again, looking at our two usual suspects of the 1N4148 and 1N4004, the maximum reverse voltage is 100V and 400V, respectively. • Forward voltage drop: Nothing comes for free! When conducing (forward biased), the diode drops a certain amount of voltage across its terminals. This, of course, ends up as heat and so diodes have power limitations as well. The 1N4148 and 1N4004 have similar forward voltage drops of 1V. A common use of a diode is to avoid damage to a piece of circuitry if the power is connected back to front. When using diodes in this manner, you need to consider all three of the previously mentioned parameters, particularly the current-handling capability—is it high enough; and the forward voltage drop —are you going to end up with a marginal supply voltage because of it? An alternative approach is to use a diode connected across the power supply input such that it only conducts if the power is connected back to front. A quick blow fuse must also be used so that the diode doesn’t stay conducting all this power for too long. The advantage of this approach is that you don’t get the forward voltage drop, the drawback being you blow a fuse—and if your design is marginal, you may blow the diode, negating the protection circuit entirely. Some subtlety is called for with this one. Power Supplies There are many different ways of powering your Arduino project. Low-power Arduino projects can be powered from either the host PCs USB port or batteries. Projects that make use of devices with higher power demands—solenoids, servos, motors, lots of LEDs and the like—are best powered off a mains- powered supply (transformer or plugpack/wallwart) or larger capacity battery. This section discusses some of the options available to the Arduino experimenter. USB Power The regular USB port on a PC provides 5V at a maximum of 500mA or so—about 2.5W. This is ample for many projects that just contain a few LEDs, an LCD, or an Arduino shield, but that’s about it. Anything that involves motors, solenoids, or servos will likely have peak current demands higher than the port can provide, meaning it shouldn’t be used. On the plus side, USB ports on most PCs are pretty well protected. If you draw too much current, they usually will just shut down gracefully before anything melts. With this in mind, using a $30 mains- powered USB hub while experimenting may be prudent insurance for your $1,500 laptop. USB ports have power control; that is to say, in most cases, they start out with a lower maximum current then switch up when the device is identified by the host as a high-power device. In practice, this means that if you simply tap into the USB supply, you can draw a maximum of 100mA, not 500mA, though this varies among computers. 9 CHAPTER 1  INTRODUCTION The FTDI chip commonly used to provide a serial interface to Arduino boards can either identify itself as low or high power according to an EEPROM setting. If you are going down this route and need the higher power, you’ll need to do some homework into how the FTDI has been programmed in your case. Two more caveats if using USB to power your project: (1) USB has a specific lower power or sleep state—if your device continues to draw power when the system powering it expects to go to sleep, strange things may happen and/or you’ll flatten the battery of your host device; and (2) never feed power back into the USB port of the host system! Batteries Batteries can either be rechargeable (secondary cells) or non-rechargeable (primary cells). Within each category there is a vast array of different battery chemistries and capacities. Key figures for batteries are the terminal voltage (V) and capacity, typically measured in ampere-hours (Ah), which give an indication of how long they can provide power before being discharged. The standard 9V “PP3” battery is really only a good choice for very low-current applications, perhaps a project that drives one or two LEDs and/or an LCD. Three or four 1.5V AAA, AA, C, or D cells provide a great deal more capacity at the expense of size, particularly for C or D cells. But, if you’re driving motors, servos, or solenoids, you’ll want to aim for C or D cells as a minimum to get any reasonable battery life.  A crude but effective trick when powering 5V circuitry from a 6V battery is to put one or two diodes in series with the supply. The typical forward voltage drop of 0.4V per diode brings the 6V down to a more ideal 5.2V and you get reverse polarity protection for “free.” For these readily available cells, there are also rechargeable equivalents which we’d encourage you to consider to reduce landfill. Bear in mind that the base cell voltage is lower for nickel-cadmium (NiCd) or nickel-metal hydride (NiMH) cells at 1.25V per cell, so an AA NiCd will provide around 1.3V when fully charged versus 1.5–1.6V for an alkaline. Sealed lead acid (SLA) batteries are an attractive option. While heavier, they have, depending on size, the ability to supply several amps for a few hours or more—good if you’re building a robot, for example. The strength of SLA batteries can be a weakness if things go wrong— that same ability to provide high currents can result in melted wires or circuit boards if things go amiss. Accordingly, we strongly encourage you to put a fuse in the circuit, as near the battery as practicable, if you use an SLA. Constructing your own charger circuit is beyond the scope of this book, but good resources are available on the Internet. For most applications, it’s likely to be simpler to just swap the batteries out into a commercial charger. 10 CHAPTER 1  INTRODUCTION What about LiPo? Lithium polymer (LiPo) and similar “exotic” batteries are very attractive from a weight/capacity standpoint, but require specific circuitry to ensure they work correctly and, when being charged, don’t overheat or catch fire. The per cell voltage for a LiPo battery is around 3.7V, but being sensitive to over discharge, steps must be taken to disconnect the battery when its terminal voltage drops below around 3.2V. LiPo cells can be permanently damaged if the terminal voltage drops below 3V or so. If your application needs the power density or the light weight of LiPo, a little Googling will yield some ready-made packs that have built-in charge/discharge controllers. We provide links to some examples on the Practical Arduino web site. Wall Warts/Plugpacks Wall warts (or plugpacks as they tend to be called in Australia) are an ideal way of powering all but the most power-hungry Arduino projects. Most plugpacks output a DC voltage, and this voltage can be regulated or unregulated (more on this in a moment). Some plugpacks output AC only, so are just a transformer in a safe-to-use box. These can be useful for some applications (such as referencing a clock to the mains as we touch on in Chapter 16) or when you otherwise want to do your own rectification and filtering. We won’t go into AC plugpacks in more detail here. DC plugpacks supply a DC voltage. “Regulated” plugpacks have built-in voltage-regulation circuitry, so they will provide a specific voltage (say, 5V) for any output current up to their rated maximum. By contrast, unregulated plugpacks have limited, if any, regulation and instead provide the nominated voltage only under the expected load. So if the plugpack is rated at 12V at 500mA, it may actually output 15V or more if only 200mA is being drawn. This explains why when you measure some supplies with a multimeter they show a much higher output voltage than what is written on the label. For Arduino projects, we generally recommend you stick with regulated supplies, as it reduces the chances of exceeding maximum voltages for any connected circuitry. Experience suggests that if the supply is rated at 5V or 3V3, then it’s probably regulated; by contrast, 12V supplies often aren’t. Regulated supplies use a transformer, rectifier, filter capacitor, and regulator or may be a more sophisticated switchmode supply. Switchmode supplies are often much smaller and lighter, more energy efficient, have good stable outputs, and tend to have better over-current protection. You can often pick up plugpacks cheaply at surplus sales, new from your local electronics store, or for lower-power projects from mobile phone chargers. Nokia in particular seem to have standardized on 5.2V for some years now, which is ideal for 5V-based projects. Capacitance and Capacitors Capacitors are electronic components that store charge. From an Arduino perspective, we most commonly encounter them when they are used to ensure stable power supply for our circuits. Fundamentals Capacitance (C) is measured in farads (F), though most devices we will encounter will be considerably smaller than a Farad— µF or nF, for microfarad and nanofarad, respectively. 11 CHAPTER 1  INTRODUCTION Capacitors can be connected in series or parallel to yield a circuit element that has a total capacitance lower or higher than the individual components. When capacitors are connected in series as in Figure 1-8 the total is given by C = C1× C2 / (C1 + C2) Figure 1-8. Two capacitors connected in series. As shown in Figure 1-9, the total capacitance of two capacitors in parallel is the sum of their values. Note that capacitance values work in the “opposite” way to resistance values when multiple components are connected together. Figure 1-9. Two capacitors connected in parallel Capacitor Types There are many different types of capacitors, but the main differentiator is polarized vs. nonpolarized or unipolar. Polarised capacitors are most common for capacitances over 1µF or so and will be clearly marked with a + symbol or stripe to show the lead that should be connected to the most positive part of the circuit. Nonpolarized capacitors are typically used for filter circuits or directly adjacent to digital ICs to provide supply bypassing (see the section “Power Supply Bypass” for more information). All capacitors have a maximum, or safe-working, voltage. These are particularly important for high- capacitance values where the capacitor is physically small. The maximum working voltage will be printed on the capacitor body. 12 CHAPTER 1  INTRODUCTION There are many different capacitor chemistries/construction methods. Wherever we make use of capacitors in Practical Arduino projects, we’ll call out what types are suitable. Power Supply Bypass Cutting a rather long and complex story short, digital circuits like the Arduino have quite low constant current requirements, but relatively higher peak or transient current when internal circuits change state. Supply bypass capacitors give a means to supply these transients in a circuit and ensure reliable operation. The Arduino boards themselves have these built in, but when prototyping or building your own external circuits, it’s good practice to add in these parts. For each digital IC, a 0.1µF-chip ceramic capacitor across the power supply pins and physically adjacent to the part is good practice. Each group of digital ICs or board is well served to have 10–100µF of electrolytic or tantalum capacitors where the supply enters the board. ESD Precautions Electrostatic discharge (ESD) is a phenomenon familiar to everyone—the spark or small shock you get when you touch a metal door handle after walking on synthetic carpet, for example. While the shock we experience is a mere irritation, it can be very problematic for electronic circuitry. The design and handling considerations necessary to avoid ESD-related problems are taken care of in well designed electronics, but when we are dealing with hardware of our own making, we need to do this ourselves. When constructing or prototyping circuitry, it is good to get in the habit of grounding yourself to an earthed piece of equipment before picking up any bare components or circuit boards. Keep static- sensitive components or assemblies in antistatic bags when not in use and consider getting an antistatic mat and wrist strap for your work area. The I/O lines of the standard Arduino boards connect directly to the ATMega chip itself without any filtering or protection. This is appropriate given the myriad of ways the board may end up being used, but does mean the chip is prone to damage if seriously mishandled. If your project needs signals to be brought into the Arduino board from the outside world, take a few minutes to review the section on Input Conditioning in Chapter 16 for design considerations. That said, we’ve heard the ATMega chips described as tanks—pretty hard to damage in practice— but good ESD habits will serve you well nonetheless! Tools Figure 1-10 shows a selection of tools that will be invaluable in your Arduino endeavors. A selection of small screwdrivers, diagonal cutters, long-nose pliers , tweezers, soldering iron, soldering iron tip cleaner, solder, desoldering braid, anti-static wrist strap, and a multimeter will well equip you to begin with. Adafruit and SparkFun are among a number of Arduino suppliers that have kits of these basic tools to help you get started. 13 CHAPTER 1  INTRODUCTION Figure 1-10. A recommended starter set of tools Soldering is a whole topic in itself—we provide a few pointers in the projects that involve soldered shields, and the Practical Arduino web site has some links to more resources. Don’t be daunted by soldering. As long as you take the obvious precautions (the handle is the “cool” end), it’s pretty easy to get the hang of it. More “exotic” tools become a matter of personal choice, necessity, or budget and often are only needed for more involved projects. Thus an illuminated magnifier, stereo microscope and oscilloscope are all nice to have, but only if you’re doing fine work, surface mount soldering, or sophisticated electronics development, respectively. Start off small, buy as good a quality as you can afford, and in no time you’ll have a nice range of tools. Parts A selection of parts—what the hobbyists of yore would call their “junk box”—can be tremendously useful, particularly when inspiration strikes late at night. Consider having on hand at least the following: • A good assortment of 1/4W resistors: you can usually pick up mixed bulk packs for a few dollars from your local electronics component shop or online. Consider adding some extras of popular values—the authors tend to have lots of 270R (for LEDs), 1k, and 10k resistors on hand, for example. • A handful of LEDs: obviously, you’ll need more if your project is specifically using them, but even if not, they’re handy to have on hand for debugging purposes. 14 CHAPTER 1  INTRODUCTION 15 • Some signal and rectifier diodes: 1N4148 and 1N4004 (or equivalents), the former for logic level applications, the latter for protection circuits, back EMF protection when using relays etc. • A few capacitors: 100nF, 1uF, 10uF. • An asso rtment of bipolar transistors: 2N3904, BC548, etc. • Some momentary buttons: for, say, reset or interacting with the circuit and some breadboard friendly switches. Further Reading Clearly, electronics engineering is a whole field in its own right, and we can give only a limited treatment within a few chapters. We have found these two titles to be a good companion when tinkering: • Wi lliams, Tim. The Circuit Designer’s Companion, Second Edition. Newnes, 2005. • Horowitz, Paul, and Winfield Hill. The Art of Electronics, Second Edition. Cambridge Univeristy Press, 1989. C H A P T E R 2    Appliance Remote Control One of the basic tasks in many home automation systems is controlling power to appliances. These could be lights, a heater, an exhaust fan, or just about anything else that runs on mains power. The problem, of course, is that it’s dangerous to mess with mains-level power directly and you may even be in violation of your local building code if you don’t have the necessary qualifications. This project uses a general-purpose appliance remote control that can be obtained from a local hardware store. It can be easily modified to link it to an Arduino for software control of devices around your house, without having to touch any mains-level wiring. This technique isn’t limited to just controlling appliances, though, and is a great way to modify just about any device with a remote control so that it can be linked to an Arduino. Any device with push- button control can be modified so that an Arduino can simulate button presses and have the device respond as if you’d pressed the buttons yourself. You could do the same thing with a TV remote control or a garage door opener. One of the authors has even done it with the temperature preset buttons on a gas-powered continuous hot-water service and on the control panel for his electric curtain tracks. You can see the parts needed in Figure 2-1 and the complete schematic in Figure 2-2. Parts Required 1 Arduino Duemilanove, Arduino Pro, Seeeduino, or equivalent 1 RF appliance remote control 1 Prototyping shield 4 5V reed relays 4 1N4001 power diodes or similar 4 PCB-mount male connectors 4 line-mount female connectors 10cm ribbon cable Source code available from www.practicalarduino.com/projects/appliance- remote-control. 17 CHAPTER 2  APPLIANCE REMOTE CONTROL Figure 2-1. Parts required for Applicance Remote Control Figure 2-2. Complete schematic for Appliance Remote Control 18 . electronics store, or for lower-power projects from mobile phone chargers. Nokia in particular seem to have standardized on 5.2V for some years now, which is ideal for 5V-based projects. Capacitance. 10cm ribbon cable Source code available from www.practicalarduino.com /projects/ appliance- remote-control. 17 CHAPTER 2  APPLIANCE REMOTE CONTROL Figure 2-1. Parts required for Applicance Remote. what is written on the label. For Arduino projects, we generally recommend you stick with regulated supplies, as it reduces the chances of exceeding maximum voltages for any connected circuitry.

Ngày đăng: 03/07/2014, 20:20

Từ khóa liên quan

Mục lục

  • Prelim

  • Contents at a Glance

  • Contents

  • About the Author

  • About the Technical Reviewers

  • Acknowledgments

  • Introduction

  • Introduction

    • Fundamentals

    • Sharing Your Work

    • Practical Electronics for Software Developers

      • Current, Voltage, and Power

      • Mains Is Nasty

      • Reading Schematics

      • Resistance and Resistors

      • Ohm’s Law and Current Limiting

      • Choosing Wire

      • Diodes

      • Power Supplies

      • USB Power

      • Batteries

      • Wall Warts/Plugpacks

Tài liệu cùng người dùng

Tài liệu liên quan