Tesis de RC Car

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

DEGREE PROJECT IN TECHNOLOGY,

FIRST CYCLE, 15 CREDITS


STOCKHOLM, SWEDEN 2016








Advanced RC car

Avancerad radiostyrd bil

FILIP LENSUND

JOHAN ERKERS














































KTH ROYAL INSTITUTE OF TECHNOLOGY
SCHOOL OF INDUSTRIAL ENGINEERING AND MANAGEMENT
















This page has been intentionally left blank.

i


Bachelor Thesis MMKB 2016:31 MDAB092


Advanced RC car



Filip Lensund
Johan Erkers

Approved Examiner Supervisor
2016-06-07 Martin Edin Grimheden Nihad Subasic

ABSTRACT
This report contains improvements of the radio controlled car which is developing an
electronic differential and a speed controller. The report contains theory of engine
modelling, steering and testing of these theories. Ackerman steering is used to get
different steering radius of the inner and outer wheel when cornering. In order to regulate
the velocity of the rear wheels they are individually controlled by implementing two
separate controllers one for each wheel. To control the system PD-controllers is used for
a fast rise time, two types of PD-controllers are tested, feed-back and feed-forward.

A demonstrator was constructed to execute the two tests, one of the test was to determine
the electronic differentials efficiency by measuring the cornering ability of the car with
and without differential at different speeds. The second test was performed to determine
which regulator gave the fastest controlling of the speed. This by exposing both
controllers with different test scenarios.

Based on our tests the conclusion is drawn that the electronic differential had a very
positive impact on the turning radius. While testing, the controllers showed only a small
difference, where the feed-forward controller was slightly faster in some of the tests.

ii
















This page has been intentionally left blank.

iii

Kandidatarbete MMKB 2016:31 MDAB092

Avancerad radiostyrd bil

Filip Lensund
Johan Erkers

Godkänt Examinator Handledare


2016-06-07 Martin Edin Grimheden Nihad Subasic
SAMMANFATTNING
Rapporten behandlar förbättringar av den radiostyrda bilen med fokus på utveckling av
en elektronisk differential samt reglering av hastigheten. I rapporten kommer teori kring
motormodellering och styrning, samt tester av dessa teorier. Ackerman-styrning
användes för att få olika radie på inner och ytter hjulen vid kurvtagning. För att kunna
reglera hasigheten på bakhjulen individuellt implementerades två separata regulatorer.
För reglering av hastighet på bakhjulen användes PD-regulatorer för en snabb stigtid, två
typer av PD-regulatorer testades en feed-back och en feed-forward.

En demonstratör konstruerades för att möjliggöra tester av forskningsfrågorna. Det
första testet utfördes för att undersöka den elektroniska differentialaxelns inverkan på
bilens förmåga att ta kurvor i olika hastigheter. Det andra testet genomfördes för att
undersöka vilken regulator som gav den snabbade regleringen av hastigheten. Detta
genom att utsätta regulatorerna för olika test senarior.

Utifrån testerna kunde slutsatsen dras att den elektroniska differentialen har en mycket
stor positiv inverkan på bilens sväng radie. Medan testerna av regulatorerna endast gav
en marginell skillnad men Feed-Forward regulator var något snabbare i en del av
testerna.

iv
















This page has been intentionally left blank.

v

PREFACE
We would like to thank our supervisor Nihad Subasic for feedback and our dear friends
Simon Gärtner and Anton Dahlquist for the help and support.

Filip Lensund & Johan Erkers

Stockholm, June 2016


vi















This page has been intentionally left blank.

vii

NOMENCLATURE
For the convenience of the reader all the symbols and abbreviations have been gathered under
this chapter.

Symbols
Symbol Description
𝜃 Angle of the Ackerman-Steering (degrees)
𝐿# length between wheel axis(m)
𝐿$ length between front wheels(m)
𝑅# Radius outer wheel (m)
𝑅$ Radius inner wheel (m)
𝑋' Estimation (position)
𝐾' Kalman Gain
𝑍' Measured value
𝑋'*# Previous estimation (position)
U Voltage (V)
R Resisters (ohm)
i Current (A)
L Inductance (H)
𝑒,-. Back electro motive force (V)
𝜏- Torque produced by motor (Nm)
𝜏0 Torque produced by Wheel (Nm)
𝜑- Angle(rad)
𝜑- Angular velocity (rad/s)
𝐾2 Armature constant (Nm/A)
𝐾, Motor torque constant (V/A)
𝜑0 Velocity wheel (rad/s)
𝜑0 Acceleration wheel (rad/s2)
𝑟 Radius (m)
𝑣 Speed (m/s)
𝐽0 Moment of inertia for wheel (kgm2)
𝐽- Moment of inertia for motor (kgm2)
𝑑 Dynamic friction coefficient (𝜇)

viii

N Gear ratio
𝐾8 Proportional part parameter
𝐾9 Derivative part parameter

