|
Using the ATMEGA168/Arduino with the TA8050 Motor Controllerby Lewis Loflin The purpose of this tutorial is the demonstrate using the ATMEGA168/Arduino to control the speed and direction of a 12 volt DC using an "h" bridge. We will make use of pules-width modulation (PWM) to control motor speed. In this case we are using Toshiba TA8050 integrated circuit and a home-built "H" bridge using power MOSFETs.An H-bridge is an electronic circuit which enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards and backwards. H-bridges are available as integrated circuits, or can be built from discrete components or even relays and manual switches. A solid-state H-bridge is typically constructed using reverse polarity devices such as PNP bipolar transistors or P-channel MOSFETs connected to the positive voltage bus and NPN bipolar junction or N-channel MOSFETs connected to the negative voltage bus). Pulse-width modulation (PWM) is a very efficient way of providing intermediate amounts of electrical power between fully on and fully off. A simple power switch with a typical power source provides full power only when switched on. PWM is a comparatively-recent technique made practical by modern high speed electronic power switches. This goes beyond mere thermostats that cycle on and off at very slow rates. An inexpensive solid-state lamp dimmer controls the amount of time each AC half-cycle (120 Hertz) is on. See Basic Triacs and SCRs In the past, when only partial power was needed (such as for a sewing machine motor), a variable power resistor (foot-controlled; a rheostat) connected in series with the motor adjusted the amount of current flowing through the motor. Part of the power was wasted as heat in the resistor element. Auto transformers could be used but are costly.
The term duty cycle describes the proportion of on-time versus off-time.Duty cycle is expressed in percent, 100% being fully on 0% is fully off. In the ATMEGA168/Arduino has six digital pins (3, 5, 6, 9, 10, 11) that can be programmed as 8-bit PWMs. Using the command analogWrite(pin, value) where 'pin' is the output pin and 'value' is a number from 0 to 255. In the above example we could have a frequency (f) of 1000 Hertz which give us the period or cycle time (1/f = T) of 1 millisecond or 1000 microseconds. If the digital pulse is HIGH for 250 microseconds and LOW for 750 microseconds we have a duty cycle of Ton/T X 100 = 250/1000 X 100 = 25%.
For example an analogWrite(3, 0) outputs zero volts or fully off on digital pin 3. And analogWrite(255, 3) outputs 5 volts or fully on with digital pin 3. A value of 128 produces a a square wave that's 50% on and 50% off for a duty cycle of 50%. In the example above the motor would run somewhere around half-speed without wasting half the power as heat if we had used a variable resistor in series.
PWM works well with digital controls because of its on/off nature. Finally a simple resistor/capacitor low pass filter on the output pin will produce an analog voltage of 0 to 5 volts depending on duty cycle. You do not need to call pinMode() to set the pin as an output before calling analogWrite(). The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs.
Above we see the general hookup diagram. V+ is 12 volts. See test console schematic. and my own design H bridge that functions the same as the TA8050 using MOSFETs instead of bipolar transistors.
[ My Homepage ] [ Electronics Mainpage ]
Added February 2009: Using a CdS Photo resistor. How to use photocells and touches on comparators, thermistors, relays, etc. Includes circuits to build and test.
Arduino demos April 30, 2009: Atmega168/Arduino features: Visitors since |