Вы находитесь на странице: 1из 15

Application Note

Cordless Drill Motor Control with Battery


Charging Using Z8 Encore! F0830
Reference Design
AN025503-1207

Abstract
Currently, most hand-held electric drilling
machines operating on batteries need a separate
external battery charger to charge the batteries.
This reference design describes the implementation
of motor control for a 350 W hand-held electric
drilling machine along with Nickel Cadmium
(NiCd) battery charging in a single unit. This
design is based on Zilogs Z8 Encore! F0830
microcontroller, which primarily controls the speed
of the motor, motor current monitoring, fault detection, and controlled dv/dt charging of NiCd battery.
All functionalities of the design are implemented
with minimum hardware. The on-chip peripherals
of Z8 Encore! F0830 are used to drive the drill
motor at LowMediumHigh speeds using the
pulse width modulation (PWM). The battery voltage and the charger input voltage are monitored by
analog-to-digital converter (ADC) and the batteries
are charged depending on the voltage read from the
batteries and the charger. The light emitting diodes
(LEDs) are provided to indicate the motor running,
motor fault, low battery, and battery charging condition.
Note: The source code associated with this
reference design is available as
Motor Control Library in Application Sample Libraries on
www.zilog.com.

Features
The key features of this reference design include:

Motor control and battery charging in a single


unit

Smooth start-up of motor, reducing the starting


current of motor

Three-step speed control of the motor using


PWM

Microcontroller based over current protection

Monitoring of battery charger input voltage


and battery voltage

Controlled dv/dt charging of NiCd battery

LED indication of motor running, over load


and fault condition

LED indication of battery charging and low


battery status

Three-way switch for LowMediumHigh


motor speed selection

Two-way switch for Forward and Reverse


operation of the motor

Discussion
The drill motors used in most of the cordless handheld electric drilling machines are controlled by
electronic circuit. This electronic circuit mainly
comprises of a simple square wave generator to
control the speed. Usually batteries used in these
machines are charged using a separate charging
unit. By designing a control circuit based on Z8
Encore! F0830 microcontroller, it is easy to
accomplish motor control at different speeds and
battery charging as a single unit. This is an added
advantage because the battery used to drive the
motor is charged in the drilling machine without a
separate battery charger.
The functions of the drilling machine like motoring, stop (break), and the steps of speed, that is,
High, Medium and Low can be effectively controlled by changing the duty cycle of the PWM
generated by the microcontroller. LEDs are provided for monitoring fault condition like overload,

Copyright 2007 by Zilog, Inc. All rights reserved.


www.zilog.com

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

short circuit of motor, and the charging status of


the battery. Motor control operation resumes after
the overload and short circuit faults are rectified.
The controller circuit based on Z8 Encore! F0830
can also be used to charge Nickel Metal Hydride
(NiMH), NiCd, or Lithium ion batteries. The battery status such as low battery, charging, and
charge completed are displayed using LEDs.
This reference design is implemented with very
minimum hardware changes to accommodate
interfacing motors and batteries rated for different
voltage and current ratings.
This reference design can be easily ported to Z8
Encore! F083A microcontroller with 20 MHz
internal precision oscillator (IPO) for better operation in terms of processor speed and ADC conversion. The changes to be implemented are to modify
the setting of the clock source frequency defined as
a macro in the header files and configure ADC
Register used in the project.

Theory of Operation
The basic functions of the hand-held drill are
classified as forward motoring, reverse motoring,
speed control, and torque adjustment. Motors used
in the cordless hand-held drives are available at
different voltage ratings. The commonly used voltage ratings for the motor are 7.5 V, 12 V, 14.4 V, 18
V, 24 V, and 36 V DC. These motors have the maximum constant current rating and so can be operated at the maximum specified current rating which
in turn specifies torque. Motors used in this
application are rated from 300 W to 500 W. Generally, the no load current consumption of a
1/4-inch drill is in the range of 2 A to 2.5 A and the
stall current of the motor is in the range of 80 A to
100 A. The speed of these drilling machines is
adjustable from 150 rpm to 1200 rpm. Speed
variation is necessary for different type of work
from screw driving to drilling metal sheet.
Rechargeable batteries are used to provide power
to the drill motor. Most common rechargeable
batteries are NiCd, NiMH or Lithium ion. The
design uses NiCd cells of 1.2 V each connected in

AN025503-1207

series to form 14.4 V battery pack. NiCd battery