Abbreviations
CAD Computer Aided Design
DC Direct current
DMP Digital Motion Processor
DPS Degrees per second
𝐼 $ 𝐶 Inter-integrated Circuit
IMU Internal Measurement Unit
KTH Kungliga Tekniska Högskolan (Royal Institute of Technology)
MATLAB Computer Aided Engineering
PWM Pulse-width Modulation
RC Radio controlled
Rpm Revolution per minute

ix


CONTENTS
ABSTRACT ........................................................................................................................................................ II
SAMMANFATTNING ...................................................................................................................................... IV
PREFACE .......................................................................................................................................................... VI
NOMENCLATURE ........................................................................................................................................ VIII
CONTENTS ........................................................................................................................................................ X
1 INTRODUCTION .................................................................................................................................... 1
1.1 BACKGROUND ....................................................................................................................................................... 1
1.2 PURPOSE ............................................................................................................................................................... 1
1.3 SCOPE .................................................................................................................................................................... 1
1.4 METHOD ................................................................................................................................................................ 2
2 THEORY ................................................................................................................................................... 3
2.1 ELECTRONIC DIFFERENTIAL .............................................................................................................................. 3
2.2 ACKERMAN STEERING ........................................................................................................................................ 4
2.3 IMU ........................................................................................................................................................................ 4
2.4 ENCODER .............................................................................................................................................................. 5
2.5 KALMAN FILTER .................................................................................................................................................. 5
2.6 SMOOTH FILTER ................................................................................................................................................... 5
2.7 MODEL OF THE SYSTEM ...................................................................................................................................... 5
2.7.1 Model of the DC-motor ................................................................................................................................ 6
2.7.2 Model of the Gearbox and Wheel ............................................................................................................ 6
2.8 PD-CONTROLLER ................................................................................................................................................. 7
2.8.1 Transfer function PD-controller ............................................................................................................. 8
2.8.2 Pol-placement ................................................................................................................................................. 9
2.8.3 Implementation ............................................................................................................................................ 10
3 DEMONSTRATOR ................................................................................................................................ 11
3.1 PROBLEM FORMULATION ............................................................................................................................... 11
3.2 SOFTWARE ......................................................................................................................................................... 11
3.2.1 The software structure for the hand unit ......................................................................................... 11
3.2.2 The software structure in the car unit ............................................................................................... 11
3.3 ELECTRONICS .................................................................................................................................................... 12
3.3.1 Microcontroller ............................................................................................................................................ 12
3.3.2 Battery ............................................................................................................................................................. 12
3.3.3 Internal measurement unit or IMU ..................................................................................................... 12
3.3.4 Xbee ................................................................................................................................................................... 12
3.3.5 H-bridge ........................................................................................................................................................... 13
3.3.6 DC-motor and gearbox .............................................................................................................................. 13
3.3.7 Servo motor .................................................................................................................................................... 13
3.3.8 Encoder ............................................................................................................................................................ 13
3.3.9 Block diagram ............................................................................................................................................... 13
3.4 HARDWARE ....................................................................................................................................................... 14
3.4.1 Laser cut .......................................................................................................................................................... 14
3.4.2 3D-printed ...................................................................................................................................................... 14
3.4.3 Soldering ......................................................................................................................................................... 14
3.5 THE DEMONSTRATOR ...................................................................................................................................... 14
3.5.1 Steering with the IMU ................................................................................................................................ 14
3.5.2 The hand and car unit ............................................................................................................................... 15

x

4 RESULTS ................................................................................................................................................ 16
4.1 RESULTS FROM THE CORNERING TEST ......................................................................................................... 16
4.2 RESULTS FROM THE TEST OF THE CONTROLLERS ....................................................................................... 17
5 DISCUSSION AND CONCLUSIONS ................................................................................................... 18
5.1 DISCUSSION ....................................................................................................................................................... 18
5.1.1 Parts used in the project ........................................................................................................................... 18
5.1.2 Results .............................................................................................................................................................. 18
5.1.3 Error sources ................................................................................................................................................. 18
5.2 CONCLUSIONS .................................................................................................................................................... 18
6 RECOMMENDATIONS AND FUTURE WORK ............................................................................... 19
6.1 RECOMMENDATIONS ....................................................................................................................................... 19
6.2 FUTURE WORK .................................................................................................................................................. 19
REFERENCES .................................................................................................................................................. 20
APPENDIX A: DATA FROM CORNERING TEST ..................................................................................... 22
APPENDIX B: DATA FROM CONTROLLER TEST ................................................................................. 23

xi

1 INTRODUCTION
This chapter contains an introduction to the project. It will introduce the background,
purpose, scope and method.

1.1 Background
The radio controlled car, or RC car was invented in 1966 by an Italian company named
Elettronica Giocattio. In the beginning the RC cars were run by gasoline or nitrogen [1].
Today the cars run on electricity or gasoline and are popular, fun and exciting toys. Ever
since the beginning, the cars have been controlled with levers or a wheel on a handheld
remote. The idea is to make a new way to control the car and other RC-toys and implement
an electronic differential instead of the classic mechanic differential and implement a
controller for the speed on the rear wheels. Research has been done in the area of
controlling the car whit an IMU and a few similar hobby projects [2] have been found but
no scientific studies.

