Difference between revisions of "Driving Large Loads with the Arduino"

From OpenCircuits
Jump to navigation Jump to search
(Created page with '= Driving Large Loads with the Arduino = '''This is a draft it still has a ways to go''' ( and with other micro controllers, the PIC ….. ) == What are Large Loads == The …')
 
(link to related articles, etc.)
 
(13 intermediate revisions by 3 users not shown)
Line 8: Line 8:
  
  
The Arduino has a bunch of output pins that can do things like light led's and provide signals to servo motors, but try connecting it to a hi fi loud speaker and not much happens ( although you may damage the Arduino forever ).  For out purpose a large load is almost any load ( what you connect the output to ) that is too much for the Arduino.  These methods for large loads fall into several different classes with some common features.
+
The Arduino has a bunch of output pins that can do things like light led's and provide signals to servo motors, but try connecting it to a hi fi loud speaker and not much happens ( although you may damage the Arduino forever ).  For our purpose a large load is almost any load ( what you connect the output to ) that is too much for the Arduino.  These methods for large loads fall into several different classes with some common features.
  
 
== Ideas for Driving the Loads ==
 
== Ideas for Driving the Loads ==
Line 14: Line 14:
 
In some sense anything that can be used to drive a large load is an amplifier, a device with a output bigger than its input.  If you want loud sounds from a Arduino you can use some computer's amplified speakers, or a hi fi.  There are some cautions, but it is pretty basic, for most audio amplifiers the arduino outputs are close to what these audio amplifiers expect as inputs.  
 
In some sense anything that can be used to drive a large load is an amplifier, a device with a output bigger than its input.  If you want loud sounds from a Arduino you can use some computer's amplified speakers, or a hi fi.  There are some cautions, but it is pretty basic, for most audio amplifiers the arduino outputs are close to what these audio amplifiers expect as inputs.  
  
In many cases a simpler amplifier will do, many of these fall in the category of a low side switch ( http://www.opencircuits.com/Basic_Circuits_and_Circuit_Building_Blocks#Transistor_Low_Side_Switch |Transistor Low Side Switch ]] ).  Here is a schematic of one using a push button ( not useful for the arduino, because the arduino cannot press the switch ):
+
In many cases a simpler amplifier will do, many of these fall in the category of a low side switch ( [[http://www.opencircuits.com/Basic_Circuits_and_Circuit_Building_Blocks#Transistor_Low_Side_Switch |Transistor Low Side Switch ]] ).  Here is a schematic of one using a push button ( not useful for the arduino, because the arduino cannot press the switch ):
  
schematic here
+
<schematic here>
  
 
To be useful to the Arduino you need to replace the push button with something the Arduino can push:
 
To be useful to the Arduino you need to replace the push button with something the Arduino can push:
  
*Relay  
+
*Relay  
*Transistor ( bipolar, but not too depressed )
+
*Transistor ( bipolar, but not too depressed )
*Transistor ( fet, field effect )
+
*Transistor ( fet, field effect )
*Triac
+
*Triac
*Driver ICs
+
*Driver ICs
  
 
== Relay  ==
 
== Relay  ==
Line 44: Line 44:
 
== Transistor Low Side Switch ==
 
== Transistor Low Side Switch ==
  
The following is for the old time standard bipolar transistor.  This type of transistor is basically a current amplifier, it takes an input current and produces a larger output current, this output current is largely independent of the supply voltage so the transistor can switch large voltages as well ( not too difficult up to 100 volts ).  The amplification of current can be a factor between say 10 to 1000 ( the later for so called darling ton transistors ).  Here is the same circuit we have looked at for the relay, we are considering the relay as the large load. 
+
We have discussion of low side switch on other pages of this site:
  
( [[http://www.opencircuits.com/Basic_Circuits_and_Circuit_Building_Blocks#Relay_with_Diode_Snubber ]])
+
*[[Basic_Circuits_and_Circuit_Building_Blocks#Transistor_Low_Side_Switch]]
 
 
Some characteristics:
 
 
 
Useful ( with simple circuits and common components ) for currents from a max of a few amps and voltages of 10's of volts.
 
Can be very fast, into the Mega Hz.
 
Can be very cheap at the low end.
 
Small, simple.
 
Some integrated circuit drivers like the  are basically multiple transistor low side switches.
 
  
 +
*[[Basic_Circuits_and_Circuit_Building_Blocks#Relay_with_Diode_Snubber Relay with Diode Snubber]]
  
 
== Transistor ( fet, field effect transistors ) ==
 
== Transistor ( fet, field effect transistors ) ==
Line 68: Line 61:
  
 
any help here?
 
any help here?
 +
 +
=== DC motor driver ===
 +
 +
Relays and small DC motors are often driven with a circuit like this:
 +
 +
 +
<pre>
 +
                            +Vhigh
 +
                    D1    |
 +
                +---|>|-----+
 +
                |          |
 +
                +--(motor)--+
 +
  Arduino      |
 +
    GPIO-+-R2-|[nFET Q1
 +
          |    |
 +
          R1    |
 +
          |    |
 +
        GND---GND
 +
 +
      Low-side driver with logic-level nFET
 +
 +
</pre>
 +
 +
''(FIXME: show corresponding pFET circuit?)''
 +
 +
R1 is typically in the range of 10 KOhm to 1 MOhm.
 +
R1 is a "pull-down" resistor that turns the nFET off and holds it off
 +
when that Arduino GPIO pin is tri-stated -- such as while you are pushing the Arduino reset button,
 +
or if your program accidentally makes that Arduino pin an "input" pin.
 +
 +
(While most people seem to attach R1 to the "Arduino" end of R2,
 +
other people attach R1 to the "FET" end of R2.
 +
It doesn't make any difference).
 +
 +
D1 is often a Schottky diode, perhaps a 1N582x (3 ampere), to handle PWM.
 +
D1 is often a rectifier diode, perhaps a 1N5400 series (3 ampere) diode, when the designer expects the Arduino to switch only "occasionally" -- less than 100 times a second.
 +
D1 is a flyback diode.
 +
[http://en.wikipedia.org/wiki/flyback_diode Wikipedia: flyback diode]
 +
 +
Q1 is some logic-level FET.
 +
There are hundreds of such FETs available, such as
 +
the PSMN041-80YL in a Power-SO8.
 +
the BUK9515-60E in a TO-220-3
 +
 +
R2 is often 100 Ohms.
 +
R2 is the "series gate resistor", aka "Rgate".
 +
Some people take the approach of picking a resistor to guarantee that the Arduino will stay within its maximum current limit (40 mA) at every instant.
 +
Since the gate of the FET acts like a small capacitor,
 +
these people pick R = V/I = 5V/40mA = 125 Ohm for a 5 V Arduino,
 +
minus the roughly 25 Ohm internal resistance of the Arduino I/O drivers, giving a minimum gate resistance of 100 Ohm.
 +
 +
For Rgate, some people recommend anything from 100 Ohm to 270 Ohm,
 +
to keep the gate from "ringing" due to the capacitance of the gate and the inductance of the wires between the Arduino and the FET.<ref>
 +
http://forum.allaboutcircuits.com/showthread.php?t=53431
 +
</ref>
 +
 +
This 2-resistor connection between the Arduino and the FET is adequate when
 +
* (a) driving a logic-level FET, and
 +
* (b) switching at relatively low frequencies (<1000 Hz ???), and
 +
* (c) the switched leg of the motor is intended to be switched between (a) connected to the Arduino GND or (b) disconnected. (or switched between (a) connected to the Arduino VCC or (b) disconnected.) and
 +
* (d) the motor is driven by extra-low voltage (<60 Vdc ???).
 +
 +
This 2-resistor circuit allows the Arduino to directly turn on and off a logic-level FET, and so indirectly turn on and off relays and 12 VDC lamps and other devices that the Arduino cannot directly drive.
 +
 +
However, there are cases where the Arduino can't directly switch a high-power FET on and off fast enough (1 MHz DC-DC converters, so (b) doesn't apply) or with the right voltage ("standard" nFETs that require Vgs above 8 V to turn all the way on, so (a) doesn't apply) or the Arduino needs to control both a high-side and a low-side FET (many kinds of [[motor driver]], where (c) doesn't apply).
 +
  
 
== Triac ==
 
== Triac ==
Line 90: Line 149:
 
=== Multiple Switches ===
 
=== Multiple Switches ===
  
ULN2803 OCTAL PERIPHERAL DRIVER ARRAYS eight NPN Darlington – drive 2 stepper motors, or 8 fairly heavy loads, max at 35 v and 500 ma
+
This first example is a Low side switch  (add link here )  ULN2803 OCTAL PERIPHERAL DRIVER ARRAYS eight NPN Darlington – drive 2 stepper motors, or 8 fairly heavy loads, max at 35 v and 500 ma
 +
See it used in:  [[http://www.opencircuits.com/Stepper_Motor_Demonstration_and_Tester ]] 
 +
 
 +
On a bit of a different note shift registers are often used to expand the number of output pins.  Some of these also contain fairly high power low side switches.  Look up: [http://focus.ti.com/lit/ds/symlink/tpic6595.pdf tpic6595]
  
[[http://www.opencircuits.com/Stepper_Motor_Demonstration_and_Tester ]]
+
Often we use so called row and column drive ( google it ) to drive things like led arrays.  In this case we cannot use just low side switches, but also need to use high side switches.  One that is good for tens of volts, hundreds of ma, and can be driven from arduino logic outputs is. Look up: UDN2981.
  
 
=== Stepper Drivers ===
 
=== Stepper Drivers ===
 +
 +
* [[Motor driver]]
 +
 
===  H Bridges ===
 
===  H Bridges ===
 +
 +
An H Bridge ( usually a transistor circuit, often an IC ) consists ( logically ) of 4 switches, 2 low side and 2 high side.  This arrangement makes it possible to not only turn current on through a device but additonaly reverse its direction.  Useful for dc motors, a component in some servo motors, and with bipolar stepper motors running on a single polarity power supply.
 +
 +
Links:
 +
 +
*[[http://en.wikipedia.org/wiki/H_bridge H bridge From Wikipedia, the free encyclopedia]]
 +
 
===  Power OpAmps ===
 
===  Power OpAmps ===
 +
 +
* [[op amp]]
  
 
=== LED Drivers ===
 
=== LED Drivers ===
  
  
Links:
+
== Links ==
 
 
http://www.opencircuits.com/Motor_driver
 
  
 +
*[http://www.acroname.com/robotics/info/articles/drivers/drivers.html Driving Loads with High Current]
 +
 +
*[http://www.thekanes.org/index.php/2010/06/09/expanding-the-arduino-cheap-ways-to-add-output-pins-and-power/ Expanding the Arduino: cheap ways to add output pins and power]
  
 +
*[http://itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads Using a transistor to control high current loads with an Arduino]
 +
*[http://www.kpsec.freeuk.com/trancirc.htm Transistor Circuits]
 +
*[http://www.electronics-tutorials.ws/transistor/tran_4.htmlElectronics Tutorial about Transistors as Switches]
 +
*[http://teachmetomake.wordpress.com/how-to-use-a-transistor-as-a-switch/ Teach Me To Make How to Use A Transistor as a Switch]]
  
  
 
[[Category:Microcontroller]][[Category:Arduino]][[Category:PIC]]
 
[[Category:Microcontroller]][[Category:Arduino]][[Category:PIC]]

Latest revision as of 07:03, 2 February 2017

Driving Large Loads with the Arduino[edit]

This is a draft it still has a ways to go

( and with other micro controllers, the PIC ….. )

What are Large Loads[edit]

The Arduino has a bunch of output pins that can do things like light led's and provide signals to servo motors, but try connecting it to a hi fi loud speaker and not much happens ( although you may damage the Arduino forever ). For our purpose a large load is almost any load ( what you connect the output to ) that is too much for the Arduino. These methods for large loads fall into several different classes with some common features.

Ideas for Driving the Loads[edit]

In some sense anything that can be used to drive a large load is an amplifier, a device with a output bigger than its input. If you want loud sounds from a Arduino you can use some computer's amplified speakers, or a hi fi. There are some cautions, but it is pretty basic, for most audio amplifiers the arduino outputs are close to what these audio amplifiers expect as inputs.

In many cases a simpler amplifier will do, many of these fall in the category of a low side switch ( [|Transistor Low Side Switch ] ). Here is a schematic of one using a push button ( not useful for the arduino, because the arduino cannot press the switch ):

<schematic here>

To be useful to the Arduino you need to replace the push button with something the Arduino can push:

  • Relay
  • Transistor ( bipolar, but not too depressed )
  • Transistor ( fet, field effect )
  • Triac
  • Driver ICs

Relay[edit]

With a relay we have a simple adaptation of the push button switch but the “button” is pushed by an electro magnet. Often the electro magnet is itself a large load, but for some relays ( particularly ones called reed relays ) the drive may be within the capacity of the arduino. When the relay is a large load you can use a transistor low side switch to drive it. Here are some features of the relay that are either naughty or nice:

A relay can be set up where there is no electrical connection between the input circuit and the output circuit ( we call this isolating the input from the output ). This can protect both the input circuit and any person who might come in contact with the input circuit or other parts of it ( like control push buttons ) A relay can switch large currents and large voltages: 2 amps 120 volts is pretty easy, currents of 10's of amps and 100's of volts are manageable A relay can not switch too fast, 1 Hz ( one a second ) is pretty fast for most relays, Reed relays tend to be some of the fastest. A relay cannot switch too many times. A transistor might switch at 10 kHz for hours, reaching millions of switching in little time. There are relays called solid state relays that have no mechanical parts, generally they are electrically more like transistors, but configured so that they can be more or less drop in replacements for electro mechanical relays. Solid state diodes can also be fast. Relays use magnets so when turned off they have what is called and “inductive kick”, this can destroy the Arduino. A snubber diode can be used to deal with this. ( [[1]]) Relays are not cheap or small for small large loads, a transistor is a few cents ( at the low end ) relays tend to be larger and a few dollars. .


This circuit shows how to connect a relay with a transistor low side switch and a snubber diode, it is a partical circuit for many relays with the Arduino, it leaves out a few details like the values of the components and voltages ( [[2]])

Transistor Low Side Switch[edit]

We have discussion of low side switch on other pages of this site:

Transistor ( fet, field effect transistors )[edit]

Fet are not so much current or voltage amplifiers, but variable resistors whose resistance is controlled by a control voltage ( much like the voltage on a capacitor, no current is required once the capacitor – gate on a fet – is charged, substantial current is required to charge this fast ). We typically use these in either the on or off state, resistance of infinity ( in partice mega ohms ) and resistance of 0 ( in practice often a small fraction of an ohm ). Unfortunately many fets need voltages in the range of 10 volts, too much for an Arduino. To avoid this we use a special set of fets called logic level which can be switched to low resistance with voltages the arduino can deliver. The characteristic are similar to bipolar transistors hear we will contrast them to bipolar transistors.

Often have a lower voltage drop when turned on and therefore waste less power as heat Many other small technical differences we will skip. May be more susceptible to static damage.

Examples in projects:

any help here?

DC motor driver[edit]

Relays and small DC motors are often driven with a circuit like this:


                            +Vhigh
                     D1     |
                +---|>|-----+
                |           |
                +--(motor)--+
  Arduino       |
     GPIO-+-R2-|[nFET Q1
          |     |
          R1    |
          |     |
         GND---GND

      Low-side driver with logic-level nFET

(FIXME: show corresponding pFET circuit?)

R1 is typically in the range of 10 KOhm to 1 MOhm. R1 is a "pull-down" resistor that turns the nFET off and holds it off when that Arduino GPIO pin is tri-stated -- such as while you are pushing the Arduino reset button, or if your program accidentally makes that Arduino pin an "input" pin.

(While most people seem to attach R1 to the "Arduino" end of R2, other people attach R1 to the "FET" end of R2. It doesn't make any difference).

D1 is often a Schottky diode, perhaps a 1N582x (3 ampere), to handle PWM. D1 is often a rectifier diode, perhaps a 1N5400 series (3 ampere) diode, when the designer expects the Arduino to switch only "occasionally" -- less than 100 times a second. D1 is a flyback diode. Wikipedia: flyback diode

Q1 is some logic-level FET. There are hundreds of such FETs available, such as the PSMN041-80YL in a Power-SO8. the BUK9515-60E in a TO-220-3

R2 is often 100 Ohms. R2 is the "series gate resistor", aka "Rgate". Some people take the approach of picking a resistor to guarantee that the Arduino will stay within its maximum current limit (40 mA) at every instant. Since the gate of the FET acts like a small capacitor, these people pick R = V/I = 5V/40mA = 125 Ohm for a 5 V Arduino, minus the roughly 25 Ohm internal resistance of the Arduino I/O drivers, giving a minimum gate resistance of 100 Ohm.

For Rgate, some people recommend anything from 100 Ohm to 270 Ohm, to keep the gate from "ringing" due to the capacitance of the gate and the inductance of the wires between the Arduino and the FET.<ref> http://forum.allaboutcircuits.com/showthread.php?t=53431 </ref>

This 2-resistor connection between the Arduino and the FET is adequate when

  • (a) driving a logic-level FET, and
  • (b) switching at relatively low frequencies (<1000 Hz ???), and
  • (c) the switched leg of the motor is intended to be switched between (a) connected to the Arduino GND or (b) disconnected. (or switched between (a) connected to the Arduino VCC or (b) disconnected.) and
  • (d) the motor is driven by extra-low voltage (<60 Vdc ???).

This 2-resistor circuit allows the Arduino to directly turn on and off a logic-level FET, and so indirectly turn on and off relays and 12 VDC lamps and other devices that the Arduino cannot directly drive.

However, there are cases where the Arduino can't directly switch a high-power FET on and off fast enough (1 MHz DC-DC converters, so (b) doesn't apply) or with the right voltage ("standard" nFETs that require Vgs above 8 V to turn all the way on, so (a) doesn't apply) or the Arduino needs to control both a high-side and a low-side FET (many kinds of motor driver, where (c) doesn't apply).


Triac[edit]

Is a bit of a specialized part, but is often useful ( again connected as a low side switch ) for controlling fairly large ( 100 or more volts ) voltages at modest currents. One application is EL wire switching.

Links:

[3] [4]

Examples in projects:

[[5]]


Driver IC[edit]

There are all sorts of driver IC's so coverage here will, at least for awhile, be brief. A driver can use all of the parts above plus others.

Multiple Switches[edit]

This first example is a Low side switch (add link here ) ULN2803 OCTAL PERIPHERAL DRIVER ARRAYS eight NPN Darlington – drive 2 stepper motors, or 8 fairly heavy loads, max at 35 v and 500 ma See it used in: [[6]]

On a bit of a different note shift registers are often used to expand the number of output pins. Some of these also contain fairly high power low side switches. Look up: tpic6595

Often we use so called row and column drive ( google it ) to drive things like led arrays. In this case we cannot use just low side switches, but also need to use high side switches. One that is good for tens of volts, hundreds of ma, and can be driven from arduino logic outputs is. Look up: UDN2981.

Stepper Drivers[edit]

H Bridges[edit]

An H Bridge ( usually a transistor circuit, often an IC ) consists ( logically ) of 4 switches, 2 low side and 2 high side. This arrangement makes it possible to not only turn current on through a device but additonaly reverse its direction. Useful for dc motors, a component in some servo motors, and with bipolar stepper motors running on a single polarity power supply.

Links:

Power OpAmps[edit]

LED Drivers[edit]

Links[edit]