Micro Controller Interfacing
Micro Controller Interfacing
Micro Controller Interfacing
Home
Electronics
Tropical Fish
Garden
Ham Radio
Although the main point of this series is on hardware, sometimes it will be necessary to discuss programming. It will be kept to a minimum and attempts will be made to keep program examples generic. The series will start with the basics and move to more complex subjects. Additional parts will be added as time allows. Most of this series will cover low voltage circuits. Extreme caution must be exercised when working with high voltage circuits. Every effort is made to ensure this information is correct. This information is provided as is, and without warranty. The reader is responsible for implementing any circuits in a safe manner. Development hardware and software for many microcontrollers is powerful and inexpensive. The immensely popular Arduino systems are a great way to start. The open source software handles a lot of the low level details, allowing new programmers to get their applications running quickly. Arduino hardware is low cost and available from a number of vendors. Sidebars with
special tips for Arduino users are included on some topic pages. Note that the series may not follow a logical order. Sections are added as I get the urge or based on requests from readers. Rather than re-sorting them from time to time, I decided to leave them in the order they are written so that external links to these pages are not affected. I'm always looking for feedback on this series. Please contact me if you find any errors. If there is a specific topic you would like covered, please send me an email and I will put it on the list for consideration for future installments. Email: w9xt (at) unifiedmicro (dot) com. Be sure to include Microcontroller I/F Series in the subject line so it will not be caught in the spam filter. Enjoy your journey into the world of embedded systems!
Applications Integration
Go Open Source For Your Application Integration. Free Product Download!
www.talend.com/Free_Inte
Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 2 Back to Electronics Main Page Home Page
Unified Microsystems Electronic equipment, modules and kits for engineers, students, electronic hobbyists and Amateur Radio operators.
Home
Electronics
Tropical Fish
Garden
Ham Radio
V=I*R
Simple algebra lets us manipulate the equation to solve for the unknown variable.
I = V/R
or R = V/I
In Figure 2-1, if we know our voltage source is 5V, and we have a 1000 ohm resistor, we can calculate the current in amperes. I = V/R = 5/1000 = .005 A, more often stated as 5 ma. In designing circuits, we often have a given value for one parameter of V, R, or I, and a desired value for one of the other variables. The goal is to select the remaining component to give provide the desired value. For example, suppose we have a 12 V battery, and want 65 ma of current. What resistor value do we need? R = V/I = 12/.065 = 184.6 ohms Now, finding a 184.6 ohm resistor is going to be difficult, but fortunately in most cases you do not need (and are unable) to get that sort of precision. The closest standard 5% resistor is 180 ohms. If we use a 180 ohm resistor, and it is right on 180 ohms (it wont be), we will get the following current. Figure 2-1 I = V/R = 12/180 = .067 A, or 67 ma. In most cases this will be close enough.
Voltage Dividers Figure 2-2 shows a slightly more complex circuit, one that has a voltage source and two resistors. There are several points to illustrate with such a circuit. The first is that resistors in series have a total resistance equal to the sum of the individual resistances.
What would the current be in the circuit shown in Figure 2-2 be? Since the two resistors could be substituted by a single resistor with a value equal to the sum of the two, Ohms Law states
I = V/(R1 + R2)
The other important point is to realize the there will be a voltage across each component in the circuit. If you put a voltmeter across the power source you would read Vs. Measuring across R1, you would measure voltage V1. Voltage V2 would appear across R2. Note the polarity of the voltages with reference to the arrow indicating current. The ones across the resistors are opposite polarity of the voltage source. This is because the net voltage around the loop must be zero. Mathematically, the voltages follow this equation:
Figure 2-2
Vs = V1 + V2
So, what are the voltages V1 and V2? That depends on the ratio of the values of R1 and R2. The voltage across a resistor will be proportional to the value of that resistor compared to the total. The following equations apply: Multisim Simulation
Optimize circuit design performance with simulation. Learn how.
www.ni.com/multisim
V1 = Vs* R1/(R1+R2)
V1 = Vs* R1/(R1+R2+R3)
Suppose Vs = 12V, R1 = 1200 and R2 = 2400. What is the voltage across each resistor? V1 = Vs* R1/(R1+R2) = 12* 1200/(1200 +2400) = 4 V
To calculate the voltage across R2 we could use the equation for V2 or we could apply the knowledge that the total voltage across the loop must equal 0V.
Vs = V1 + V2 Summary
--> V2 = Vs - V1 = 12- 4 = 8V
Designing interface circuits to microcontrollers requires some simple mathematics. Understanding Ohms Law and voltage dividers will cover a large percentage of the situations for simple circuits.
Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 1 Microcontroller Interfacing Part 3
http://www.w9xt.com/page_microdesign_pt2_basic_elect.html[27/06/2011 1:34:04 PM]
assemblies.
anaconpower.com
8 Out of 10 Engineers Optimize circuit design Rely on Our performance with Oscilloscopes. Come simulation. Learn how. See Why Today. www.ni.com/multisim
www.tek.com
Electric Circuits 9th the Rick Lyons Course Edition Solutions. View only from Besser Free! Associates Cramster.com/Nilsson
www.besserassociates.com
Home
Electronics
Tropical Fish
Garden
Ham Radio
Figure 3-1
Circuit oscilloscope www.tek.com 8 Out of 10 Engineers Rely on Our Oscilloscopes. Come See Why Today.
interest. To do something useful it must be connected to another device, referred here simply as a load. A real world load could be an LED, a lamp, a transistor, or some other circuit element. Generally there are two ways to connect an output pin to a load. The first is where the microcontroller supplies the current to drive the device. The microcontroller is referred to as the source. Current flows from the microcontroller power to the output pin, through the load and to ground. This configuration is shown in Figure 3-2a.
PCB Load Cells www.pcbloadtorque.com Strain guage Load Cells Lifetime Warranty Plus
Buy Electronic LED Sign www.MegaSignInc.com Spend Less On Top Quality, Long Lasting Programmable LED. Order Now Pro Energy www.proenergy.ca Rental Power Solutions. Generators, Lights, Electrical Dist Solid State Relays anaconpower.com Manufacturer of DIN and Panel mount solid state relay assemblies. Multisim Simulation www.ni.com/multisim Optimize circuit design performance with simulation. Learn how.
The microcontroller pin can also sink the current as shown in Figure 3-2b. Here the current flows from the power supply through the load and through the output pin to ground. It is important that the load be connected to the same power supply line as the microcontroller, or you can destroy the IC. Output Currents Figure 3-2 Microcontrollers are somewhat delicate devices and the I/O lines can only carry a relatively small amount of current. The current limit will depend on the type of microcontroller, and the specific pin. There will usually be a maximum total current the pins of a single 8 bit port can handle, as well as a limit for all of the outputs for the entire microcontroller. Exceeding the limits will destroy the microcontroller. To find out what the maximum currents are, you need to look at the data sheet for the microcontroller. PDF formatted data sheets can be downloaded from the manufacturer. These can be quite large, several
Circuit oscilloscope www.tek.com 8 Out of 10 Engineers Rely on Our Oscilloscopes. Come See Why Today. PCB Load Cells www.pcbloadtorque.com Strain guage Load Cells Lifetime Warranty Plus
Analog Mixed Signal www.besserassociates.com Courses from Besser Associates Multisim Simulation www.ni.com/multisim Optimize circuit design performance with simulation. Learn how.
hundred pages for a fairly complex one. Look for a section titled Electrical Specifications or something similar. Usually in the section there will be a table called Absolute Maximum Ratings or similar. You will find a table containing a number of specifications including:
Characteristic Circuit mixed signal ASIC www.LinearChip.com Analog oscilloscope www.tek.com 8 Out of 10 Engineers Rely on Our Oscilloscopes. Your complex analog & mixed signal ASIC design Come See specialists Why Today. Transformer Services transformerengineeringservices.com Transformer Substation Maintenance, Construction, 24 hr Emergency Srvs Dc dc converter design www.cdiweb.com/minmax Split Core Current Sensor www.opensourcemeter.com AC/DC Power Modules, Low Cost Great specifying Low Cost Current Transformers Get help Delivery, Standard and your solution Custom Custom Pins - Crane Scales www.cscforce.com Dynamometer, Free Quote www.qualitylapelpins.com Highest Overhead Use-High Price Custom Pins as Safe for Quality at the LowestAccuracy Dial, Digital. low as $0.49 each New, Used, Rentals Output Source Current Output Sink Current
Ioh stands for Current (I), output high. Iol stands for current, output low. Currents are traditionally referenced as going into a pin. If the output is high, the current flows out, so it is given a negative number. In some microcontrollers the maximum sink and source current limits for a given pin might be different. You will also want to check the portion of the data sheet that covers the port you are using. Some ports have more drive capacity than others on some microcontrollers. Exceptions will be spelled out there. Some manufacturers such as Atmel will not give a single value for the maximum current allowed for output pins. Instead they provide a graph that plots the Voh vs. Ioh and Vol vs. Iol. Voh stands for Voltage, output high, and Vol is Voltage, output low. As a first approximation, Voh is equal to the supply voltage, and Vol is zero volts. However, as the current increases, the voltage drop across the output transistor will increase. This results in the voltage being less than the supply voltage when the pin is set to a 1, and the output voltage being more than 0 volts when the output is set to a 0. If you try to sink or source large amounts of current, the change in the output voltage can cause problems in your circuit operations. A simple and practical rule of thumb is to find the current when Voh is 90% of the supply voltage and use that as your maximum Ioh. Similarly, find the current on the chart where Vol is 10% of the supply voltage and use it as the maximum Iol. This will keep you out of trouble in most situations. It should be noted that some microcontrollers have a few I/O pins that are open collector. These dont have the upper (red) transistor as shown in Figure 3-1. These will need external pull up resistors. Summary A microcontroller I/O pin can be set by the program to operate as an output. The output voltage will be close to the supply voltage when the output is set to a logical 1. The output voltage will be close to 0 volts when the pin is set to a logical 0. An output pin can either source or sink the current to or from a load. It is important not to exceed the maximum current ratings, which can be found in the microcontrollers data sheet.
Arduino Tips
The I/O pins of the ATMega328 used on the Arduino Duemilanove can sink and source 40 ma per pin. There is a maximum of 200ma total for the package. About 25 ma should be reserved for the internal operation of the ATMega328 leaving about 175ma maximum current for the rest of the I/O pins.
Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 2 Microcontroller Interfacing Part 4 Back to Electronics Main Page Home
Unified Microsystems for electronic equipment, modules and kits for engineers, electronic hobbyists and Amateur Radio operators.
Lecroy Used Oscilloscopes
Order securely 24/7 at TechRecovery Instock, Fully Guaranteed!
www.TechRecovery.com
Digital Oscilloscopes
Digital Oscilloscopes now from Rohde&Schwarz. Get Details Here!
www.scope-of-the-art.com/RTO
Home
Electronics
Tropical Fish
Garden
Ham Radio
LEDs are diodes. Diodes conduct current when they are forward biased. LEDs give off light when a current flows through them. The amount of light given off, or its brightness, will be proportional to the current. The more current that is allowed to flow, the brighter it will get. This will continue until you get one bright flash, after which it no longer emits light, or acts as a diode for that matter. The data sheet for the LED will generally give the light output at some typical operating current. You can operate the LED at a lower current and get less light or at a higher current and get more light as long as you dont exceed the maximum ratings of the LED. Different LEDs will produce different amounts of lights for the same current. High efficiency LEDs will be brighter, but will be more expensive than garden variety LEDs. Small LEDs typically run at 15 to 25 ma, while larger, high output types may run 100ma or more. Another important characteristic of an LED is the Vfwd, or forward drop voltage. A diode has an exponential V-I curve. As the current through the LED increases, the voltage drop across it will increase only slightly. Vfwd will be listed at a specific current, usually the same one used for rating the light output. Vfwd will usually be around 2 volts for red LEDs, and increase with different colors. Blue or white LEDs are often a bit over 3 volts. Vfwd will be important for setting the proper current level for the LED. LED design example Your project will control a motor. It will use an LED to indicate an over temperature condition. A second identical LED will indicate an over speed condition. You select a red LED and look up the specs in the data sheet. The luminosity (light output) is what you want at the recommended current of 15 ma. The voltage drop at that current is 1.9 volts. Figure 4-1 shows the two LEDs being driven in different ways. LED1 is uses the microcontroller output pin P0 as a sink, and LED2 uses the pin P1 as a source. You will note a resistor in series with the LEDs. If you were to omit the resistor and drove the LED directly with the microcontroller pin, excessive current would flow when you turned on the LED, probably burning out that pin on the microcontroller or maybe the
Multisim Simulation
Optimize circuit design performance with simulation. Learn how.
www.ni.com/multisim
LED. The question is what value should we use for the resistor? BC LED LightsDirect LED
LED Grow Lights - 35WATT- LED UFO99.95 - NEW- 300Watt 599.95
www.bcledlights.com
We will use the LED1-R1 combination to do the calculation. The source voltage is 5V from our supply. The voltage dropped across the LED is 1.9, which we found in the data sheet. Since the voltage around the circuit loop must be zero volts, Vdd = Vr + Vfwd Rearranging the terms gives us Vr = Vdd Vfwd = 5 1.9 = 3.1 V We now know the voltage across the resistor is 3.1V, and we decided earlier that we wanted to drive the LED at 15ma, so a simple application of Ohms Law will tell us what value resistor is needed. R = V/I = 3.1/.015 = 207 ohms. Resistors come in standard values. The closest 5% resistor values are 200 ohm and 220 ohm. Either would be OK. The 200 ohm would result in a little more than 15ma of current, and the 220 ohm resistor would be less than 15ma. The value for R2 is the same as R1. The only real difference is the microcontroller is supplying 5 volts instead of directly getting it from the power supply. Sink or Source? Which one should you use? In most cases it is a matter of personal preference. To turn on LED 1 you need to set the PO register bit to a zero. To turn on LED2, you set P1 to a logical 1. To many developers, setting a pin to a 1 or high seems more natural for turning something on, so you might want to use the microcontroller pin as a source. One case you might need to use one driving method over another is when the maximum source and sink currents are not the same, and only one method will be able to handle the current needed. If the pin you selected is an open drain type, you will need to sink the current. Open drain outputs do not have an internal transistor to Vdd, so the pin cant supply current. Some microcontrollers have a few I/O pins that are open drain. Summary Controlling an LED with a microcontroller is a common application and is easy to implement. Make sure that current limits of the microcontroller and LED are not exceeded.
AC/DC Power Modules, 30 years of LED Low Cost Great experience offering Delivery, Standard custom LED Sign and Custom solutions www.cdiweb.com/minmax
www.DataDisplayUsa.com
Figure 4-1
Analog Mixed Signal www.besserassociates.com Courses from Besser Associates Transformer Services transformerengineeringservices.com Transformer Substation Maintenance, Construction, 24 hr Emergency Srvs Microcontroller Kits www.ATRIATechnologies.com 8, 32 bit, LCD, USB Order NOW! Starting At $79 Shop On Line Multisim Simulation www.ni.com/multisim Optimize circuit design performance with simulation.
Learn how.
Arduino Tips
Gotcha Checklist 1. Ensure the operating current does not exceed the LED maximum operating current. 2. Ensure the operating current does not exceed the microcontroller sink or source maximums. 3. If using the current sinking configuration, use the same voltage to drive the LED that supplies the microcontroller. The I/O pins of the ATMega328 used on the Arduino Duemilanove can sink and source 40 ma per pin. There is a maximum of 200ma total for the package. About 25 ma should be reserved for the internal operation of the ATMega328 leaving about 175ma maximum current for the rest of the I/O pins.
Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 3 Microcontroller Interfacing Part 5 Back to Electronics Main Page Home Page
Unified Microsystems for electronic equipment, modules and kits for engineers, electronic hobbyists and Amateur Radio operators.
Home
Electronics
Tropical Fish
Garden
Ham Radio
Figure 5-1
5 Pin Modules
State of the Art Protection Modules Competitive Pricing
lea-networks.com
little noise on an input can cause an improper read. For applications with noisy electrical environments, it is usually best to run the microcontroller near the high end of the allowable Vcc range. On the other hand, running at higher supply voltages will mean more power consumption. Those are the kind of tradeoffs that you will need to make as a circuit designer. The actual levels and slope of the thresholds indicated by the blue and green lines of Figure 6-1 will depend on the microcontroller in question. They will also change a bit depending on the device temperature. Some special pins such as the reset pin might have different thresholds than regular I/O pins. Referring again to Figure 5-1, the red line shows the input voltage equal to the supply voltage. You dont want to subject inputs to voltages above Vcc or you can damage the IC. For that matter, you do not want the input to go below ground (0V). That can cause the internal circuitry in the IC to latch up, and possibly draw excessive current and damage or destroy the IC. Pull ups and pull downs Sometimes you want an input to read as a 1 or 0 as a default. Suppose you have a sensor on a cable that plugs into your device. It is possible that the user will disconnect the cable. If the input pin is left floating, it might sometimes read as a 1, sometimes as a 0. Your code might interpret this as changes from a sensor and not act the way you want. Putting a pull up resistor will set the input voltage near Vcc and it will read as a 1. A pull down resistor will bring the voltage near 0V, and it will read as a zero. Figure 5-2 shows pull up and pull down resistors. The switch, sensor, or other component that generates the normal 1 and 0 voltages must be able to over drive the resistor. What value resistor should you use for these resistors? There are no hard and fast rules, but there are some guidelines. A resistor with a relatively low resistance is called a strong pull up. That is because it takes a lot of current to pull it down. Alternatively, a high resistance pull up is a weak pull up because it will not take much to pull it down. If your circuit is in an electrically noisy environment, some of that will get coupled into your circuit. If a weak pull up is used, the noise could be powerful enough to cause a false reading. If you use a strong pull up, the noise risk is reduced, but the circuit driving the input must be able to handle the load, and the systems over all power consumption will be higher. You have to understand the conditions your circuit will operate in, and make the proper compromises.
Substation Courses from Besser Maintenance, Associates www.besserassociates.com Construction, 24 hr Emergency Srvs
Attract Customers Optimize circuit design With Programmable performance with Digital LED Boards. simulation. Learn how. Contact Us Now. www.ni.com/multisim
www.MegaSignInc.com
AC/DC Power Modules, Optimize circuit design Low Cost Great performance with Delivery, Standard simulation. Learn how. and Custom www.ni.com/multisim
www.cdiweb.com/minmax
One thing to keep in mind is that some microcontrollers require one or more clock cycles after a direction change before the data on the pin can be trusted. Many designers have wasted a lot of time trying to figure out why their system does not work because they overlooked this fact. Summary Microcontroller pins can be used as inputs to sense conditions in the outside world. Digital I/O pins can only detect ON or OFF (1 or 0) states. A high voltage (near Vcc) will read as a logical 1, and a low voltage (near 0V or Ground) will read as a logical 0. Some microcontrollers have internal pull ups. You set a bit in an internal register to turn them on. These are nice because you dont have to add the pull up resistors in the hardware design, saving cost, board space and assembly time. The value of internal pull ups is usually pretty high (weak pull up), and the actual value often has a huge range. Internal pull ups are handy, but evaluate the parameters in the data sheet before using them. So, what values should be used for pull ups and pull downs? There are no hard and fast rules, but generally anything under a few thousand ohms is a strong pull up. Weak pull ups often reach 40-50K. I dont like to go over 10K unless I have a specific reason, like needing to keep power consumption extremely low. Switching between Input and Output Mode In some applications you may want a pin to be an input some of the time, and an output at other times. An example is where the microcontroller is communicating with another system or IC. Sometimes the microcontroller is sending data to another IC, and at other times the IC is sending data to the microcontroller. I2C and Two Wire Interfaces are common examples where an I/O pin is used as both an input and output.
Figure 5-2
Arduino Tips
You can enable the internal pull up resistor on an Arduino pin with the following instructions:
Gotcha Checklist 1. Ensure signals applied to digital inputs are either near Vcc or ground. 2. Size pull ups and pull downs appropriately. 3. Allow time enough time when switching an I/O pins direction. Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 4 Microcontroller Interfacing Part 6 Back to Electronics Main Page Home
Home
Electronics
Tropical Fish
Garden
Ham Radio
Circuit oscilloscope www.tek.com 8 Out of 10 Engineers Rely on Our Oscilloscopes. Come See Why Today.
Honeywell Distributor AlliedElec.com/Honeywell Allied Has the Honeywell Parts You Need. Order Today!
5 Pin Modules lea-networks.com State of the Art Protection Modules Competitive Pricing Figure 6-1 Make Prototypes In-House www.lpkfusa.com Prototyping equipment from LPKF Circuit Board Plotter, Plating, etc
Circuit oscilloscope www.tek.com 8 Out of 10 Engineers Rely on Our Oscilloscopes. Come See Why Today.
www.cirexx.com
Selecting Resistor Values What value should be used for pull up (or pull down) resistors? A lot depends on the demands of the application. A big part of the decision is how much power the application Note that some microcontrollers have internal pull up resistors that can be enabled under program controller. You can afford to use. dont need to wire up R1 if you use an internal pull up resistor. If you use an external pull up resistor, tie the high end to When a switch is closed, current will flow through the resistor. The voltage will depend on microcontroller, and a the same voltage used to run the microcontroller. Using a higher current damage the the voltage of the resistor circuitthe voltage used todiscussed the use of pullcurrent can be more detail. value may result the and not working. Part 5 power the circuit. The up resistors in lower determined with Ohms Law: P1 has R2 as a pull down resistor. When SW2 is open, P1 is pulled low, and read as a logical 0. Closing SW2 I voltage causes current to flow through R2, raising the = V/R at P1 to the Vcc level. At that point P1 will read as a logical 1. Similarly, the power up or pull down resistor, the input will float and when the switch is open the input will be very If you dont have a pullconsumed by using the formula: susceptible to noise causing false readings. Part 5 discusses this in more detail. Which of the two methods should P= V^2/R you use? I usually use the pull up resistor. That is a habit gained when I did a lot of design with bipolar transistor TTL With a 1000 (1K) ohm resistor are not supply voltage, we that technology. logic gates. Pull down resistors and a 5Vrecommended with get the following: With MOS microcontrollers there is no major V/R = 5/1000 one over another. UseV^2/R = 5 * 5/1000 = .025W or 25 mw I = advantage of = .005 A or 5 ma P= whatever you prefer. Your program can check the resistorof the switches, andwe get: different code depending on the state of the switch. With a 10,000 (10K) ohm states in the same circuit execute I = V/R = 5/10000 = .0005 A or .5 ma P= V^2/R = 5 * 5/10000 = .0025W or 2.5 mw Clearly using a higher value resistor uses less power, so why not just use very large resistors for switch pull ups? The problem is that high resistor values make the circuit more sensitive to noise. A small amount of noise current injected into a high impedance circuit could generate enough voltage to cause an incorrect reading. Too high a resistance can also make a circuit sensitive to leakage from moisture or contamination on the circuit board. I once designed a portable device with a PIC microcontroller. It had some input switches for operator control. Wanting to maximize battery life, I used 47K pull up resistors. Things worked fine until units started to get returned for erratic operation. They all worked fine once they got back. The ones getting returned were coming back from Central America and Pacific islands. It turned out that condensation from the high humidity was enough of a path to pull the input pins low. After that the boards were given a conformal coating to keep moisture off the conductors. The purpose of the switch will also determine how critical power consumption is, even in a battery application. If the switch is a push button type the user only presses occasionally for a fraction of second, the total power consumption will be low. A slide or toggle switch that might be left in the closed position for long periods of time could cause significant battery drain. As a practical matter, values greater than 1K and less than 20K will work pretty well. Unless I have some special needs I usually just use 10K resistors as a good compromise between power use and noise immunity. A future section of this series will cover handling
Honeywell Distributor
Allied Has the Honeywell Parts You Need. Order Today!
AlliedElec.com/Honey
Avnet Express
5 Million Reasons to See What's In Stock. Order Components Online!
AvnetExpress.Avnet.com
DWYER DWYER Level Level Switches Switches Full Range of Full Range of Level Sensors for Level Sensors for all applications applications
www.dwyer-inst.com www.dwyer-inst.com
AlliedElec.com/Honey AlliedElec.com/Honey
Avnet Express Distributor of Quality Electronic Components, Components by Same Day EE Times-Order Shipping. Order Online Online! AvnetExpress.Avnet.com
AvnetExpress.Avnet.com
they dont switch cleanly. The mechanical components of a switch vibrate back and forth making a number of momentary contacts before finally settling down to the final state. Figure 6-2 shows what an oscilloscope attached to P0 in Figure 6-1 would show when SW1 is closed. P0 goes high and low a number of times when the switch is first closed. A microcontroller operates thousands of times faster than a mechanical switch. It would see each of the short pulses as individual switch openings and closures. If the switch is used for counting events, the microcontroller count would be many times the true number of events. In another application the switch might be used to turn a light or motor on and off.
Figure 6-2
Press the button and the light goes on. Press it again and it will go off. If switch bounce is not accounted for, the user would think the switch or device is operating erratically. When the button is pressed, sometimes the light will not go on, other times it will not turn it off when it was supposed to. In reality the microcontroller is turning the light on and off several times, but too fast to observe. The final number of bounces the switch makes each time will determine if desired operation is achieved. There are a number of ways of handling switch bounce. Simple cross couple logic gates forming flip-flops can be used, but debouncing switches is usually done in software. Once developed, software is free. Hardware costs money each time another unit is manufactured. Simple C-like pseudo code to debounce a switch is shown in Listing 6-1. It could be used with the configuration of P0 in Figure 6-1.
Listing 6-1 is a function that the program calls every time it needs to check the status of a switch attached to I/O pin P0. The function returns a byte with the value of 1 if the switch is closed, and a value of 0 if it is open. It is assumed that the port pin has already been set up to act as an input. The actual syntax of the statements for reading the state of a pin will depend on the compiler. The C language standards do not define syntax for how an input is read, so each compiler implements this differently. The first statement inside the function checks if the port is reading low (switch closed). If it is, wait 50 milliseconds and see if it is still closed. If it is still closed, the function returns a value of 1 to indicate the switch is closed. If none of the conditions are met, the function returns a logical 0, indicating the switch is open. The program must call this function frequently to ensure it catches every switch closure. This is especially true if the switch closure is going to be short, say for a user press of a momentary push button switch. If the delay function is not in there, and the switch has bounce, the function could be called several times and get multiple readings of
char Check_P0(void) //returns 1 if switch attached to //P0 is closed, 0 if switch is open { if(P0 == 0) //check if pin P0 is low, meaning switch is on { delay_msec(50); //wait 50 msec to allow any //switch bounce to die out if(P0 == 0)return(1); //the switch is really closed } return(0); //the switch is open } /* end of Check_P0 function */
Listing 6-1 the switch being open and closed. The delay prevents the function from being called multiple times during a debounce period. The delay function in Listing 6-1 sits in a loop until the period specified has elapsed. Your compiler may have a delay function as part of its library functions. Otherwise you will have to write your own. You will also need to write your own or find one on line if you program in assembly language. The listing shows a delay of 50 milliseconds. The actual delay you need will depend on the switch you are using. This is usually done experimentally. The value of 50 milliseconds works well for many switches and is a good starting point.
If your delay period is too short you risk reading multiple switch closures from a single actual switch closure. If your period is too long, you risk missing multiple real short period switch closures. Also, with simple program delay functions, you are just in a loop counting milliseconds. Unless you have a multitasking application with an appropriate delay function, your program is not doing any other useful things during the delay period. Fifty milliseconds is a very long time to a modern microcontroller. This may or may not be important depending on your application. There is one other programming consideration. After it detects a switch closure, the program needs to verify the switch is then opened before assuming the value returned by the function is a new switch closure. Summary This section covered the basic methods of using a switch to indicate an external event. Switched inputs need a pull up or pull down resistor to hold the input to a specific value when the switch is open. The value of the resistor will have an effect on the power consumption of the circuit. Switches do not switch cleanly, and some debounce method must be used to prevent multiple false readings.
Arduino Tips
You can use the internal pull up resistor when connecting a switch to an Arduino pin. Connect the other switch pin to ground like SW-1 in Figure 6-1. You can enable the internal pull up resistor on an Arduino pin with the following instructions: pinMode(pin, INPUT); digitalWrite(pin, HIGH); // set pin to be an input // turn on pin's pull up resistor
Honeywell Distributor
Allied Has the Honeywell Parts You Need. Order Today!
AlliedElec.com/Honeywell
Avnet Express
Avnet Express-- We Have 5,000,000 Parts! Build Your Own BOM.
AvnetExpress.Avnet.com
Allied Has the Honeywell boards for sensor and Parts You Need. Order Today! automation modules AlliedElec.com/Honeywell
Gotcha Checklist 1. Use a pull up or pull down resistor to ensure the pin state when the switch is open 2. Account for switch debounce to prevent detecting multiple false switch closures (or opens).
Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 5 Microcontroller Interfacing Part 7 Back to Electronics Main Page Home Page
Home
Electronics
Tropical Fish
Garden
Ham Radio
Figure 7-1
Example: Driving a Relay Figure 7-2 shows a typical circuit where a transistor is used to drive a relay. A relay can be used to switch higher voltages and currents than the microcontroller can. It can also be used to switch AC signals. Looking through a catalog we select a 12V relay. The data sheet says the coil resistance is 360. What will the current through the coil be? Ohms Law says
I = V/R = 12/360 = .033A or 33ma. We cannot drive this relay with the microcontroller output pin directly for two reasons. First, the relay must use 12V and the micro runs at 5V. Connecting 12V to a microcontroller pin would probably destroy the chip. Fortunately we can run most transistors at higher voltage and isolate the microcontroller from it. Second, the relay requires 33ma of current, and the micro we are using is limited to 25ma. We must use a transistor to drive the relay. The first step is to select a transistor. The transistor must be able to handle the voltages and currents of the application. In this case just about any NPN switching transistor will do. The 2N2222 and is relations, the 2N2222A, PN2222, etc. are commonly used in these circuits. A quick review of the transistor data sheet shows:
Absolute Maximum Ratings Symbol Parameter Vceo Collector-Emitter voltage Ic Collector current Value 30V 600 ma
Circuit oscilloscope www.tek.com 8 Out of 10 Engineers Rely on Our Oscilloscopes. Come See Why Today.
Order Omron Parts AlliedElec.com/Omron Fast Shipping & a Wide Selection. Buy Online & Save Time!
Multisim Simulation www.ni.com/multisim Optimize circuit design performance with simulation. Learn how. Figure 7-2
Circuit oscilloscope www.tek.com 8 Out of 10 Engineers Rely on Our Oscilloscopes. Come See Why Today.
Our circuit uses 12V and will draw 33ma. Clearly this transistor will easily handle this. The next step is to ensure we drive the transistor into saturation. We will do this by selecting the proper value for
R1. As mentioned before, transistors are current amplifiers. The collector current will be the base current multiplied by the DC gain, hFE. One question is what is the hFE? The data sheet for a PN2222 shows the hFE as a minimum of 35 under one set of circumstances, and a minimum of 100 and a maximum of 300 under other circumstances. That is a huge range! What value should we use? The reality is that transistor parameters run all over the place. The simplest thing to do here is use the worst case value, or 35 in this case. Changing the transistor gain equation around and using the 33ma relay coil current and PN2222 hFE gives us Ib = Ic/hFE = 33/35 = .94 ma For simplicity we will round up Ib to 1ma. Actually we will probably want to double it. Tolerances in the value of R1, the transistor and microcontroller suggest we should be on the conservative side. Running Ib at 2 or 3 ma will not cause any damage and will give an extra margin to ensure the transistor is driven hard into saturation. One reason you might want to stay near the 1ma base current is if your application is battery operated and you want to conserve every microamp to increase battery life. In that case you would probably not be using a relay anyway, so we will use 2 ma as our base current for this example. The driving pin from the microcontroller will supply 5V. There will be a voltage drop between the base and emitter VBE(sat). The data sheet shows this as 2V maximum with much higher base and collector currents that we will be using. In our circuit it will probably be in the .7V to 1V range. For simplicity we will use 1V. Since the voltages across the circuit loop must be 0V we have the following:
VP0 = VR1 + VBE Solving for the voltage across R1, we get the following VR1 = VP0 VBE = 5V 1V = 4V So, R1 will drop 4V with a current of 2ma. Ohms Law says R = V/I = 4/.002 = 2000 We will use a 2K resistor for R1. There are two more components in Figure 7-2 we have not accounted for, D1 and R2. D1 is a diode to snub the current spike from the inductor coil. A lot of energy is stored in the magnetic field of the relay coil when it is energized. When we turn off the relay, that energy has to go somewhere. The collapsing magnetic field will generate a current spike. It sees a turned off transistor. This current, combined with a high transistor resistance will be translated into a high voltage across the transistor, possibly damaging it. The diode should be put across all inductive loads including relays, solenoids, motors, etc. The diode type is not too particular. Diodes from the 1N400X family (1N4001, 1N4002, 1N4004) are commonly used and inexpensive. Their current rating is 1A, and the 1N4001 has a breakdown voltage of 100V. The other members of the family have even higher voltage ratings. The remaining component is R2, and may not be needed in some applications. When power is first applied to the circuit, you might get some current glitch through the transistor, turning it and the relay on momentarily. This might not be tolerable. Putting R2 in will help prevent the transistor from turning on (no guarantees) by draining any charge out of the base of the transistor. 10K resistors are a typical value for this component. Lets take a closer look the voltages across the relay and transistor. We know we will have 12V from the supply, and Vcesat is going to be around 1 volt. We know that the voltage across the transistor plus the voltage across the relay must be 12V. That means that the voltage across the relay must be Vcc = Vrelay + Vcesat Vrelay = Vcc Vcesat = 12 .3 = 11.7V But our relay is a 12V relay! Is it going to work? Relays are very forgiving devices and will usually work at much lower voltages than the nominal voltage. The data sheet will usually have a specification like Must Close Voltage. For a 12V relay this will usually be in the 9-10V range. Keep in mind that the operating time will usually increase as the voltage drops below the nominal voltage.
It might seem to be a lot of work to calculate all this. After you work with these circuits for a while you will just know that the value of R1 in not very critical and anything from 1K to 3.3K will work fine in most cases.
In Part 4 we had an example of driving an LED directly by the microcontroller pin. In this example we will assume we want to drive a bright blue LED. The data sheet shows we want to run this at 50ma, and the forward voltage drop across this LED is 3.1V. Lets further assume that this is a portable device and we want to run it off a 9V battery. The circuit has a 5V regulator to run the micro, but we want to run the LED off the 9V. We will use a similar circuit to the relay driver above, but like the LED circuit in Part 4, we need a current limiting resistor R2. The circuit is shown in Figure 7-3. From our earlier example we learned that the value of R1 is not too critical, and just decide to use a 1.5K resistor. We want to control the current through the LED fairly closely so we need to consider a few things we ignored in the relay example. We will factor in the voltage drop (VCE) across the transistor switch for this application. The data sheet says VCE(sat) = 1V max. The conditions for this value are pretty high base and collector currents, which we are not using. VCE will probably be closer to .3V for us, and we will use that value. The LED circuit is driven by 9V. The voltage around the circuit loop must be 0, so we have Vbat = VR2 + VLED + VCE Rearranging this gives us VR2 = Vbat VLED VCE = 9 3.1 - .3 = 5.6V We now know that R2 will drop 5.6V and the current will be 50ma. Ohms Law says R = V/I = 5.6 /.05 = 112
Power Management
Courses from Besser Associates
www.besserassociates.com
Multisim Simulation
Optimize circuit design performance with simulation. Learn how.
www.ni.com/multisim
Power Management
Courses from Besser Associates
www.besserassociates.com
Flex Circuit / RigidOptimize circuit design Flex Boards performance with Manufacturing PCB simulation. Learn how. Services www.ni.com/multisim
www.cirexx.com
Dc to dc converter circuit
AC/DC Power Modules, Low Cost Great Delivery, Standard and Custom
www.cdiweb.com/minmax
The nearest common resistor value is 110 so that is what we will use. Note this circuit does not have a couple of components that are in the relay driving circuit. We dont need the D1 diode across the LED because the LED is not an inductive load. We also removed the resistor from the transistor base to ground. We decided in this application that a brief flash of light from the diode would not be a problem when the device is first turned on. Other considerations In both of the examples we had the transistor in a common emitter configuration, meaning the transistors emitter is grounded. The transistor is acting as a low side switch. Since the transistor is a switch, couldnt we also connect the NPN transistors collector to the power supply voltage, and put the load between the emitter and ground? After all, there are some cases we would like the load to be at ground potential. This will not work in most cases. The reason is that the load will generate negative feedback, causing the transistor to try to turn off. Suppose we tried that. As the port pin started to go high, current would flow through the base of the transistor, causing current to flow into the collector and out the emitter though the load. This current would cause a voltage to form on the load. As the voltage at the emitter rises, the current through the base would decrease, causing a reduction in current through the transistor. Essentially the transistor will not turn on properly in this configuration. If it is necessary to ground the load and use a transistor as a high side switch, a PNP transistor will be needed. This will be covered in a future segment. Summary When the load the microcontroller must control has voltage or current requirements that exceed the capability of the micros output pin, an NPN transistor can be used to switch the load. Be sure the transistor can handle the voltage and current requirements. Gain and other specifications of transistors have a very wide tolerance range. Fortunately it is easy to make the design tolerant of component variations.
Figure 7-3
Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 6 Gotcha Checklist 1. Ensure the transistor can handle the voltage and current required by the load. 2. Protect the transistor with a snubbing diode if the load is a relay, solenoid, motor or otherwise inductive. 3. With an NPN transistor use a common emitter circuit with the emitter grounded and the load on the collector. Microcontroller Interfacing Part 8 Back to Electronics Main Page Home Page
Home
Electronics
Tropical Fish
Garden
Ham Radio
Circuit oscilloscope www.tek.com 8 Out of 10 Engineers Rely on Our Oscilloscopes. Come See Why Today.
Phase Perfect www.PhasePerfect.com Digital Phase Converters Perfectly balanced 3phase power
Figure 8-1
Capacitor Switching www.bnj-usa.com Benedikt Jager Capacitor switching contactors B&J USA 919 553 5501
Circuit oscilloscope www.tek.com 8 Out of 10 Engineers Rely on Our Oscilloscopes. Come See Why Today.
Motors www.applied-motion.com Capacitor Switching www.bnj-usa.com Matched Jager & Drives switching contactors B&J Benedikt MotorsCapacitor from Stock Low Cost, Same Day Shipping USA 919 553 5501
Capacitor Switching www.bnj-usa.com 3 Power Distribution www.SpecPower.com Benedikt Jager Capacitor switching contactors B&J High Efficiency AC Solutions MIL STD Compliant USA 919 553 Custom Build 5501
The alternative is to use a PNP type transistor. Using PNP transistors is essentially the same as NPN transistors, except the polarities are reversed. Figure 8-2 shows a circuit using a PNP transistor as a high side switch. Notice that the emitter is connected to the positive voltage. The arrow in the emitter of a PNP transistor points in the opposite direction than in an NPN transistor. Base current flows from the emitter to the base, and collector current flows from the emitter. This is all backwards compared to an NPN transistor. The signal needed to control the PNP transistor is also reversed from NPN transistors. With the NPN transistor you set the port pin to the high state to turn on the transistor. With the PNP transistor you need to bring the port pin low to turn on the transistor.
The calculations for base current and the base resistor are identical to those outlined in Part 7 for NPN transistors except the polarities are reversed. One additional thing you need to be careful with PNP high side switches is the voltage used to drive the load. Normally it is best to use the same voltage to drive the load that is used to power the microcontroller. Consider the following. Suppose the load voltage is +12V and the microcontroller is running at 5 volts. Ignore R2. R2 would normally have a value high enough to have little effect and ignoring it makes the calculations that follow simpler. Assume that P0 is high, at 5V, and R1 is 1000 ohms. Base current would be calculated by Ib = (Vcc Vp0 Vbesat)/R1 =( 12 5 .7)/1000 = .0063A = 6.3ma Unless the transistor has exceptionally low gain, it will be turned on even though with P0 high it should be turned off. Worse yet, the microcontroller pin P0 will be seeing more than 5V, which greatly exceeds the usual limitation of the microcontroller supply voltage plus 0.3V. The microcontroller would likely be damaged in this situation. Part 12 discusses ways of driving a PNP transistor when the load must be driven with a higher voltage than the microcontroller.
Figure 8-2
The circuit in figure 8-2 contains two other components, D1 and R2. D1 is a snubbing diode and is needed if the load is inductive like a relay, solenoid or motor. The previous section discussed the use of diodes across inductive loads in more detail. R2 is used to keep the base pulled high if the microcontroller output pin is in the high impedance state, which it is after power up until the I/O pins are configured. This prevents the load from being powered until the microcontroller has active control of the transistor. R2 might not be needed in applications where the load being briefly turned on
will not cause problems, say in an LED indicator. This might not be tolerable in other applications, such as controlling a motor or other load where improper operation might cause damage or other harm. As a rule of thumb, R2 should be 10 times the value of R1. Summary When the load must be at ground potential, and the microcontroller cannot supply enough current, a PNP transistor can be used to switch the load from the Vcc side. The circuit analysis is almost identical to using an NPN transistor except that the polarities are all reversed. Be sure the transistor can handle the voltage and current requirements.
Microcontroller Interfacing Table of Contents Gotcha List 1. Dont use the single PNP circuit to switch voltages greater than the microcontroller supply voltage. 2. Ensure the transistor can handle the voltage and current required by the load. 3. Protect the transistor with a snubbing diode if the load is a relay, solenoid, motor or otherwise inductive. 4. You must set the port pin low to turn on the PNP transistor. With NPN transistors you set the port pin high. Microcontroller Interfacing Part 7 Microcontroller Interfacing Part 9 Back to Electronics Main Page Home
Capacitor Switching Benedikt Jager Capacitor switching contactors B&J USA 919 553 5501 3 Power Distribution High Efficiency AC Solutions MIL STD Compliant - Custom Build Analog mixed signal ASIC Your complex analog & mixed signal ASIC design specialists
www.bnj-usa.com
www.SpecPower.com www.LinearChip.com
Inrush Current Limiters Available Online App switching Free Samples USA 919 553 5501 Capacitor Switching Benedikt Jager CapacitorNotes and contactors B&Jwww.ametherm.com
www.bnj-usa.com
Capacitor Distribution High Efficiency Capacitor switching Compliant B&J USA 919 553 5501 www.bnj-usa.com 3 Power Switching Benedikt Jager AC Solutions MIL STDcontactors - Custom Build www.SpecPower.com 3 Power Distribution Your complex analog & mixed MIL STD Compliant - Custom Build www.SpecPower.com Analog mixed signal ASICHigh Efficiency AC Solutions signal ASIC design specialists www.LinearChip.com
Home
Electronics
Tropical Fish
Garden
Ham Radio
Capacitor Switching
Benedikt Jager Capacitor switching contactors B&J USA 919 553 5501
www.bnj-usa.com
3 Power Distribution
High Efficiency AC Solutions MIL STD Compliant - Custom Build
www.SpecPower.com
Transistor
Search Thousands of Catalogs for Transistor
Power fet
CDI Stocks SEDI RF Devices Microwave & Millimeterwave RF
www.cdiweb.com/sedi
Figure 9-1 The maximum voltage across the device Vds is 60V, so our 12V supply will not be an issue. We calculated 33ma of current so we are way under the 200ma limit. The power limit is 400 mW. Assuming a worst case of 5.3 ohm Rds we get the following Pd = I^2 * R = .033 * .033 * 5.3 = 5.7 mW The 2N7000 will be fine in this application. Note the use of diode D1. It is used to steer the current produced by the collapsing magnetic field caused when the FET is turned off. Without the diode voltages high enough to cause damage could be generate across the FET. Diodes are needed whenever an inductive load is used. So, why would we want to use a FET instead of a BJT? A 2N7000 FET costs more than say a PN2222 BJT. In this particular application, there is probably not a big reason to use FETs. There are some situations where a FET has one or more major advantages. Consider a design for a portable battery operated device. Battery life is a huge concern in our application so we want to reduce current consumption in every part of the circuit we can. Now, instead of switching a power hungry relay, we need to turn on a component that requires 9V (from our battery) but only a few ma of current. In this situation, we would probably drive the base of a bipolar transistor with a ma or more of current. This current will be an additional drain on the battery. With a FET, if the switching frequency is low, the current into the gate of the FET will be negligible. Using a FET in this situation would save power. High Power Switching The main situation where FETs are superior is in high current circuits. Suppose we want to switch a motor, electrical heater or other high current load. FETs are produced with very low Rds, the resistance between the drain and source. The lower the Rds, the more efficient the circuit will be. Suppose we are making a heater for some application. The heating element runs off of 24V and draws 8 amps when it is on. Let first look at using a bipolar transistor. A 2N3055 is a common high current transistor. 2N3055 Vce 60V (max) Ic 15A (max) Vce(sat) 3V (Ic = 10A, Ib = 3A) Our requirements for Vce (24V) and Ic (8A) are well below the limits for the 2N3055. So far, so good. Now look at Vce(sat). It is 3V. What happens when we run 8A through this? Pd = Vce(sat) * Ic = 3V * 8A = 24W Those 24 watts are a lot of wasted power. Not only that, but that power is converted to heat. We will need to use a large heat sink to safely remove that heat. Also look at the transistor base current as the conditions for the Vce(sat). It is 3A! Our poor micro can only source 25ma. We would need a circuit to boost the 25ma to 3A. That will add cost and complexity to the design. Lets take a look at using an IRF530 FET. The maximum voltage, Vdss , and maximum current , Id, are well under the operating conditions of our circuit. We selected a logic level type FET so we can directly drive it with our microprocessor. The switching voltage is 2V, well below the 5V the micro output line will supply. We will be driving the FET fairly hard, which is good, but still below the 16V maximum. What about the power that is dissipated across the FET? Pd = Id^2 * Rds = 8A * 8 A * .15 ohm = 9.6W The power dissipated across the FET is still fairly high, 9.6W, but is well under the 79W device limit, and much less than the 24W for the 2N3055 bipolar transistor. The
IRF530 Vdss 100V Id 17A Pd 79W Rds(on) .15 ohm (Vgs = 4V, Id=8A) Vgs(th) 2V Vgs 16V max
FET will still need heat sinking, but it will not be nearly as difficult as with the 2N3055. With a little bit of effort we could probably find a FET with a lower Rds, further reducing the power dropped across the FET.
PWM FET transistors are often used to control DC motors. What if we wanted to control the speed of the motor? We can control the speed of a DC motor by changing the voltage across it. One way to do that with a microcontroller is to use Pulse Width Modulation (PWM). Suppose we have a 12V motor. If we just apply the supply voltage to the motor. It sees 12 volts, and runs at full speed. Now suppose we turned the 12V on and off very fast. The time on and time off are the same. It is on 50% of the time and off 50% of the time. The signal is said to have a 50% duty cycle. The average voltage the motor would see is 50% of 12V or 6V. The motor runs slower at 6V. Suppose we change the duty cycle to 75%. The voltage is now on 75% of the time and off 25% of the time. The motor now sees an average of 75% of 12V, or 9V. It runs faster than at 6V, but slower than 12V. We can create any voltage we want between 0 and 12V by changing the duty cycle. Many microcontrollers have built in PWM peripherals. Once you set them up they will run at the prescribed frequency and duty cycle without any further attention. If your micro does not have a PWM you can do the same thing with either hardware or software timers controlling the output. PWM circuits usually run at a few 10s of KHz. This can bring up a situation that if not accounted for can result in the destruction of the FET. Remember earlier we said that the gate looks like a capacitor to the micros output line. This capacitor has to be charged or discharged each time the drive signal toggles. While the capacitor is charging or discharging, the FET will not be either On or Off. It will be in its linear range and the Rds will be between Rds(on) and Rds(off). Current flowing through the FET will cause high power dissipation. In our examples above we didnt turn the load on and off very fast, so the FET has time to dissipate the extra heat between transitions and can be generally ignored. If the FET is changing states 20,000 times a second (10 KHz PWM rate), it will be spending a larger percentage of its time in this linear range. It is possible that the power dissipated by the FET in these conditions will exceed the maximums, and destroy the FET. The amount of gate capacitance is really the gate charge and will be shown in the data sheet. Higher power FETs have larger dies, and thus will have a larger gate charge. In such situations it is necessary to drive the gate will enough voltage and current to charge (discharge) the gate fast enough that the time spent in the FETs linear region is very short. This is frequently done with special FET driver circuits or ICs. Calculations and circuit board layout techniques for high speed PWM are beyond the scope of this tutorial. FET manufacturers have application notes that go into this subject in greater detail.
Summary FETs are an alternative to bipolar transistors for switching loads beyond the range of the microcontroller to directly control. FETs are generally superior in applications where high currents are required and in some low power situations. FET circuits require some special considerations, especially at higher switching speeds.
Capacitor Switching
Benedikt Jager Capacitor switching contactors B&J USA 919 553 5501
www.bnj-usa.com
Power Management
Gotcha List 1. Ensure the FET can handle the voltage and current required by the load. 2. Consider logic level switching FETs to simplify interfacing to microcontrollers. 3. Protect the transistor with a snubbing diode if the load is a relay, solenoid, motor or otherwise inductive. 4. High power PWM applications must consider drive requirements to overcome gate charge.
Power SwitchesLimiters Inrush Current & Relays
www.DowKey.com
Order Power Switches & Relays Now. Search Available Online App Notes and Free Samples and Save www.ametherm.com
Benediktfrom Besser Associates Courses Jager Capacitor switching contactors B&J USA 919 553 5501 www.besserassociates.com
Fast Shipping Besser Associates Buy Online & Courses from & a Wide Selection. Save Time! www.besserassociates.com
Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 8 Microcontroller Interfacing Part 10 Back to Electronics Main Page Home Page
Home
Electronics
Tropical Fish
Garden
Ham Radio
Capacitor Switching
Benedikt Jager Capacitor switching contactors B&J USA 919 553 5501
www.bnj-usa.com
Figure 10-1 Assume that the input voltage Vin and voltage across the capacitor Vc is zero volts. At some point Vin jumps to the value V. At that instant Vc is still zero volts. Over time the capacitor will start to charge and if Vin stays at V long enough, Vc will approach V. The rate Vc approaches V depends on the time constant (TC).
TC =R*C
Where R is resistance of R in ohms, and C is capacitance of C in Farads. TC is measured in seconds. The voltage at time t can be calculated with the following equation:
Multisim Simulation
Optimize circuit design performance with simulation. Learn how.
www.ni.com/multisim
Vc=V(1-e^(-t/RC))
At a period of 1 TC Vc will reach about 63% of V. At 2 TC the voltage will reach 63% of the remaining difference between Vc and V, or about 86% of V, and so on. At 4 * TC Vc will be within 99% of V. Technically Vc will never reach V, but the difference will be infinitesimal. At some point Vin returns to zero volts, and the capacitor will
discharge at the same rate it charged. Now consider the situation where Vin is at voltage V for a short period of time. The capacitor will not have time to charge very much, and Vc will not be able to approach V. If the length of Vin being high is short compared to TC, Vc may not get high enough to reach the threshold voltage of the microcontroller input. The microcontroller will never recognize the input signal went high. Lets get back to our static electricity problem. A static electricity burst is usually a very short pulse. The RC circuit will limit how high the voltage will get. A resistor of a couple of hundred ohms and a capacitor of .01 or .1 microfarads will give reasonable protection to the input.
Figure 10-2
An RC circuit is also known as a low pass filter. If the period of a signal is long (low frequency) compared to TC, the signal will pass through reasonably intact. If the period is short with respect to TC it will be filtered out. The low pass filter can be used for other purposes. Part 6 mentioned switch bounce. This is where a mechanical switch will often make and break contact when it is actuated. Proper values of RC can filter out these spikes. RC filters are also used for filtering out high frequencies for A/D (Analog to Digital) converters. Their use in those applications will be covered in a future installment. The nature of the signal inputs must be kept in mind when using RC filtering. Suppose we have a sensor that indicates one revolution of a motor. If the motor is running fast enough, or if the values of R and C are too high, the inputs will be filtered out. The voltage at the pin will never reach the switching threshold and the micro will think the motor is not running. Looking at the situation from the analog world, an RC circuit has a frequency at which point of the input voltage is lost. This is also known as the 3dB point. This is known as the cut off frequency, or Fc.
Fc = 1/(2RC)
The frequency of a signal going through an RC filter must be much less than Fc for proper operation. Another characteristic of an RC filter might be important in some applications. Take a look at Figure 10-2. Suppose that our application requires the microcontroller to perform some operation very quickly when Vin rises to V. Further assume that the threshold voltage for determining the input registering as a 1 or a 0 is at V. It takes nearly 1 full TC for Vc to reach that voltage. This might be too late for the microcontroller to complete its operation in time. Some microcontroller inputs depend on the input signal rising quickly. Reset pins and edge triggered interrupt lines may not work properly if an RC circuit slows the rate the signal changes. Consult the microcontroller data sheet before putting RC networks on these types of microcontroller inputs. Zener Diode Protection Figure 10-3 shows an input protected with a zener diode. A zener diode acts like a regular diode with one exception. If the reverse voltage reaches a certain point, the diode will start to conduct. In combination with R to limit the current and drop the excess voltage, the voltage seen by the input will never exceed the zener voltage, Vz. This of course assumes the input signal does not exceed the ratings of the zener diode or resistor.
http://www.w9xt.com/page_microdesign_pt10_input_protection.html[27/06/2011 1:36:46 PM]
Select a zener diode with a Vz that is higher than the Vcc powering the microcontroller, but less than the voltage that will cause damage. For 5V systems, 5.1V zeners such as the 1N5231 and the 1N4733 are commonly used. Transient Suppressor Protection Special electronic components specifically designed for ESD protection are available. The go by the name of TVS, MOV, and a large number of trade names. They are easy to use, and have many advantages over the zener protection including faster response times and higher energy capacity. Some are also available as arrays, handling a number of signal lines in a single package. Figure 10-4 shows a microcontroller input protected by one of these devices. The schematic symbol may vary depending on the technology of the device. In normal operation these look like a capacitor. If the applied voltage reaches the Varistor Voltage, the varistor acts like a switch shorting the signal to ground. Most types are bidirectional, meaning they will switch on if the varistor voltage is reached regardless of polarity. The first data sheet parameter to look for is the Maximum Allowable Voltage. This must be higher than the normal operating signal voltages. Otherwise, the normal signal will trip it, possibly preventing the signal from reaching the threshold voltage. Another key specification is the capacitance. You will want to use low capacitance suppressors for high frequency signals. Otherwise, the signal will get filtered out as in the RC filter described earlier. Another specification is the maximum surge current. The higher this is, the more abuse the circuit can take, but often at a higher cost, size and capacitance. Figure 10-3
Figure 10-4
Since transient suppressors look like capacitors during normal operation, you need to consider the same frequency related considerations as if you had used a regular RC filter. The resistor is optional. Use one between 10 and a few hundred ohms for things like user switches. Leave the resistor off and use low capacitance types for high frequency signals. Summary It is a dangerous world out there. For tough environments or equipment with high reliability requirements, input protection is called for. RC filters, zeners and transient protectors are some of the methods that can be used to protect your sensitive microcontroller circuit.
Gotcha List 1. Be sure the cut off frequency of the RC network is higher than the desired signal. 2. Protection devices can affect the accuracy and maximum conversion rates of A/D inputs. 3. Check the microcontroller data sheet before putting RC networks on reset or edge triggered interrupt inputs. 4. RC networks add a delay. This will affect how fast your microcontroller can react to an input change. 5. Select zener voltages and varistor voltages above the normal operating voltages of your system.
Circuit oscilloscope www.tek.com 8 Out of 10 Engineers Rely on Our Oscilloscopes. Come See Why Today. Miraco FPC Options MiracoInc.com Flexible Printed Circuits and Other Interconnect Solutions Options. Analog Mixed Signal www.besserassociates.com Courses from Besser Associates Capacitor Switching www.bnj-usa.com Benedikt Jager Capacitor switching contactors B&J USA 919 553 5501
EMC Mid-Tier VNX Storage www.emc.com/VNX-Data-Prote Simple, Efficient Storage by EMC Starting Under $10K. Free VNX Demo. Flexible Printed Circuits MiracoInc.com Analog Mixed Signal www.besserassociates.com Flexible Printed Circuit & Other Interconnect Courses from Besser Associates Solutions Experts Printed Circuit Boards www.cirexx.com Analog Mixed Signal www.besserassociates.com Flex Circuit / Rigid-Flex Boards Manufacturing PCB Courses from Besser Associates Services Capacitor Switching www.bnj-usa.com Benedikt Jager Capacitor switching contactors B&J USA 919 553 5501
Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 9 Microcontroller Interfacing Part 11 Back to Electronics Main Page Home Page
Home
Electronics
Tropical Fish
Garden
Ham Radio
Figure 11-1 being. In most cases this can be eliminated from the circuit. The first step is to determine the value for R1, the LED current limiting resistor. The spec sheet for the 4N32 says the maximum continuous forward current for the LED is 80ma. We dont want to exceed that. Many of the parameters on the spec sheet say the test case is 10ma. That is a good value to us if our application will allow that much current from the signal source. From Part 4 we learned the current limiting resistor can be calculated if we specify the current and know the forward drop. For the 4N32 the typical forward drop is 1.2V. Thus R = (Vin-Vf)/If = (12-1.2)/.01 = 1080 ohms. You wont find a 1080 ohm resistor even if you specify 1% resistors. The actual value is not critical so you can use a 1.0 or 1.2K resistor. The next step is to determine the value of R2, the transistor collector load resistor. The value for this is not very critical either. A 10K resistor works well in most cases. Assume the microcontroller is powered by 5V. The 4N32 data sheet shows Vce-sat is 1V. The current through the opto with a 10K resistor will be I = (Vcc-Vce)/R = (5-1)/10,000 = .4ma This is well below the maximum opto collector current of 150ma. Lets do a quick sanity check. Lets say we picked the 1.2K resistor. The LED current will be If = (Vin-Vf)/R = (12-1.2)/1200 = .009 = 9ma. Couplers Opto.Toshiba.com KNICK Signal Isolators coupler TLP2066 - 3.3V TLP117 - 5V 50Mbps IC www.knick-usa.com Signal Conditioners, Analog Digital Current, Voltage, 20Mbps IC coupler Temp, Strain, Res Special Summer Offer www.cuflex.com Flexible Circuit Prototypes $900.00 limited time only. Made in USA. Analog Mixed Signal www.besserassociates.com CoursesAvnetBesser Associates Search from Express AvnetExpress.Avnet.com 5 Million Parts, Expert Service & Same Day Shipping! Order Online. Miraco FPC Options MiracoInc.com Analog mixed signal ASIC www.LinearChip.com Flexible Printed Circuits and Other Interconnect Your complex analog & mixed signal ASIC design Solutions Options. specialists Flexible Printed Circuits MiracoInc.com Flexible Printed Circuit & Other Interconnect Solutions Experts
KNICK Signal Isolators www.knick-usa.com Signal Conditioners, Analog Digital Current, Voltage, Temp, Strain, Res
Ground Loop Isolators www.adtech-inst.com Signal Conditioners and Temperature Transmitters Custom Designs
Multiply the 9ma by the transfer ratio of 500%, and we get the collector current of 45ma. This is well above the saturation current of .4ma (limited by the 10K R2). We will be driving the output well into saturation, which is what we want.
Input Example Variations Lets say our source signal cant drive the LED with that much current. Select the value for R1 to allow the current it can drive. Multiply that by the transfer ratio to find what the theoretical collector current will be. If this current is several times the saturation current (.4ma in the example above) you will be OK. You have a couple of options if the LED current multiplied by the transfer ratio is too low. You might be able to use a larger value for R2. This will reduce the saturation current. You might also want to increase the value of R2 if your microcontroller circuit needs to run on very low power. In the example above, .4ma is not a lot of current, but in a battery powered device, every micro amp adds up. Why not just make R2 very large to start with? Why not make it 1M ohm or more right from the start? The problem is that it will take very little current to drive the output to saturation. Small noise spikes can give false responses. You can also get situations where leakage currents on the circuit board can cause the circuit to fail. The oils from solder flux, finger prints or other sources can collect dirt over time and allow minute current flows that will cause problems. There is another spec on the data sheet called dark current. This is the collector current that will flow even if there is no light from the LED. Typically these are measured in nano-amps, but there can be an appreciable drop across the load resistor if it has a very high resistance value.
If you must run your circuit near the edge with a high value opto collector load, you might need to put in resistor from the opto pin from the transistor base to ground. The base pin is not connected in Figure 11-1. This resistor will help to keep the transistor or Darlington pair turned off when no signal is present. The value for this situation might need to be determined by trial and error. Typical values will range from 100K to several meg-ohms depending on your circuit. Besides providing excellent isolation from the outside world, the reader might have noticed that the opto also acted as a voltage level translator. It converted the 12V input signal to the Vcc level used by the microcontroller. This is convenient, but one has to consider the Vce-sat , the voltage across the collector and emitter of the output when the output is turned completely on. This is especially true if the microcontroller is using a Vcc less than 5V. The Fairchild 4N32 lists the Vce-sat at 1.0V (maximum). This means that when the LED is driven and the output is turned on to saturation, 1V could be present at the microcontrollers input, not the zero volts we normally expect for a logical 0. If you were using one of the low voltage micros with Vcc at 1.8V or less, the circuit would never register a logical zero. If you find yourself in this situation consider using an opto with a single transistor output instead of a Darlington. It will have a lower Vce-sat. Another option would be to use an opto with an FET output. These look like a very low value resistor when turned on, and can get logical 0 voltages very close to ground. FET output optos are often called solid state relays and tend to be more expensive than optoisolators with bipolar transistor outputs. When writing code for your application keep in mind that there is a phase inversion of the input signal. The condition that causes voltage to be applied at the optos LED input will cause the micros input to read as zero, and vice versa. Example: AC inputs Lets say your application needs to sense AC line voltage. Your application might need to know right away if the AC power is lost so it can store some critical values or put something into a safe state. A simple way to do that is to connect a low voltage UL rated wall transformer to the opto LED. For this example assume that we picked a 12V AC wall transformer. It is important we used an AC version instead of the more common DC wall wart because we want to see each cycle of the AC. Because it is 12V, we could start with the resistor values we used in the DC example above, but there are a couple of other considerations because it is AC. First of all, AC transformers will vary in the output voltage. With a lightly loaded circuit like this, they will tend to exceed the nominal rating. They will read even higher if your line voltage is on the high side. You might want to start by assuming your wall wart is going to put out 15V to start.
The 12 volt rating is based on its RMS value. The peak value will be 1.4 times the RMS value. If we assume that our 12V transformer is really going to be 15V, the peak voltage will be 15 times 1.4, or 21volts peak-peak. You could specify the limiting resistor for 21 volts but you will probably get conditions where the voltage doesnt get that high and the circuit wont work. Quite a dilemma!
A practical solution is to design for the nominal voltage and verify that the peak wont cause damage. If we used 1.2K for R1 in Figure 11-1, we would know it would work fine at 12VAC. If we assume a peak of 21V, the LED current at the peak would be I = (Vin-Vf)/R = (21-1.2)/1200 = .0165 = 16.5ma The 16.5 ma is well below the 80ma maximum current specified for the 4N32, so we are safe. If one is especially paranoid the value for R1 could be increased to 1.5 or 2K.
Figure 11-2
Figure 11-2 shows the wave forms for the AC input and the output of the opto. The blue line represents the AC signal applied to Vin in Figure 11-1. The red signal is the output of the 4N32 optoisolator and what the microcontroller input pin PO sees. The first thing to notice is the output is low only during the positive half cycle of the input. We will get one low pulse every 1/60 of a second in the US and 1/50 of a second in many other places of the world. Another thing to notice is that near the zero crossing we dont get the low output. This is because the LED needs about 1.2 volts to turn on and then provide enough LED current to produce enough light to turn on the transistor. This is OK if we are just detecting the presence of line power, but must be accounted for if we want to synchronize with the line voltage phase. Take a look at what happens during the negative half of the AC cycle. With the conditions described above, we could have 21V reverse biasing the LED. The spec sheet says the reverse voltage must not exceed 3V. Putting this much reverse voltage will change the Light Emitting Diode (LED) into a Darkness Emitting Arsenide Diode (DEAD). A simple solution to this problem is to install D1. It will conduct current during the negative half cycle and limit the reverse voltage across the LED to about .7 volts. Diodes like the 1N400n series work well for this. Speed consideration By electronic standards, optoisolators tend to be rather slow. Generally they turn on reasonably fast, but turn off somewhat slowly. The 4N32 can take 5 usec to turn on and 100 usec to turn off under some conditions. This might be fine for your application but it might be an issue for high frequency signals or for high speed data communications. The slow turn off is due to internal capacitance inside the output transistors. Using a low value load resistor will discharge this capacitance faster but at higher current consumption. There are some optos designed for high speed applications. Using one might be the preferred solution. Summary An optoisolator can protect microcontroller circuits since there is no physical connection between the microcontroller and the outside world. The only connection is a beam of light. Besides providing isolation, optoisolators provide a convenient way to interface higher voltages and AC to microcontroller inputs.
Gotcha List 1. Ensure that the input has enough voltage to overcome the drop of the LED. 2. Dont exceed the maximum LED current 3. Be sure the Vce-sat of the output transistor is below logic zero voltage levels 4. Protect the LED from reverse over voltage if you are feeding it with AC.
Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 10 Microcontroller Interfacing Part 12 Back to Electronics Main Page Home
CellMite Model 4325B Digital Signal Conditioner with TEDS-Tag Auto Identification
www.electrostandards.com/ www.ni.com/multisim
Multisim Simulation Optimize circuit design performance with simulation. Learn how. Power Management Courses from Besser Associates
www.besserassociates.com
Couplers TLP117 - 5V Flex Circuit / Rigid-Flex Boards Manufacturing coupler Opto.Toshiba.com Printed Circuit Boards50Mbps IC coupler TLP2066 - 3.3V 20Mbps IC PCB Services www.cirexx.com Printed Circuit Boards Flex Circuit / Rigid-Flex Boards Manufacturing PCB Ok - No Tooling www.PCBnet.com PCB - Introductory Offer 2 Layers $25ea - 4 Layers $50ea Even 1 piece isServices www.cirexx.com Analog mixed PCB Partner Easy PCB Solution - Design-Printed Circuit Board Fabrication-Assembly www.electrocircuit.com Discover Your signal ASIC Your complex analog & mixed signal ASIC design specialists www.LinearChip.com
Home
Electronics
Tropical Fish
Garden
Ham Radio
Figure 12-1
Vceo is -100V. That is well above the 12V that drives the load. It can handle 3A of collector current which is well above the load current, so it looks like a good candidate. The next step is to determine what it will take to drive a TIP32. The minimum HFE, or gain of a TIC32C is 10 with a collector current (Ic) of 3A is 10. We wont be switching nearly that much current and the HFE will be higher under those conditions, but we want our designs to be reliable and reproducible, so we use the conservative value of 10. The collector current of a transistor is the base current multiplied by the gain. Ic = Ib * HFE Rearranging the equation gives us Ib = Ic/HFE = .5A/ 10 = .05A, or 50ma This means that transistor Q1 must sink at least 50ma. Another important parameter for Q1 is to be able to handle the load supply voltage, V+ on Figure 12-1. Another search of the parts bin produces a 2N2222A transistor. Its specs are in Table 1. From our calculations above, Ib2 is 50ma minimum. Ib2 is also the collector current of Q1 if you ignore current supplied by R3, which we will do for now. We need to select a value for R2 that will allow 50ma to flow from V+ through the emitter-base junction of Q2 through R2 and into the collector of Q1. Thus Ib2 is the same as Ic1.Ohms law tells us the value of R2 is R2 = Vr2/Ir2 We know that the current through R2, Ir2, is 50 ma. What is the voltage across R2? That will be V+ (12V) minus the base emitter voltage, Vbe(sat), of Q2 and the Vce(sat) of Q1. From Table 1 Vr2 = V - Vbe2 - Vce1 = 12 -1.8 - .3 = 9.9 V Knowing the voltage across R2 and the desired current Ohms Law says: R2 = V/I = 9.9/.05 = 198 ohms
TIP32C Key Specs Vceo Ic Vce(sat) Vbe(sat) HFE (I c =3 A) -100V -3A -1.2V -1.8V 10
Table 1
Since 198 ohms is not a standard resistor value we will use a 220 ohm resistor. I might consider using a the next standard value resistor less than 198 ohms to increase the current and improve the margins. The problem here is that 50ma is quite a bit of current for a resistor. Consider this
http://www.w9xt.com/page_microdesign_pt12_hv_pnp_switching.html[27/06/2011 1:37:19 PM]
P = I*I*R = .050 * .050 * 198 = .495W We will need at least a 1/2W resistor. If we use a lower value resistor the current will increase slightly, but since power is related to the square of the current, the power dissipated will go up fast. So what do we do? So far we have been conservative in our estimates and used a worst case value for HFE, the gain of the transistor. Chances are the gain will be much higher than 50 so we could get by with less base current, maybe quite a bit less. If I were just making one or two copies of this circuit, and these were the only PNP power transistors I had on hand, I would try a larger value for R2, maybe approaching 1K. I could tweak the circuit until it worked properly and did not burn up resistors. If I were designing a circuit for mass production this would be a bad idea. Sooner or later a batch of boards would be produced where the components had a mix of parameters that did not work. Or worse yet, they would test OK in the factory but fail in the field. In a production design, a better option would be finding a PNP power transistor with a higher gain so less base current would be required. One option might be a Darlington transistor. Darlington pairs are two transistors in an array so the gain of the two transistors are multiplied together to give the gain of the device. One possible part is a TIP117 which has a minimum gain of 500. A TIP117 would only need 1ma, or 1/50th the base current of the TIP32 we started with. Rather than start all over in the calculations, we will continue the design with the TIP32C. The next step is to calculate the value for R1. R1 will limit the base current through Q1. Since Q1 is acting as a switch to turn on Q2, we need to drive Q1 into saturation. We know the base current multiplied by the gain will be the collector current. Switching that equation around and plugging in the parameters for Q1, a 2N2222 we had in our parts box we get Ib1 = Ic1/HFE = .050/50 = .001A We have the current through R1. Now we need the voltage across it. As explained in Part 2, the voltage across the loop must be zero. Since the micro is running off 5V, the voltage at P0 when it is set high will also be near 5V. Other than the resistor R1, the only other circuit element in the loop is Q1s base-emitter junction. The data sheet says this value, Vbe(sat) = 1.2V. So:
Multisim Simulation
Optimize circuit design performance with simulation. Learn how.
www.ni.com/multisim
Manufacturer of DIN low to medium and Panel mount solid volume flex circuits state relay quick turn & flex assemblies. circuit assembly anaconpower.com
www.allflexinc.com
High Efficiency AC the Rick Lyons Course Solutions MIL STD only from Besser Compliant - Custom Associates Build www.besserassociates.com
www.SpecPower.com
Analog mixed Flex Circuit Boards signal ASIC All in One PCB
Your complex analog Solution Services PCB & mixed signal ASIC / Design / Fabrication
http://www.w9xt.com/page_microdesign_pt12_hv_pnp_switching.html[27/06/2011 1:37:19 PM]
Digital Signal Flex Circuits Design to Conditioner with Assembly Thinking TEDS-Tag Auto Flex Think Lenthor Identification www.Lenthor.com
www.electrostandards.com/
Vr1 = Vp0 Vbe = 5 1.2 = 3.8V. By Ohms law R = V/I = 3.8/.001 = 3800 or 3.8K ohms. These values will give 1ma of base current though Q1. That is probably enough, but we can increase it quite a bit and give more margin for out of spec parts and other real world issues by using a lower value resistor. Lets pick a 2.2K resistor. Plugging that in, Ib1 = V/R =3.8/2200 = .0017A This would give us a collector current of Ib * HFE = .0017 X 50 = .086A This is more than the .050A required to drive Q2 into saturation. Just to be sure this value will not cause problems we see that the maximum base current for a TIP32C, Ibmax is 3A, and Ic for Q1 is .6A. This is not even close to the limits of our transistors. We now only need to figure the values of a few more components. The first is R3. When we want the load turned off, the base off Q2 must be at a voltage near or higher than its emitter. R3 will supply that voltage. The only thing we need to be concerned with is if the value is too low, and Q1 is turned on, current will flow through R3 and through R2 and Q1. If the value of R3 is too low, there will be more current through R2, which will raise the voltage of the base of Q2. This could prevent Q2 from fully turning on.
A good rule of thumb would be to make R3 at least 10 times the value of R2. This will not increase the current through Q1 and R2 much. We already checked to see that we are not near the maximum collector current for Q1, so a bit more wont harm anything. The final resistor is R4. When the system is turned on, there might be a some transient currents though P0 which could turn on Q1 and ultimately the load. If the load is a motor or other device that could cause damage if the load is turned on until the micro is in full control, R4 would help prevent (but not guarantee) Q1 from being turned on. If the load is an LED or other device where a brief flash would not cause problems, R4 can be left off. A rule of thumb of around 10X the value of R1 will be a good starting point for this resistor. Finally, there is D1. As explained in earlier sections, we want to put the diode in the circuit if the load is inductive to protect the switching transistors. Motors, solenoids, and relays are all inductive loads. If the load is purely resistive, D1 can be skipped. Summary Sometimes the design requirements require more than a single transistor when the load requires more voltage and/or current than the micro is capable of handling. Using an NPN transistor to drive a PNP transistor will allow driving a grounded load with higher voltages and currents.
http://www.w9xt.com/page_microdesign_pt12_hv_pnp_switching.html[27/06/2011 1:37:19 PM]
Gotcha List 1. Be sure both transistors can handle the voltage supplying the load. 2. Ensure the PNP transistor can handle the current required by the load. 3. Pick a PNP transistor with good gain to minimize base current requirements and excessive power consumption. 4. Protect the transistor with a snubbing diode if the load is a relay, solenoid, motor or otherwise inductive. Microcontroller Interfacing Table of Contents Microcontroller Interfacing Part 11 Back to Electronics Main Page Home
Rotary Position Sensor SENSOFOIL: Ultra-flat membrane potentiometer, standard & custom Ground Loop Isolators Signal Conditioners and Temperature Transmitters Custom Designs CellMite Model 4325B Digital Signal Conditioner with TEDS-Tag Auto Identification
www.sensofoil.com
www.adtech-inst.com
www.electrostandards.com/
KNICK Signal Isolators Signal Conditioners, Analog PMT Current, Voltage, Temp, Strain, Res www.knick-usa.com High Voltage Power Precision high voltage power forDigital and analytical instruments www.kilovoltech.com Power Switches & Relays 5 Million Parts Online. & Relays Now. Search and Express! AvnetExpress.Avnet.com Avnet Express Search Order Power Switches Order Parts Online @ AvnetSave www.DowKey.com Ground Free Isolators Signal Conditioners and Temperature Supplier ISO 9001 www.prelogtech.com Try Our Loop Parts Search Quality Parts since 1993 Stocking Transmitters Custom Designs www.adtech-inst.com