can be charged by a constant current from an
adapter plugged to the drive unit. The theory of
charging the NiCd batteries is described in Appendix CBattery Technology on page 14. The
charge termination to the battery is done by observing the zero or negative dv/dt on the battery terminals or by charging for a fixed time interval. In this
design the charge termination is done by zero/negative dv/dt or fixed interval timeout whichever
occurs first.
Motors
Brushed Universal Motors are commonly
employed in the cordless electric hand-held drives.
These motors can be operated using a DC power
supply. Brushed DC motors are classified as permanent magnet and temporary magnet motors. Permanent magnet DC motors are employed where
very low power/torque is needed (for example,
toys, tape players, instrument cooling fans, etc.).
Similarly the temporary magnet DC motors are further classified based on the type of magnetic field
winding used for their construction. Temporary
magnet DC motors are classified as:

Shunt motor

Series motor

Compound motor
Shunt motors are employed where the constant
speed is required. Series motors are employed
where high torque is required. But series motors
rotate at very high speed when they are not loaded.
Compound motors combine the features of series
and shunt motors. Hand-held drilling machines
require high torque to drill objects, maintenance of
speed is not a criteria in drilling applications, so
series motors are most suitable for most of the
drilling machines.
Rechargeable Batteries
Batteries are used to power cordless electric handheld drill motor. Drill motors consume high power
during their operation. The no load current consumed by a 350 W motor can be in the range of 2
A to 2.5 A and motor stall current can be in the
range of 80 A to 100 A. The batteries required for
Page 2 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

this application should have a high charge density


to meet the power requirements of the motor.
Rechargeable NiCd or NiMH batteries have a
moderate charge density which can be considered
suitable to the application. NiMH batteries exhibit
higher power density compared to their NiCd
counterparts. The voltage per cell of the NiCd
battery type is 1.2 V. NiCd batteries are charged
using the constant current charging method.

Hardware Architecture
Block Diagram
Figure 1 displays the functional block diagram of
Z8 Encore! F0830 hand-held drill motor control.

Battery Charging Section

Speed Control & Trigger Switch

20 V, 1A
power
supply

Power supply filter


& voltage regulator

Power Electronic Drive


Battery
charging
circuit

Power
Electronic
converter

DC
Motor

Batteries
Z8F0830 Microcontroller
Current
Sensor
Controller
Section
Fault & Status
Indicators

Figure 1. Block Diagram of Z8 Encore! F0830 Hand-Held Drill Motor Control


The block diagram is divided into following functional blocks:

Battery Charging Section

Controller Section

Power Electronic Drive

AN025503-1207

All functional blocks are controlled by Z8 Encore!


F0830 microcontroller operation using IPO at
5.5296 MHz.
Z8 Encore! F0830 20-pin microcontroller pins are
used for the functions listed in Table 1 on page 4.

Page 3 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

Table 1. Pin Function Descriptions


Pin No

Pin Function

Function Used

Input/Output/
PWR

Function on Board

PB1/ANA1

ANA1

Input

Battery charger voltage sensing

PB2/ANA2

Not Used

PB3/CLKIN/ANA3

Not Used

VDD

PWR

3.3 V supply

PA0/T0IN/T0OUT/XIN

Not Used

PA1/T0OUT/XOUT

Not Used

GND

PWR

GND

8, 9

PA2, PA3

PA2, PA3

Input

Three-level speed setting

10

PA4

PA4

Input

Run/Break switch

11

PA5

PA5

Output

Charger ON/OFF control

12

PA6/T1IN/T1OUT

Not Used

13

PA7/T1OUT

T1OUT

Output

PWM to drive MOSFET


connected to motor

14

RESET/PD0

RESET

Input

RESET

15

DBG

DBG

Input/Output

DEBUG

16

PC0/ANA4/CINP/LED

CINP

Input

Current sense input for


comparator

17

PC1/ANA5/CINN/LED

Not Used

18

PC2/ANA6/LED/VREF

PC2

Output

LED

19

PC3/COUT/LED

Output

LED

20

PB0/ANA0

ANA0

Input

Battery voltage sensing

The detailed descriptions below are reflected in the


schematics in Appendix ASchematics on page 9.

Battery Charging Section


The output of 110/230 V AC to 20 V DC, 1 A
power adapter is connected to the input of the battery charger section. The battery charging section
comprises of the charging current limiting resistor,
transistor to turn on/off the charging current,
trickle charging resistor, and 14.4 V NiCd battery
pack. The resistor across the transistor provides
trickle charging current of C/40 to the battery,
where C is the rated battery capacity in Ampere
Hours (AH). The transistor switching is controlled

AN025503-1207

by the Z8 Encore! F0830 microcontroller. The


