Anda di halaman 1dari 17

Brushed DC Speed Control with Back EMF Feedback

SET4

Julian Hayes

Sean Hearne

Cillian Howley

Conor Hough

Bachelor of Engineering in Sustainable Energy Technology (YEAR 4)

Mechatronics System Design MECH8014

Department of Mechanical Engineering

Supervisor: Michael J. O’Mahony

Submitted to Cork Institute of Technology, 10th May 2010


Abstract

The main reason for carrying out this project was so that the project group could investigate the
use of Brushed DC Speed Control with Back EMF Feedback.

This was to be done by the use of an analogue to digital converter device, connected to a
microcontroller, and using the MPLAB IDE software.

To enable us to carry out our investigations of this project, a variety of key steps had to be
followed. These steps are;

• Formulating a project specification; including required inputs, outputs, and logical


requirements

• Selection of microcontroller & analysis of its architecture

• Selection & Analysis of software development tools

• Hardware Schematics

• Design of pseudo code of application software

• Generation of Program Descriptor & Flowchart

• Implementation of that Software

In order to carry out this work, a team of four was assigned to the above tasks. Using the
knowledge gained in previous studies of mechatronics, and from demonstration & practical
labs carried out, the team was confident about the successful implementation of the program.
Acknowledgements

Firstly we would like to extend our thanks to Dr. Michael J. O’ Mahony who provided help,
advice and great support with every request throughout the duration of this project, and was
most patient and obliging with the whole project group throughout this entire process.

We wish also to thank Dr. Richard Guinnee, our Mechatronics systems lecturer, for the advice
he has given us during our final year. He was very approachable and always forthcoming to
offer his time and experience when approached.

We would also like to thank all our other lecturers in the Sustainable Energy division of The
Mechanical Engineering Department in CIT, for their advice, support and guidance throughout
the last two years.
Table of Contents Page

Project Management 5

Literature Review 6

Project Specifications 8

Microprocessor Architecture 12

Software Development Tools 18


Group E is made up of four student members, Julian Hayes, Sean Hearne, Conor Hough &
Cillian Howley. Upon first assembly of the group it was decided that the project would be split
into four evenly divided sections.

When dividing up the work it was important to ensure that each group member was content
with the section that they were assigned and it was also important that the skills of each group
member were fully utilised in this project. Therefore, where possible the work was divided into
areas which were specific to that persons skill set. The project was divided as follows;

• Julian Hayes:

Project specifications, required inputs, outputs, logical requirements

Justification of microcontroller selection.

Microcontroller architecture

• Sean Hearne:

Selection of software development tools

Selection of electronic components, sensor – actuator characteristics

Hardware schematics (as appropriate)

• Conor Hough:

Design: pseudocode of application software

Program descriptor

Program flowchart

• Cillian Howley:

Implement the software.


2 Literature Review:

Microprocessor

A microprocessor also known as a central processing unit, CPU for short, is a complete
computation engine that is fabricated on a single chip component. A microprocessor executes
lines of coded machine instructions which tell the processor exactly what to do and when to do
it. The microprocessor uses its arithmetic logic unit to carry out all mathematical operations
including addition, subtraction, multiplication and division. More modern microprocessors can
even contain complete floating point processors which can perform extremely sophisticated
operations on large floating point numbers in an extremely efficient manner. A microprocessor
can move data from one memory location to another. A microprocessor can make decisions
and jump to a new set of instructions based on decisions predetermined by the code inputted.

Analogueue to digital conversion

Analogue-to-digital conversion is an electronic process in which a continuously variable


analogue signal is changed, without altering its essential content, into a multi-level digital
signal.

The input to an analogue-to-digital converter (ADC) consists of a voltage that varies among
a theoretically infinite number of values. Examples are sine waves, the waveforms representing
human speech, and the signals from a conventional television camera. The output of the ADC,
in contrast, has defined levels or states. The number of states is almost always a power of two
-- that is, 2, 4, 8, 16, etc. The simplest digital signals have only two states, and are called
binary. All whole numbers can be represented in binary form as strings of ones and zeros. This
is the basis of conversion units.

