1. ELECTROMAGNETIC HYBRID SUSPENSION SYSTEM
(EHS)
APPLICATION ON A SCALED CAR MODEL
ABDULLAH BIN KAMARUZAMAN
UNIVERSITI TEKNOLOGI MALAYSIA
2. 2
UNIVERSITI TEKNOLOGI MALAYSIA
NOTES : * If the thesis is CONFIDENTIAL or RESTRICTED, please attach with the letter from
the organisation with period and reasons for confidentiality or restriction.
DECLARATION OF THESIS / UNDERGRADUATE PROJECT PAPER AND COPYRIGHT
Author’s full name : ABDULLAH B KAMARUZAMAN
Date of birth : 23 APRIL 1988
Title : ELECTROMAGNETIC HYBRID SUSPENSION SYSTEM
APPLICATION ON A SCALED CAR MODEL
Academic Session : 2011/2012
I declare that this thesis is classified as:
I acknowledged that Universiti Teknologi Malaysia reserves the right as follows:
1. The thesis is the property of Universiti Teknologi Malaysia.
2. The Library of Universiti Teknologi Malaysia has the right to make copies for the
purpose of research only.
3. The Library has the right to make copies of the thesis for academic exchange.
Certified by:
________________________ ___________________________
SIGNATURE SIGNATURE OF SUPERVISOR
880423-87-5027 PROF. DR. MOHD FUA'AD BIN HJ RAHMAT
(NEW IC NO. /PASSPORT NO.) NAME OF SUPERVISOR
Date : 6TH JULY 2012 Date : 6TH JULY 2012
√
CONFIDENTIAL (Contains confidential information under the Official Secret
Act 1972)*
RESTRICTED (Contains restricted information as specified by the
organisation where research was done)*
OPEN ACCESS I agree that my thesis to be published as online open access
(full text)
PSZ 19:16 (Pind. 1/07)
3. i
" I declare that I have thoroughly read this work and
is adequate in terms of scope and quality for the purpose of awarding
a Bachelor's Degree of Electrical Engineering (Instrumentation & Control)"
Signature : ..................................................
Name of Supervisor : Prof. Dr. Mohd Fua'ad bin Hj Rahmat
Date : ..................................................4/7/2012
4. ii
ELECTROMAGNETIC HYBRID SUSPENSION SYSTEM (EHS)
APPLICATION ON A SCALED CAR MODEL
ABDULLAH BIN KAMARUZAMAN
A report submitted in partial fulfilment of the
requirements for the award of the degree of
Bachelor of Electrical Engineering (Instrumentation & Control)
Faculty of Electrical Engineering
Universiti Teknologi Malaysia
JULY 2012
5. iii
I declare that this project entitled "Electromagnetic Hybrid Suspension
System (EHS) Application on a Scaled Car Model" is the result of my own
research except as cited in the references. The project has not been accepted
for any degree and is not concurrently submitted in candidature of any other
degree.
Signature : ...........................................
Name : Abdullah bin Kamaruzaman
Date : 6th
July 2012
6. iv
Dedicated, in thankful appreciation for support, encouragement and
understandings to my supervisor, my beloved mother, father, brothers, sisters and
friends.
7. v
ACKNOLEDGEMENT
First and foremost, I would like to express my gratitude to my supervisor,
Prof. Dr. Mohd Fua'ad bin Hj Rahmat for the guidance and enthusiasm given
throughout the progress of this project.
My appreciation also goes to my family who has been so tolerant and
supports me all these years. Thanks for their encouragement, love and emotional
support that they had given me.
Nevertheless, my great appreciation dedicated to my friends Ridhwan, Rifqi,
Fauzi, Zul, Wan, Hannan, Ammar, Azu and all SEI members 08/12 and those whom
involved directly or indirectly with this project. Thank you.
8. vi
ABSTRACT
An electromagnetic hybrid suspension system is basically an electromagnetic
actuator coupled in parallel to a passive suspension. This creates a controllable high
response suspension system that have lower power consumption than a normal active
suspension system. It features robustness like a normal passive suspension system
and does not require major modification to the existing system. A microprocessor is
fitted to read the distance between the RC car and the ground using the IR sensors to
calculate when and how much force the solenoid needed to move. All four of the
passive suspension was fitted with an electromagnetic actuator (solenoid). A track
profile was constructed based on the real life road conditions and used as the test
track to measured the response of the RC car with and without the EHS system. New
data that was collected with and without the EHS system on board. The results were
compared and proved to reduce the vibration and oscillation by 50% but more study
is needed to further improve the response. No control tuning was implemented as it
was pure feed forward control and further improvements should be done in order for
the system to be more effective. This project was the first to be conducted practically
to prove the effectiveness of combining active and passive suspension systems.
9. vii
ABSTRAK
"Externally Mounted Electromagnetic Hybrid Suspension System (EHS)"
adalah dimana aktuator elektromagnet telah disambungkan selari bersama dengan
suspensi pasif. Ini dapat menghasilkan sistem suspensi yang dapat dikawal dan
mempunyai ciri penggunaan kuasa yang rendah daripada sistem suspensi aktif biasa.
Ia mempunyai daya ketahanan terhadap lasak seperti suspensi pasif biasa dan tidak
memerlukan perubahan yang banyak terhadap sistem asal. Mikropemproses telah
disambungkan pada sistem ini untuk membaca jarak yang terdapat diantara kereta
dan lantai menggunakan sensor IR dan seterusnya membuat perkiraan untuk
menetukan berapa tenaga yang perlu dibekalkan kepada solenoid. Kesemua empat
suspensi telah dilengkapkan dengan aktuator elektromagnetik. Profil jalan telah
direka khas berdasarkan keadaan jalan sebenar and profil jalan ini digunakan untuk
menguji respon sistem EHS tersebut. Maklumat yang baru diambilkira dan dapat
membuktikan bahawa EHS dapat mengurangkan getaran sebanyak 50% akan tetapi
kajian yang lebih terperinci perlu dilaksanakan untuk membaiki respon getaran.
Tiada tuning dilakukan terhadap sistem kawalannya kerana sistem ini adalah suap
depan semata-mata dan pembaikan perlu dilakukan pada masa depan untuk
menjadikan sistem ini lebih efektif. Projek ini adalah projek pertama yang telah
dilaksanakan secara praktikal untuk membuktikan bahawa gabungan antara suspensi
aktif dan pasif adalah lebih efektif berbanding suspensi biasa.
10. viii
TABLE OF CONTENT
CHAPTER TITLE PAGE
DECLARATION OF PROJECT REPORT iii
DEDICATION iv
ACKNOWLEGMENT v
ABSTRACT vi
ABSTRAK vii
TABLE OF CONTENT viii
LIST OF TABLES x
LIST OF FIGURES xi
LIST OF ABBREVIATIONS xii
LIST OF APPENDICES xiii
1 INTRODUCTION
1.1 Electromagnetic Hybrid Suspension System (EHS) 1
1.2 Background 1
1.3 Problem Statement 2
1.4 Project Scope 3
1.5 Objectives 3
1.6 Outline of Project Report 4
2 LITERATURE REVIEW
2.1 Suspension Types 5
2.2 Shock Absorber 5
2.3 Suspension Medium 6
2.4 Electromagnetic Hybrid Suspension (EHS) 7
11. ix
2.5 Surface and Linear Displacement Sensors 7
2.6 The Microcontroller 8
3 METHODOLOGY
3.1 Introduction 10
3.2 Hardware Setup 10
3.3 Sensor Design 12
3.4 MOSFET and solenoid selection 14
3.5 MOSFET and Solenoid Arrangement 16
3.6 Power Consumption 16
3.7 The dsPIC30F4011 Microcontroller 18
3.8 ADC converter on 30F4011 19
3.9 Pulse-Width-Modulation in Microcontrollers 20
3.10 Microcontroller Circuit Design and Programming 20
3.11 Road Profile Design 22
3.12 Data Collection Method 26
4 RESULTS AND DISCUSSIONS
4.1 Introduction 27
4.2 Output Vibration Response of the RC Car 27
4.3 Uneven Surface Response 29
4.4 Paint Strip Response 31
4.5 Potholes Response 33
4.6 Bumper Response 35
4.7 Discussion 36
5 CONCLUSION AND RECOMMENDATIONS
5.1 Conclusion 37
5.2 Suggestions 38
REFERENCES 39
APPENDICES 40
12. x
LIST OF TABLES
TABLE TITLE PAGE
3.1 IRF530 Electrical Specifications 15
3.2 Solenoid output with varied voltages 17
3.3 Pin Connection to the 30F4011 19
13. xi
LIST OF FIGURES
FIGURE TITLE PAGE
3.1 Original car setup 11
3.2 Modified car setup (with EHS) 11
3.3 Sony Ericsson Xperia X8 Smartphone used as DAQ 12
3.4 GP2D120XJ00F Infra-red Analog Sensor 12
3.5 Analog distance IR sensor output versus distance 13
3.6 12 V Solenoid Suspension System (EHS) 15
3.7 Program Flowchart 21
3.8 Paint strip 22
3.9 Paint Strip Road Profile 22
3.10 Bumpers 23
3.11 Bumps Road Profile 23
3.12 Uneven road 24
3.13 Uneven Surface Road Profile 24
3.14 Road with Potholes 25
3.15 Potholes Road Profile 25
4.1 Acceleration versus Time Graph for Even Surface 28
4.2 Acceleration versus Time Graph for Uneven Surface Without EHS 30
4.3 Acceleration versus Time Graph for Uneven Surface With EHS 30
4.4 Acceleration versus Time Graph for Paint Strip Without EHS 32
4.5 Acceleration versus Time Graph for Paint Strip With EHS 32
4.6 Acceleration versus Time Graph for Potholes Without EHS 34
4.7 Acceleration versus Time Graph for Potholes With EHS 34
4.8 Acceleration versus Time Graph for Bumper Without EHS 35
4.9 Acceleration versus Time Graph for Bumper Without EHS 35
14. xii
LIST OF ABBREVIATIONS
EHS - Electromagnetic Hybrid Suspension System
IR - Infra-red
RC - Remote controlled
NiMH - Nickel-metal hydride
LiPO - Lithium polymer
MMC - Mitsubishi Motor Corporation
ECS - Electronically controlled suspension
DAQ - Data acquisition system
FYP - Final year project
F1 - Formula One
i.e. - In other words
TOF - Time of flight
m - Metres
cm - Centimetres
m/s - Meters per second
ms - milliseconds
RAM - Random access memory
ROM - Read-only memory
IC - Integrated circuit
I/O - Input/output
DC - Direct current
MOSFET - Metal–oxide–semiconductor field-effect transistor
FKE - Fakulti Kejuruteraan Elektrik
PWM - Pulse-width modulation
RM - Ringgit Malaysia (Malaysian currency)
ECU - Electronic Control Unit
15. xiii
LIST OF APPENDICES
APPENDIX TITLE PAGE
A FYP1 Gantt Chart 40
B FYP2 Gantt Chart 41
C Project Programming of the EHS system 42
16. CHAPTER 1
INTRODUCTION
1.1 Electromagnetic Hybrid Suspension System (EHS)
An Electromagnetic Hybrid Suspension System (EHS) is a concept where an
electromagnetic actuator or also known as a linear motor is coupled with a passive
suspension system. It is externally mounted in a sense that the electromagnetic
actuator is added to the existing system without making extensive changes. The
mechanism that sense the road surface is via front mounted sensor.
1.2 Background
The EHS system is relatively new in the sense that an electromagnetic
actuator is used but all the other components that is being used have been explored
extensively. The study of active or hybrid suspension systems can be traced back to
old days where researchers wanted a car that can provide good performance,
handling, and ride comfort. But the primary function of vehicle suspension is to
isolate the vehicle body and passengers from the oscillations created by the road
irregularities and produce a continuous road-wheel contact(Martins, Esteves et al.
1999). A practical use of an active suspension system was first demonstrated when
MMC developed the world’s first active ECS system (a means of actively controlling
a vehicle’s cornering attitude and dynamic performance) and adopted it in the 1987
Mitsubishi GALANT(Toru HASHIMOTO 2005). This spurred a beginning of the
17. 2
active suspension system and have been continuously improved as the years
progressed. Recently, Amar Bose of the Bose Corporation revealed that they have
manifested an electromagnetic active suspension system that have better response
than the traditional hydraulic active suspension system. But one of the disadvantage
of the fully active suspension system is cost. Active suspension have always been a
premium technology and have always exclusive to the high end, high performance
cars. Whereas by implementing the EHS, this issue can be resolved by
uncomplicated setup and without major changes to the existing system.
1.3 Problem Statement
The problem statement of the project are listed as follows.
(i) Low and medium range cars that is fitted with passive suspension system lack
ride comfort.
(ii) Bad road surface is inevitable and turns to a bad riding experience due to the
passive characteristics of passive suspension.
(iii) Comfortable suspension either in the form of semi or fully active suspension
system are exclusive to high-range, expensive cars only.
(iv) Fully active suspension systems require extensive modification to existing
suspension setups and is ideally constructed together with the initial car
design.
(v) Active suspension system requires large power to operate therefore requiring
larger and more powerful engines in order not to affect the cars' overall
engine performance.
18. 3
1.4 Project Scope
The project scope are listed as follows.
(i) Analysing the response characteristics of a passive suspension on a scaled
hardware suspension system model (e.g. remote control car model).
(ii) Obtaining the data using the offline portable Data Acquisition (DAQ)
hardware and software.
(iii) Generating appropriate responses based on data acquired to control the
actuation of the EHS system.
(iv) Compensation design using analysis, control, compensation and estimation
methods in modern control system.
(v) Type of sensor that will be used in this project is limited to surface detection
only.
1.5 Objectives
The objectives of the project are listed as follows.
(i) To obtain the response of passive suspension model of the scaled car model.
(ii) To obtain the response of an Externally Mounted Electromagnetic Hybrid
Suspension System when fitted to the scaled car model.
(iii) To simulate and control an Externally Mounted EHS System that actively
compensate linear changes of road surface in order to reduce or eliminate
body oscillation when going through uneven surface.
19. 4
1.6 Outline of Project Report
Chapter 2 provide an introduction, overview and details of the EHS system.
Each of the components are reviewed and discussed as how the system tends to
operate.
Chapter 3 explains and demonstrates how the EHS system is carried out and
tested. The methodology also include specific method of implementing the EHS on
an RC car and how the data was collected.
Chapter 4 presents the results that was obtained and further discusses on it.
All the results are plotted into graphs and a comparison is made between EHS and
non-EHS.
Finally in Chapter 5, the conclusions and suggestions for further
developments are summarized.
20. 5
CHAPTER 2
LITERATURE REVIEW
2.1 Suspension Types
There are three type of suspension system which is passive, semi-active, and
active. Passive suspension system is commonly used in the mass production cars due
to low cost, high reliability and simple mechanical setup(Martins, Esteves et al.
1999). But semi active suspension became popular due to the improve comfort and
performance. But a semi active suspension costs more that a passive suspension. The
active suspension system is mostly used in high performance sport cars. It was even
used in the Formula One Racing Grand Prix in 1993 but was banned later due to the
fact that the F1 cars were going through the corners too fast and pose a high safety
risk. The active suspension offers high performance and ride comfort that the other
types of suspension cannot. But the downside of the active suspension is that it has
high maintenance and construction cost.
2.2 Shock Absorber
Shock absorbers slow down and reduce the magnitude of vibratory motions
by turning the kinetic energy of suspension movement into heat energy that can be
dissipated through hydraulic fluid. To understand how this works, it's best to look
inside a shock absorber to see its structure and function.
21. 6
A shock absorber is basically an oil pump placed between the frame of the
car and the wheels. The upper mount of the shock connects to the frame (i.e., the
sprung weight), while the lower mount connects to the axle, near the wheel (i.e., the
unsprung weight). In a twin-tube design, one of the most common types of shock
absorbers, the upper mount is connected to a piston rod, which in turn is connected to
a piston, which in turn sits in a tube filled with hydraulic fluid. The inner tube is
known as the pressure tube, and the outer tube is known as the reserve tube. The
reserve tube stores excess hydraulic fluid.
When the car wheel encounters a bump in the road and causes the spring to
coil and uncoil, the energy of the spring is transferred to the shock absorber through
the upper mount, down through the piston rod and into the piston. Orifices perforate
the piston and allow fluid to leak through as the piston moves up and down in the
pressure tube. Because the orifices are relatively tiny, only a small amount of fluid,
under great pressure, passes through. This slows down the piston, which in turn
slows down the spring.
All modern shock absorbers are velocity-sensitive, the faster the suspension
moves, the more resistance the shock absorber provides. This enables shocks to
adjust to road conditions and to control all of the unwanted motions that can occur in
a moving vehicle, including bounce, sway, brake dive and acceleration squat.(Harris
2005)
2.3 Suspension Medium
Most suspension systems be it a passive, semi-active, or active suspension
uses either pneumatic, hydraulic or electromagnetic medium as a method to suspend
and absorb the car. As the years progressed by, new technology has enabled
automotive engineers to come up with new ways to in providing better suspension
systems.
22. 7
Pneumatic and hydraulic types of suspension is commonly used due to cheap
cost to build and hydraulic has been the more favourable because of easier
construction.
The electromagnetic suspension system is a new technology that is being
explored but the concept was known earlier with the exception that other supporting
technology was not available yet at that time. An electromagnetic suspension is
basically a linear motor that levitates the shaft that is connected to the wheels so that
it acts as an invisible spring and damper.
2.4 Electromagnetic Hybrid Suspension (EHS)
An electromagnetic hybrid suspension system is basically an electromagnetic
actuator coupled in parallel to a passive suspension. This creates a controllable high
response suspension system that have lower power consumption than a normal active
suspension system. It features robustness like a normal passive suspension system
and does not require major modification to the existing system. The EHS is still
categorised as an active suspension due to the active actuator component. For low
bandwidth vibrations, the passive system covers the damping and isolation of that
vibration from that car chassis. When the vehicle enters big holes or high bandwidth
vibrations, the linear motor (electromagnetic actuator) move accordingly to the road
surface so that it cancels out the vibration.
2.5 Surface and Linear Displacement Sensors
There are many techniques in obtaining linear displacement but in this
project, non invasive sensors are being researched because invasive methods will
cause drag and interference to the chassis of the car. Some types of the sensors being
explored are infrared, ultrasonic and laser.
23. 8
Laser distance measurement have long been used for quick and precise
distance measurement. But the major disadvantage of this is that it is a very
expensive technology. Furthermore, the construction of the sensor is such that it is
not robust. Therefore, if being mounted on the chassis of a car, the laser sensor will
be damaged.
The ultrasonic sensor is also considered as a good distance sensor. The
ultrasonic is usually used in cars for keeping a safe distance while the car is to be in
reverse gear. The detectable distance ranges about from 10 cm to 200 cm. For
conditioning the very weak signal that is due to its small membrane area and based
on the time-of-flight (TOF) measuring, we need a great deal of circuits(Chin-Fu,
Yuan-Kai et al. 2011). This TOF is the time elapsed between the emission and
subsequent arrival after reflection of an ultrasonic pulse train travelling at the speed
of sound (approximately 340 m/s). This causes large response times (35 ms for
objects placed 6 m away) for a single measurement(Benet, Blanes et al. 2002).
Measuring distance using infrared is relatively new to the other sensors but
significant study and result have been obtained and proves that IR sensors can be
viable to be used as surface distance measurement(Benet, Blanes et al. 2002). The
robustness of infrared makes this type of sensor favourable and suitable to be placed
on a car chassis.
2.6 The Microcontroller
Microcontrollers must contain at least two primary components – random
access memory (RAM), and an instruction set. RAM is a type of internal logic unit
that stores information temporarily. RAM contents disappear when the power is
turned off. While RAM is used to hold any kind of data, some RAM is specialized,
referred to as registers. The instruction set is a list of all commands and their
corresponding functions. During operation, the microcontroller will step through a
program (the firmware). Each valid instruction set and the matching internal
hardware that differentiate one microcontroller from another(John 2000).
24. 9
Most microcontrollers also contain read-only memory (ROM), programmable
read-only memory (PROM), or erasable programmable read-only memory (EPROM).
Al1 of these memories are permanent: they retain what is programmed into them
even during loss of power. They are used to store the firmware that tells the
microcontroller how to operate. They are also used to store permanent lookup tables.
Often these memories do not reside in the microcontroller; instead, they are
contained in external ICs, and the instructions are fetched as the microcontroller runs.
This enables quick and low-cost updates to the firmware by replacing the ROM.
The number of I/O pins per controllers varies greatly, plus each I/O pin can
be programmed as an input or output (or even switch during the running of a
program). The load (current draw) 18 that each pin can drive is usually low. If the
output is expected to be a heavy load, then it is essential to use a driver chip or
transistor buffer.
Most microcontrollers contain circuitry to generate the system clock. This
square wave is the heartbeat of the microcontroller and all operations are
synchronized to it. Obviously, it controls the speed at which the microcontroller
functions. All that needed to complete the clock circuit would be the crystal or
resistance/capacitance circuit components. We can, therefore precisely select the
operating speed critical to many applications.
To summarize, a microcontroller contains (in one chip) two or more of the
following elements in order of importance (Duarte 1998):
i. Instruction set
ii. RAM
iii. ROM,PROM or EPROM
iv. I/O ports
v. Clock generator
vi. Reset function
vii. Watchdog timer
viii. Serial port
ix. Analog-to-digital converters
25. 10
CHAPTER 3
METHODOLOGY
3.1 Introduction
In order to realise and test the Electromagnetic Hybrid Suspension System
(EHS), there were a lot of preparation and prior setup so that the data collection can
be done. Step that were taken are: setting up the hardware, selecting the sensor,
solenoid and microprocessor, determining power consumption, programming the
microcontroller and designing the road profiles. Only then the data collection could
be carried out.
3.2 Hardware Setup
All the figures below shows the instruments that was used throughout the
project. Figure 3.1 shows the original car setup that has not been modified. All the
components are labelled as follows.
26. Figure 3.2 sho
solenoids, three extra b
which altogether works
Fig
McPherson
type
suspension
Front
sponge
Solenoid
Figure 3.1: Original car setup
.2 show the car setup after it is modified and
extra batteries, two IR sensors and a dsPIC 30F401
works as an EHS system.
Figure 3.2: Modified car setup (with EHS)
Tyres Plastic
chassis Battery
DC Motor
Speed
controller
Steering
Servo
rson
sion
Wireless
receiver
11
d and fitted with four
0F4011 microcontroller
Rear
suspension
Solenoid
27. 12
Figure 3.3 shows the smart phone model, Sony Ericsson Xperia X8 that was
used as a DAQ.
Figure 3.3: Sony Ericsson Xperia X8 Smartphone used as DAQ
3.3 Sensor Design
Measuring distance using infrared is relatively new to the other sensors but
significant study and result have been obtained and proves that IR sensors can be
viable to be used as surface distance measurement(Benet, Blanes et al. 2002). The
robustness of infrared makes this type of sensor favourable and suitable to be placed
on a car chassis. In this project, the Sharp GP2D120XJ00F Analog Distance sensor
was used as shown in Figure 3.4.
Figure 1: GP2D120XJ00F Infra-red Analog Sensor
28. 13
It has a range of 4 cm to 30 cm and operates at 5 V. This sensor also has good
detection rate due to the fact that it still can retain consistent readings even though
with low reflectance surfaces of 18%. Figure 3.5 shows its output range according to
distance.
Figure 3.5: Analog distance IR sensor output versus distance
29. 14
The sensor is positioned at the front left and front right of the RC car chassis
so that the surface of the incoming road can be detected before it reaches the tyres.
The height of the sensor was set to 5 cm from the ground that gives a minimum of
2.0 V and a maximum of 2.5 V, with the distance range of 2 cm.
It was initially planned that a total of four analog distance sensors to be used
in front of each wheel but due to cost limitation, only two sensors were used.
Therefore to compensate the reduction of sensors, a delay was added to the output for
the rear solenoid so that it behaves similar to the planned setup.
3.4 MOSFET and solenoid selection
The MOSFET that was selected for this project was the IRF530 an N-
Channel Power MOSFET that features a maximum of 14 A and 100 V. These are N-
Channel enhancement mode silicon gate power field effect transistors. They are
advanced power MOSFETs designed, tested, and guaranteed to withstand a specified
level of energy in the breakdown avalanche mode of operation. All of these power
MOSFETs are designed for applications such as switching regulators, switching
convertors, motor drivers, relay drivers, and drivers for high power bipolar switching
transistors requiring high speed and low gate drive power. These types can be
operated directly from integrated circuits.
The reason of selecting particularly the IRF530 for this project is that it is
readily available from the FKE store and specifically the N-channel is the correct
type to receive PWM output from the 30F4011 microprocessor due to its very fast
on-off timing. Table 3.1shows some of the electrical characteristics obtained from its
datasheet.
30. 15
Table 3.1: IRF530 Electrical Specifications
The solenoid that was selected is a 12 V generic solenoid. Specific details are
not available and there were no datasheet provided. Therefore, the type of solenoid
that was selected was based on how strong the solenoid can pull based on samples
obtained. Figure 3.6 depicts the selected solenoid that is the blue open frame 12 V
solenoid due to it reasonable price and strong pulling force.
Figure 3.6: Open Frame 12 V Solenoid
31. 16
3.5 MOSFET and Solenoid Arrangement
A total of four MOSFETs were used, one for each solenoid. The solenoid is
placed at each suspension brackets in such a way that it has the best efficiency in the
force being applied when the solenoid is active. The height of the solenoids are
adjusted to a position where the solenoid core is at the center position between the
lowest and highest points. This position helps to give the best minimum and
maximum height of the wheels in reference to the RC car chassis when going
through uneven surface.
3.6 Power Consumption
Before the solenoid was assembled to the chassis, it was first tested in a
laboratory to obtain its power requirements, the maximum force that it can sustain
and the maximum distance at selected voltage levels.
The equipments that were used in this research are as follows: a food scale, a
variable voltage supply, an ammeter, a ruler, and the solenoid that was to be tested.
The end of the solenoid that was to be pushed is pressed lightly to the food scale that
is on its back and has been set to zero. The wires coming out of the solenoid was
connected to the positive and negative terminals of the power supply. Different
voltages were applied and solenoid distance readings, current readings and the strain
on the food scale was all recorded into Table 3.2 as shown.
32. 17
Table 3.2: Solenoid output with varied voltages
Volts (V) Amperes (A) Distance (cm) Strain (grams)
5.0 0.23 1.00 20
5.5 0.26 1.00 70
6.0 0.28 1.00 80
6.6 0.30 1.10 80
7.0 0.33 1.10 100
7.6 0.35 1.10 180
8.5 0.38 1.20 200
9.5 0.42 1.20 250
10.5 0.46 1.25 300
11.5 0.50 1.25 320
12.7 0.53 1.30 350
From the data obtained, the strength of the solenoid at 12.7 V is not enough to
make significant actuation when it is fitted together with a spring and the solenoid
was rated at a maximum of 12 V. Therefore, higher voltage was applied and at 20 V,
the force of the solenoid is strong enough to actuate. This causes the solenoid to heat
up but in this particular application, the heat build-up is negligible because only part
of the time the solenoid needs to be at its most powerful state. Other times the
solenoid only needs a small amount of power to help dampen the passive suspension.
In order to meet the requirement of four solenoids requiring a total maximum
of 8 amperes and a minimum of 20 V, three NiMH 7.2 V batteries were connected in
series to produce 21.6 V.
33. 18
3.7 The dsPIC30F4011 Microcontroller
The microcontroller acts as the RC car Electronic Control Unit (ECU) and as
the EHS control system. The microcontroller chip that has been selected for the
purpose of controlling the speed of DC motor is the dcPIC30F4011 manufactured by
Microchip. This chip is selected based on several reasons:
i. Its size is small and equipped with sufficient output ports without having to
use a decoder or multiplexer.
ii. Its portability and low current consumption.
iii. It has 6 PWM output with 3 individual oscillators and also 4 CCP
oscillators output integrated within the chip itself which allows the duty
cycle to be varied accordingly to give different voltage output to the
solenoid.
iv. It is a very simple but powerful microcontroller. Users would only need to
learn 35 single word instructions in order to program the chip.
v. It can be programmed and reprogrammed easily (up to 10,000,000 cycles)
using the MicroC for dsPIC programmer available free on the internet.
Table 3.3 shows the pin connection of dsPIC30F4011for the EHS control
system. Pins not stated in the table are not used and left floating. First, the
microcontroller receives input from the analog inputs AN0 and AN1. The converted
reading of the ADC is feed forwarded to the PWM output port. The microcontroller
performs the calculations based on the program designed (detail program at
Appendix C) to produce a new duty cycle that is proportional to the analog input of
the IR sensor. Thus, the voltage applied to the solenoid can be varied in order to
obtain the desired level of pull to compensate for uneven surfaces.
34. 19
Table 3.3: Pin Connection to the 30F4011
Pin Name Pin Number Description Application
AN0 2 Analog input Analog input from left IR sensor
AN1 3 Analog input Analog input from right IR sensor
PWM1H 37 PWM output Output to front left solenoid
PWM2H 35 PWM output Output to front right solenoid
OC1 23 PWM output Output to rear left solenoid
OC3 22 PWM output Output to rear right solenoid
VDD 11,21,32 5V supply voltage Voltage supply to IR sensor
3.8 ADC converter on 30F4011
The 10-bit, high-speed Analog-to-Digital Converter (ADC) allows
conversion of an analog input signal to a 10-bit digital number. This module is based
on a Successive Approximation Register (SAR) architecture and provides a
maximum sampling rate of 1 Msps. The ADC module has 16 analog inputs which are
multiplexed into four sample and hold amplifiers. The output of the sample and hold
is the input into the converter which generates the result. The analog reference
voltages are software selectable to either the device supply voltage (AVDD/AVSS)
or the voltage level on the (VREF+/VREF-) pins. The ADC module has a unique
feature of being able to operate while the device is in Sleep mode. The ADC module
has six, 16-bit registers:
• A/D Control Register 1 (ADCON1)
• A/D Control Register 2 (ADCON2)
• A/D Control Register 3 (ADCON3)
• A/D Input Select Register (ADCHS)
• A/D Port Configuration Register (ADPCFG)
• A/D Input Scan Selection Register (ADCSSL)
35. 20
The ADCON1, ADCON2 and ADCON3 registers control the operation of the ADC
module. The ADCHS register selects the input channels to be converted. The
ADPCFG register configures the port pins as analog inputs or as digital I/O. The
ADCSSL register selects inputs for scanning.
3.9 Pulse-Width-Modulation in Microcontrollers
The Pulse-Width-Modulation (PWM) in the microcontroller is used to control
duty cycle of the output to give different levels of voltage output to the solenoid.
Duty cycle refers to the percentage of one cycle during which duty cycle of a
continuous train of pulses. 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 the duty cycle in PWM.
3.10 Microcontroller Circuit Design and Programming
A microcontroller is basically a small computer that can calculate and
compute any data given to it so that controlling a process is automatically controlled
without continuous monitoring from the user. There are many types of
microcontrollers available but a couple of considerations must be made in choosing
the appropriate model.
The microcontroller must be fast enough to obtain the analog output of the
distance sensor, convert to digital values using its internal analog to digital converter
(ADC), compute the data and send out four individual PWM signals to the solenoids.
The microcontroller must also be as low cost as possible. Therefore the suitable chip
that was selected is the 30F4011 from Microchip that supports up to 6 PWM outputs.
The basic flowchart of how the 30F4011 is programmed is shown below.
36. The program o
and configuring all inp
input except for pin B0
order to ensure that the
and not as high and lo
will give PWM outpu
reference is set to 0 V
The program th
using the integrated AD
variable. The value is
and if true, it is calcula
0% ~ 100%. The duty
appropriate voltage ou
reading the analog inpu
Figure 27: Program Flowchart
ram of EHS control within the 30F4011 starts of
all input and output ports of the controller. All of
pin B0 and B1 which were set to analog input. Th
hat the data sent from the analog IR sensor is read w
and lows. The output PORTD and PORTE are con
outputs. The ADCON ports are configured so
V ~ 5 V and the frequency of the PWM are set
ram the n enters a loop that reads the analog inpu
ted ADC converter and stores the digital value int
lue is then checked whether it is in range of the a
alculated to return a value in the format of a duty c
e duty cycle is then set to the PWM outputs so th
age output to the solenoid. The program then
g input and so on until the program is switched off
21
arts off with initialising
All of PORTB is set to
ut. This is important in
read with proper values
are configured so that it
ed so that the voltage
re set to 200 kHz.
g input and converts it
lue into the l_ir and r_ir
f the allowable distance
duty cycle ranging from
so that it will give the
then repeats again by
ed off.
37. 22
3.11 Road Profile Design
The road profile design was inspired by real life examples of road surfaces
and conditions. Research was done by testing out common road surfaces that gives
discomfort to the drivers and passengers of a typical car and determined four
common road surfaces that could be modelled and scaled so that it is suitable for the
RC car to test out. The four road profiles are; potholes, paint strips, speed bumps and
uneven surface.
Figure 3.8 is a picture of paint strips that are usually located before entering
toll booths. These paint strips create repetitive vibrations that causes discomfort to
the passengers inside the car. Therefore, the road profile in Figure 3.9 tries to mimic
the road effect of paint strips.
Figure 3.8: Paint strip
Figure 3.3: Paint Strip Road Profile
38. 23
The road bumpers or also known as speed bumps shown in Figure 3.10 are
fairly common in any roads. The main purpose of a speed bump is to slow down a
moving car because the road ahead is not safe to be driven fast. With safety as its
main purpose, the effect of discomfort is often neglected when the bums are placed.
Figure 3.11 is the road profile that was constructed and two types of bumps were
made. On the left is a small bump and the right is a wider bump.
Figure 3.10: Road Bumpers
Figure 3.11: Bumps Road Profile
The effects of heavy load, heavy rain and thin layer of tarmac causes the road
to corrode as depicted in Figure 3.12. this uneven plane still causes some discomfort
to drivers and passengers when going through it. The uneven surface road profile in
Figure 3.13 is a sample of how an uneven road surface is like.
39. 24
Figure 3.12: Uneven road
Figure 3.13: Uneven Surface Road Profile
Potholes in roads as shown in Figure 3.14 are also common due to the soft
soil the road was laid upon. The potholes ted to get bigger as time passes by because
of corrosion. The potholes road profile in Figure 3.15 has different depth of holes so
that the effect on the RC car would be different.
40. 25
Figure 3.14: Road with Potholes
Figure 3.15: Potholes Road Profile
The base material that was used in making the road profile is polystyrene
boards with a thickness of 12 mm. To create the different surfaces, cardboards and
newspapers were used and stuck together using cellophane tapes. Then it is covered
by diluting glue and shredded newspaper together to create a hardened surface when
dry. Mural paints were used to colour the surface and draw out lines to mimic the
colours of real life road surfaces.
41. 26
3.10 Data Collection Method
At first the data collection was done via a USB DAQ by National
Instruments(M. F. Rahmat 2009; Mohd. Fua’ad Rahmat 2010), but problem arise
because the DAQ needs to be connected to the USB port of the computer in order to
operate. Therefore an alternative was discussed and the idea of using an
accelerometer inside a smart phone was chosen as the solution.
In order to obtain the data of the integrated accelerometer in the smart phone,
an application was needed to obtain and store the output of the accelerometer. After
searching the Android Market, an application named Accelerometer Toy developed
by Chris Pearson was found as the most suitable to be used in this project. Therefore,
the smart phone is mounted on top of the RC car while going through the different
surfaces. The result is calculated and displayed in excel in the form of a line graph.
42. 27
CHAPTER 4
RESULTS AND DISCUSSIONS
4.1 Introduction
In total, two experiments were conducted to obtain the output vibration data
from the smart phone, where the first one is the response of the car without the EHS
system and then with the EHS system. In this section, the results are arranged so that
we can compare the outputs of before and after EHS so that we can see whether the
system has improved the original response.
4.2 Output Vibration Response of the RC Car
The following graphs shows the amplitude of vibration detected by the
accelerometer when the RC car runs through the road profiles. Bigger amplitudes
means higher vibration and higher force of acceleration is exerted on to the car.
Therefore, the ideal goal is to obtain a constant line output as close to steady-state
acceleration as possible. The graph shows the vibration about the Z axis which is in
line with the gravity, explaining the 10ms-2
offset.
43. 28
Figure 4.1: Acceleration versus Time Graph for Even Surface
Figure 4.1 is the vibration response of the car when going through an even
flat surface. It is used as a reference to the other responses and this response shows
that there is still some disturbance in the readings of the accelerometer even though
going through an even surface. There are many sources of this disturbance and one of
them is the unbalanced and uneven surface of the tyres of the RC car.
0
2
4
6
8
10
12
14
16
0
0.136
0.272
0.408
0.544
0.681
0.817
0.953
1.089
1.226
1.362
1.498
1.645
1.781
1.917
2.054
2.19
2.326
2.462
2.598
2.734
2.871
3.007
3.143
Acceleration(m/s2)
Time (s)
Even Surface Graph (no EHS)
Z axis
44. 29
4.3 Uneven Surface Response
Figure 4.2 and 4.3 shows the difference between the response of the RC car
with and without the EHS system when going through an uneven surface. From
Figure 4.2, the maximum and minimum point of acceleration without EHS are at 14
m/s2
and 5.5 m/s2
respectively. When the car has EHS enabled, the maximum and
minimum points have greatly reduced to 12 m/s2
and 7.9 m/s2
. The EHS output
response is also more uniformed than non EHS output response. Here the effect of
implementing EHS can be seen clearly.
45. 30
Figure 4.2: Acceleration versus Time Graph for Uneven Surface Without EHS
Figure 4.3: Acceleration versus Time Graph for Uneven Surface With EHS
0
2
4
6
8
10
12
14
16
0
0.122
0.242
0.358
0.475
0.612
0.734
0.849
0.965
1.081
1.198
1.316
1.433
1.569
1.685
1.8
1.939
2.054
2.17
2.286
2.402
2.518
2.634
Acceleration(m/s2)
Time (s)
Uneven Surface Graph (no EHS)
Z axis
0
2
4
6
8
10
12
14
16
0
0.17
0.327
0.484
0.641
0.799
0.957
1.115
1.272
1.43
1.588
1.746
1.904
2.062
2.22
2.378
2.535
2.718
2.877
3.035
3.192
3.35
3.507
3.664
Accelleration(m/s2)
Time (s)
Uneven Surface Graph (EHS)
Z axis
46. 31
4.4 Paint Strip Response
Figure 4.4 and 4.5 shows the difference between the response of the RC car
with and without the EHS system when going through a paint strip road profile.
From Figure 4.4, the maximum and minimum point of acceleration without EHS are
at 13 m/s2
and 1 m/s2
respectively. There is also clear dips in acceleration that can be
translated to very poor riding comfort. When the car has EHS enabled in Figure 4.5,
the maximum and minimum points have sufficiently reduced to 13 m/s2
and 5.8 m/s2
.
The EHS output response is also more uniformed than non EHS output response.
Here the improved response of implementing EHS can be seen clearly.
47. 32
Figure 4.4: Acceleration versus Time Graph for Paint Strip Without EHS
Figure 4.5: Acceleration versus Time Graph for Paint Strip With EHS
0
2
4
6
8
10
12
14
16
0
0.168
0.336
0.504
0.673
0.841
1.01
1.18
2.553
3.356
3.357
3.358
3.359
3.36
3.361
3.368
3.369
3.37
3.371
3.373
3.435
3.603
3.771
Accelleration(m/s2)
Time (s)
Paint Strip Graph (no EHS)
Z axis
0
2
4
6
8
10
12
14
16
0
0.178
0.356
0.535
0.713
0.891
1.069
1.247
1.425
1.603
1.781
1.969
2.147
2.325
2.503
2.681
2.859
3.037
3.215
3.393
3.571
3.749
3.928
4.116
Accelerometer(m/s2)
Time (s)
Paint Strip Graph (EHS)
Z axis
48. 33
4.5 Potholes Response
Figure 4.6 and 4.7 shows the difference between the response of the RC car
with and without the EHS system when going through the potholes road profile.
From Figure 4.4, the maximum and minimum point of acceleration without EHS are
at 15.8 m/s2
and 1.8 m/s2
respectively. There is also clear dips and very irregular
spacing in acceleration that can be translated to very poor riding comfort. When the
car has EHS enabled as shown in Figure 4.7, the maximum and minimum points
have sufficiently reduced to 13 m/s2
and 6 m/s2
. The EHS output response is also
more uniformed than non EHS output response. Here the improved response of
implementing EHS can be seen.
49. 34
Figure 4.6: Acceleration versus Time Graph for Potholes Without EHS
Figure 4.7: Acceleration versus Time Graph for Potholes With EHS
0
2
4
6
8
10
12
14
16
0.00…
0.09…
0.19…
0.29…
0.39…
0.55…
0.61…
0.71…
0.80…
0.93…
1.02…
1.14…
1.23…
1.33…
1.42…
1.52…
1.61…
1.71…
1.80…
1.90…
1.99…
2.09…
2.18…
2.28…
Acceleration(m/S2)
Time (s)
Potholes Graph (no EHS)
Z axis
0
2
4
6
8
10
12
14
16
0
0.147
0.294
0.441
0.587
0.734
0.881
1.028
1.174
1.321
1.468
1.615
1.761
1.908
2.054
2.201
2.347
2.494
2.641
2.787
2.934
3.081
3.228
3.374
Acceleration(m/s2)
Time (s)
Pothole Graph (EHS)
Z axis
50. 35
4.6 Bumper Response
Figure 4.8: Acceleration versus Time Graph for Bumper Without EHS
Figure 4.9: Acceleration versus Time Graph for Bumper With EHS
0
2
4
6
8
10
12
14
16 0
0.122
0.239
0.346
0.459
0.564
0.695
1.082
1.083
1.083
1.152
1.257
1.362
1.47
1.575
1.681
1.805
1.91
2.02
2.13
2.235
2.341
2.451
2.558
Acceleration(m/s2)
Time (s)
Bumper Graph (no EHS)
Z axis
0
2
4
6
8
10
12
14
16
0
0.157
0.315
0.472
0.629
0.786
0.943
1.101
1.257
1.415
1.572
1.729
1.886
2.043
2.2
2.358
2.515
2.672
2.829
2.987
3.144
3.301
3.458
Acceleration(m/s2)
Time (s)
Bumper Graph (EHS)
Z axis
51. 36
Figure 4.8 and 4.9 shows the difference between the response of the RC car
with and without the EHS system when going through a bumper road profile. From
Figure 4.8, the maximum and minimum point of acceleration without EHS are at
15.8 m/s2
and 0.6 m/s2
respectively. The change in acceleration is very high can be
interpreted to very bad riding comfort. Particularly this response is the worst
response to have been collected. When the car has EHS enabled as shown in figure
4.9, the maximum and minimum points have not changed much to 16 m/s2
and 1
m/s2
. Although the EHS output response have not changed much of its minimum and
maximum extremes, but it has reduced a significant amount of vibration. The EHS is
less effective here because the range of the bumpers are very big and the IR sensor
fails to pick up its distance in relation to the ground.
4.7 Discussions
Figures 4.2 to 4.9 generally proves that by applying the EHS system, the
vibration amplitude of the RC car is significantly reduced thus giving a more
comfortable ride. The EHS was tested on four different road profiles and all of the
output improved around 50% except for the bumper profile where the improvement
is around 30%. This may be due to the fact the surface size of the bumpers is large
and the actuation of the solenoid is not enough to compensate the vibration effect.
As we can see from the comparisons, the response is not linear as we had
hoped but there more room for improvement. The tests were conducted with the
slowest speed possible for the RC car but no specific control mechanism was placed
to make sure the speed was constant. But as a whole the results shows that by
implementing EHS, there is significant difference in the output response.
52. 37
CHAPTER 5
CONCLUSION AND RECOMMENDATIONS
5.1 Conclusion
In the automotive industry, continuous research and improvements have
contributed to better performance and comfort to automotive users. There are many
aspects that have been greatly improved and there are many more to be improved.
Electronics has been an integral part of advancement in technology over the
years and the automotive industry have transitioned from a mix of analogue and
mechanical to a fusion of mechanical, digital and electronics. Drive train has slowly
improved from internal combustion engines to DC motors where it is more efficient
and powerful.
Thus, it is inevitable that the suspension system is also following the trend of
transitioning to an electrical approach. The suspension system has always been
faithful in providing the best possible comfort at the best possible value. By turning
to a hybrid suspension system that implements modern control technology and fast
computing, better comfort and value can be achieved.
Therefore, by exploring the Electromagnetic Hybrid Suspension System
(EHS) practically we have managed to obtain proof that the system can actively
compensate the effects of different road surfaces to reduce the vibration onto the RC
car chassis. This in turn can prove that if implemented in a real car, it can improve
ride comfort for the driver and passengers inside.
53. 38
5.2 Suggestions
The EHS system was implemented using the solenoid as the actuator due to
simplicity mechanically, but for future improvements, other methods of actuation
should be considered such as using a servo motor instead by varying the angle based
on the input. This method can be explored but its response time must be improved
first in order to exploit its advantages such as precision and control.
The mechanical action of the solenoid that was being used is limited to a
pulling action. It could be replaced with an electromagnetic actuator that could have
more precise linear positioning and also having both push and pull action.
The microprocessor used in this project could be replaced with an Adriano
Board that is a lot more simple and specific. Another suggestion is to use two
controllers or a controller that has multithreading so that the calculation could be
processed faster. Also, microprocessors could be replaced with hardware circuitry to
provide faster signal conditioning and signal processing so that the overall response
could be improved.
The control system that was implemented in the EHS is only a feed forward
control. By adding a feedback loop to the system with an accelerometer and/or a
gyroscope as the feedback sensor, the output could be improved significantly and
errors could be minimised or ideally eliminated(Nise 2008).
An addition to the two IR analog distance sensor, two more sensor should be
fitted to the system so that all four tyres are independent and will respond
individually to the road irregularities this providing even better response. Also, a
speed sensor is an essential improvement to be implemented so that the actuator can
respond differently depending on the current speed the car is going.
Due to cost limitations in order to ensure that the EHS is cheaper than an
active suspension, cheap heavy inefficient batteries were used. As an improvement,
lighter batteries such as the LiPO (lithium polymer) battery should be used due to its
light weight and large capacity.
54. 39
REFERENCES
Benet, G., F. Blanes, et al. (2002). "Using infrared sensors for distance measurement in
mobile robots." Robotics and Autonomous Systems 40(4): 255-266.
Chin-Fu, T., W. Yuan-Kai, et al. (2011). Implementation and analysis of range-finding based
on infrared techniques. Control Conference (ASCC), 2011 8th Asian.
Duarte, L. A. (1998). The Microcontroller Beginner's Handbook, Prompt Publication.
Harris, W. (2005). "How Car Suspensions Work." from http://auto.howstuffworks.com/car-
suspension.htm.
John, I. (2000). PIC Microcontroller Project Book, Mc Graw-Hill.
M. F. Rahmat, Z. (2009). "Application of Self-tuning Fuzzy Logic PID Controller on Industrial
Hydraulic Actuator Using System Identification Approach." International Journal On Smart
Sensing And Intelligent Systems 2(2).
Martins, I., M. Esteves, et al. (1999). Electromagnetic hybrid active-passive vehicle
suspension system. Vehicular Technology Conference, 1999 IEEE 49th.
Mohd. Fua’ad Rahmat, N. W., Kamaruzaman Jusoff (2010). "Comparative Assessment Using
LQR and Fuzzy Logic Controller for a Pitch Control System." European Journal of Scientific
Research Vol.42(No.2): 184-194.
Nise, N. S. (2008). Control Systems Engineering, John Wiley & Sons (Asia) Pte Ltd.
Toru HASHIMOTO, K. F., Nobuhiro OIKAWA, Tateo KUME (2005). "Technology DNA of
MMC." Mitsubishi Motors Technical Review(17).
55. Work Plan Part 1
APPENDIX A
Figure A: FYP1 Gantt Chart
40
56. Work Plan Part 2
APPENDIX B
Figure B: FYP2 Gannt Chart
41
57. 42
APPENDIX C
Project Programming for the EHS system
int l_ir,r_ir;
int k;
int l_fb,r_fb;
int spd;
unsigned int pwm_period1, pwm_period2;
int main(void)
{
// Configure analog inputs
TRISB = 0x01FF; // Port B all inputs
ADPCFG = 0xFFF8; // Lowest 3 PORTB pins are analog inputs
ADCON1 = 0; // Manually clear SAMP to end sampling, start conversion
ADCON2 = 0; // Voltage reference from AVDD and AVSS
ADCON3 = 0x0005; // Manual Sample, ADCS=5 -> Tad = 3*Tcy = 0.1us
ADCON1bits.ADON = 1; // Turn ADC ON
// Frequency - approx.200KHz
58. 43
PTPER = 0x0032; // 0x0032 = 50
PTCON = 0x8000; // Enabling the PWM Motor Control module
PWMCON1 = 0x0f03; // RE0,RE2 are configured as PWM outputs whereas rest
are Normal I/Os(PWM1L & PWM2L)
PWMCON2 = 0x0000; // Configured to obtain Duty Cycle through PDC registers
PTMR = 0x0000;
PDC3 = 0x0000;
TRISD=0x0000; // Set PORTD as output
PORTD=0x0000; // Initialise all zero
pwm_period1 = PWM_Init(200000 , 2, 1, 2); //Initialise Simple PWM at PORTD
pwm_period2 = PWM_Init(200000 , 4, 1, 3);
PWM_Start(2);
PWM_Start(4);
while(1){
l_ir =ADC1_read(0); // read from analog in
if((l_ir<650)&&(l_ir>570)){ // check if sensor is in range
PDC1 = ((l_ir-540)/80.0)*100; // set duty cycle of front left solenoid appropriately to
analog in
}
else PDC1=0x0000; // set zero if not in range
r_ir =ADC1_read(1);
59. 44
if((r_ir<650)&&(r_ir>570)){
PDC2 = ((r_ir-540)/80.0)*100; // set duty cycle of front right solenoid appropriately to
analog in
}
else PDC2=0x0000;
l_fb = PDC1*4; // convert to simple PWM duty
r_fb = PDC2*4;
PWM_Set_Duty(l_fb, 2); // Set current duty for PWM1
PWM_Set_Duty(r_fb, 4); // Set current duty for PWM2
}
}