1.2 Purpose
The purpose of this project is to design an electronic differential, a controller for the speed
of the back wheels and a new way to control a RC car and other remote controlled vehicles,
for example boats and airplanes. The static controller is replaced with an IMU and
Wireless communication placed on the driver’s arm. The new control unit consists of an
Xbee, Arduino NANO and an IMU [3]. The Arduino and Xbee are placed on the forearm so
no extra weight is put on the hand where the IMU is placed, this will make it easier to
move the hand. When the hand is tilted forward the car will go forward and if the hand is
tilted to either side the car will turn right or left. To drive the car forward two DC-motors
are used. For an exact steering the DC-motors will act as an electronic differential,
meaning that the back wheels will have different speeds when turning.

This thesis will cover the following research questions:

• How will the electronic differential effect cornering at different speeds?
• Which control theory will be best for the task, a feed-back or a feed-forward
controller?

1.3 Scope
This project is completed for a Bachelor thesis at KTH and extends over a period of 16
weeks. The project budget is 1000 Swedish crowns.
To control the system an Arduino UNO is provided by KTH and is an open source platform.
The Arduino NANO, IMU, H-bridge, DC-motors, servo and wheels have been purchased.
The Kalman filter, smooth filter, encoder counter and 𝐼 $ 𝐶 bus have been obtained from
open source libraries, and are redesigned so that they will work with the electronics that
are used. The obtained open source libraries will be explained briefly, since they are very
complex. The focus in this project will be to create a controller (chapter 2.7) and make an
electronic differential.

1

1.4 Method
The project started with a research about how the components is used in an efficient and
smart way. Two units are incorporated, one hand unit for the remote control and one car
unit. Between them there is a wireless connection to transfer data from the remote control
to the car unit using an Xbee (chapter 3.3.4). To be able to investigate the research
questions a demonstrator was made.

To determine how the cars turning radius is affected by an electronic differential, four
different speeds were tested with the same steering angle and no differential. To achieve
the four different speeds, the PWM signal were set to 255(max speed), 205, 155 and 105.
10 test was performed for each speed and the radius of the cars route was measured
(figure 1). For the test with electronic differential the same speed was set as in the first
test to the outer wheel. For the inner wheel the speed was set to match the inner radius
of the turning circle.


Figure 1. Test of the turning radius

The second test was to determine which controller is best suited for controlling the speed
on the rear wheels, a feed-back or feed-forward controller. The test was divided in to four
different scenarios, during the tests time and speed was measured using an encoder and
Arduinos built in timer. The first scenario was executed by letting the car accelerated up
to maximum speed from a stand still. The second test was to let the car accelerate to 50%
of the max speed form a stand still. The third test was acceleration from a constant speed
at 50% of top speed down to a stop. The last test was acceleration from constant top speed
to a standstill. All four scenarios were tested five times in order to provide more even test
results.

2

2 THEORY
This chapter describes all the theory behind the project. It gives an understanding of how
the different parts work.

2.1 Electronic differential


When cornering the outer wheel travels a greater distance then the inner wheel. This
means that the outer wheel needs a greater angular velocity then the inner wheel. To solve
this problem a differential is used. The two axes shafts in figure 2 can rotate at different
speed thanks to the differential pinion gear. The theory behind it is that if one of the axle
shafts rotates slower the differential side gear and pinion gear forces the other axle to
rotate faster [4].


Figure 2. Mechanical differential [4]

The electronic differential uses the same theory as the mechanical, but instead of using a
mechanical differential the electronic uses an individual electric motor for each wheel.

3

2.2 Ackerman steering
The Ackermann-principle is based on that the axes of the steering knuckle always cutting
the rear axis at the same point (figure 3). When cornering, the front wheels will have
different turning radius, the principle is that the wheels will have different angels to
prevent them from sliding on the surface [5]. To enforce this the angle is calculated
between the steering knuckle and the wheel arch (equation 1).

𝐿$
𝜃 = arctan (1)
2 ∙ 𝐿#


Figure 3. Ackerman steering principal.


The radius of the outer and inner wheel was determined using Solid edge CAD and is
calculated to 286mm.

2.3 IMU
An IMU is an electronic component that measures the specific force and angular rate. The
IMU uses combinations of an accelerometer, which measures force and a gyroscope,
which measures angular velocity to determine the sensor movement. The sensors read
the movements around all three axes. The movements are defined as roll, pitch and yaw,
see figure 4. The IMU uses a digital motion processor (DMP) to process the data from the
sensors [3].


Figure 4. How Roll, Yaw and Pitch is defined.

4

2.4 Encoder
The encoder uses two pulses to determine the direction of the turning wheel. The A and
B pulse uses an offset as seen in figure 5 to determine which way the encoder is turning.
If the A pulse changes from high to low while the B pulse is low the motion is like the
arrow in figure 5. If the A pulse changes from high to low and the B pulse is high the motion
is reversed [6].