Digital signals propagate more efficiently than analogue signals, largely because digital
impulses, which are well-defined and orderly, are easier for electronic circuits to distinguish
from noise, which is chaotic. This is the chief advantage of digital modes in communications.
Computers "talk" and "think" in terms of binary digital data; while a microprocessor can
analyze analogue data, it must be converted into digital form for the computer to make sense of
it.

Analogue to digital converters


Analogue-to-digital converters are used in a variety of information-processing applications.
Information collected from analogue phenomena such as sound, light, speed, temperature and
pressure can be digitized and made available for digital processing. A codec (coder/decoder) is
the device that transforms the analogue signals to digital signals. The process involves
sampling, quantizing, and digitizing. The amplitude of a signal is measured at various intervals.
The tighter these intervals are, the more accurate the recording. Figure A-3 illustrates how a
wave is sampled 16 times per second, with a sampling rate of 16Hz. While sampling at this rate
is impractical for voice or music, it illustrates how each sample records a different amplitude
value for the sound. Generally, a rate of 8,000 samples per second or higher using 8 bits per
sample is adequate for voice-quality signals. Quantizing is the process of replacing the sampled
value with the nearest value within the range of the device and the sampling rate. Digitizing
completes the process.

Fundamental Brushed DC Motor Operation

A brushed DC motor usually consists of stationary fixed permanent magnets called the stator, a
rotating electromagnet which act as the rotor and a metal body to concentrate the flux (see Fig
1 below). The fundamental laws of magnets state that by attraction of opposite poles and
repulsion of like poles, a torque acts on the rotor and makes it turn. This is a form of
conversion from electrical energy into mechanical energy. As soon as the rotor begins to turn,
fixed brushes make and break contact with the rotating segments (commutation) in turn. The
rotor coils are energized and de-energized in such way that as the rotor turns, the axis of the
new rotor poles are always opposed to the stator poles. Because of the way the commutation is
arranged, the rotor is in constant motion. By reversing the power supply to the motor, the
current in the rotor coils and therefore the north and south poles are reversed and the motor
changes its direction of rotation.

The speed and torque of the motor depend on the strength of the magnetic field generated by
the energized windings of the motor, which depend on the current through them. Therefore
adjusting the rotor voltage (and current) will change the motor speed. In this application note
speed control is based on generating and varying a PWM signal by the PIC16F917
microcontroller.

Speed control
The motor speed with no-load is proportional to the voltage supplied across the motor.
Therefore by simply varying the voltage across the motor, we could control the speed of the
motor. Pulse Width Modulation (PWM) is used to implement this. It is based on a fixed
frequency pulse waveform with a variable duty cycle. The average voltage applied to the motor
is proportional to the PWM duty cycle. This basically involves taking a constant D.C. supply
voltage and chopping it so that the average value is varied.
Current sense
Low cost motor current measuring is implemented using a current sensing resistor between the
MOSFETs and ground. The small voltage appearing across the current sense resistor is filtered
and amplified, before being fed to an ADC input of the microcontroller. Current is always
measured at its highest point, just before the end of the PWM ‘on’ time. This is accomplished
by using an extra Timer match interrupt that starts the AD conversion. The converted value
represents the motor current.
In this application note measuring the motor current is used as a safety. In case the motor is in
a stalled position, the current will increase dramatically. Due to this exceptional increase in
current, the ADC values will reach a current limit level that will cause the system to shut down,
avoiding any damages

Motor feedback

RPM measurement
Low cost sensorless motor rotation speed feedback is implemented by Back EMF voltage
measuring. Back electromotive force (also called BEMF) is an electromotive force that occurs
in electric motors and generators where there is relative motion between the rotor magnet of
the motor and the external magnetic field. In other words, the motor acts like a generator as
long as it rotates. The RPM is directly proportional to the back EMF voltage.
Back EMF is measured with the modulated MOSFET switched off (‘brake’ mode). In this
application note the BEMF measurement is used to determine whether or not the motor has
completely stopped, before for example the rotation direction is reversed. A voltage divider is
used to fit the back EMF voltage (max. 12 V) into the 0 V to 5V range of the PIC16F917 ADC
input.

Controlling speed and direction


In order to control the direction and speed of the motor a 10 kΩ potentiometer, connected to an
ADC input of the PIC16F917, is used. The A/D converter has a 10-bit resolution, but in our
case only 8 bits are used in order to avoid any possible jitter. This means there are 256 possible
potentiometer steps. The center position (+ hysteresis) is the resting point for the motor speed
(‘break’)