charging input voltage and the battery terminal
voltage are attenuated to a voltage level acceptable
by the ADC peripheral within the Z8 Encore!
F0830 microcontroller. The attenuated voltage is
connected to the respective pins of the microcontroller. The microcontroller monitors the attenuated charging voltage and battery voltage for
charging the battery. The microcontroller measures
the voltage slope of the battery every 32 s. When
the batteries show a negative voltage slope (-dv/dt)
the microcontroller turns off the charging transistor
by making the GPIO pin low.

Page 4 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

This design accomplishes either


Note: battery charging or the drill motor
control function at a time. It is not
possible to run the motor when the
batteries are charged and vice versa.

Controller Section

current sense resistor is the input to the CINP pin


of the microcontroller. The CINP pin is the input
connected to the positive input of the comparator
within the Z8 Encore! F0830 microcontroller. The
negative input of the comparator is connected to
the programmable internal reference voltage generated within Z8 Encore! F0830 microcontroller.

The controller section comprises of Z8 Encore!


F0830 microcontroller operating at 5.5296 MHz
using IPO. The power supply for the controller is
derived from the battery or the charger input
voltage. Battery voltage of 14.4 V and charger
input voltage of 20 V are logically ORed using the
diode and stepped down to 3.3 V. The stepped
down voltage is achieved using a transistor and
zener diode combination. The microcontroller is
connected to a 3-position switch for speed control
of the DC motor. Based on the switch position, the
PWM duty cycle is varied to achieve Low
MediumHigh speed operation of the motor. A
trigger switch (ON/OFF) to turn on/turn off the
drill motor is connected to PA4. The LEDs to indicate battery and motor status are connected to PC2
and PC3 pins of the microcontroller respectively.
The voltage developed across the current sensing
resistor, when the current flows through it, is fed to
the positive input of the on-chip comparator. When
the voltage on the positive input of the comparator
exceeds the on-chip reference voltage connected to
the non-inverting input of the comparator, PWM
stops. Every 10 ms, the PWM is initialized to
check fault. If PWM is not started the motor status
LED blinks to indicate motor fault/overload.

The user interface consists of switch inputs for forwarding, stopping or breaking, and reversing the
motor, setting the speed of the motor to Low
MediumHigh. Two LEDs are provided for status
indication of motor and battery.

Power Electronic Drive

6. Continuously monitor for changes in the speed


setting switch and trigger switch release.

The power electronic drive unit consists of transistors to drive the metal oxide semiconductor field
effect transistor (MOSFET) connected to the low
side of the supply voltage. The transistor drive
stage forms a voltage level converter stage to drive
the gate of the MOSFET with appropriate voltage.
A switching frequency of 100 Hz gives a smooth
variation of the motor speed. The MOSFET is
switched at a frequency of 100 Hz. The source pin
of the MOSFET is connected to the ground through
a current sense resistor. The voltage drop across the
AN025503-1207

Software Implementation
The motor control and battery charging software
implementation procedures include the following
sequences of events:
1. Initialize the comparator, timer 0, timer 1
PWM, ADC, WDT, and GPIO upon power up
or external pin reset.
2. Read battery voltage and update the status
flags reflecting the battery condition.
3. If the battery voltage is above or below the
threshold limit, turn on the battery damage
Flag and charge the battery for 60 seconds.
4. If the trigger switch is not pressed continue to
step 8.
5. If the trigger switch is pressed and the battery
has sufficient charge set the speed of the motor
to the value set by the settings switch.

7. If the trigger switch is released or the battery is


completely discharged turn off the PWM.
8. If the battery is not completely charged and the
charger voltage is present turn on the charger.
9. Continuously monitor the battery status and
trigger switch press.
10. If the trigger switch is pressed, repeat step 5
through step 7.

Page 5 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

11. If the charger voltage is not present or the battery is completely charged turn OFF charger
and enter the stop mode.

Disconnect the smart cable from the target


device and recycle the power to the application.

12. The stop mode is recovered when WDT times


out or the trigger switch is pressed.

Connect a multi-meter in series with the


battery and the circuit to measure motor
current/battery charging current.

Testing

Connect an oscilloscope across the terminals


of the motor.

Test Setup

Press and hold RUN/STOP switch.

Observe the motor speed as it gradually


increases up to the maximum speed set by the
speed position switch.

Observe the wave forms on the oscilloscope.

Change the speed settings of the motor by


changing the position of the speed setting slide
switch.

Measure the speed and observe the wave forms


for all of the speed settings.

See schematics in Appendix ASchematics on


page 9 and Test Procedure to connect the test
circuit.

Equipment Used
The equipments used for testing consist of the
following:

14.4 V DC operated Cordless hand-held drill/