Figure 5. Pulse train of the encoder [6].

There are different ways to count pulses. In the way described above one pulse is counted
when the A pulse changes from high to low, this is called Falling. The second way to count
pulses is when A changes state from low to high, this is called Rising. The third way is to
count on every changes of state on the A pulse and this is called Change. The benefit of
counting on change is that the pulses of each revelation will double.

2.5 Kalman filter


The Kalman filter is an algorithm that uses a series of measurements to make a prediction
of what the next measured value will be. This is useful when the measured value has a lot
of fluctuations. The Kalman filter uses a mean value which is the value that is the most
likely and a variance. The estimated value tends to be more precise than the measured.
By implementing equation (2) to the IMU, an average measurement is received [7]

𝑋' = 𝐾' . 𝑍' + 1 − 𝐾' . 𝑋'*# (2)


where the 𝐾' is the Kalman gain 𝑍' is the measured value and 𝑋'*# is the previous
estimation. The Kalman filter is used for filtering the signal from the IMU.

2.6 Smooth filter


Since the data received from the Xbee (chapter 3.3.4) contains noise, a Smooth filter [8] is
implemented. The Smooth filter is a digital low-pass filter for smoothing out the input
signal to the servo. An internal buffer stores data and limits the amount of new data
entering the system.

2.7 Model of the system


To be able to calculate the control parameters for the feed-back and feed-forward
controllers, a model of the system was developed.

5

2.7.1 Model of the DC-motor
To describe the model of the DC-motor an example from Control Tutorials [9] was
followed. Figure 6 bellow shows the DC-motors circuit.


Figure 6. Model of a DC-motor.

The supply voltage is U. R and L are the motor resistance and inductance, 𝑒,-. is the
induced motor voltage and i the current. 𝜏- is the torque produced by the motor, 𝜑- the
angle and 𝜑- is the angular velocity, b is the dynamic motor friction and Jm is the motors
moment of inertia.
According to Kirchhoff’s law [9] the voltage U can be described as

𝑑𝑖
𝑈 = 𝑅𝐼 + 𝐿 − 𝑒,-. (3)
𝑑𝑡
and the torque is given by [9]

𝜏- = 𝐾2 𝑖 (4)
where 𝐾2 is the armature constant and the back 𝑒,-. is given by

𝑒,-. = 𝐾, 𝜑- (5)
where 𝐾, is the motor torque constant which is equal to 𝐾2 so 𝐾 = 𝐾, = 𝐾2 .
2.7.2 Model of the Gearbox and Wheel
The angular velocity 𝜑0 on the wheel on the outgoing axis from the gearbox is given by
[8]

𝜑- = 𝑛𝜑0 (6)
and the torque is given by

1
𝜏- = 𝜏 (7)
𝑛 0


Figure 7. Motor axis into the gearbox and wheel axis out of the gearbox.

6

where 𝜑- is the angle velocity on the motor shaft, 𝜑0 is the angle velocity on the wheel
axis and 𝑛 the gear ratio of the gearbox. For the wheel in figure 7 the speed 𝑣 and torque
𝜏0 is given by [10][9]

𝑣 = r𝜑0 (8)

𝜏0 = 𝐽0 𝜑0 + 𝑑𝜑0 (9)

where r being the radius of the wheel, 𝐽0 the moment of inertia and d the dynamic friction
coefficient of the wheel.


Figure 8. A turning wheel.

The parameters for the system can be found in table 1.

Table 1. Motor data.

Symbol Value Reference


Resistance R 4Ω Measured
Voltage constant 𝐾, 176,9 ∗ 10*T 𝑉/𝐴 Calculated
Armature constant 𝐾2 176,9 ∗ 10*T 𝑁𝑚/𝐴 Calculated
Motor moment of inertia 𝐽- 212,1 ∗ 10*T 𝐾𝑔 𝑚$ Solid edge CAD
Wheel moment of inertia 𝐽0 51013 ∗ 10*T 𝐾𝑔 𝑚$ Solid edge CAD
Gear ratio N 48 Datasheet

2.8 PD-controller
The reason to use a PD-controller was that the driver will correct any type of static error
and a fast rise time is required. Two types of control theory will be tested, feed-back
control figure 9 and feed-forward control figure 10. Both theories are using the error 𝑒(𝑡)
which is the difference between the reference signal 𝑟(𝑡) from the IMU and the calculated
speed 𝑦(𝑡). The difference between the two theories is that feed-forward not only uses
the error 𝑒(𝑡), it also makes an educated guess about what the output signal 𝑢(𝑡) should
be. The control function for the feed-forward is 𝐹.. 𝑠 = 1/𝐺(𝑠). The output signal 𝑢 𝑡
for a PD-controller is [11]

𝑑 (10)
𝑢 𝑡 = 𝐾8 𝑒 𝑡 + 𝐾9 𝑒(𝑡)
𝑑𝑡
𝐾8 and 𝐾9 are parameters that can be changed to get the system to behave as desired.