1. Unidirection BDC motor control only requires one PWM output controlling one
MOSFET to run the motor.

2. The duty cycle (PWM high time or period) sets the speed

3. Motor speed is proportional to the duty cycle of the PWM output on the CCP1 pin
Characteristics of a Brush DC Motor:

• Good controllability:On/Off, Proportional


• Linear torque/current curve
• Speed proportionate to voltage applied
• Requires little maintenance
• Low overloading capability
• Low heat dissipation

Brush DC Motor Applications include:

• Toys
• Cellular phones
• Wipers
• Door locks
• Window lifts
• Antenna retractor
• Seat adjust
• Anti-lock Braking System
• Cordless hand drill
• Electric lawnmower

Project Specification
The motor RPM can be measured by underlying principal that a motor is a generator. So long
as the motor is rotating, it is producing a voltage which is proportional to the motors
revolutions per minute (RPM). This is called back EMF which is the backbone of this project.
If the Pulse Width Modulation (PWM ) signal to the motor is turned off and the voltage across
the windings is measured, the back EMF voltage can be sensed from there and the RPM can be
obtained.
A/D Conversion Steps

1. Turn on the analogue module

2. Set GO_DONE bit of ADCON0

3. Wait for GO_DONE bit to be cleared

4. Read A/D result in ADRESH


The analogue to digital conversion module will be used on the PIC16F917 to read this voltage
and display the digital representation of that voltage on the LCD. What an analogue-to-digital
converter does is it measures an analogue voltage, and then based on the resolution of the
module converts that voltage into a number. On this slide you can see how many counts are
possible for a 8-bit and 10-bit analogue to digital module. The analogue-to-digital conversion
module on the PIC16F917 is a 10-bit module. For simplicity we will be ignoring the least
significant 2 bits. In other words we will be using only the highest 8 bits. You can see on this
Slide that 256 counts are possible in 8-bit mode. Over 5 volts this is 19.5mV per count. In our
application, this means that every 19.5mV that the POT1 output increases will be interpreted
by the analogue to digital converter as one increment

Frequency
Selecting a PWM frequency for the motor control application will effect the sound of the motor
and the power transistor's switching speed. The human ear can detect frequencies ranging from
20 Hz-20 kHz. Generally, frequencies greater than 4 kHz are not audible to the human ear.
Choosing a PWM frequency greater than 4 kHz helps reduce the humming sound heard while
the motor is running. The PWM period and frequency can be calculated using these equations
1 and 2.

Duty Cycle
Changing the PWM duty cycle will change the average voltage across the motor, which
changes the motor's speed. The PWM duty cycle is calculated by using Equation 3. The
average voltage across the BDC motor is calculated by using Equation 4.
Resolution

The PWM duty cycle resolution determines the amount of precision with which the duty cycle
can be changed. For example, a 10-bit resolution allows 1024 possible values for the duty cycle
where an 8-bit resolution only allows 256 values. The PWM frequency, PIC16F684 oscillator
frequency and Timer2 prescaler all effect the resolution value.

- 8-bit -> 28 -> 256 possible readings

- 10-bit -> 210 -> 1024 possible readings

Example: 8-bit resolution over 5 volts:

Voltage resolution = 5V/256 = 19.5 mV per count

CCPR1L:CCP1CON<5:4>
The PWM duty cycle has a full resolution of 10 bits.
Since all registers on the PIC16F684 are 8-bits wide, the 10 bits are spread over two registers.
CCPR1L contains the upper 8 bits and CCP1CON<5:4> contains the lower 2 bits. The 10-bit
value for
CCPR1L:CCP1CON<5:4> is calculated by using Equation 7.

CCP1CON
In addition to storing the lower 2 bits of the 10-bit PWM duty cycle, CCP1CON is used to set
up the ECCP in PWM mode using bits CCP1CON<3:0> and can change the motor direction
using bits CCP1CON<7:6>.
When setting up the ECCP in PWM mode, there are four possible configurations. These
configurations accommodate H-bridges with MOSFETS that are active high, active low or a
combination of both active high and active low. Motor direction can be changed in hardware
by configuring bits CCP1CON<7:6> to be ‘01’ for forward or ‘11’ for reverse. The PIC16F684
ECCP hardware takes care of switching channels for activating and modulating the appropriate
MOSFET drivers in the H-bridge.