screwdriver

20 V, 1 A DC power supply

Digital multi-meter

Oscilloscope

Serial/USB Smart Cable

ZDS II installed PC, a USB/serial port to compile code and download the code to the target

Test Procedure
Follow the steps below to test the Z8 Encore!
F0830 microcontroller-based design:

Connect the circuit as displayed in the


Schematics in Appendix ASchematics on
page 9.

Connect the 14.4 V battery to the circuit.

Connect a Serial/USB Smart Cable to the


debug connector in the circuit and to the PC.

Open
the
Project
file
Motor_Control.zdsproj in the source
folder of this application installation using the
ZDS II Compiler, build the project and download the code to the target device.

AN025503-1207

Test Results
The results in the table below are obtained for
various speed settings of the motor.

Trigger
switch
position

Speed
switch
position

No load
speed
Current
(RPM)
(A)

Released

Pressed

Low

400

2.00

Pressed

Medium

800

2.90

Pressed

High

1150

3.20

Page 6 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

Peak motor starting


current = 18.72 A

Nominal motor operation


peak current = 9.75 A

Duty cycle:
Average motor current:
Frequency:
Motor speed:

10%
2.00 A
100 Hz
400 RPM

Figure 2. Starting and Operating Current of Motor with Speed Set to Minimum
A load current of 5.6 A is utilized when drilling an
aluminum sheet of 5 mm thickness.
LED D6 lights up to indicate Low battery when the
battery voltage is at 13.8 V or lower. The system
shuts down when the battery voltage reaches 12 V.

AN025503-1207

Battery Charging Test Results


The test results for battery charging are listed in
Table 2 on page 8.

Page 7 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

Table 2. Battery Charging Test Results


Parameters

Value

Battery type

Nickel Cadmium

Battery voltage

14.4 V

Ampere Hour rating

1500 mAH

Charging type

Constant voltage

Charging current

800 mA (initial, decreases with charging time)

Charging time

2 Hours (approximately for completely


discharged battery pack)

Charge termination

Negative voltage on battery terminals/


constant time interval

Maximum battery voltage when


18.2 V
charging completely discharged battery
Trickle charging current

40 mA

Voltage of the battery when completely 12 V


discharged using motor load

Summary
This reference design describes smooth speed
control of battery operated drilling machine motor
along with in-built battery charger using low cost
Z8 Encore! F0830/F083A. This design has two
LEDs which indicate various conditions like motor
operation, motor over current, battery charging,
and low battery.
This design also includes features like motor
protection for over current and short circuit,
controlled NiCd battery charging. The advantages
of this design over the existing cordless hand-held
drives are there is no need to plug the battery pack
to a separate charger unit, and smooth start-up of

AN025503-1207

the motor reduces high starting current of the


motor.

References
The documents associated with Z8 Encore! F0830
MCU or battery charger available on
www.zilog.com are listed below:

Z8 Encore! F0830 Series Product Specification (PS0251)

Z8 Encore! Based AA Type NiMH and NiCd


Battery Charger Reference Design (AN0229)

Z8 Encore! XP Based NiCd Battery Charger


Application Note (AN0221)

Page 8 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

Appendix ASchematics
Figure 3 displays the implementation of cordless drill motor control with battery charging using Z8 Encore! F0830 Series MCU.

Figure 3. Schematic Diagram of the Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830
AN025503-1207

Page 9 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

Appendix BFlowcharts
This Appendix displays the flowcharts of main function and interrupts in the application of cordless drill
motor control with battery charging using Z8 Encore! F0830. See Figure 4 through Figure 8 for details.

START

Initialize GPIO, Timer1 PWM,


Timer0, Comparator and ADC

WDT/GPIO Stop
Mode Recovery

Read Battery Voltage

Is Battery Low on
charge?

STOP MODE

Yes

No
No
Is Trigger Switch ON?
No
Yes
Motor
Control

Is Battery Charger
voltage present?
Yes
Charge
Battery

Figure 4. Flowchart of Main Function

AN025503-1207

Page 10 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

Motor
Control

Update motor control and


battery status flags

Read battery voltage and


update battery status field

Yes

Is Battery Voltage < Min.


Threshold?
No

Turn on
Battery
Low flag

Read speed setting switch position


(Low/Medium/High speed settings)

Has speed settings


changed?

No

Yes
Set PWM duty cycle to any of
the speed settings

No

Is Trigger released?
Yes
Turn off PWM, update status
flags

Figure 5. Motor Control Algorithm

AN025503-1207

Page 11 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

Charge
Battery

Is battery completely
charged?

Yes

No
Turn on battery charging
transistor, LED