7

The parameter 𝐾8 determines how the controller reacts proportional to the error and 𝐾9
determines how the controller reacts on the derivative of the error. The transfer function
𝐺(𝑠) and how to obtain it is described and calculated in chapter 2.8.1.


Figure 9. Feed-back control.


Figure 10. Feed-forward control.

2.8.1 Transfer function PD-controller


The transfer function is

𝑉 𝑠 (11)
𝐺 𝑠 =
𝑈 𝑠
where 𝑉 𝑠 is the velocity and 𝑈 𝑠 is the output voltage. To obtain the transfer function
the model and equations in chapter 2.7 are used. The torque of the motor can be written
as [9]

𝜏- = 𝐽- 𝜑- + 𝑏𝜑- (12)
Equations 3, 4, 5 and 12 are used, with the assumption that the induction 𝐿 ≈ 0 then the
motion of the motor can be described as

𝐾 (13)
𝐽- 𝜑- + 𝑏𝜑- = 𝑈 + 𝐾𝜑-
𝑅
To describe the motion of the wheel the equations 6, 7, 8 and 9 are used in 13

𝑛𝐾 $ + 𝑑 𝑛𝐾 (14)
𝜑0 + 𝜑0 =𝑈
𝐽0 𝐽0 𝑅
Laplace transformation [12] of equation 8 and 13 gives

𝑉(𝑠) = 𝑟𝑠𝜑0 (𝑠) (15)

8

𝑛𝐾 $ + 𝑑 𝑛𝐾 (16)
𝑠 $ 𝜑0 𝑠 + 𝑠𝜑0 𝑠 =𝑈 𝑠
𝐽0 𝐽0 𝑅
by using and simplifying equation 11, 15 and 16 the transfer function is obtained
fgh (17)
𝐺 𝑠 = -
ijk lml(g n mo)


2.8.2 Pol-placement
The requirements for the controller is to make it as fast as possible, without having a
system that oscillates. The closed loop system can be described as [13]


Figure 11. Feed-back control.

The transfer function is equal to [13]

𝑆𝐴 𝑆𝐴
𝐺ph 𝑠 = = . (18)
𝐴𝑅 + 𝐵𝑆 𝐴- 𝐴s
where the output signal from the regulator can be written as

𝑆
𝑢 𝑡 = (𝑟 𝑡 − 𝑦(𝑡)) (19)
𝑅
Equation 17 and figure 9 gives

𝐵 𝑛𝐾𝑟
= (20)
𝐴 𝑠𝐽0 𝑅 + 𝑅(𝐾 $ + 𝑑)
and for the controller function for the feed-back 𝐹.t (𝑠)

𝑆 𝑃𝑠 + 𝐷
= (21)
𝑅 𝑠 + 𝑟s
From this the equation 22 is obtained

𝐴wx = 𝐴𝑅 + 𝐵𝑆 (22)
were 𝐴- is a polynomial that have the same order as A and 𝐴wx is a polynomial of the same
order as 𝐴- 𝐴s . The poles 𝛼 and 𝛽 can then be chosen as

𝐴- = 𝑠 + 𝛼 (23)

𝐴s = 𝑠 + 𝛽 (24)

9

By choosing 𝛼 = 1 and 𝛽 = 5 the system has a rise time of 6,58 ∗ 10*| seconds this meets
the requirements of the desired system. In figure 12, a step response for the closed loop
system is shown.


Figure 12. Step response for the closed loop system.

2.8.3 Implementation
The microcontroller works in discrete time steps so the controller function for the feed-
back and feed-forward must be discretized. This is done using Tustins approximation [14]

𝑑𝑢
= Δ2 𝑢(𝑡) (25)
𝑑𝑡
where Δ2 𝑢(𝑡) is

1 1
(Δ2 𝑢 𝑡 + Δ2 𝑢 𝑡 − 𝑇 ) = (𝑢 𝑡 + 𝑢 𝑡 − 𝑇 ) (26)
2 𝑇
were T being the sample time. Whit calculations in MATLAB this gives the discrete system
for the feed-back (equation 27) and feed-forward (equation 28)

𝑢.t = 𝑎# 𝑒 𝑡 + 𝑏# 𝑒 𝑡 − 𝑇 − 𝑐# 𝑢(𝑡 − 𝑇) (27)

𝑢.. = 𝑎$ 𝑒 𝑡 + 𝑏$ 𝑒 𝑡 − 𝑇 − 𝑐$ 𝑢(𝑡 − 𝑇) (28)


were the constants can be found in table 2.

Table 2. constants of the output signal for feed-back and feed-forward.

𝑎# 14,47
𝑏# -14,10
𝑐# 0,65
𝑎$ 0,08
𝑏$ 0,02
𝑐$ 1

10

3 DEMONSTRATOR
This chapter describes the problems which will be faced when building the demonstrator,
and it describes the software, electronics and hardware that are used.