T2CON
The T2CON register is used for setting up the Timer2 prescaler and turning on Timer2. The
Timer2 prescaler is contained in bits T2CON<1:0> and is used in determining the PWM
frequency, duty cycle and resolution. Timer2 must be turned on by setting bit
T2CON<2> before the PWM signal will start. For an algorithm that calculates the Timer2
prescaler and PR2 values given a known PWM.
Sensor Feedback
There is a wide range of sensors on the market used for speed feedback. The most common types
are hall effect sensors and optical encoders.

Optical Encoder Hall Effect Sensor

Optical encoders are made up of several components. A slotted wheel is mounted to the shaft at
the non-driving end of the motor. An infrared LED provides a light source on one side of the
wheel and a photo transistor detects light on the other side of the wheel. Light passing through
the slots in the wheel will turn the photo transistor on. As the shaft turns, the photo transistor
turns on and off with the passing of the slots in the wheel. The frequency at which the
transistor toggles is an indication of motor speed. In the case of positioning applications, an
optical encoder will also provide feedback as to the position of the motor.

Hall effect sensors are also used to provide speed feedback. Like optical encoders, hall effect
sensors require a rotary element attached to the motor and a stationary component. The rotary
element is a wheel with one or more magnets positioned on its outer rim. A stationary sensor
detects the magnet when in passes and generates a TTL pulse

Microcontroller Board Setup

Using the provided wire jumpers and shunts, the board was configured as listed below.
1. Attach the leads of the Brushed DC motor to Drive 1(P9) and Drive 2 (P10) using the
screwdriver.
2. Connect the right and centre pins on JP8 using a shunt.
3. Connect RD7 (J10) to P1 (J1)
4. Connect CCP2 (J10) to N2 (J1)
5. Connect AN0 (J13) to POT1 (J4)
6. Connect AN1 (J13) to BACK EMF (J16)
Header and jumper Functions

J1* - Output MOSFET drive pins.

J2 - Full-bridge drive circuit (Drives 1 and 2): Place three shunts vertically on these pins to create a
full-bridge drive circuit incorporating Drives 1 and 2.

J3 - Full-bridge drive circuit (Drives 3 and 4): Place three shunts vertically on these pins to create a
full-bridge drive circuit incorporating Drives 3 and 4.

J4* - Temperature sensor, light sensor, potentiometers, 32.768 oscillator and switches signal pins.

J10* - Right-side signal pins of the 40-pin DIP socket (U1, pins 21-40).

J13* - Left-side signal pins of the 40-pin DIP socket (U1, pins 1-20).

J16* - Back EMF feedback signal pins.

JP8 - Drive circuit voltage selection. See diagram on board.

* On these jumpers, the pins are connected in pairs horizontally. This allows
one pin to be used for jumping to/from the microcontroller (using a wire jumper) and the other pin
for probing the circuit with test equipment.

POT1 adjusts the speed of the motor. For this project POT1 is set at 100% to run the motor at full
speed. Next, the motor is run at half speed by setting POT1 to 50% and this is repeated.
REQUIRED Inputs

1. Power Supply

The board must be powered by one of the following:

• A 9-12 VDC source at the screw terminals (P20 and P21)

• A 9-12 VDC source at J9

• A 9VDC battery

• A 5VDC power source at TP2 and TP3

Supplying less than 9 VDC at J9 or the screw terminals will not allow the regulator
To function properly causing VDD to be below 5 VDC.
The PWR ON LED lights up when a power source is applied to the board. The fault LED also
light up which represents over current. This fault most be cleared by pressing SW5 (CLEAR
FAULT SWITCH). This light remains on if the drive current is greater than 1.2A. The board is
now set up to start the project.

2. Debugger
MPLAB ICD 2 is an in circuit Debugger and Programmer
Debug mode:
Finds out any errors in your code and details faults so they can be alleviated with ease.
Looks at the data memory
Steps through the code
Brake points are set
Program mode:
Program a device using the
Pickit 2 Debugger and Mechatronics demo board
The diagram provided above shows the PICkit 2 debugger and its features..

Outputs