Read battery voltage, update


battery status

Is Trigger Switch
pressed?

Yes

No
No

Has 30 seconds lapsed?


Yes
Is present battery voltage
>= previous battery voltage?

No

Yes
No

Has charging timed out?


Yes
Turn off battery status LED
and transistor

STOP MODE

Figure 6. Battery Charging Algorithm

AN025503-1207

Page 12 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

START

Stop PWM

Set comparator reset bit to 1

Return

Figure 7. Comparators Interrupt

START

Update LED status

Decrement charge counter

If comparator reset
restart PWM timer

Refresh WDT, update time in


seconds

Return

Figure 8. Timer0 Interrupt

AN025503-1207

Page 13 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

Appendix CBattery Technology


The four popular battery types (NiCd, NiMH, SLA,
Li-Ion) displays different charging and discharging
characteristics. The battery life and performance
mainly depends upon the battery charging mechanism. Therefore, batteries must be charged in a
proper mechanism. Charging must be terminated
when the battery is completely charged as overcharging of the battery invariably results in poor performance and can also damage the battery. Different
batteries require different charge termination techniques as they behave differently when approaching
the full charge state. While charging, batteries
exhibit marked rise in voltage above the rated battery
voltage. The NiCd and NiMH rechargeable battery
types used in this reference design are briefly discussed below.

Nickel Metal Hydride (NiMH)N i M H b a t t e r i e s

exhibit high power density compared to the NiCd


batteries. The per cell voltage of the NiMH battery
type is 1.2 V which is similar to NiCd batteries.
NiMH batteries are charged with constant current
charging method. While charging, the voltage drop is
not as low compared to NiCd batteries.
Therefore, -dv/dt charge termination is not recommended. Instead of the drop in cell voltage, the battery tends to stabilize after a small drop. This flat
region is the indication for full battery charging. This
termination mechanism is known as zero dv/dt termination. NiMH batteries do not suffer with memory
effect as compared to NiCd batteries. As a result,
they replace NiCd batteries in devices such as cell
phones. The increase in price is justified by the
reduction in weight and absence of memory effect.

Nickel Cadmium (NiCd)NiCd batteries are used


in portable consumer equipments. The single-cell
voltage for NiCd batteries is 1.2 V. These batteries
are charged using the constant current charging
method. While charging, as the voltage crosses the
full charge point, the voltage gradually drops. This
voltage drop is approximately 15 mV per cell in the
battery. This voltage drop is recognized as full charge
condition resulting in the termination of the charge.
This termination mechanism is known as -dv/dt termination. The battery voltage rises to 1.65 V per cell
during charging. The main disadvantage of the NiCd
battery is that it must be discharged periodically to
protect the performance. This phenomenon is known
as memory effect.

AN025503-1207

Page 14 of 15

Cordless Drill Motor Control with Battery Charging Using Z8 Encore! F0830

Warning:

DO NOT USE IN LIFE SUPPORT

LIFE SUPPORT POLICY


ZILOG'S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE
SUPPORT DEVICES OR SYSTEMS WITHOUT THE EXPRESS PRIOR WRITTEN APPROVAL OF
THE PRESIDENT AND GENERAL COUNSEL OF ZILOG CORPORATION.

As used herein
Life support devices or systems are devices which (a) are intended for surgical implant into the body, or (b)
support or sustain life and whose failure to perform when properly used in accordance with instructions for
use provided in the labeling can be reasonably expected to result in a significant injury to the user. A
critical component is any component in a life support device or system whose failure to perform can be
reasonably expected to cause the failure of the life support device or system or to affect its safety or
effectiveness.

Document Disclaimer
2007 by Zilog, Inc. All rights reserved. Information in this publication concerning the devices,
applications, or technology described is intended to suggest possible uses and may be superseded. ZILOG,
INC. DOES NOT ASSUME LIABILITY FOR OR PROVIDE A REPRESENTATION OF ACCURACY
OF THE INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED IN THIS DOCUMENT.
Z I L O G A L S O D O E S N O T A S S U M E L I A B I L I T Y F O R I N T E L L E C T U A L P R O P E RT Y
INFRINGEMENT RELATED IN ANY MANNER TO USE OF INFORMATION, DEVICES, OR
TECHNOLOGY DESCRIBED HEREIN OR OTHERWISE. The information contained within this
document has been verified according to the general principles of electrical and mechanical engineering.
Z8, Z8 Encore!, and Z8 Encore! XP are registered trademarks of Zilog, Inc. All other product or service
names are the property of their respective owners.

AN025503-1207

Page 15 of 15

Вам также может понравиться