3.1 Problem Formulation


To get a functional demonstrator the following problems were to be solved.

• The weight of the hand unit must be light.
• The parts on the car must be strong so they do not shatter when colliding with
objects.
• The front wheels must have different turning radius.
• The speed must be individually controlled on the back wheels.

3.2 Software
The software is divided into two subsystems, one for the hand unit and one for the car.
The Programing languages for both units was primarily C.
3.2.1 The software structure for the hand unit
The software for the hand unit runs on an Arduino NANO. The hand unit starts to read the
roll (X-axis) and the pitch (Y-axis) from the IMU gyroscope and accelerometer the roll
representing the steering and the pitch representing the driving signals. The incoming
data from the IMU is filtered through an open source Kalman-filter (chapter 2.5). The roll
and pitch angle is rescaled to PWM-signals and transmitted to the car by the Xbee
transmitter (figure 13).


Figure 13. Flowchart of the program on the hand unit.

3.2.2 The software structure in the car unit


The signals from the Xbee transmitter are received by the Xbee receiver. The PWM-signals
are then smoothed out through an open-source low pass filter (chapter 2.6) to eliminate
any noise caused by the Xbee communication. The PWM-signal for controlling the steering
is processed and sent to the servo (chapter 3.3.7). When cornering, both steering and
driving inputs are necessary for calculating the individually speed for each back wheel to
create the electronics differential (chapter 2.1). The back tires are individually controlled
by two PD-controllers for the speed control that was developed and tested in Matlab. The
overall structure of the system is described in the flowchart below (figure 14).

11


Figure 14. Flowchart of the car program.

3.3 Electronics
On each unit there is a couple of electrical components. Below, all electrical components
will be reviewed. In chapter 3.3.9 are two figures which contains flowcharts of the
components on each unit.
3.3.1 Microcontroller
To control the system on the car an Arduino UNO [15] is use. It is an open source platform
and uses C/C++ language and has a clock speed of 16MHz. The board has 14 digital pins
which can be used as inputs or outputs, it also has 6 analog inputs. On the hand unit an
Arduino NANO [16] is used and the NANO board has the same layout as the UNO. The
difference between the boards is that the NANO has 8 analog pins. The UNO is powered
with 7,4V and the NANO with 9V.
3.3.2 Battery
A standard 9V alkaline battery will power the Arduino NANO on the hand unit. The battery
on the car is a 7,4V lithium battery and will power the motors and the Arduino UNO.
3.3.3 Internal measurement unit or IMU
The IMU is an inertial measurement unit of type MPU-6050 [3] and can measure angles
and acceleration up to ±2000𝑑𝑝𝑠 (degrees per second) and ±16𝑔 in three axes. This is
much faster than necessary so the refresh rate was set to ±200𝑑𝑝𝑠 and ±2𝑔 to give a
more exact reading. The IMU has six degrees of freedom but to solve the problem of
driving and steering the car only four will be needed (two angles in the plane and the
acceleration).
3.3.4 Xbee
For the wireless communication a system of two Xbees series 2 [17] are used. One of the
Xbees is configured as coordinator and this unit receives the data to the microcontroller.
The other one is configured as end point, this Xbee transmit the outputs from the Arduino

12

NANO. The Xbees are using Zigbee for the wireless control with a frequency at 2,4 GHz.
These modules are very energy efficient and have a range of 40 meters indoors and up to
100 meters outdoors.
3.3.5 H-bridge
The H-bridge [18] is a dual motor drive and makes it possible to drive the motors in both
directions. It has 2 inputs and 2 outputs for each motor. By using the PWM signal [19] the
voltage to the motor can be controlled. With continuous driving, the output current can
be up to 1,5 Ampere and peaks can be up to 2 Ampere for a short period of time.
3.3.6 DC-motor and gearbox
The DC-motors and gearbox [20] are of type DG02S and can be driven on voltages from 0-
8V and have a no load current of 125mA and a no load speed of 140rpm. The gearbox has
a gear ratio of 48:1.
3.3.7 Servo motor
The servo motor [21] is used for the steering of the car. In the servo there is a DC-motor
and gearbox with a high gear ratio. To control the output angle, the servo uses its own
controller. The servo has a range of 180 degrees and runs at 5V.
3.3.8 Encoder
To measurer the speed of each wheel an encoder of type M, 512 CPT [22] is placed on the
axis of the wheel. It has 2 channels and an A-, and B-pulse with 512 pulses per revolution.
This makes is possible to determine which way the wheels are turning and how fast by
counting the pulses per time unit.
3.3.9 Block diagram
Figure 15 and figure 16 shows a block diagram of all the electronic parts on the hand unit
and car unit and how they work together.


Figure 15. Hand unit with the components.


Figure 16. Car unit with the components.

13