The main output from the device is the analogue to digital conversion which is displayed on a
LCD screen. A LCD screen is used to display the digital output value so that it can be read.

LCD unit

The LCD is driven directly from the LCD module on-board the PIC16F917. The LCD is a 3½
digit display. Pins that are connected to the LCD are indicated by a white box enclosing the pin
designation.

Logical Requirements

There are several logical requirements that are essential for the successful implementation of
this program.
• The microprocessor is the backbone for data transfer between buses.
• Motor which is built into the PIC16F917
• PWM (pulse width modulation) circuit
• an ADC (analogue to digital converter)
• a tacho-generator
The system accuracy depends the performance of the ADC used to digitize the sensor output.
In many cases as the magnitude of the signal from the sensor is quite small, a high-resolution
ADC is required.
For example, an ADC with a resolution of 8 bits can encode an analogue input to one in 256
different levels, since 28 = 256. The analogue signal is continuous in time and it is necessary to
convert this to a flow of digital values. It is therefore required to define the rate at which new
digital values are sampled from the analogue signal. The rate of new values is called the
sampling rate.

Justification of the Microcontroller Selection

This microcontroller was selected due to its versatility and ability with ease of use to convert
analogue to digital in an efficient manner and its capability to display the output on a LCD
screen. This microcontroller has a built in LCD display which is of huge advantage over
competing microcontroller manufacturers.
This microcontroller also provides high accuracy due to the precision of the speed sensing and
A/D controller on the microcontroller. One of the biggest advantages to using a PIC®
microcontroller in applications that require speed sensing is that the microcontroller can be
used to calibrate the speed sensor reading automatically (over varying supply voltages and
process variations in the parts themselves). This saves the manufacturer costly calibration time
at the factory that is typically required by traditional speed sensing technologies. This
microcontroller had the necessary specification to complete the task in hand and its relatively
cheap price was a decisive factor in the selection process. The simplicity and user friendliness
of the device were a critical selection factors.
Standard analog peripherals include up to 8 channels of 10-bit A/D, an analog comparator
module with two comparators programmable on-chip voltage reference and an Enhanced
/Capture /Compare /PWM (ECCP). The ECCP peripheral offers up to four outputs with
programmable dead band delay and auto-shutdown and restart options.

Parameter Name Value


Program Memory Type Flash
Program Memory (KB) 14
CPU Speed (MIPS) 5
RAM Bytes 352
Data EEPROM (bytes) 256
Digital Communication 1-A/E/USART, 1-SSP(SPI/I2C)
Peripherals
Capture/Compare/PWM 2 CCP
Peripherals
Timers 2 x 8-bit, 1 x 16-bit
ADC 8 ch, 10-bit
Comparators 2
Segment LCD (pixels) 96
Temperature Range (C) -40 to 125
Operating Voltage Range (V) 2 to 5.5
Pin Count 40
The PIC16F917 offers multiple features including:

• Up to 96 LCD segments
• Internal 32kHz to 8MHz oscillator
• Low-power nanoWatt Technology
• 25mA Source/Sink current I/O
• Two 8-bit Timer (TMR0/TMR2)
• One 16-bit Timer (TMR1)
• Extended Watchdog Timer (EWDT)
• Wide Operating Voltage (2.0V – 5.5V)
• Brown-Out Reset (BOR) with Software Control
• In Circuit Serial Programming (ICSP)
• Programmable Low Voltage Detect (PLVD)
• Wake on change
• I2C, SPI, AUSART

The Analogue-to-Digital converter (A/D) allows conversion of an analogue input signal to a


10-bit binary representation of that signal. The PIC16F917 has up to eight analogue inputs, one
of these includes speed, multiplexed into one sample and hold circuit. The output of the sample
and hold is connected to the input of the converter. The converter generates a binary result via
successive approximation and stores the result in a 10-bit register. The Microprocessor also has
an LED screen to create digital outputs
Devices used for feedback may be a tacho-generator or an electronic encoder. A tacho-
generator requires an analogue to digital converter to input data into the microprocessor
conversely signal from the microprocessor must be converted from digital to analogue where it
is then used to very the voltage applied to the armature. If the signals are entirely digital, PWM
is applied and the electronic encoder feeds the signal back to the microprocessor..

Anda mungkin juga menyukai