i UNIVERSITY OF NAIROBI DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING DESIGN OF A PWM BASED DC MOTOR CONTROL FOR ELECTRIC VEHICLE USING A MICROCONTROLLER PROJECT INDEX: PRJ 82 BY TOWETT FESTUS KIPNGENO REGISTRATION NO. : F17/30740/2010 SUPERVISOR: MR. OMBURA EXAMINER: PROF. MANGOLI Project report submitted in partial fulfillment of the requirement for the award of the degree of: Bachelor of Science in Electrical and Electronic Engineering of the University of Nairobi. Submitted on: 24th day of April, 2015
70
Embed
DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERINGeie.uonbi.ac.ke/sites/default/files/cae/engineering/eie... · · 2015-06-29DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
i
UNIVERSITY OF NAIROBI
DEPARTMENT OF ELECTRICAL AND INFORMATION
ENGINEERING
DESIGN OF A PWM BASED DC MOTOR CONTROL FOR ELECTRIC
VEHICLE USING A MICROCONTROLLER
PROJECT INDEX: PRJ 82
BY
TOWETT FESTUS KIPNGENO
REGISTRATION NO. : F17/30740/2010
SUPERVISOR: MR. OMBURA
EXAMINER: PROF. MANGOLI
Project report submitted in partial fulfillment of the requirement for the award of the degree of:
Bachelor of Science in Electrical and Electronic Engineering of the University of Nairobi.
Submitted on: 24th day of April, 2015
ii
DEDICATION To my family, for believing in me.
iii
DECLARATION OF ORIGINALITY
FACULTY/ SCHOOL/ INSTITUTE: Engineering
DEPARTMENT: Electrical and Information Engineering
COURSE NAME: Bachelor of Science in Electrical & Electronic Engineering
TITLE OF NAME OF STUDENT: Towett Festus Kipngeno
REGISTRATION NUMBER: F17/30740/2010
COLLEGE: Architecture and Engineering
WORK: DESIGN OF A PWM BASED DC MOTOR CONTROL FOR ELECTRIC VEHICLE
USING A MICROCONTROLLER
1) I understand what plagiarism is and I am aware of the university policy in this regard.
2) I declare that this final year project report is my original work and has not been
submitted elsewhere for examination, award of a degree or publication. Where other
people’s work or my own work has been used, this has properly been acknowledged
and referenced in accordance with the University of Nairobi’s requirements.
3) I have not sought or used the services of any professional agencies to produce this work.
4) I have not allowed, and shall not allow anyone to copy my work with the intention of
passing it off as his/her own work.
5) I understand that any false claim in respect of this work shall result in disciplinary
action, in accordance with University anti-plagiarism policy.
Signature: ………………………………………………………………………………………
Date: ……………………………………………………………………………………………
iv
ACKNOWLEDGEMENT
This is an honor for me to thank those who have helped to make this report possible.
First of all I would like to pay my deepest gratitude to my supervisor, Mr. Ombura for
giving me the opportunity to work on this project under his supervision. His support,
guidance and encouragement from the initial stage to the end has enabled me to
understand the concept behind this thesis work. I also express my gratitude to all the
faculty members and lab technologist for their guidance and support. Finally, all the
thanks to Almighty GOD that I have come to this far.
v
Table of Contents
DEDICATION ......................................................................................................................................................... ii
DECLARATION OF ORIGINALITY .............................................................................................................. iii
TABLE OF FIGURES ......................................................................................................................................... vii
TABLE OF FIGURES Figure 2.1 classification of hybrid electric vehicles .............................................................................................. 10
Figure 2.2primary electric vehicle power train ..................................................................................................... 12
Figure 2.3 conceptual illustration of general ev configuration ...................................................................... 13
Figure 2.4 possible ev configurations ......................................................................................................................... 15
Figure 2.5 types of dc motors ......................................................................................................................................... 17
Figure 2.6 permanent magnet dc motor and curves ............................................................................................ 18
Figure 2.7 shunt wound dc motor and curve ........................................................................................................... 19
Figure 2.8 series dc motor ............................................................................................................................................... 21
Figure 4.14 lcd and led output ....................................................................................................................................... 53
1
ABSTRACT
The aim of this project is to design and implement a power controller based on a
microcontroller to be used in controlling a DC motor driving an electric vehicle. The
ease of control and excellent performance of the DC motors will ensure that it is widely
used in many applications. This project is mainly concerned on DC motor speed control
system by using microcontroller PIC 16F877A. Pulse Width Modulation (PWM)
technique is used where its signal is generated in microcontroller. The program for
PWM generation is written in C Language using MIKROC software. It is programmed
into the microcontroller using Pickit 2. Then the microcontroller is installed into the
motor control circuit. The Microcontroller acts as the motor speed controller in this
project. Based on the result, the readings are quite reliable. Through the project, it can
be concluded that microcontroller PIC 16F877A can control motor speed at desired
speed efficiently by using Pulse Width Modulation signal.
Keywords: DC motor, Microcontroller, Pulse Width Modulation.
2
1 INTRODUCTION Electro mobility has always been an issue that has helped drive the development of
vehicles. It did become less important for a while because the oil fields did not appear
to be drying up, but now electro mobility is becoming increasingly significant as people
become aware of the depletion of oil reserves and the need for of global environmental
and climate protection.
The present discussion on the CO2 emissions of passenger cars gives a new stimulus to
electric traction drives. At least for city travel the fuel consumption and consequently
the CO2 emissions can be reduced by applying a concept containing electric traction. By
electric traction is meant locomotion in which the driving (or tractive) force is obtained
from electric motors. It is used in electric trains, tramcars, trolley buses and diesel-
electric vehicles etc. [1]
The development of internal combustion engine vehicles, especially automobiles, is one
of the greatest achievements of modern technology. Automobiles have made great
contributions to the growth of modern society by satisfying many of its needs for
mobility in everyday life. The rapid development of the automotive industry, unlike that
of any other industry, has prompted the progress of human society from a primitive one
to a highly developed industrial society. However, the large number of automobiles in
use around the world has caused and continues to cause serious problems for the
environment and human life. Air pollution, global warming, and the rapid depletion of
the Earth’s petroleum resources are now problems of paramount concern.
At present, all vehicles rely on the combustion of hydrocarbon fuels to derive the
energy necessary for their propulsion. Combustion is a reaction between the fuel and
the air that releases heat and combustion products. The heat is converted to mechanical
power by an engine and the combustion products are released into the atmosphere [2].
A hydrocarbon is a chemical compound with molecules made up of carbon and
hydrogen atoms. Ideally, the combustion of a hydrocarbon yields only carbon dioxide
and water, which do not harm the environment. But the combustion of hydrocarbon
fuel in combustion engines is never ideal. Besides carbon dioxide and water, the
combustion products contain a certain amount of nitrogen oxides (NO), carbon
monoxides (CO), and unburned hydrocarbons (HC), all of which are toxic to human
health.
3
1.1 APPLICATION OF ELECTRIC TRACTION
Over the years study and research of electric traction have intensified and its
application be used in many different ways such as electric vehicle, electric train,
electric motorcycles and electric traction elevators.
1.1.1 ELECTRIC TRAIN
The railway as a means of transport is a very old idea. At its beginnings, it was mainly
utilized in the central European mines with different means of traction being applied.
But it did not come into general use until the invention of the steam engine. Since the
18th century it has developed faster and faster until in the 21st century it has become
the most efficient means of transport for medium distances thanks to the development
of High Speed. Railway electrification as a means of traction emerged at the end of the
nineteenth century, although experiments in electric rail have been traced back to the
mid-nineteenth century [3].
An electric locomotive is a locomotive powered by electricity from overhead lines, a
third rail or an on-board energy storage device (such as a chemical battery or fuel cell).
Electrically propelled locomotives with on-board fuelled prime movers, such as diesel
engines or gas turbines, are classed as diesel-electric or gas turbine electric locomotives
because the electric generator/motor combination only serves as a power transmission
system. Electricity is used to eliminate smoke and take advantage of the high efficiency
of electric motors; however, the cost of railway electrification means that usually only
heavily-used lines can be electrified.
Electric locomotives benefit from the high efficiency of electric motors, often above
90% [4]. Additional efficiency can be gained from regenerative braking, which allows
kinetic energy to be recovered during braking to put some power back on the line.
Newer electric locomotives use AC motor-inverter drive systems that provide for
regenerative braking.
1.1.2 ELECTRIC MOTORCYCLES
Electric motorcycles, though still in their infancy, are starting to gain a foothold in the
marketplace. Most electric motorcycles and scooters today are powered by
rechargeable lithium ion batteries, though some early models used nickel-metal
hydride batteries. As technology improves and costs of battery starts to come down it is
most likely that more and more of electric motorcycle will be manufactured.
armature with a series of two or more windings of wire wrapped in insulated stack
slots around iron pole pieces (called stack teeth) with the ends of the wires terminating
on a commutator. The armature includes the mounting bearings that keep it in the
center of the motor and the power shaft of the motor and the commutator connections.
The winding in the armature continues to loop all the way around the armature and
uses either single or parallel conductors (wires), and can circle several times around
the stack teeth. The total amount of current sent to the coil, the coil's size and what it's
wrapped around dictate the strength of the electromagnetic field created. The sequence
of turning a particular coil on or off dictates what direction the effective
electromagnetic fields are pointed. By turning on and off coils in sequence a rotating
magnetic field can be created. These rotating magnetic fields interact with the magnetic
fields of the magnets (permanent or electromagnets) in the stationary part of the motor
(stator) to create a force on the armature which causes it to rotate. In some DC motor
designs the stator fields use electromagnets to create their magnetic fields which allow
greater control over the motor. At high power levels, DC motors are almost always
cooled using forced air [1].
2.2.1 CLASSIFICATION OF A DC MOTORS
DC motors can be divided into two general categories;
2.2.1.1 Brush-type DC Motors:
They have a mechanical brush pair on the motor frame and makes contact with a commutator ring assembly on the rotor in order to communicate current, i.e. to switch current from one winding to another, as a function of rotor position so that the magnetic fields of the rotor & stator are always at a 90 degrees angle relative to each other.
2.2.1.2 Brushless DC Motors:
They are an inside-out version of the brush-type DC motors, i.e. the rotor has the permanent magnets and the stator has the winding. Hence, magnetic fields of the rotor & stator must be perpendicular to each other at all rotor positions. Communication is done by solid-state power transistors based on a rotor position sensor, hence it is considered a servo motor.
2.2.2 CLASSIFICATION ON BASIS OF EXCITATION WINDING
Further classification of dc motors is on the basis of their excitation winding. Field winding may be connected to armature winding (in series or parallel) or it may be separately excited [13]. Figure 2.5 below shows the various types available;
In this paper we are concern majorly on controlling DC Motors for electric Vehicle. DC
motor is an electric motor that runs on direct current (DC) electricity. The DC motors
will be used to providing the motive power for the electric vehicles and operate directly
from rechargeable battery of 12V 7AH battery hence allow regenerative braking to be
implemented.
While designing a DC motor control for electric vehicle can be complex, it does become
easier when broken down into its component steps. The following sections detail each
component within the project, as well as how each section is constructed and interacts
with other blocks.
The two stages of this work are the hardware development and software development.
The first stage i.e. the hardware development, has the following sections;
1. H-bridge 2. Display Unit (LCD) 3. Input Unit 4. Motor controller circuit, this includes the circuit for the PIC16F877A
microcontroller and the H-bridge. 5. DC-motor and Mechanical Vehicle Parts (Wheels and Gears) 6. Dc Power Supply and charging unit
The second stage i.e. the software development, has two parts which are;
1) To develop embedded system software using the MikroC PRO for PIC16F877A
microcontroller.
2) Simulating the control system using Proteus software.
3.1 HARDWARE DEVELOPMENT
The block diagram of the system is shown in Figure 3.1
25
3.1.1 H-BRIDGE
An H-Bridge or full bridge converter is a switching configuration composed of four
switches in this case MOSFETs in an arrangement that resembles an H and enables a
voltage to be applied across a load in either direction [14]. These circuits are often used
in robotics and other applications to allow DC motors to run forwards and backwards.
Figure 3.2 h-bridge
Figure 3.1 block diagram
26
By controlling which switches are closed at any given moment, the voltage across the
motor can be either positive, negative, or zero. As shown in Figure 3.2 . A solid state H-
bridge is built using four switches. When switch Q1 and Q4 are closed and switches Q2
and Q3 are open (according to Figure 3.3 a) a positive voltage will be applied across the
motor. During forward free driving Q4 is kept on so when the PWM signal is off,
current can continue to flow around the bottom loop through Q3's intrinsic diode as
shown in Figure 3.3Figure 3.3b.By closing Q2 and Q3 switches and opening Q1 and Q4
switches (according to Figure 3.3c) a reverse voltage will be applied to the load allowing
reverse operation of the motor. Also during reverse free driving Q3 is kept on so when
the PWM signal is off, current can continue to flow around the bottom loop through
Q4's intrinsic diode as shown in Figure 3.3d. Using nomenclature above switches Q1
and Q2 should never be closed at the same time as this will cause a shot circuit on
between the power supply and ground, potentially damaging the devices or draining
the power supply. The same applies to switches Q3 and Q4. This condition is known as
shoot-through.
Figure 3.3 h-bridge switch configuration
For regeneration, when the motor is going backwards for example, the motor (which
is now acting as a generator) is forcing current right through its armature, through
27
Q2's diode, through the battery (thereby charging it up) and back through Q3's
diode. Regenerative braking is shown in Figure 3.4 below.
Figure 3.4 regenerative braking
TABLE 1 below outlines the positions. Note that shoot-through switch positions are
omitted. The switches used to implement an H-Bridge can be mechanical built from
solid state transistors. Selection of the proper switches varies greatly.
TABLE 1 H-BRIDGE SWITCHES CONFIGURATION
S1 S2 S3 S4 OPERATION PERFORMED
1 0 0 1 Forward Drive
0 1 1 0 Reverse Drive
0 0 0 0 Free Running
1 0 1 0 Brakes
0 1 0 1 Brakes
28
3.1.1.1 CHOICE OF SWITCHING TRANSISTOR
While designing this circuit, a choice had to be made between the two main types of
switches used in power electronics. One is the power MOSFET which is much like a
standard MOSFET but designed to handle relatively large voltages and currents. The
other is the insulated gate bipolar transistor (IGBT) [15]. Each has its advantages, and
there is a high degree of overlap in the specifications of the two. IGBTs tend to be used
in very high voltage applications, nearly always above 200V, and generally above 600W.
They do not have the high frequency switching capability of MOSFETs, and tend to be
used at frequencies lower than 29 kHz. They can handle high currents, are able to
output greater than 5kW, and have very good thermal operating ability, being able to
operate properly above 100 Celsius. One of the major disadvantages of IGBTs is their
unavoidable current tail when they turn off. Essentially, when the IGBT turns off, the
current of the gate transistor cannot dissipate immediately, which causes a loss of
power each time this occurs. This tail is due to the very design of the IGBT and cannot
be remedied. IGBTs also have no body diode, which can be good or bad depending on
the application.
Power MOSFETS have a much higher switching frequency capability than do IGBTs, and
can be switched at frequencies higher than 200 kHz. They do not have as much
capability for high voltage and high current applications, and tend to be used at voltages
lower than 250V and less than 500W [1]. MOSFETs do not have current tail power
losses, which makes them more efficient than IGBTs. Both MOSFETs and IGBTs have
power losses due to the ramp up and ramp down of the voltage when turning on and off
(dV/dt losses). Unlike IGBTs, MOSFETs have body diode. Generally, IGBTs are the sure
bet for high voltage, low frequency (>1000V, <20 kHz) uses and MOSFETs are ideal for
low voltage, high frequency applications (<250V, >200 kHz). In between these two
extremes is a large grey area. In this area, other considerations such as power, percent
duty cycle, availability and cost tend to be the deciding factors. Since this project is
about design of a 12V, DC motor control to be used in electric vehicle MOSFET is the
ideal choice. Also MOSFET being a voltage controlled device, it can be driven directly
from CMOS or TTL logic and the same gate signal can be applied to diagonally opposite
switches since the gate drive current required is very low.
3.1.1.2 ENHANCED N-CHANNEL VS ENHANCED P-CHANNEL MOSFETS
The use of P-Channel MOSFETs on the high side and N-Channel MOSFETs on the low
side is easier, but using all N-Channel MOSFETs and a FET driver, lower “on” resistance
can be obtained resulting in reduced power loss. This requires a more complex circuit
29
since the gate of the high side Mosfet must be driven positive with respect to Vs bus
voltage to turn on Mosfet [15].
3.1.1.3 MOSFETs CHARACTERISTIC
In this project enhanced n-channel Mosfet was chosen for both high side and low side
switches of the H-bridge. For the Mosfet to carry drain current Id (on state) a channel
between the drain and source must be created [1]. This occurs when drain to source
Vgs voltage exceeds the device threshold (Vgs>Vth). Once the channel is induced the
Mosfet can operate in either triode region (drain current proportional to channel
resistance) or the saturation region (constant drain current). The gate to drain voltage
Vgs determines whether the induced channel enters pitch-off or remains in triode
region. When used as a switching device only triode and cut-off region are utilized. The
device will operate at cut-off (off state) when gate to source voltage Vgs is less than
threshold voltage Vth (Vgs<Vth) [1].
a. Triode region; Vds<Vgs-Vth b. Saturation region; Vds>Vgs-Vth c. Cut-off region; Vgs<Vth
3.1.1.4 MOSFET DRIVER
As stated in the previous section, it is beneficial to use N-channel MOSFETs as the high
side switches as well as the low side switches because they have a lower ‘ON’ resistance
and therefore less power loss. However, to do so, the drain of the high side device is
connected to 12V DC power. This is a problem because the 12V is the highest voltage in
the system and in order for the switch to be turned on the voltage at the gate terminal
must be 10V higher than the drain terminal voltage [15]. Therefore, to drive MOSFETs
in the H-Bridge MOSFET driver IC is used with a bootstrap capacitor specifically
designed for driving a half-bridge. After considering various IC options, the ideal choice
was the IR2110, which is rated at 600V, with a gate driving current of 2A and a gate
driving voltage of 10-20V. The turn on and turn off times are 120ns and 94ns
respectively [16].
The MOSFET driver operates from a signal input given from the microcontroller and
takes its power from the battery voltage supply that the system uses. The driver is
capable of operating both the high side and low side devices, but in order to get the
extra 10V for the high side device, an external bootstrap capacitor is charged through a
diode from the 12V power supply when the device is off. Because the power for the
30
driver is supplied from the low voltage source, the power consumed to drive the gate is
small. When the driver is given the signal to turn on the high side device, the gate of the
MOSFET has an extra boost in charge from the bootstrap capacitor, surpassing the
needed 10V to activate the device and turning the switch on [17].
FIGURE 3.5 IR2110 CONNECTION
3.1.1.4.1 BOOTSTRAP CAPACITOR
As shown in FIGURE 3.5, the bootstrap diode and capacitor are the only external
components strictly required for operation in a standard PWM application. Local
decoupling capacitors on the VCC (and digital) supply are useful in practice to
compensate for the inductance of the supply lines. The voltage seen by the bootstrap
capacitor is the VCC supply only. Its capacitance is determined by the following
constraints:
(i) Gate voltage required to enhance MGT
(ii) IQBS - quiescent current for the high-side driver circuitry
(iii) Currents within the level shifter of the control IC
(iv) MGT gate-source forward leakage current
(v) Bootstrap capacitor leakage current
Factor 5 is only relevant if the bootstrap capacitor is an electrolytic capacitor, and can
be ignored if other types of capacitor are used. Therefore it was ignored since only
31
nonelectrolyte capacitors were used. The minimum bootstrap capacitor value was
calculated from the following equation [17]:
𝐶 ≥ 2[2𝑄𝑔+
𝐼𝑞𝑏𝑠
𝑓+𝑄𝑙𝑠+
𝐼𝑐𝑏𝑠(𝑙𝑒𝑎𝑘)
𝑓]
𝑉𝑐𝑐−𝑉𝑓−𝑉𝑙𝑠−𝑉𝑚𝑖𝑛
Where:
Qg = Gate charge of high-side FET=16nC f= frequency of operation=5000Hz ICbs (leak) = bootstrap capacitor leakage current=0A Iqbs (max) = Maximum VBS quiescent current=230µA VCC = Logic section voltage source=12V Vf = Forward voltage drop across the bootstrap diode=1.4V VLS = Voltage drop across the low-side FET or load=1.8V VMin = Minimum voltage between VB and VS=0V Qls = level shift charge required per cycle (typically 5nC for 500 V/600 V MGDs and 20nC for 1200 V MGDs)
The values substituted into this equation were found either in driver datasheet for
IR2110 IC or IRF540 MOSFET datasheet. Using these numbers minimum bootstrap
capacitance value was calculated in the equation below:
𝑐 ≥2[(2∗16∗10−9)+
230∗10−6
5000+(5∗10−9)]
12−1.4−1.8
𝑐 ≥ 18𝑛𝐹
The capacitor value obtained from the above equation is the absolute minimum
required, however due to nature the bootstrap circuit operation, a low value of
capacitor can lead to overcharging which could in turn damage the IC. Therefore to
minimize the risk of overcharging and further reduce ripple on the Vds voltage the
capacitor value obtained is multiplied by a factor of 5 to get a capacitor value of 90nF
where by 100nF is selected.
3.1.1.4.2 BOOTSTRAP DIODE
The bootstrap diode must be able to block the full voltage seen in the specific circuit
and is about equal to the voltage across the power rail. The current rating of the diode is
the product of gate charge times switching frequency. The high temperature reverse
leakage characteristic of this diode can be an important parameter in those applications
where the capacitor has to hold the charge for a prolonged period of time. For the same
reason it is important that this diode have an ultra-fast recovery to reduce the amount
of charge that is fed back from the bootstrap capacitor into the supply [17]. In order to
32
improve decoupling a decoupling capacitors has to be connected directly across the VCC
and COM pins as shown in FIGURE 3.5.
3.1.1.4.3 GATE RESISTOR
Driving MOS-gated power transistors directly from the driver can result in
unnecessarily high switching speeds. Increasing the value of the series gate resistor,
results in a rapid decrease of the amplitude of the negative spike, while the turn-off
time is a linear function of the series gate resistance. Selecting a resistor value just right
from the “knee” in Figure 3.6 provides a good trade-off between the spike amplitude
and the turn-off speed the di/dt losses may have to be reduced by reducing the
switching speed by means of the gate resistor [17]. A graph of the negative spike and
the turn-off time versus series gate resistance is shown in Figure 3.6. The layout should
also minimize the stray inductance in the charge/discharge loops of the gate drive to
reduce oscillations and to improve switching speed and noise immunity, particularly
the “dV/dt induced turn-on”. For this design resistor values of 20 ohms was chosen.
Figure 3.6 series gate resistance vs. Amplitude of negative voltage spike and turn-off time
3.1.2 CONTROL SYSTEM
Control theory is an interdisciplinary branch of engineering and mathematics that deals
with the behavior of dynamical systems .The desired output of a system is called the
reference. When one or more output variables of a system need to follow a certain
33
reference over time, a controller manipulates the inputs to a system to obtain the
desired effect on the output of the system [18].
If we consider an automobile cruise control, it is design to maintain the speed of the
vehicle at a constant speed set by the driver. In this case the system is the vehicle. The
vehicle speed is the output and the control is the vehicle throttle which influences the
engine torque output. One way to implement cruise control is by locking the throttle at
the desired speed but when encounter a hill the vehicle will slow down going up and
accelerate going down. In fact, any parameter different than what was assumed at
design time will translate into a proportional error in the output velocity, including
exact mass of the vehicle, wind resistance, and tire pressure [18] .This type of controller
is called an open-loop controller because there is no direct connection between the
output of the system (the engine torque) and the actual conditions encountered mean
the system does not and cannot compensate for unexpected forces. For the purpose of
keeping the cost of the project at minimum this is the type which is going to be
implemented in this design. Although, there is another type known as closed loop
control system.
For a closed-loop control system, a sensor will monitor the vehicle speed and feedback
the data to its computer and continuously adjusting its control input or the throttle as
desired to ensure the control error to a minimum therefore maintaining the desired
speed of the vehicle [18]. Feedback on how the system is actually performing allows the
controller (vehicle's on board computer) to dynamically compensate for disturbances
to the system, such as changes in slope of the ground or wind speed. An ideal feedback
control system cancels out all errors, effectively mitigating the effects of any forces that
may or may not arise during operation and producing a response in the system that
perfectly matches the user's wishes.
3.1.2.1 PULSE WIDTH MODULATION (PWM)
From research, I have found several ways to control the motor speed using electronic
devices. There is voltage speed control, field speed control (I field), resistance speed
control and PWM technique. These control method have their benefit and
disadvantages respectively which is more focus to efficiency element. In this project
only PWM technique will be consider and be implemented.
Pulse Width Modulation (PWM) uses digital signals to control power applications, as
well as being fairly easy to convert back to analog with a minimum of hardware. Analog
systems, such as linear power supplies, tend to generate a lot of heat since they are
34
basically variable resistors carrying a lot of current. Digital systems don't generally
generate as much heat. Almost all the heat generated by a switching device is during the
transition (which is done quickly), while the device is neither on nor off, but in between.
This is because power follows the following formula:
P = E I, or Watts = Voltage X Current
If either voltage or current is near zero then power will be near zero. PWM takes full
advantage of this fact. Pulse-width modulation uses a square wave whose pulse width is
modulated resulting in the variation of the average value of the waveform [19]. An
example of pwm signal is shown in Figure 3.7.
The average of voltage that supply to DC motor is given by,
𝑉𝑎𝑣𝑒 =𝑡𝑜𝑛
𝑇∗ 𝑉𝑖𝑛
Where Vave = average voltage supply to DC motor
ton = time ON of switches
T = period of PWM
ton /T = DC, duty cycle
One of the parameters of any square wave is duty cycle. The ratio of on to off time is
called as duty cycle. Most square waves are 50%, this is the norm when discussing
them, but they don't have to be symmetrical. The ON time can be varied completely
between signal being off to being fully on, 0% to 100%, and all ranges between.
Examples of a 10%, 50%, and 90% duty cycle are shown in Figure 3.8.
PWM is an effective method for adjusting the amount of power delivered to the load.
PWM technique allows smooth speed variation without reducing the starting torque
and eliminates harmonics. In PWM method, operating power to the motors is turned on
and off to modulate the current to the motor. The duty cycle determines the speed of
Figure 3.7 PWM signal
35
the motor. The desired speed can be obtained by changing the duty cycle. The Pulse-
Width Modulation (PWM) in microcontroller is used to control duty cycle of DC motor
drive. Since the frequency is held constant while the on-off time is varied, the duty cycle
of PWM is determined by the pulse width. Thus the power increases with increase of
duty cycle in PWM.
3.1.3 MICROCONTROLLER
A microcontroller (sometimes abbreviated µC, uC or MCU) is a small computer on a
single integrated circuit containing a processor core, memory, and programmable
input/output peripherals. Program memory in the form of NOR flash or OTP ROM is
also often included on chip, as well as a typically small amount of RAM. Microcontrollers
are designed for embedded applications. Microcontrollers are used in automatically
controlled products and devices, such as automobile engine control systems,
implantable medical devices, remote controls, office machines, appliances, power
tools, and other systems. The Microcontroller used in this design is PIC16F877A.
3.1.3.1 REASONS FOR CHOOSING PIC MICROCONTROLLER (PIC16F877A)
3.1.3.1.1 INTERNAL ARCHITECTURE
PIC16F877a has Harvard architecture. Harvard architecture is a newer concept than
von Neumann [20]. It rose out of the need to speed up the work of a microcontroller. In
Harvard architecture data bus and address bus are separate. Thus a greater flow of data
is possible through the central processing unit and of course a greater speed of work.
Separating a program from data memory makes it further possible for instructions not
to have to be 8-bits instructions which allows for all instructions to be one word
instructions.
Figure 3.8 examples of PWM signal
36
3.1.3.1.2 INSTRUCTION SET
It is also typical for Harvard architecture to have fewer instructions than von-
Neumann's, and to have instructions usually executed in one cycle. Microcontrollers
with Harvard architecture are also called "RISC microcontrollers" [21]. Stands for
Reduced Instruction Set Computer. Microcontrollers with von-Neumann's architecture
are called 'CISC microcontrollers', which stands for Complex Instruction Set Computer.
PIC16F877A is a RISC microcontroller that means it has a reduced set of instructions;
more precisely 35 instructions. Advantages of RISC is that the microcontroller is fast
and it’s easy to learn programming language needed to program it and the user only
sees the final results [22].
3.1.3.1.3 COST
PIC16F877A is an 8 bit microcontroller classified under medium range
microcontrollers which makes it very cost competitive with other similar products in
the market and hence its pocket friendly. Due to its low cost the overall cost of the
inverter ends up being low and market competitive given that the microcontroller is the
most expensive chip in the design.
3.1.3.1.4 AVAILABILITY IN THE MARKET
Since in our country we don’t have a plant to fabricate microchips it is very important
to choose a chip which readily available in the local market to avoid incurring extra cost
of shipping. PIC16F877A was available in the local stores hence the reason to using it.
PIC16F877a perfectly fits many uses, from automotive industries and controlling home
appliances to industrial instruments, remote sensors, electrical door locks and safety
devices. It is also ideal for smart cards as well as for battery-supplied devices because of
its low power consumption [22].
3.1.4 LCD DISPLAY UNIT
A suitable display unit is required to display the gear engaged which selects the mode of
operation of the driving motor and also show the speed at which the vehicle is moving.
A 16x2 Liquid Crystal Display is a low power, low cost, basic electronic display. A 16x2
LCD means it can display 16 characters per line and there are 2 such lines. In this LCD
each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely,
Command and Data. The command register stores the command instructions given to
the LCD. A command is an instruction given to LCD to do a predefined task like
initializing it, clearing its screen, setting the cursor position, controlling display etc. The
data register stores the data to be displayed on the LCD. The data is the ASCII value of
37
the character (measured distance) to be displayed on the LCD [23]. The Figure 3.9
below shows LCD screen chosen for this project.
Figure 3.9 16X2 LCD display
3.1.5 INPUT UNIT
In order to be able to select different types of operation a suitable input was to be
selected capable of communicating with the microcontroller and relaying the command
from operator efficiently and fast. Several factors were considered such as the size,
weight and mode of interconnection either wireless or wired. An ideal and user friendly
would have been the wireless mode of connection but given the complicity of the circuit
needed and the cost of implementation 4 way DIP switch was selected instead. 2
switches was programmed to emulate function of gears in a vehicle while the third
switch be the brake paddle and the fourth accelerating paddle.
3.1.6 DC MOTOR
There are several types of DC motors that are available their advantages, disadvantages,
and other basic information are listed below in Table 2 [1]. In this design DC geared
motor operating at rated voltage 12V and no load speed of 200rpm was selected to be
used due to its low cost and small size and also availability in the market.
38
Table 2 Advantages and disadvantages of various types of DC motor
TYPE ADVANTAGES DISADVANTAGES
DC Geared Motor Very precise speed and position control. High Torque at low speed.
Low speed. Mechanical wear and require regular servicing
DC Motor w/field coil Wide range of speeds and torques. More powerful than permanent magnet motors
Require more current than permanent magnet motors, since field coil must be energized. Generally heavier than permanent magnet motors. More difficult to obtain.
DC permanent magnet motor
Small, compact, and easy to find. Very inexpensive
Generally small. Cannot vary magnetic field strength.
Gasoline (small two stroke) Very high power/weight ratio. Provide Extremely high torque. No batteries required.
Expensive, loud, difficult to mount, very high vibration.
3.1.7 POWER SUPPLY
Signal generation begins with the power supply for the microcontroller. As a battery’s
stored energy depletes, its voltage is reduced. Several of the amplifiers in the control
signal generation circuits rely on the rail voltages to charge and discharge capacitors
which cause a controlled oscillation Generally speaking, the correct voltage supply is of
utmost importance for the proper functioning of the microcontroller system.
For a proper function of this circuit design, it is necessary to provide 2 stable power
rails source of supply. One to power low voltage components of 5V and another 12V to
drive high voltage electronics such as IR2112 Mosfet driver and the DC motor.
According to technical specifications by the manufacturer of PIC microcontroller,
supply voltage should move between 2.0V to 5.0V in all versions [21]. The solution
comes in the form of a linear voltage regulator. There are other types of voltage
regulation, mainly switching regulators, but their benefits are of little use in powering
39
chips. Switching regulators are more efficient than linear regulators and they have the
ability to boost voltages, but the supply voltage is well-defined and the op-amps require
very little power relative to what a lead acid battery can provide. Thus, the simplest
solution to the source of supply is using the voltage stabilizer LM7805 which gives
stable +5V on its output [24]. Its connection as per datasheet is shown in Figure 3.10
below.
Figure 3.10 Voltage regulator circuit
3.1.8 CIRCUIT PROTECTION
MOSFETs turn OFF more slowly than they turn ON. If you attempt to turn on a high side
MOSFET at the same time you're turning OFF a low-side MOSFET (or vice versa), you
will wind up having both of them turned on at the same time, causing the dreaded
"shoot-through" condition, which will lead to damage of the components [17]. For this
reason one of the major factor in inverter device is its ability to protect itself from
surges that could damage the circuitry. The IR2110 used in this design does not have
built-in optoisolators hence it does not provide for "dead time" which is much needed
in order to avoid short circuiting of the rail voltage. Another protection of the circuit
needed is MOSFET gate protection, which employed a resistor between “gate” and
“source”. It prevents accidental turn on of the MOSFET by external noise usually at
startup when the gate is floating. The MOSFET may sometimes turn on with a floating
gate because of the internal drain to gate "Miller" capacitance. A gate to source resistor
acts as a pull-down to ensure a low level for the MOSFET.
The principle of operation is that when the parasitic capacitance of the circuit comes
into play. The resistor creates an RC circuit complete with its time constant. And this RC
40
delays the time the circuit switches ON just enough to allow the complementary part of
the bridge circuit to switch OFF. Typical values of this resistor a 1 kΩ, 10 kΩ, or 100 kΩ
depending on the rail voltage of the h bridge. Some of the factors which need to be
considered when selecting the value of resistor are;
1. The resistance needs to be low enough so that the gate is discharged in time, and
can be held in the low state despite capacitive coupling from startup transients.
The gate of a FET has very high resistance and mostly looks capacitive. Even a
large resistor can eventually discharge the gate capacitance. The limiting factor
there is how fast the device might be turned off and then back on again. Usually
this isn't the issue though. Keeping the gate low despite startup transients is
much harder to judge since it's almost impossible to know where these
transients may be coming from and how strongly they will couple onto the gate
node.
2. On the other end, pull-down resistor should not draw significant current that
would otherwise go to driving the gate high quickly or at all.
3.2 SOFTWARE DESIGN
The program design for this project was done in C language using MikroC compiler. It is
easy to develop and implement PIC microcontroller like the one used in this design PIC
16F877A program in C language due to its flexibility, easiness of Programming and
debugging. After writing the program code it was burned to the microcontroller using
the Pickit 2 programmer.
The flow chart of the program is shown in Figure 3.11 below. The code execution starts
by initializing ports, LCD module and setting all analogue channels off. Next, variables
used in codding are defined and interrupt function called. By using interrupt function to
monitor the input from the 4 channel DIP switch the microcontroller is able to respond
to user command without affecting the normal execution of the program.
Main function which defines the start of execution code is now called and pulse width
modulation modules of the microcontroller initialized. If input issued by the driver
changes the code executes a switch function where the command is compared among