3.4 Hardware
The methods of creating the different components for the demonstrator are presented
below. The four wheels and the gears for the encoder were purchased.
3.4.1 Laser cut
The base of the car was made from 6mm thick acrylic plastic. The shape and size of it is
optimised so that all the components will have a narrow fit and the car is kept small.
3.4.2 3D-printed
The holder for the Arduino UNO, servo and battery is 3D-printed. To fasten the holder on
to the base of the car the holder is glued. The holder for the Xbee, Arduino NANO and
battery are 3D-printed as well as the holder for the IMU. The benefits of 3D-printing are
that the pieces are light and easy to make.
3.4.3 Soldering
The circuit board for the hand and car unit was made from a perfboard. The perfboard is
for prototyping electrical circuits. It has premade holes and has good functionality.

3.5 The demonstrator


3.5.1 Steering with the IMU
Figure 17 shows how to operate the car with the IMU placed on the hand.


Figure 17. Top left: forward, top right: right turn, bottom left: break/back, bottom right: left turn.

14

3.5.2 The hand and car unit
The final result of the hand and car unit is shown below in figure 18.


Figure 18. Hand and car unit

15

4 RESULTS
The results of the two test are presented in this chapter.

4.1 Results from the cornering test


In figure 19 the test results from no electronic differential are presented. All 10 different
tests of each speed is displayed as well as the average turning radius.


Figure 19 Turning radius without electronic differential.

All 10 different test is displayed and the average turning radius is displayed in figure 20.
Only one test was executed, this because of the near perfect result at maximum speed.
Tests at lower speeds was unnecessary.


Figure 20 Turning radius with electronic differential.

16

Table 3. Average turning radius and percent improvement with differential.

Average radius No Average radius with Percent improvement


differential [mm] differential [mm] with differential [%]
PWM 255 846 298 64,8

Table 3 shows the average radius in the two different tests for maximum speed. For all
measured data see appendix A.

4.2 Results from the test of the controllers


The results from the tests of the controllers performance are shown in figure 21. The blue
lines represent the feed-back controllers average test performance and the red lines
represent the feed-forwards average test perform. The plot of test 1 is from 0% to 100%
of the max speed, test 2 is from 0% to 50% of the max speed, test 3 is from 50% of the
max speed to 0% and test 4 is from 100% of max speed to 0%. With time in milliseconds
on the x-axis and speed measured in rad/s on the y-axis. The exact data from the tests can
be found in appendix B.


Figure 21. Plot of the average test results from the feed-error and feed-back controller.

17

5 DISCUSSION AND CONCLUSIONS
In this chapter conclusions are drawn from the tests in previous chapter and the project is
discussed.

5.1 Discussion
5.1.1 Parts used in the project
• The DC-motors that drives the car should have been of better quality. It was
difficult to find information and a datasheet of the motors. The associated
gearboxes for the motors has a high gear ratio, which leads to a low speed.
• The battery used on the car is large and has a high capacity. The better choice
would be to have a smaller battery to save space and weight on the car.
• The angle velocity for the servo is low, this means that the steering is not so
responsive.
5.1.2 Results
• In theory the Feed-forward controller should perform better [23] because it uses
both the feed-back and feed-forward signal as described in chapter 2.8. One reason
for this may be bad components and primarily the motors due to inconsistent
performance, another reason is that the model of the system is not entirely correct.
• The variation in the test results of the electronic differential could have been
affected by the surface the car was tested on.
5.1.3 Error sources
• The two different motors have different speeds for the same PWM-signal or
voltage, therefore the results of driving whiteout differential on a constant PWM-
signal can have an error margin in the measurements.
• For modelling of the system the moment of inertia for both the motor and wheel
are calculated in Solid edge CAD. The parts made in Solid edge CAD are not a
perfect replica of the real motors and this affect the parameters of the controller.

5.2 Conclusions
Conclusions after conducting tests on the demonstrator and analysing the data.

How will the electronic differential effect cornering in different speeds?

From the test in chapter 4.1 the conclusion to be drawn is that the electronic differential
will clearly help the car to take the corner at a radius closer to the calculated turning
radius.

Which control theory will be best for the task, a feed-error or a feed-forward
controller?

From the test in chapter 4.2 the conclusion is that there is not a big difference in results,
part from test 2 figure 21 where it is clear that the Feed-forward controller is
75 Ms faster to achieve 50% of max speed and more stable.

18

6 RECOMMENDATIONS AND FUTURE WORK
Recommendations for making the robot and things that could be made in the future.

6.1 Recommendations
For building a demonstrator like this an Arduino is recommended due to the open-source
libraries. It is easy to find code for the Xbee, IMU and other electrical components. It is fun
to make the mechanical parts for the demonstrator but it requires 3D-printers and laser
cutters, if not available the parts can be bought in various stores. When selecting
electronic parts, it is recommended to buy quality products that are accurate rather then
cheaper copies. For choosing Dc-motors for a project like this it is recommended to choose
motors of good quality and good data sheets.

6.2 Future work


The base of the car unit could be wider so that the car gets a lower centre of gravity. The
clearing in between the parts of the steering could be tighter, this will give a more exact
steering. Another type of construction of the steering could be chosen so that the steering
would be faster. For a greater speed of the car a DC-motor with higher rpm is
recommended. To prevent the car from driving in to objects an ultrasonic sensor could be
fitted to the roof on the car. The hand unit could use a flexible cable between the IMU
holder and the battery/Xbee/Arduino NANO holder. The holder for the battery, Xbee and
Arduino NANO could be smaller so that it will be lighter and more comfortable.
To make the controller faster, a state space controller could be constructed.

19

REFERENCES
1. History of Radio Controlled Cars. Available at:
http://www.classic.rc-junkies.net/?page_id=637 [Accessed: 2016-02-23]

2. Inspiration project, 2015-11-03. Available at:
https://developer.mbed.org/users/Xiaofei/notebook/imu-controlled-robot/
[Accessed: 2016-02-23]

3. Invensense, MPU-6050, 2011-10-24. Available at:
https://cdn.sparkfun.com/datasheets/Components/General%20IC/PS-MPU-
6000A.pdf [Accessed: 2016-02-23]

4. Mechanical differential. Available at:
http://constructionmanuals.tpub.com/14050/css/Figure-11-17-Typical-
differential-and-axle-assembly-with-ring-and-pinion-272.htm

5. Encoder theory. Available at:
https://www.pjrc.com/teensy/td_libs_Encoder.html [Accessed: 2016-04-23]

6. Ackerman steering. Available at:
http://www.rctek.com/technical/handling/ackerman_steering_principle.html
[Accessed: 2016-04-25]

7. Kalman Filter, 2015-08-11. Available at:
http://www.bzarg.com/p/how-a-kalman-filter-works-in-pictures/
[Accessed: 2016-04-16]

8. Smooth Filter, 2007.Available at:
http://playground.arduino.cc/Main/Smooth [Accessed: 2016-03-12]

9. Control Tutorial DC-motor. Available at:
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed&section=S
ystemModeling [Accessed: 2016-04-10]

10. Maskinelement HANDBOK 2008 vol. 1. Instutionen för maskinkonstuktion, KTH.
pp. 7

11. Reglerteknik, grundläggande teori 2015 vol. 4:13. Torkel Glad & Lennart Ljung.
pp. 19

12. Reglerteknik, Grundläggande Teori. 2015 vol. 4:13. Torkel Glad & Lennart Ljung.
pp. 232

13. Dynamics and motion control Lie Feng
https://www.kth.se/social/files/56b9a1f9f2765457b115e464/C3_Feedback_20
16.pdf

20

14. Reglerteknik, Grundläggande Teori. 2015 vol. 4:13. Torkel Glad & Lennart Ljung.
pp. 211

15. Arduino UNO Board. Available at:
https://www.arduino.cc/en/main/arduinoBoardUno [Accessed: 2016-02-10]

16. Arduino NANO Board. Available at:
https://www.arduino.cc/en/Main/ArduinoBoardNano [Accessed: 2016-02-10]

17. Building Wireless Sensor Networks. 2011 vol 1. Robert Faludi
pp 3, 25-31.

18. H-bridge Data sheet, 2015-07. Available at:
http://www.ti.com/lit/ds/symlink/drv8833.pdf [Accessed: 2016-04-25]

19. PWM signal Available at:
https://www.arduino.cc/en/Tutorial/PWM [Accessed: 2016-04-28]

20. DC-motor. Available at:
http://www.dagurobot.com/goods.php?id=86 [Accessed: 2016-04-28]

21. Servo motor, 2011-10-24. Available at:
https://www.parallax.com/sites/default/files/downloads/900-00005-Standard-
Servo-Product-Documentation-v2.2.pdf [Accessed: 2016-03-10]

22. Encoder, 2015-04. Available at:
http://www.maxonmotor.com/medias/sys_master/root/8816813441054/15-
353-354-EN.pdf [Accessed: 2016-04-27]

23. Control System Design Lecture notes for Karl Johan Åström, Engineering
University of California, Santa Barbara 2002.
http://www.boti.oil.gov.iq/book/english%20ebooks/%D8%A7%D9%84%D9%
83%D9%87%D8%B1%D8%A8%D8%A7%D8%A1/control%20sys/CSYS%20%
203-Control%20System%20Design.pdf [Accessed: 2016-03-10]

21

APPENDIX A: DATA FROM CORNERING TEST
Data from the cornering test.
Without
DIFF With DIFF
(mm) (mm)
Test PWM PWM PWM PWM
nr 255 205 155 105 PWM 255
1 1305 1010 630 294 320
2 1374 976 617 280 300
3 1354 1005 636 270 295
4 1522 943 643 268 310
5 1499 947 605 276 315
6 1535 920 575 258 280
7 1350 962 570 280 295
8 1390 1022 576 284 295
9 1060 947 578 260 305
10 1070 945 572 268 270

22

APPENDIX B: DATA FROM CONTROLLER TEST
Data from the controller test.

23



























































TRITA MMKB 2016:31 MDAB092









www.kth.se

24

You might also like