Professional Documents
Culture Documents
Designing Development and Testing of A PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID
Designing Development and Testing of A PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID
\
|
+
=
on off
on
T T
T
DutyCycle
(Eqn
4.1)
Where: - Ton = Time On
: - Toff = Time Off
48
Chapter 5
Shaft Encoder
5.0 Introduction
The shaft encoder is used to provide feedback from the wheels. the encoder is very
essential in controlling the speed of the automatic vehicle. the encoder provides a signal
produced by the rotation of the wheel is the feedback that is fed back to interrupt port of
the microprocessor that is port b.
The robotic group at the university of the south pacific has used various shaft encoders to
get feedback of the motor speed from the wheels. the most common shaft encoders used
by the groups are heds and oktec pair in house built shaft encoder to filter feedback.
5.1 HEDS 5540 a06
The previous year project groups have used HEDS 5540 a06 as their shaft encoder. each
encoder contains a lensed led source, an integrated circuit with detectors and output
circuitry, and a code wheel which rotates between the emitter and detector IC this
encoder has 1024 counts per revolution and its maximum operating frequency is
100Khz.It has three channels (channel i, channel a and channel b).
Figure 5.1 heds 5540 a06
features
Supply voltage 5 v _ 10 %
Output signal ttl compatible
49
Phase shift _ (nominal) 90e
Logic state width s min. 45e
Signal rise time
(Typical at cl = 25 pf, rl = 2.7 k_, 25c) 180 ns
Signal fall time
(Typical at cl = 25 pf, rl = 2.7 k_, 25c) 40 ns
Index pulse width (nominal) 90e
Operating temperature range -40 ... +100c
Moment of inertia of code wheel _ 0.6 gcm2
Max. Angular acceleration 250 000 rad s-2
output current per channel min. -1 ma, max. 5 ma
5.1.1 Advantages of using HEDS 5540 a06
The major advantages of using this shaft encoder are:
It offers high resolution (that is it gives a high precision).
Enclosed device therefore it is not affected by external light sources.
5.1.2 Disadvantages of using heds 5540 a06
The disadvantage of using this shaft encoder is that it very expensive and maintenance is
very costly. Each HEDS 5540 a06 cost about 114 Australian dollars. Also it has a high
resolution which is not needed for our application.
HEDS 5540 a06 has 1024 pulses per revolution means it has 512 slots. the wheel
diameter is 140mm so the circumference is:
Circumference = 2r
= 2 x x 0.14
= 0.44m
Each time the wheel makes a turn it rotates 360 and since there are 1024 pulses per
revolution the angle of each pulse is given as:
=
1024
360
= 0.35
Hence, the linear distance that the wheel moves when one of the 1024 pulses passes by is
given as:
d =
360
x circumference
=
360
35 . 0
x 0.44m
= 0.000427m
50
Therefore it gives feedback at every 0.35 turn and the linear distance which the wheel
moves is 0.000854m which is very precise and not needed for our application.
5.2 Oktec pair shaft encoder
For our application we have used a oktec pair shaft encoder to filter feedback. oktec pair
shaft encoder is an in-house built shaft encoder. Its a 16 slot encoder cut out on 5mm
aluminum plate together with a pair of IR phototransistor/photodiode (op140/op550)
sensors used to design the shaft encoder. Both have the same emitting and receiving
frequency
Figure 5.2 hardware setup for oktec shaft encoder
Figure 5.3 16 slots aluminum plate
This 16-slot encoder is not capable of differentiating between CW and ACW direction
which incorporates a comparator circuit designed using lm324 operational amplifier. The
two 1k ohm resistors are placed such that the comparator threshold voltage is 2.5v.hence
any input signals blow this threshold voltage would produce a logic low output and above
this threshold voltage would produce a logic high output.
51
Figure 5.4 shows the shaft encoder between two ir sensors along with the comparator
circuit.
5.2.1 Advantages of using oktec pair
The major advantage of using the in-house built shaft encoder is that:
Cheaper (as compared to other encoders which are bought).
Since it is built in-house any problems can be easily resolved.
it is suitable for this particular application
A 16 slot shaft encoder generates 32 pulses per revolution. The wheel diameter is 140mm
so the circumference is:
r = 70mm = 0.07m
Circumference = 2r
= 2 x x 0.07
= 0.44m
Each time the wheel makes a turn it rotates 360 and since there are 32 pulses per
revolution the angle of each pulse is given as:
=
32
360
= 11.25
Hence, the linear distance that the wheel moves when one of the 1024 pulses passes by is
given as:
d =
360
x circumference
=
360
25 . 11
x 0.44m
= 0.01375m
Therefore it gives feedback at every 11.25 turn and the linear distance which the wheel
moves is 0.01375m which is applicable for our application.
52
5.2.2 Disadvantages of using oktec pair
The major disadvantage of using this shaft encoder is that there could be errors if lights
from external sources pass through the shaft encoder. The light can interface with the IR
sensors and cause errors. Therefore, to reduce this error an external cover is needed.
5.3 Comparator
The main purpose comparator circuit (lm324 operational amplifier) is to smoothen the
output that is coming from the receiving sensor. For the operational amplifier to function
a +5 volts and a ground have to be supplied
5.3.1 Output from the comparator
Figure 5.6 shows the signal given by the ir sensors which is amplified by the comparator
circuit giving a smooth square wave signal (0v and 5v).
Figure 5.6: Output from the comparator
CHAPTER 6
Figure 5.5 shows the hardware for the comparator circuit
53
Transfer Function of the Driver Motor
6.1 Outline
The transfer function of the driver motor was calculated by using four different feedbacks. The
feedback was recorded at 35% and 50 % duty cycle. Two sets of duty cycle of which the
feedbacks were recorded and tabulated in the table 6.1 below. This was done to achieve the correct
transfer function. The transfer functions at two different duty cycles should be nearly same
because it involves one motor for feedback operation. Also the poles and zeros of the transfer
function should not be greatly affected by constantly increasing the speed of the dc motor. Hence,
to show the correct transfer function, the transfer function of four different duty cycles were
calculated and compared. The sections below show how the transfer function was calculated and
the results that are obtained from the differential drive setup. The data was recorded was at free
wheel stage of the 12V dc motor. It is assumed that the transfer functions of all four different duty
cycles should be nearly the same.
6.2 Calculation of Transfer Function at 35% duty cycle
Firstly, the Revolution per Minute (RPM) values of the driver motor is obtained. The
sampling time is the time obtained using the get_timer () function whereby it is the time
taken for the counter to overflow. The steps involved in obtaining the transfer function of the
driver motor are in detail discussed in this section.
Table 6.1
Step 1: The table below shows data recorded at 35% duty cycle.
Sampling Time (s) Cumulative Time (s) Cumulative Time (s) RPM
0 0 0 0
1482 1482 0.001482 307.4527
16274 17756 0.017756 286.0276
16854 34610 0.03461 284.9476
28142 62752 0.062752 270.3799
25120 87872 0.087872 274.188
27528 115400 0.1154 271.1852
32982 148382 0.148382 264.6483
2935 151317 0.151317 268.9437
54
30984 182301 0.182301 267.1916
29969 212270 0.21227 268.3087
30815 243085 0.243085 267.3582
28845 271930 0.27193 269.4353
32102 304032 0.304032 265.6395
31457 335489 0.335489 266.508
33264 368753 0.368753 264.4407
29894 398647 0.398647 268.268
29857 428504 0.428504 268.4408
30026 458530 0.45853 268.3892
30699 489229 0.489229 267.4059
29103 518332 0.518332 269.2805
32742 551074 0.551074 265.0786
37491 588565 0.588565 259.6178
43586 632151 0.632151 252.9458
4493 636644 0.636644 251.3426
4818 641462 0.641462 248.0302
48968 690430 0.69043 247.1617
42646 733076 0.733076 253.7438
40656 773732 0.773732 255.7959
41805 815537 0.815537 254.7046
45116 860653 0.860653 251.2373
43568 904221 0.904221 252.8733
43682 947903 0.947903 252.6752
46146 994049 0.994049 250.0615
4441 998490 0.99849 251.9548
45247 1043737 1.043737 251.0429
47278 1091015 1.091015 248.9596
46483 1137498 1.137498 249.8772
45687 1183185 1.183185 250.5272
4627 1187812 1.187812 250.0365
47763 1235575 1.235575 248.4277
4583 1240158 1.240158 250.3902
46461 1286619 1.286619 249.7409
4846 1291465 1.291465 247.6688
46397 1337862 1.337862 249.8647
46715 1384577 1.384577 249.4958
48774 1433351 1.433351 247.3829
46806 1480157 1.480157 249.4357
47962 1528119 1.528119 248.2396
48703 1576822 1.576822 247.5217
45985 1622807 1.622807 250.3327
55
47455 1670262 1.670262 248.7645
48523 1718785 1.718785 247.5697
48025 1766810 1.76681 248.2663
4781 1771591 1.771591 248.4092
46636 1818227 1.818227 249.6495
49436 1867663 1.867663 246.6781
46862 1914525 1.914525 249.3735
4718 1919243 1.919243 249.1415
49851 1969094 1.969094 246.3236
47496 2016590 2.01659 248.683
47298 2063888 2.063888 248.9286
50898 2114786 2.114786 245.3235
47915 2162701 2.162701 248.2766
49274 2211975 2.211975 246.938
50718 2262693 2.262693 245.3877
49804 2312497 2.312497 246.362
49328 2361825 2.361825 246.9177
4996 2366821 2.366821 246.2842
50158 2416979 2.416979 246.0358
49522 2466501 2.466501 246.7643
4959 2471460 2.47146 246.5585
51657 2523117 2.523117 244.4649
48569 2571686 2.571686 247.6177
49159 2620845 2.620845 247.058
51866 2672711 2.672711 244.3066
Step 2: Draw transient response of the graph
From the above data, the transient response was drawn using Microsoft Excel. This graph shows
the transient response of the motor with respect to time.
56
Figure 6.1 Shows the Graph of Motor Speed versus time at 35% duty cycle
From the above graph the settling time is assumed to be 0.860653 seconds as shown
on the graph.
ts =0.860653 s
Step 3: Step Response
As referenced from the text Feedback control of dynamic systems[9] the step
response of a motor is given by:
t
e t y
o
= 1 ) (
(Eqn 6.1)
Thus, to use the above equation, we need to calculate the value of sigma (o). If we
want the settling time to occur when the decaying exponential reaches 1% ~
(0.01),the following equations were derived as shown below.
0
50
100
150
200
250
300
350
0 0.5 1 1.5 2 2.5 3
Graph of Motor Speed Versus Time @ 35% duty
cycle
57
n
s
s n
s n
t W
W
t
t W
t W
e
s n
,
,
,
,
61 . 4
61 . 4
) 01 . 0 ln(
01 . 0
=
=
=
=
Since, wn = o
Therefore, we can calculate :
o
61 . 4
=
s
t
(Eqn 6.2)
s
t
61 . 4
= o
(Eqn 6.3)
Using equation 6.3 and the settling time from step 2, we can now calculate the value of
sigma (o).
356 . 5
860653 . 0
61 . 4
61 . 4
=
=
=
o
o
o
s
t
Now, we know the value of sigma and can use the equation 6.1 from step 3 to calculate the
step response.
Table 6.2
The table below shows the step response figures at 35% duty cycle.
Cumulative Time (s) -o x t Exp(-o x t) y(t)
0
0 1 0
0.001482 -0.007937592 0.992093827 0.007906173
0.017756 -0.095101136 0.909280969 0.090719031
0.03461 -0.18537116 0.830795868 0.169204132
0.062752 -0.336099712 0.714551853 0.285448147
0.087872 -0.470642432 0.624600876 0.375399124
0.1154 -0.6180824 0.53897699 0.46102301
0.148382 -0.794733992 0.451701375 0.548298625
0.151317 -0.810453852 0.444656212 0.555343788
0.182301 -0.976404156 0.376663088 0.623336912
0.21227 -1.13691812 0.320806186 0.679193814
58
0.243085 -1.30196326 0.271997267 0.728002733
0.27193 -1.45645708 0.233060529 0.766939471
0.304032 -1.628395392 0.196244217 0.803755783
0.335489 -1.796879084 0.165815578 0.834184422
0.368753 -1.975041068 0.138755614 0.861244386
0.398647 -2.135153332 0.118226461 0.881773539
0.428504 -2.295067424 0.1007546 0.8992454
0.45853 -2.45588668 0.085787096 0.914212904
0.489229 -2.620310524 0.072780259 0.927219741
0.518332 -2.776186192 0.062275562 0.937724438
0.551074 -2.951552344 0.05225852 0.94774148
0.588565 -3.15235414 0.042751366 0.957248634
0.632151 -3.385800756 0.033850525 0.966149475
0.636644 -3.409865264 0.033045653 0.966954347
0.641462 -3.435670472 0.032203811 0.967796189
0.69043 -3.69794308 0.024774433 0.975225567
0.733076 -3.926355056 0.019715403 0.980284597
0.773732 -4.144108592 0.015857565 0.984142435
0.815537 -4.368016172 0.012676363 0.987323637
0.860653 -4.609657468 0.009955228 0.990044772
0.904221 -4.843007676 0.007883308 0.992116692
0.947903 -5.076968468 0.006238793 0.993761207
0.994049 -5.324126444 0.004872606 0.995127394
0.99849 -5.34791244 0.004758073 0.995241927
1.043737 -5.590255372 0.003734074 0.996265926
1.091015 -5.84347634 0.002898748 0.997101252
1.137498 -6.092439288 0.00225989 0.99774011
1.183185 -6.33713886 0.001769357 0.998230643
1.187812 -6.361921072 0.001726048 0.998273952
1.235575 -6.6177397 0.001336448 0.998663552
1.240158 -6.642286248 0.001304042 0.998695958
1.286619 -6.891131364 0.001016763 0.998983237
1.291465 -6.91708654 0.000990712 0.999009288
1.337862 -7.165588872 0.000772724 0.999227276
1.384577 -7.415794412 0.000601674 0.999398326
1.433351 -7.677027956 0.00046335 0.99953665
1.480157 -7.927720892 0.000360607 0.999639393
1.528119 -8.184605364 0.000278914 0.999721086
1.576822 -8.445458632 0.000214874 0.999785126
1.622807 -8.691754292 0.000167965 0.999832035
1.670262 -8.945923272 0.000130267 0.999869733
1.718785 -9.20581246 0.000100454 0.999899546
59
1.76681 -9.46303436 7.76706E-05 0.999922329
1.771591 -9.488641396 7.57069E-05 0.999924293
1.818227 -9.738423812 5.89734E-05 0.999941027
1.867663 -10.00320303 4.52547E-05 0.999954745
1.914525 -10.2541959 3.52095E-05 0.999964791
1.919243 -10.27946551 3.43309E-05 0.999965669
1.969094 -10.54646746 2.62862E-05 0.999973714
2.01659 -10.80085604 2.0382E-05 0.999979618
2.063888 -11.05418413 1.58208E-05 0.999984179
2.114786 -11.32679382 1.20458E-05 0.999987954
2.162701 -11.58342656 9.31927E-06 0.999990681
2.211975 -11.8473381 7.15758E-06 0.999992842
2.262693 -12.11898371 5.45497E-06 0.999994545
2.312497 -12.38573393 4.17777E-06 0.999995822
2.361825 -12.6499347 3.20777E-06 0.999996792
2.366821 -12.67669328 3.12307E-06 0.999996877
2.416979 -12.94533952 2.38732E-06 0.999997613
2.466501 -13.21057936 1.83113E-06 0.999998169
2.47146 -13.23713976 1.78313E-06 0.999998217
2.523117 -13.51381465 1.35215E-06 0.999998648
2.571686 -13.77395022 1.04244E-06 0.999998958
2.620845 -14.03724582 8.01127E-07 0.999999199
2.672711 -14.31504012 6.06816E-07 0.999999393
A step response graph was drawn as shown in Figure 6.2.
Figure 6.2 shows the step response of the Graph of Motor at 35% duty cycle
60
From the above graph it can be demonstrated that the settling time of 0.904221s
is achieved at 0.992116692 as marked on the graph, at this point the exponential
decay reaches within 1% of the final value. By looking at the step response
graph above, we can assume that it is given by a sum of exponentials, thus we
can write
(Eqn
6.4)
Subtracting off the final value and assuming that
-o (alpha) is the slowest pole, the following equation can be written as:
(Eqation 6.5)
The slope of the equation 5.5 gives the value of alpha (o), and the intercept gives the value of
A. If equation 5.5 is plotted (log graph) it should result in the positive value of A because we
use log(y (t)-y (infinity)). Step 4 shows how A and was calculated.
0
0.2
0.4
0.6
0.8
1
1.2
0 0.5 1 1.5 2 2.5 3
Graph of y(t) vs Time (s)
61
Step 4: Drawing log(y (t)-y ()) vs. time graph and calculating the value of constant A
and alpha (o).
Table 6.3
The table below shows the log(y (t) y ()) data at 35% duty cycle.
Cumulative Time (s) 1 - y(t) Log |1 - y(t)|
0
1 0
0.001482 0.992093827 -0.003447252
0.017756 0.909280969 -0.041301899
0.03461 0.830795868 -0.080505672
0.062752 0.714551853 -0.14596625
0.087872 0.624600876 -0.204397411
0.1154 0.53897699 -0.268429776
0.148382 0.451701375 -0.345148587
0.151317 0.444656212 -0.351975636
0.182301 0.376663088 -0.424046937
0.21227 0.320806186 -0.493757266
0.243085 0.271997267 -0.565435459
0.27193 0.233060529 -0.632531273
0.304032 0.196244217 -0.707203133
0.335489 0.165815578 -0.780374671
0.368753 0.138755614 -0.857749437
0.398647 0.118226461 -0.92728531
0.428504 0.1007546 -0.996735118
0.45853 0.085787096 -1.066578033
0.489229 0.072780259 -1.137986401
0.518332 0.062275562 -1.205682344
0.551074 0.05225852 -1.281842896
0.588565 0.042751366 -1.369050008
0.632151 0.033850525 -1.470434585
0.636644 0.033045653 -1.480885668
0.641462 0.032203811 -1.492092728
0.69043 0.024774433 -1.605996274
0.733076 0.019715403 -1.705194335
0.773732 0.015857565 -1.799763494
0.815537 0.012676363 -1.89700532
0.860653 0.009955228 -2.001948802
0.904221 0.007883308 -2.10329151
0.947903 0.006238793 -2.20489939
0.994049 0.004872606 -2.312238736
62
0.99849 0.004758073 -2.322568862
1.043737 0.003734074 -2.42781706
1.091015 0.002898748 -2.53778953
1.137498 0.00225989 -2.645912764
1.183185 0.001769357 -2.752184438
1.187812 0.001726048 -2.762947216
1.235575 0.001336448 -2.874047834
1.240158 0.001304042 -2.884708265
1.286619 0.001016763 -2.992780325
1.291465 0.000990712 -3.004052515
1.337862 0.000772724 -3.111975707
1.384577 0.000601674 -3.220638592
1.433351 0.00046335 -3.334090879
1.480157 0.000360607 -3.442965437
1.528119 0.000278914 -3.554528946
1.576822 0.000214874 -3.667816081
1.622807 0.000167965 -3.774780927
1.670262 0.000130267 -3.885165113
1.718785 0.000100454 -3.998033553
1.76681 7.76706E-05 -4.109743605
1.771591 7.57069E-05 -4.120864599
1.818227 5.89734E-05 -4.229343724
1.867663 4.52547E-05 -4.344335876
1.914525 3.52095E-05 -4.453340696
1.919243 3.43309E-05 -4.464315147
1.969094 2.62862E-05 -4.580272623
2.01659 2.0382E-05 -4.690752178
2.063888 1.58208E-05 -4.800771169
2.114786 1.20458E-05 -4.919164052
2.162701 9.31927E-06 -5.030618235
2.211975 7.15758E-06 -5.145233562
2.262693 5.45497E-06 -5.263207751
2.312497 4.17777E-06 -5.379055901
2.361825 3.20777E-06 -5.493796837
2.366821 3.12307E-06 -5.505417939
2.416979 2.38732E-06 -5.622089522
2.466501 1.83113E-06 -5.737281717
2.47146 1.78313E-06 -5.748816754
2.523117 1.35215E-06 -5.868975133
2.571686 1.04244E-06 -5.981950573
2.620845 8.01127E-07 -6.096298401
2.672711 6.06816E-07 -6.216942931
63
The graph of Log |1 y(t)| vs. time was obtained from table 6.3 above.
Figure 6.3 shows the graph of Log |1 y (t)| vs. time motor at 35% duty cycle
From the graph in Figure 6.3 and equation 6.5, we now calculate the value of A and alpha
(o).
1
0 log
10
=
=
A
A
Using equation 6.5 and the slope of the graph in figure 6.3 the value of o is calculated as
shown:
-7
-6
-5
-4
-3
-2
-1
0
0 0.5 1 1.5 2 2.5 3
Graph of Log |1 - y(t)| vs Time (s)
64
383 . 5
338 . 2 4343 . 0
768779 . 1
113708 . 4
904221 . 0 673 . 2
103292 . 2 217 . 6
4343 . 0
=
=
=
=
o
o
o
Step 5: Drawing log Be
-|t
Vs. time graph and calculating the value of B and|.
Table 6.4
Cumulative
Time (s)
-o x t Exp(-o x t) 1 + A*Exp(-
o x t)
1 + A*Exp(-o
x t) y(t)
Log (1 + A*Exp(-o
x t) y(t))
0
0 1 2 2 0.301029996
0.001482 -0.007977606 0.992054131 1.992054131 1.984147958 0.297574054
0.017756 -0.095580548 0.908845153 1.908845153 1.818126122 0.259624007
0.03461 -0.18630563 0.830019877 1.830019877 1.660815746 0.220321454
0.062752 -0.337794016 0.71334221 1.71334221 1.427894063 0.154695988
0.087872 -0.473014976 0.623120739 1.623120739 1.247721615 0.096117699
0.1154 -0.6211982 0.537300259 1.537300259 1.076277248 0.03192416
0.148382 -0.798740306 0.449895338 1.449895338 0.901596713 -0.04498768
0.151317 -0.814539411 0.442843249 1.442843249 0.887499461 -0.051831902
0.182301 -0.981326283 0.37481366 1.37481366 0.751476748 -0.124084452
0.21227 -1.14264941 0.318972812 1.318972812 0.639778998 -0.193970021
0.243085 -1.308526555 0.270217914 1.270217914 0.542215182 -0.265828327
0.27193 -1.46379919 0.231355639 1.231355639 0.464416167 -0.33309267
0.304032 -1.636604256 0.194639869 1.194639869 0.390884085 -0.407952011
0.335489 -1.805937287 0.164320369 1.164320369 0.330135947 -0.481307185
0.368753 -1.984997399 0.137380971 1.137380971 0.276136585 -0.55887605
0.398647 -2.145916801 0.116960758 1.116960758 0.235187219 -0.628586283
0.428504 -2.306637032 0.099595626 1.099595626 0.200350226 -0.698210164
0.45853 -2.46826699 0.084731572 1.084731572 0.170518669 -0.768228067
0.489229 -2.633519707 0.071825213 1.071825213 0.144605472 -0.839815271
0.518332 -2.790181156 0.061410088 1.061410088 0.12368565 -0.907680684
0.551074 -2.966431342 0.051486721 1.051486721 0.103745241 -0.984031816
65
0.588565 -3.168245395 0.042077362 1.042077362 0.084828728 -1.071457046
0.632151 -3.402868833 0.033277665 1.033277665 0.06712819 -1.173095061
0.636644 -3.427054652 0.032482472 1.032482472 0.065528125 -1.183572261
0.641462 -3.452989946 0.03165086 1.03165086 0.063854672 -1.194807324
0.69043 -3.71658469 0.024316876 1.024316876 0.049091309 -1.308995388
0.733076 -3.946148108 0.019329012 1.019329012 0.039044415 -1.408441078
0.773732 -4.164999356 0.015529725 1.015529725 0.03138729 -1.503246178
0.815537 -4.390035671 0.012400287 1.012400287 0.02507665 -1.600730477
0.860653 -4.632895099 0.009726559 1.009726559 0.019681787 -1.70593548
0.904221 -4.867421643 0.007693175 1.007693175 0.015576483 -1.807530583
0.947903 -5.102561849 0.006081148 1.006081148 0.012319941 -1.909391369
0.994049 -5.350965767 0.004743568 1.004743568 0.009616173 -2.016997721
0.99849 -5.37487167 0.004631513 1.004631513 0.009389586 -2.027353535
1.043737 -5.618436271 0.003630313 1.003630313 0.007364388 -2.132863358
1.091015 -5.872933745 0.002814604 1.002814604 0.005713352 -2.243109023
1.137498 -6.123151734 0.002191538 1.002191538 0.004451428 -2.351500687
1.183185 -6.369084855 0.001713727 1.001713727 0.003483084 -2.458036027
1.187812 -6.393991996 0.00167157 1.00167157 0.003397618 -2.468825499
1.235575 -6.651100225 0.001292599 1.001292599 0.002629047 -2.58020157
1.240158 -6.675770514 0.001261101 1.001261101 0.002565143 -2.590888422
1.286619 -6.925870077 0.000982048 1.000982048 0.001998811 -2.699228237
1.291465 -6.951956095 0.000956762 1.000956762 0.001947474 -2.710528344
1.337862 -7.201711146 0.000745309 1.000745309 0.001518033 -2.818718733
1.384577 -7.453177991 0.000579597 1.000579597 0.001181271 -2.927650474
1.433351 -7.715728433 0.000445761 1.000445761 0.000909111 -3.041383283
1.480157 -7.967685131 0.00034648 1.00034648 0.000707087 -3.150526868
1.528119 -8.225864577 0.000267641 1.000267641 0.000546555 -3.262365868
1.576822 -8.488032826 0.000205918 1.000205918 0.000420792 -3.375932563
1.622807 -8.735570081 0.000160764 1.000160764 0.00032873 -3.483161196
1.670262 -8.991020346 0.000124523 1.000124523 0.00025479 -3.593817426
1.718785 -9.252219655 9.58986E-05 1.000095899 0.000196352 -3.706963848
1.76681 -9.51073823 7.40524E-05 1.000074052 0.000151723 -3.818948846
1.771591 -9.536474353 7.21708E-05 1.000072171 0.000147878 -3.830097202
1.818227 -9.787515941 5.61482E-05 1.000056148 0.000115122 -3.938843129
1.867663 -10.05362993 4.30293E-05 1.000043029 8.8284E-05 -4.054117913
1.914525 -10.30588808 3.34356E-05 1.000033436 6.86451E-05 -4.163390471
1.919243 -10.33128507 3.25972E-05 1.000032597 6.6928E-05 -4.174391868
1.969094 -10.599633 2.49252E-05 1.000024925 5.12113E-05 -4.29063395
2.01659 -10.85530397 1.9302E-05 1.000019302 3.9684E-05 -4.401384483
2.063888 -11.1099091 1.49633E-05 1.000014963 3.07841E-05 -4.511673144
2.114786 -11.38389304 1.13773E-05 1.000011377 2.34231E-05 -4.630356026
2.162701 -11.64181948 8.79067E-06 1.000008791 1.81099E-05 -4.742083025
66
2.211975 -11.90706143 6.74262E-06 1.000006743 1.39002E-05 -4.856978716
2.262693 -12.18007642 5.13169E-06 1.000005132 1.05867E-05 -4.975241284
2.312497 -12.44817135 3.92489E-06 1.000003925 8.10266E-06 -5.09137242
2.361825 -12.71370398 3.0096E-06 1.00000301 6.21737E-06 -5.206393442
2.366821 -12.74059744 2.92974E-06 1.00000293 6.05281E-06 -5.218042901
2.416979 -13.01059796 2.2365E-06 1.000002237 4.62382E-06 -5.334999066
2.466501 -13.27717488 1.71315E-06 1.000001713 3.54428E-06 -5.450472041
2.47146 -13.30386918 1.66803E-06 1.000001668 3.45116E-06 -5.462035183
2.523117 -13.58193881 1.2631E-06 1.000001263 2.61525E-06 -5.582486219
2.571686 -13.84338574 9.7251E-07 1.000000973 2.01495E-06 -5.695736629
2.620845 -14.10800864 7.46397E-07 1.000000746 1.54752E-06 -5.810362577
2.672711 -14.38720331 5.64569E-07 1.000000565 1.17139E-06 -5.931300335
Step 5: Also shows how the value of B and (|) is calculated.
Using the data from table 5.4 the graph was plotted as shown in figure 6.4
Figure 6.4 shows the graph of Log (1+A*Exp (- x t) y(t)) Log |1 y (t)| vs. time at
35% duty cycle.
Using the intercepts and the values obtained from the graph in Figure 6.4, the
value of B and beta (|) was calculated.
2
30103 . 0 log
10
=
=
B
B
The graph of Log (1+A*Exp (- x t) y(t)) Log |1 y (t)| vs. Time gives a value for |
-7
-6
-5
-4
-3
-2
-1
0
1
0 0.5 1 1.5 2 2.5 3
Graph of Log (1 + A*Exp(oxt) - y(t)) vs Time (s)
67
370 . 5
1636 . 2
046 . 5
4343 . 0
1484 . 0 312 . 2
0458 . 0 0914 . 5
4343 . 0
=
=
=
|
|
|
Step 6: Calculating the transfer function using the values found in previous steps
Since there is not much difference in the value of o (Step 4) and | (Step 5), that is
o = 5.383
| = 5.370
Hence, using equation 6.4 from (Step 3), we get the estimate value of y (t) to be:
370 . 5 383 . 5
2 1 ) (
) ( ) (
+ =
+ + =
e e t y
Be Ae y t y
t
t t | o
Taking the Laplace of the equation gives:
) 370 . 5 )( 383 . 5 (
907 . 28 889 . 26 4
) (
) 370 . 5 )( 383 . 5 (
) 383 . 5 ( 2 ) 370 . 5 ( ) 370 . 5 )( 383 . 5 (
) (
370 . 5
2
383 . 5
1 1
) (
2
+ +
+ +
=
+ +
+ + + + + +
=
+
+
+
+ =
s s s
s s
s y
s s s
s s s s s s
s y
s s s
s y
The transfer function of the motor at 35% duty cycle is given as:
68
) 370 . 5 )( 383 . 5 (
907 . 28 889 . 26 4
2
+ +
+ +
=
s s s
s s
nction Transf erFu
6.3 Calculation of Transfer Function at 50% duty cycle
Table 6.5
Cumulative Time (s) x t Exp (- x t) y(t)=1-(exp(- x t))
0 0 1 0
0.002109 0.025755614 0.974573232 0.025426768
0.066574 0.813017666 0.443517657 0.556482343
0.069393 0.84744397 0.428508815 0.571491185
0.134515 1.642729464 0.193451303 0.806548697
0.199853 2.440652801 0.087103971 0.912896029
0.204555 2.498074753 0.082243185 0.917756815
0.207 2.52793368 0.079823791 0.920176209
0.210009 2.56468031 0.076943776 0.923056224
0.213404 2.606140865 0.073818872 0.926181128
0.21475 2.62257854 0.07261538 0.92738462
0.215564 2.632519303 0.071897103 0.928102897
0.217154 2.651936765 0.070514511 0.929485489
0.226254 2.763068149 0.063097877 0.936902123
0.226285 2.763446728 0.063073994 0.936926006
0.226469 2.765693781 0.062932423 0.937067577
0.290745 3.550647719 0.02870604 0.97129396
0.291581 3.560857151 0.028414459 0.971585541
0.292105 3.567256365 0.028233209 0.971766791
0.301493 3.681904874 0.025174974 0.974825026
0.303374 3.704876098 0.024603266 0.975396734
0.312841 3.820489374 0.021917073 0.978082927
0.377494 4.610047327 0.009951347 0.990048653
0.378904 4.627266585 0.009781459 0.990218541
0.444224 5.424970102 0.004405198 0.995594802
0.444323 5.426179114 0.004399875 0.995600125
0.445621 5.442030601 0.00433068 0.99566932
0.454847 5.554700727 0.003869226 0.996130774
0.455029 5.556923355 0.003860636 0.996139364
0.519157 6.340069882 0.001764179 0.998235821
0.583444 7.125158155 0.000804606 0.999195394
0.648902 7.92454696 0.000361754 0.999638246
0.657161 8.025407851 0.000327047 0.999672953
0.721467 8.810728156 0.000149125 0.999850875
0.722253 8.820326977 0.0001477 0.9998523
69
0.730742 8.923996682 0.000133155 0.999866845
0.739284 9.028313636 0.000119965 0.999880035
0.74014 9.038767314 0.000118717 0.999881283
0.748306 9.138492465 0.000107449 0.999892551
0.81336 9.932947526 4.85485E-05 0.999951452
0.814846 9.951094915 4.76754E-05 0.999952325
0.823322 10.05460586 4.29873E-05 0.999957013
0.823843 10.06096844 4.27147E-05 0.999957285
0.824817 10.07286316 4.22096E-05 0.99995779
0.833874 10.18346942 3.77899E-05 0.99996221
0.842931 10.29407568 3.38329E-05 0.999966167
0.843167 10.29695776 3.37356E-05 0.999966264
0.843235 10.2977882 3.37076E-05 0.999966292
0.844061 10.30787551 3.33693E-05 0.999966631
0.908684 11.09706709 1.51567E-05 0.999984843
0.90905 11.10153677 1.50891E-05 0.999984911
0.910668 11.12129618 1.47939E-05 0.999985206
0.920284 11.23872908 1.31547E-05 0.999986845
0.921276 11.25084362 1.29963E-05 0.999987004
0.923002 11.27192194 1.27253E-05 0.999987275
0.932188 11.38410358 1.13749E-05 0.999988625
0.93351 11.40024816 1.11927E-05 0.999988807
0.933654 11.40200672 1.1173E-05 0.999988827
0.934178 11.40840594 1.11018E-05 0.999988898
0.934982 11.41822458 1.09933E-05 0.999989007
1.000016 12.2124354 4.96829E-06 0.999995032
1.000384 12.2169295 4.94601E-06 0.999995054
1.002262 12.23986409 4.83387E-06 0.999995166
1.011672 12.35478127 4.3091E-06 0.999995691
1.012116 12.3602035 4.2858E-06 0.999995714
1.013277 12.37438191 4.22546E-06 0.999995775
1.078511 13.17103517 1.90499E-06 0.999998095
1.0801 13.19044042 1.86838E-06 0.999998132
1.145355 13.98735015 8.42114E-07 0.999999158
1.146102 13.99647269 8.34467E-07 0.999999166
70
Figure 6.5 Shows the Graph of Motor Speed versus time at 50% duty cycle
Table 6.6
|1-y(t)| log |1-y(t)|
1 0
0.974573232 -0.011185521
0.443517657 -0.353089086
0.428508815 -0.36804024
0.193451303 -0.713428341
0.087103971 -1.059962044
0.082243185 -1.084900081
0.079823791 -1.097867648
0.076943776 -1.113826507
0.073818872 -1.131832597
0.07261538 -1.138971388
0.071897103 -1.143288607
0.070514511 -1.151721503
0.063097877 -1.19998525
0.063073994 -1.200149665
0.062932423 -1.201125548
0.02870604 -1.542026711
0.028414459 -1.546460612
0.028233209 -1.549239755
0.025174974 -1.59903097
0.024603266 -1.609007245
0.021917073 -1.659217453
0.009951347 -2.002118115
0.009781459 -2.009596344
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
-0.2 0 0.2 0.4 0.6 0.8 1 1.2 1.4
Y
(
t
)
Time(s)
Step Response @ o.5
71
0.004405198 -2.35603458
0.004399875 -2.356559647
0.00433068 -2.36344386
0.003869226 -2.412375874
0.003860636 -2.413341149
0.001764179 -2.753457364
0.000804606 -3.094416869
0.000361754 -3.441587017
0.000327047 -3.485390345
0.000149125 -3.82645062
0.0001477 -3.830619335
0.000133155 -3.875642516
0.000119965 -3.920946793
0.000118717 -3.925486768
0.000107449 -3.968796851
4.85485E-05 -4.3138243
4.76754E-05 -4.32170561
4.29873E-05 -4.366659843
4.27147E-05 -4.369423075
4.22096E-05 -4.374588887
3.77899E-05 -4.422624575
3.38329E-05 -4.470660262
3.37356E-05 -4.471911937
3.37076E-05 -4.47227259
3.33693E-05 -4.476653453
1.51567E-05 -4.819395003
1.50891E-05 -4.821336161
1.47939E-05 -4.829917561
1.31547E-05 -4.880918021
1.29963E-05 -4.8861793
1.27253E-05 -4.895333501
1.13749E-05 -4.944053367
1.11927E-05 -4.951064869
1.1173E-05 -4.951828603
1.11018E-05 -4.954607746
1.09933E-05 -4.958871928
4.96829E-06 -5.303793303
4.94601E-06 -5.305745068
4.83387E-06 -5.315705432
4.3091E-06 -5.365613329
4.2858E-06 -5.367968175
4.22546E-06 -5.374125781
1.90499E-06 -5.720107897
1.86838E-06 -5.72853549
8.42114E-07 -6.074628985
8.34467E-07 -6.078590855
72
Figure 6.6 shows the graph of Log |1 y (t)| vs. time motor at 50% duty cycle
Table 6.7
x t exp (- x t)
1 + A*exp (-
x t)
y(t)
1 + A*exp (-
x t) - y(t)
Log (1 +
A*exp (- x t)
- y(t))
0 1 2 0 2 0.301029996
-0.02576 0.974573726 1.974573726 0.025426768 1.949146958 0.289844584
-0.813 0.443524743 1.443524743 0.556482343 0.8870424 -0.052055621
-0.84743 0.428515951 1.428515951 0.571491185 0.857024766 -0.067006628
-1.6427 0.193457548 1.193457548 0.806548697 0.386908851 -0.412391335
-2.4406 0.087108149 1.087108149 0.912896029 0.174212121 -0.758921632
-2.49803 0.082247222 1.082247222 0.917756815 0.164490407 -0.783859424
-2.52788 0.079827757 1.079827757 0.920176209 0.159651549 -0.796826864
-2.56463 0.076947654 1.076947654 0.923056224 0.15389143 -0.812785566
-2.60609 0.073822653 1.073822653 0.926181128 0.147641524 -0.830791479
-2.62253 0.072619122 1.072619122 0.92738462 0.145234502 -0.837930201
-2.63247 0.071900823 1.071900823 0.928102897 0.143797926 -0.842247377
-2.65188 0.070518186 1.070518186 0.929485489 0.141032696 -0.850680191
-2.76301 0.063101304 1.063101304 0.936902123 0.126199181 -0.898943463
-2.76339 0.06307742 1.06307742 0.936926006 0.126151414 -0.899107876
-2.76564 0.062935844 1.062935844 0.937067577 0.125868266 -0.900083749
y = -5.3037x - 9E-13
-7
-6
-5
-4
-3
-2
-1
0
1
-0.2 0 0.2 0.4 0.6 0.8 1 1.2 1.4
L
o
g
(
y
(
t
)
)
Time(s)
Log |y(t)-1| @0.5
73
-3.55058 0.028708043 1.028708043 0.97129396 0.057414084 -1.240981563
-3.56079 0.028416447 1.028416447 0.971585541 0.056830906 -1.24541542
-3.56719 0.028235188 1.028235188 0.971766791 0.056468398 -1.248194536
-3.68183 0.025176796 1.025176796 0.974825026 0.05035177 -1.297985261
-3.7048 0.024605057 1.024605057 0.975396734 0.049208323 -1.307961439
-3.82041 0.021918718 1.021918718 0.978082927 0.043835791 -1.358171153
-4.60996 0.009952249 1.009952249 0.990048653 0.019903596 -1.701068446
-4.62718 0.009782349 1.009782349 0.990218541 0.019563808 -1.708546601
-5.42486 0.004405668 1.004405668 0.995594802 0.008810865 -2.054981433
-5.42607 0.004400344 1.004400344 0.995600125 0.00880022 -2.055506494
-5.44192 0.004331144 1.004331144 0.99566932 0.008661824 -2.06239064
-5.55459 0.003869649 1.003869649 0.996130774 0.007738875 -2.111322174
-5.55681 0.003861058 1.003861058 0.996139364 0.007721694 -2.112287439
-6.33995 0.001764399 1.001764399 0.998235821 0.003528578 -2.452400312
-7.12502 0.000804718 1.000804718 0.999195394 0.001609324 -2.793356466
-7.92439 0.00036181 1.00036181 0.999638246 0.000723564 -3.140523202
-8.02525 0.000327098 1.000327098 0.999672953 0.000654145 -3.184326099
-8.81056 0.00014915 1.00014915 0.999850875 0.000298275 -3.525383023
-8.82015 0.000147726 1.000147726 0.9998523 0.000295426 -3.529551697
-8.92382 0.000133178 1.000133178 0.999866845 0.000266333 -3.574574435
-9.02814 0.000119986 1.000119986 0.999880035 0.000239951 -3.619878268
-9.03859 0.000118738 1.000118738 0.999881283 0.000237455 -3.624418197
-9.13831 0.000107468 1.000107468 0.999892551 0.000214918 -3.667727855
-9.93275 4.8558E-05 1.000048558 0.999951452 9.71065E-05 -4.012751913
-9.9509 4.76847E-05 1.000047685 0.999952325 9.53601E-05 -4.020633147
-10.0544 4.29958E-05 1.000042996 0.999957013 8.59831E-05 -4.065586938
-10.0608 4.27231E-05 1.000042723 0.999957285 8.54378E-05 -4.068350143
-10.0727 4.22179E-05 1.000042218 0.99995779 8.44275E-05 -4.073515904
-10.1833 3.77974E-05 1.000037797 0.99996221 7.55873E-05 -4.121551119
-10.2939 3.38398E-05 1.00003384 0.999966167 6.76727E-05 -4.169586335
-10.2968 3.37424E-05 1.000033742 0.999966264 6.7478E-05 -4.170837998
-10.2976 3.37144E-05 1.000033714 0.999966292 6.7422E-05 -4.171198646
-10.3077 3.3376E-05 1.000033376 0.999966631 6.67453E-05 -4.175579466
-11.0968 1.516E-05 1.00001516 0.999984843 3.03167E-05 -4.518317649
-11.1013 1.50924E-05 1.000015092 0.999984911 3.01815E-05 -4.520258787
-11.1211 1.47971E-05 1.000014797 0.999985206 2.9591E-05 -4.528840103
-11.2385 1.31576E-05 1.000013158 0.999986845 2.63124E-05 -4.579840062
-11.2506 1.29992E-05 1.000012999 0.999987004 2.59955E-05 -4.585101289
-11.2717 1.27281E-05 1.000012728 0.999987275 2.54533E-05 -4.5942554
-11.3839 1.13774E-05 1.000011377 0.999988625 2.27523E-05 -4.642974787
-11.4 1.11952E-05 1.000011195 0.999988807 2.23879E-05 -4.649986221
-11.4018 1.11755E-05 1.000011176 0.999988827 2.23486E-05 -4.650749947
74
-11.4082 1.11043E-05 1.000011104 0.999988898 2.2206E-05 -4.653529063
-11.418 1.09958E-05 1.000010996 0.999989007 2.19891E-05 -4.657793203
-12.2122 4.96948E-06 1.000004969 0.999995032 9.93777E-06 -5.002711188
-12.2167 4.9472E-06 1.000004947 0.999995054 9.89321E-06 -5.004662934
-12.2396 4.83503E-06 1.000004835 0.999995166 9.66889E-06 -5.0146232
-12.3545 4.31015E-06 1.00000431 0.999995691 8.61925E-06 -5.064530606
-12.36 4.28684E-06 1.000004287 0.999995714 8.57264E-06 -5.06688543
-12.3741 4.22649E-06 1.000004226 0.999995775 8.45195E-06 -5.073042975
-13.1708 1.90548E-06 1.000001905 0.999998095 3.81047E-06 -5.419021691
-13.1902 1.86886E-06 1.000001869 0.999998132 3.73724E-06 -5.427449201
-13.9871 8.42346E-07 1.000000842 0.999999158 1.68446E-06 -5.773539294
-13.9962 8.34697E-07 1.000000835 0.999999166 1.66916E-06 -5.777501125
Figure 6.7 shows the graph of Log (1+A*Exp (- x t) y (t)) Log |1 y (t)| vs. time at
50% duty cycle.
From the above tabulated results and graph the value of
o = 12.212
| = 12.212
y = -5.3037x + 0.301
-7
-6
-5
-4
-3
-2
-1
0
1
-0.2 0 0.2 0.4 0.6 0.8 1 1.2 1.4
L
o
g
(
1
+
A
*
e
x
p
(
-
x
t
)
-
y
(
t
)
)
Time
Log (1+A*Exp (- x t) y (t)) Log |1
y (t)| vs. time
75
t t
t t
e e t y
Be Ae y t y
212 . 12 212 . 12
2 1 ) (
) ( ) (
+ =
+ + =
| o
Taking the Laplace of the equation gives;
Therefore, the transfer function of the motor at 50% duty cycle is given as;
) 212 . 12 (
) 212 . 12 ( 3
+
+ +
=
s s
s s
nction TransferFu
6.4 Comparing the Driver Motor Transfer Function
The following transfer functions were obtained for different duty cycle values.
At 35% duty cycle, the transfer function was found to be:
) 370 . 5 )( 383 . 5 (
907 . 28 889 . 26 4
2
+ +
+ +
=
s s s
s s
nction Transf erFu
At 50% duty cycle, the transfer function was found to be:
) 212 . 12 (
) 212 . 12 ( 3
+
+ +
=
s s
s s
nction TransferFu
6.5 Obtaining the Driver Motor Transfer Function through Formula
The formula shown below is used for calculating the driver motor transfer function. This
was the second approach taken to calculate the driver motor transfer function and to
compare the transfer function of that obtained above.
2
) ( ) (
) (
S LJ s L B RJ k k RB
k
s E
s
m m m T E m
T
a
m
+ + + +
=
O
(Eq 6.6)
) 212 . 12 (
) 212 . 12 ( 3
) (
) 212 . 12 (
) 212 . 12 ( 1 3
) (
212 . 12
2
212 . 12
1 1
) (
+
+ +
=
+
+ +
=
+
+
+
+ =
s s
s s
s y
s s
s s
s y
s s s
s y
76
(Source: EE312, Chapter 5; Topic: Actuators)
Where:
-
m
B - Viscous friction (N-m per rads/sec)
-
f
T - Torque (N-m)
-
E
k - Voltage constant (volts)
-
a
L - Armature Inductance (Henries)
- R - Armature Resistance (ohms)
- k - Motor constant (N-m per amp)
-
m
J - Moment of inertia (kg-m
2
)
One of the main reasons for using the formula to obtain the transfer of the drive motor is to
get the exact transfer function of the motor. The motor resistance was obtained by measuring
the resistance between the two terminals (+ve and -ve) of motor. Hence, a digital multimeter
was used to get the resistance value of the driver motor. The resistance of the motor was
found to be:
R = 12
The Armature Inductance
a
L of the driver motor was also obtained by using the LCR meter
to measure the inductance between the two terminals. The Armature Inductance of the motor
was found to be:
a
L = 2.10mH
The moment of inertia was obtained by using the equation 5.7.
2
IR J
m
= (Eqn 6.7)
Where:
- I mass of the wheel and axle (kg)
- R Radius of the wheel (m)
The mass of the wheel and axle was weighted to be 300g and the circumference of the wheel
was calculated using the radius of the wheel, the radius of the wheel is 6.75cm.
77
m c
r c
424 . 0
0675 . 0 2
2
=
=
=
t
t
Hence, using the equation 5.7 to calculate the moment of inertia.
2 3
2
2
10 377 . 1
) 0675 . 0 )( 3 . 0 (
kgm J
J
IR J
m
m
m
=
=
=
The torque produced by the driver motor is used to drive the load that is the differential
drive motor controller setup as shown in chapter 2 of this project. Hence the motor constant,
K of the motor is calculated using the equation 5.8.
a
kI s T = ) ( (Eqn 6.8)
The armature current of the driver motor,
a
I is calculated by:
A I
I
R I V
a
a
a
0 . 1
) 12 )( ( 12
=
=
=
Therefore, the motor constant, k of the motor is:
amp Nm k
k
kI T
a f
/ 0 . 22
) 0 . 1 ( 22
=
=
=
The torque of the motor differs for different motor constant values. Thus, it can be said that
torque is directly proportional to motor constant. The viscous friction, B of the motor can be
calculated; therefore, from the C complier program the frequency is 500Hz. Using the
system frequency and equation 5.9, the angular rotation of the driver wheel is calculated.
f t e 2 =
(Eqn 6.9)
Thus,
sec / 10 14 . 3
) 500 ( 2
2
3
rad
f
=
=
=
t
t e
78
Therefore, viscous friction, B is calculated using equation 5.10
e t / =
m
B
(Eqn 6.10)
Hence,
sec / / 007 . 0
10 14 . 3 / 22
3
rad mper N
B
m
=
=
By obtaining the above parameters, the corresponding values are substituted in place of the
variable. Hence, the transfer function of the driver motor is calculated using the equation 5.6
as shown below:
2 6 3
2 3 3 3 3
2
10 89 . 2 10 91 . 15 334 . 0
5 . 0
) 10 377 . 1 )( 10 10 . 2 ( )) 10 10 . 2 )( 007 . 0 ( ) 10 377 . 1 )( 12 (( ) 5 . 0 )( 5 . 0 ( ) 007 . 0 )( 12 (
5 . 0
) ( ) (
) (
s s
s s
S LJ s L B RJ k k RB
k
s E
s
m m m T E m
T
a
m
+ +
=
+ + + +
=
+ + + +
=
O
Therefore, the transfer function of the driver motor at 50% motor constant is:
334 . 0 10 91 . 15 10 89 . 2
5 . 0
3 2 6
+ +
=
s s
nction TransferFu
6.7 Selecting the transfer function of the motor by comparing the two methods
(i) First method Deriving the transfer function of the motor by using the
feedback method
For 35% duty cycle
) 370 . 5 )( 383 . 5 (
907 . 28 889 . 26 4
2
+ +
+ +
=
s s s
s s
nction Transf erFu
For 50% duty cycle
) 212 . 12 (
) 212 . 12 ( 3
+
+ +
=
s s
s s
nction TransferFu
79
(ii) Second method Deriving the transfer function of the motor by using the
given datasheet of the motor
334 . 0 10 91 . 15 10 89 . 2
5 . 0
3 2 6
+ +
=
s s
nction TransferFu
In contrast, the transfer function is selected from 50 % duty cycle since there
are two numbers of poles as well as two numbers of zeros while had
different number of poles and zeros.
) 212 . 12 (
) 212 . 12 ( 3
+
+ +
=
s s
s s
nction TransferFu
6.8 This section will show how to use Matlab to find the proper integral gain, derivative
and proportional gain of the system.
Deriving the transfer function of a proportional controller Kp
:
) 21 . 12 (
) 21 . 12 4 (
2
s s
K s
nction TransferFu
p
+
+
=
When the proportional gain (Kp) equals 10, the output response when a step input is
applied is
Transfer function of the motor with the gain of 70
280 s + 854.7
-------------
s^2 + 12.21 s
The close loop transfer function of the motor
280 s + 854.7
---------------------
s^2 + 292.2 s + 854.7
80
Step Response
Figure 6.8 Step responses for a proportional controller
Designing a PI controller
s
K s K
i p
+
Transfer function of the motor with Kp = 0.005 and Ki = 80
81
0.02 s^2 + 320.1 s + 976.8
--------------------------
s^3 + 12.21 s^2
The close loop transfer function of the motor
0.02 s^2 + 320.1 s + 976.8
---------------------------------
s^3 + 12.23 s^2 + 320.1 s + 976.8
Step Response
Figure 6.9 a step response for a PI controller at 0.005 and 80 respectively
Transfer function of the motor with Kp = 8.5 and Ki = 75
34 s^2 + 403.8 s + 915.8
------------------------
82
s^3 + 12.21 s^2
The close loop transfer function of the motor
34 s^2 + 403.8 s + 915.8
---------------------------------
s^3 + 46.21 s^2 + 403.8 s + 915.8
Step Response
Figure 7.0 a step response for a PI controller at 8.5 and 75 respectively
Thus the proper gain value for the p-term is 8.5 with the i-term of 75
83
Chapter 7
Mechanical and Electrical Design for Robocon 2011
7.1. Mechanical Aspects of Robocon 2011 Robots
Almost one half of this project was devoted in designing the robots for next years
Robocon competition. The game strategy for the competition was planned in accordance
with the rules of the competition. As in the preliminary stages the project members had
decided to use three machines which is one manual and two automatic machines.
7.1.1 Base Design
The base unit of the machines was similar to that of the machines of 2008 Robocon
competition which was held in India. The base of the manual machine is constructed
using aluminium sheets, since the base has to handle the maximum amount of weight; a
25mm size of aluminium sheet can be used in construction of the base unit. The project
members had chosen to use aluminium because of several reasons stated below:
1) It is very strong
2) Is resistance to corrosion
3) It is affordable (locally)
4) It is bendy
5) Easy to cut, shape and drill
A comparison of the base unit from previous years robots was done and tabulated as
shown in the table below. This allows us to determine our base unit dimensions in
comparison with past years robots.
Table 7.1.0
Year 2010 2008 2007 2005 2004 2003 2002
Length (mm) 600 400 450 455 800 330 560
Width (mm) 500 400 400 400 500 330 560
Height (mm) 150 150 150 150 100 60 60
Average
Length
514mm
Average Width 441mm
Average Height 117mm
84
7.1.2 Mechanical Base Platform
Figure 7.1.1: Proposed mechanical base platform
The above shows the mechanical base of the manual robot. The size of the base is (600 X
500 X 150) mm. The reason for adapting to this style of base unit design is because of it
is easier to distribute the load evenly on both the wheels and also due to limitations of the
rules of this competition. With this type of base design, it can support the structure easily.
The height of the base unit is 1400mm.
7.1.3 Materials Used
The use of Aluminium has been common in many of the ROBOCON machines. This has
been due to the fact that Aluminium is durable, lighter than most of the other type of
metals, readily available, cheap and easy to drill and make structures out of. During the
design process of the machines aluminium angle-line has been extensively used.
Furthermore we recommend that Robotics and Automation Group (RAG) make use
aluminium that has been uniformly holed as shown in figure below. Other materials that
can be taken into consideration are the use of aluminium tubing. This can either
compliment or fully replace the use of aluminium angle line.
85
Figure: 7.1.2
This allows the machine to be lighter in weight. Since because meeting the weight
restrictions has been one of the major problems faced by the ROBOCON group. This will
allow the machines to not exceed the limit set out by the organisers and also allow better
performance.
7.1.4 Wheels
As earlier mentioned in this chapter, the wheel for the base unit can be designed and
fabricated in house. The wooden wheel portrays many advantages in robotic application
as it is useful to cover the circumference with a rubber coating. This rubber reduces the
friction in the wheels and therefore eases the circular motion activity of the robot. The
wooden wheels are more useful to use in place of the rubber or plastic wheels because the
wooden wheels and cater the weight of the whole robot while the rubber and plastic
wheels might not be able to handle the total weight of the machine and also there is a
possibility that it might wear-out at some point in time.
Wheels which have been used in previous years Robocon competitions have had some
problems with the instability of the weight of the machine and friction.
Uniform
Holes
86
Figure 7.1.3: Tricycle wheel Figure 7.1.4 :(ABURobocon2009,HongKongrobot)
Figure a
Figure 7.1.5 a),b):Proposed wooden wheel
The calculation for diameter and circumference of the proposed wheel is shown in the
Chapter 2. This type of wooden wheel is appropriate for robot since the floor that the
robot will be operating on will be very flat with almost no dents on the floor surface.
Moreover the woods lathed in the machine are very accurately made and would remain in
shape longer whereas the plastic wheels might dent as unpleasant shapes has been
experienced from previous years robots. Also the wheel is much easily fixed to the axle
since designing our own wheels allowed us to have a wheel which was much suitable for
the robot.
7.1.5 Arm Construction
The construction of the manual and automatic robotic arms was done in view of the
Robocon 2011 rule and game plan of this competition. The structure can be purely built
using aluminium material because it works well and does the same job when using steel
or any other material to construct the structure. It dimensions of the extension of robotic
arm has been carefully planned as the main aim is to complete each task in the
competition successfully.
Figure b
87
Figure 7.1.6: Robot arm design
Figure 7.4 shows the proposed arm design for Robocon 2011 competition. The design on
its own looks like a folding or integrated machine. Since arm is designed to move
up/down and back/forth. The smaller arm in the front is made up of 15mm aluminium
sheets and because it has to carry a total weight of about 250g according to the rules of
the Robocon contest rules. The smaller arms on the left hand side is design to pick up the
Joss Stick pots from the storage points and place them on the poles situated in the
common zone. The total extension of the manual arm is 650mm from the edge of the
base. This means that the robot does not require going closer to the poles to pick and drop
the Joss Stick pots. This will also allow the arms to function properly and independently
and will cause no harm to other arms located beside it. The arms are sitting on the rubber
rollers to move up and downward directions. The rubber rollers are equally spaced to
reduce friction in the arms.
7.1.6 Rubber Rollers
The operation of the manual robot is in the XYZ plane directions so that means that the
arms have to move forward and backward as well as up and down. To do this task, the
manual arm is designed with the built-in rollers to reduce the friction and also help in
sliding along the XYZ directions. By mounting the rubber rollers in the side and bottom
of the arm reduces the friction and allows the arms to slide in and out smoothly. The
roller tracks can be provided with the grease to further fine the operation of the arms. The
rollers are also designed to reduce the friction in the cable. The rollers itself is designed
with rubber coating or layer on the outer side of the roller and can freely rotate at 360.
88
Figure 7.5: Figure 7.1.7 Roller arm design Figure 7.1.8: Actual view of arm roller
Figure 7.5 shows the design for rubber rollers and its mounting on the robots arm. The
rubbers rollers are there it reduce the friction.
Figure 7.1.9: Rubber roller
Figure 7.7 shows the rubber castor with soft thread. This type of roller can be easily
mounted on the sides and bottom of the arms. It requires M22 size of bolt and machine
screws can also be used to mount it on the surface. Moreover, this type of rubber rollers
can handle maximum weight of up to 70kg. This will be an advantage to use and it can
perform the task up to standard. This type of rubber roller cab is purchased from RS
components in Australia.
7.1.7 Displacement Calculation for Manual Robot
The linear distance travelled by the manual robot was calculated using the game field
specification of Robocon 2011 rules. The trajectory followed by manual machine was
found using the concept shown below.
(Equation 2.1)
89
Where:
F - Applied force
m - Mass of the object
a - gravitational constant (9.81m/s)
Hence, objects which are picked by the manual machine are:
1) Joss Stick pots (250g)
2) Candle Base (800g)
3) Joss Stick (100g)
Therefore, a sample calculation of the force applied at the arms of the machine when
picking the Joss Stick pots is shown below.
N F
F
ma F
45 . 2
) 81 . 9 ( 25 . 0
=
=
=
Table 7.1.1
Mass (Kg) Gravitational Constant
(m/s)
Applied Force (N)
0.25 9.81 2.45
0.8 9.81 7.85
0.1 9.81 0.98
The linear distance travelled by the manual robot at each allocated task of operating point
was again calculated using the game field specification of Robocon 2011 rules. The
distance covered by the manual robot and the spring constant K was tabulated as shown
below.
kx F =
(Equation 2.1)
Where:
F Applied force (Newton)
-K spring constant (elasticity)
X is the displacement at the end operating point.
A sample calculation of the spring constant is shown below:
m N K
K
kx F
/ 13 . 0
7 . 21 ) ( 45 . 2
=
=
=
Table 7.1.2
Desired Tasks Mass (Kg) Applied Force
(N)
Distance (m) Spring
Constant (N/m)
Joss Stick Pots 0.25 2.45 21.7 0.13
Candle Base 0.8 7.85 2.0 3.93
Joss Stick 0.1 0.98 4.3 0.23
90
Table 7.2 shows the distance travelled by the manual machine, amount of weight it will
carry and the spring constant when doing the desired tasks. The time taken for the manual
machine to finish all of its tasks is calculated using the concept shown below. For manual
machine, the motor which can be used to control the speed of the wheels is the SPG
motor, which has high torque capacity of 5.3 N/m and an input voltage of 12 -24V. The
speed of the motor is 1200rpm; hence, it can drive the wheels under load condition.
Assuming the speed of the motor is 40rpm, the rpm value can be converted to m/s
including the circumference of the wheel stated in Figure 2.3.
Speed = wheel circumference x motor rpm / 60 seconds
= 0.42m x 40 / 60 sec
= 0.28 m/s
There will be some delay when the manual robot is performing a particular task for
example when aligning the position of the Joss Stick pots and gripping of the Joss
Stick from the common zone. A delay time of 10 seconds has been added to the total
duration of the manual robot.
Time = total distance travelled by the robot / speed
= 21.7/0.2
= 77.5s
Therefore, the total duration of the manual robot without any technical problems to
perform the desire tasks at the Robocon 2011 competition is
Total time covered by manual robot = 77.5 + 10 = 87.5s or 1minute and 27.5 seconds
7.2 Stress Analysis Calculation for Manual Robot
Figure 7.8 Stress Analysis
The calculation shown below is under load conditions when the manual robot picks up
the Joss Stick pots.
MB = 0 = -2.46 (0.75) + Ax (1.05)
0.75m
A
B
Fmax = 2.46N
1.05m
91
Ax = 1.76N
MA = 0 = -2.46 (0.75) - Bx (1.05)
Bx = -1.76N
Forces in the X direction is = 0
Therefore, -Ax + Bx = 0
Ay = by cancels out each other, therefore, forces in the y direction is = 0
By = -2.46N = 0
By = 2.46N
The calculation shown below is under load conditions when the manual robot picks up
the candle base. The weight of the candle base is 800g and applied force is 7.85N
Hence,
MB = 0 = -2.46 (0.8) + Ax (1.05)
Ax = 1.89N
MA = 0 = -2.46 (0.8) - Bx (1.05)
Bx = -1.89N
7.2.1 Weight Calculation for Manual Robot
The weight of the manual machine can be calculated using the formula shown below.
Considering the limitation value of the weight of all the three robots, it was deemed that
the weight of the machine be analysed and calculated such that all the three machines
does not exceed the set value for the Robocon 2011 competition.
volume mass Density / =
(Equation 2.2)
Therefore mass = Density x volume
The total density of the manual machine was totalled and found to be 9309.6m
3.
; the
density of the aluminium is 2.7g/cm.
Hence the weight of the machine is:
Mass = 2.7 x 9309.6 = 25135.92g /cm = 25.14Kg
This is the total weight of the manual machine which the whole aluminium structured
arm, base and tower.
92
7.2.2 Mechanical Design for Automatics Machines.
Figure:
Key: Auto 1 (task 1), (task 2) (task 3) Auto 2
The above figure shows the path taken by Auto 1 and Auto 2 in order to complete their
assigned tasks.
7.2.3 Distance travelled by the Auto 1
Task1 = 28 Meters
Task 2 = 12.5 Meters
Task 3 = 23 Meters
Total = 63.5 Meters
Distance travelled by the Auto 2 is equal to
Task 1 = 9.5 Meters
7.2.4 The tasks to be performed Automatic One.
:
93
- Pick up the krathong petal and flower and place it at the preparation area.
- decorate the petal and flower on the candle base.
- pick up the candle light flame and drop it on the decorated krathong at the river
surface
- Illustrations of Auto 1s Task.
Figure 7.8.1 Krathong Petal
Side
view
Top
view
Figure 7.8.3 Candle Light
Flame
B: top view
A: side view
Figure 7.8.2 Krathong Petal
Side
view
94
Table 7.2: summary of Auto 1s task objects
Object Base Diameter Height of
Placement on
Pole
Weight(approx) Applied
Force (N)
Krathong Petal 400mm 800mm 250g 2.45
Flower 280mm 800mm 250g 2.45
Candle light
flame
76mm 800mm 200g 1.962
NB: when robot is picking up an object it has to clear/lift the objects a distance of 110mm
and 45mm (+10mm allowance) to clear the objects (petal&flower, candle light flame
respectively) from the storage poles.
By using the table above, the size of the gripper can be estimated. The gripper should
have a maximum opening of 450mm (+50mm allowance). Therefore it would be easier
for the machine to grasp the object. The extension of the arm to grab the flower and petal
are
7.2.4 Weight Calculation for Automatic 1 Robot
Considering the limitation value of the weight of all the three robots, it was deemed that
the weight of the machine be analysed and calculated such that all the three machines
does not exceed the set value for the Robocon 2011 competition.
volume mass Density / =
(Equation 2.2)
Therefore mass = Density x volume
The total density of the manual machine was totalled and found to be 6550.5m
3.
; The
density of the aluminium is 2.7g/cm.
Figure 7.8.4: Automatic 1 physical diagram
95
Hence the weight of the machine is:
Mass = 2.7 x 6050.5 = 25135.92g /cm = 17.68Kg
7.2.5 Time Taken by Automatic 1
For Auto1 machine, the motor which can be used to control the speed of the wheels is the
RS motor, which has high torque capacity of 2.5 N/m and an input voltage of 12 -24V.
The speed of the motor is 2200rpm; hence, it can drive the wheels under load condition.
Assuming the speed of the motor is 65rpm, the rpm value can be converted to m/s
including the circumference of the wheel stated in Figure 2.3.
Speed = wheel circumference x motor rpm / 60 seconds
= 0.42m x 70 / 60 sec
= 0.49 m/s
There will be some delay when the robot is performing a particular task. A delay time of
10 seconds has been added to the total duration. This can be due to the fact that the
machines have to wait for the other two machines to perform their respective tasks.
Time = total distance travelled by the robot / speed
= 63.5/0.49
= 129.59s
Therefore, the total duration of the Automatic 1 robot without any technical problems to
perform the desire tasks at the Robocon 2011 competition is
Total time covered = 129.59 + 10 = 139.59s or 2minutes and 10 seconds
7.3 Automatic Two.
Pick the assembled krathong and place it on
the river surface.
Table 7.3 showing Auto 2s task objects size and weight
Object Base
Diameter
Weight(approx) Applied
Force
(N)
Krathong
Petal
400mm 0.25kg 2.45
Flower 280mm 0.25kg 2.45
Candle
Base
500mm 0.8kg 7.858
Figure 7.8.5 assembled krathong
96
Therefore the total weight of the assembled krathong (minus the candle light flame) is
1.7kg.
Figure 7.8.6: Automatic arm
7.3.1 Time Taken by Automatic 2
For Auto 2 machine, the motor which can be used to control the speed of the wheels is
the RS motor, which has medium to low torque capacity of about 2-2.5 N/m and an input
voltage of 12 -24V. The speed of the motor is 2200rpm; hence, it can drive the wheels
under load condition. Assuming the speed of the motor is 100rpm, this value is possible
since the machine is small and does not weigh much.
Speed = wheel circumference x motor rpm / 60 seconds
= 0.42m x 100 / 60 sec
= 0.7 m/s
There will be some delay when the robot is performing a particular task. A delay time of
5 seconds has been added to the total duration. This can be due to delays faced by the
machine in picking up the object.
Time = total distance travelled by the robot / speed
= 9.5/0.7
= 13.57s
Therefore, the total duration of the Automatic 2 robot without any technical problems to
perform the desire tasks at the Robocon 2011 competition is
Total time covered = 13.57 + 5 = 18.57 seconds.
97
7.3.2Moment Calculation
The calculation shown below is when Auto 2 picks up the Karthong without candle light
flame.
MB = 0 = -16.67(0.5) + Ax (1.0)
Ax = 8.335N
MA = 0 = -16.67(0.5) - Bx (1.0)
Bx = -8.335N
Forces in the X direction is = 0
Therefore, -Ax + Bx = 0
Ay = by cancels out each other, therefore, forces in the y direction is = 0
By = -16.67N = 0
By = 16.67N
The calculation shown below is under load conditions when the manual robot picks up
the candle base. The weight of the candle base is 800g and applied force is 7.85N
Hence,
MB = 0 = -16.67 (0.8) + Ax (1.0)
Ax = 13.36N
MA = 0 = -16.67 (0.8) - Bx (1.0)
Bx = -13.36N
7.3.3 Weight Calculation for Automatic 2 Robot
The weight of the manual machine can be calculated using the formula shown below.
Considering the limitation value of the weight of all the three robots, it was deemed that
the weight of the machine be analysed and calculated such that all the three machines
does not exceed the set value for the Robocon 2011 competition.
volume mass Density / =
(Equation 2.2)
Fmax =
16.67N
0.5m
A
B
1.0m
Figure 7.8.7: Auto side view
98
Therefore mass = Density x volume
The total density of the manual machine was totalled and found to be 4859.7m
3.
; The
density of the aluminium is 2.7g/cm.
Hence the weight of the machine is:
Mass = 2.7 x 4859.7 = 25135.92g /cm = 13.12Kg
7.4 Total Weight of All three Machines:
Manual + Auto 1 + Auto 2 = Total weight
24.14 + 17.68 + 13.12 = 54.94Kg
The above calculation shows that the weight of the machine exceeds by almost 5kg. And
this is with no electronics on board. Therefore, we can use alternative material or modify
the designs such that the weight can be reduced.
7.5 Electronics for Automatic machines
7.5.1 Motor Controller
From the past year of Robocon competition, the open source motor controllers (OSMC)
have been used to drive the motor which then drives the automatic vehicles. OSMC is an
high power H-bridge circuit which is designed to control permanent Dc motors.
Moreover, it was designed expressly for robot competitions. There are several types of
motor controller available on the internet but because of the OSMC performances used in
the past robot, it is recommended that it could be used again for Robocon 2011. The
reason for choosing OSMC is because it is capable of driving and at the same time can
control the speed of the motor also OSMC is cable of withstanding high currents and
voltage.
99
Figure 7.8.8: Open source motor controller
Source: http://www.robotpower.com/images/osmc-wfan-sm.jpg
The OSMC has larger current handling capability. It can also drive wide variety of motor,
since a cordless drill motor is used in the manual machine, the OSMC can drive the
motors without having any problems.
This type of motor controller is suited for robotic application hence it can be used in the
manual machine to drive the cordless frill DC motors.
7.5.2 Features of OSMC
Key Features OSMC
Supply voltage
13V to 50V (36V max battery
rating)
output Current (continuous) 160A
Output Current (surge) >400A
Weight 0.6 lb
100
Advantages of using OSMC:
- It can be easily mounted on a flat surface
- It can be interfaced with PIC microcontrollers
- the OSMC can be repaired and further modified
- it is reliable to use
7.5.3 Sensors
Light Dependant Resistor Sensors(LDRs)
Last year this particular technology has been used to navigate the Robocon machines in
their respective tasks. Therefore, for the Automatic machine we recommend to use this
technology again. This is a very simple but effective way of path-finding. The concept
makes use of basic electronics such as LEDs, LDRs, and an operational-amplifier (op-
amp) IC-LM324. In the field of robotics the use of Line tracing is very important as it
gives to the robot an easy way to navigate itself. Sensors provide a sense of perception
during navigation. Before the use of LDRs, our ROBOCON team was using Lynx Single
line detection sensor.
The basic principle for the LDR is that depending on the varying light it receives
accordingly resistance also varies. When light falls on the LDR the resistance value
decreases, this is called negative co-efficient.
Whereas when the LDR is operating in opposite way that is when resistance becomes
high in the presence of light (positive co-efficient).
MOSFETs
16 ea. IRFB3207 (or IRF1405
on older units)
On Resistance 0.0026 ohm max at 25C
Cooling 40 CFM fan
Bridge Driver Intersil HIP4081A
Logic Interface 10-pin dual-row header
RC Interface External via logic interface
Power Supply 12V .5A regulator
Current Limiting Optional Add-on
Connectors
Solder pads for up to 10 ga
wire or #8 bolts
101
The LDR in use for this project is a negative co-efficient LDR.
Figure 1 shows the property of the LDR, which
shows that resistance and Light Intensity are
inversely proportional. As Light Intensity
increased resistance decreased.
Table 7.5.1: Specification
for the LDR line tracer sensor
Specification
Sensor Type LDR(Light Dependant Resistor
LED Super-bright White (4mm)
I/O Required One digital line (input)
Minimum Range 5mm from floor
Maximum range 30mm from floor
Input Voltage 5vdc regulated
Current Requirements 18mA - 29mA
Overall Size 0.75" w x 1.5" l x 0.25 h
Weight 0.02 lbs
Figure 7.5.1
Figure 7.8.9 LDR Sensor Schematic
Figure 7.9.0 LDR Sensor
102
7.5.4 Force Sensors
Force sensors are used in the grippers of the automatic machine to detect the force and
grip it.
Figure 7.9.1 Force sensor diagram
This is a small force sensitive resistor. It has a 0.16" (4 mm) diameter active sensing area.
This FSR will vary its resistance depending on how much pressure is being applied to the
sensing area. The harder the force, the lower the resistance. When no pressure is being
applied to the FSR, its resistance will be larger than 1M, with full pressure applied the
resistance will be 2.5k.
Two pins extend from the bottom of the sensor with 0.1" pitch making it bread board
friendly.
These sensors are simple to set up and great for sensing pressure, but they aren't
incredibly accurate. Use them to sense if it's being squeezed, but you may not want to use
it as a scale
This sensor is available at http://www.sparkfun.com
Price is USD $5.95
Stock number SEN 09673
7.5.5 MICROCONTROLLER
The robotic groups in the past years have used PIC18f6722 for their microcontroller.
However for next year contest we recommend to use PIC18f4550 since the chip 18f4550
is replaceable. For the PIC18f6722 if the PIC goes bad we have to replace the whole
board since the chip is not replaceable. However for PIC18f4550 the chip is replaceable.
7.5.5.1 PIC18f6722
The Robocon projects from past two years have begun to use the PIC 18F6722 instead of
the PIC 16F877 of the following reasons :
High-Performance RISC CPU
64 pins altogether
7 ports(A,B,C,D,E,F,G) with 52 I/O pins
5 Capture/Compare/PWM (CCP) modules
Operates at DC 40MHz
17 Interrupt sources
Large amounts of RAM memory for buffering and FLASH program memory
The Table 7.5.2 summarises the other important features of PIC 18F6722.
Parameter Name Value
Program Memory Type Flash
103
Program Memory (KB) 128
CPU Speed (MIPS) 10
RAM Bytes 3,936
Data EEPROM (bytes) 1024
Digital Communication Peripherals 2-A/E/USART, 2-MSSP(SPI/I2C)
Capture/Compare/PWM Peripherals 2 CCP, 3 ECCP
Timers 2 x 8-bit, 3 x 16-bit
ADC 12 ch, 10-bit
Comparators 2
Temperature Range (C) -40 to 125
Operating Voltage Range (V) 2 to 5.5
Pin Count 64
Figure 7.9.2 PIC18f6722 Prototype board
7.5.5.2 PIC18F4550 USB DEVELOPMENT BOARD
Features of PIC18f4550 development board
Includes Microchip PIC18F4550 Microcontroller
All necessary power supply components are pre-installed and board is ready-to-run
Direct In-Circuit Program Download with the PIC Programmer or Microchip ICD2
4 Pushbuttons with Speaker On-Board
4 Variable Trimpots for Adjustable Analogue Inputs
4 Red Test LED's
Large Breadboard
USB and RS232 Connection
Selectable PROG-RUN Switch
Power and Programming LED
In-Circuit Debugging with Microchip ICD2 Unit
Ideal Training and Development Board for the PIC18F4550 Microcontroller
104
Figure 7.9.3 PIC18F4550 microcontroller
FEATURES OF PIC18F4550
105
This chip is available at http://www.futurlec.com
Price: of the PIC18f4550 development board USD $40.00
Price of PIC18f4550 chip USD $6.90
Total price is USD $46.90
7.5.5.3 VOLTS DC MOTOR
IN PREVIOUS Years the robotic groups have used cordless drill motor for their
differential drive system. However for next years robocon completion we recommend to
use Crouzet 82862 001 12 volts DC motor since it is very suitable for this application.
Features of the Motor
- Output Speed 441rpm
- Output Torque 50nm
- Power rating 3.9W
- Voltage 12V
Figure 7.9.4 Crouzet 82862 001 12 volts DC motor
Since the tasks of the automatic machines are as such we recommend using a high torque
motor.
This motor is available at http://australia.rs-online.com
RS Stock No. 178-4585
The price of each motor is Australian $155.00
7.5.5.4 Motors for the Grippers
106
After completing our possible designs for the next years competition we recommend to
use Hi-Tec servo motors for the grippers. Also these motors will be used in the automatic
machine to rotate the tower.
7.5.5.5 SERVO MOTOR
The servo motor is actually an assembly of four things: a normal DC motor, a gear
reduction unit, a position-sensing device (usually a potentiometera volume control
knob), and a control circuit.
The function of the servo is to receive a control signal that represents a desired output
position of the servo shaft, and apply power to its DC motor until its shaft turns to that
position. It uses the position-sensing device to determine the rotational position of the
shaft, so it knows which way the motor must turn to move the shaft to the commanded
position. The shaft typically does not rotate freely round and round like a DC motor, but
rather can only turn 200 degrees or so back and forth
Figure 7.9.5 SERVO MOTOR
This servo can operate 180 when given a pulse signal ranging from 600usec to
2400usec. Since most R/C controllers cannot generate this wide of signal range
This motor is available at http://www.servocity.com
107
Price is USD $8.99
Stock number: 31311S
7.5.5.6 Battery
Batteries are one of the most common parts of the machine. They are the fuel for the
machine to run. In the previous years batteries put weight to the machine. Hence we
recommend using a lighter battery which reduces the weight of the machine.
7.5.5.7 V 2300 mAH NiMH Rechargeable Battery Pack
During my research we found out that NiMH Rechargeable Battery Pack would be
suitable for application since its lighter in weight.
7.5.5.8 Features and Benefits
- 9.6V 2300mAh NIMH rechargeable battery pack
- Made of 8 x AA high capacity NiMH cells with 6" wire 14 Gu. .
- NiMH technology enables convenient charging at any time. No cell memory
effect. No need to fully discharge before recharging.
- Standard discharging rate at 1.8A and Max. discharging rate at 3.5A.
- Perfect for robots.
7.5.5.9 Technical Specifications
- Standard Dimension: 2.25"(58mm)L x 1.91"(49mm)W x 1.12"(29mm) H
- Weight: 7.8 Oz
- Capacity: 2300 mAh
- Voltage: 9.6V
- Standard Charge: 2 hours @ 0.9A with our Smart Universal Battery Pack Charger
The only disadvantage of using this battery is that the motor will not run at 100
percent duty cycle, rather it will lower close to 80 percent. However, it could be
used since from my literature review I have found out that the teams at the
competition this year have used similar batteries in their machines.
Figure 7.9.6 Battery
108
This battery is available at http://www.all-battery.com
Price is USD $15.99
109
Discussion
In this project, students are able to do a close loop speed control of the motor using PID
(Proportional Integral Derivative) control. There are two types of method used in
calculating the transfer function of the motor and the first method is deriving the transfer
function of the motor with the given speed and time obtained from the motor. In the
second method, students use a datasheet to calculate the transfer function of the motor.
Moreover, students select two duty cycles such as 35% and 50% to calculate the transfer
function of the motor. In 35% duty cycle, the transfer function of the motor comes to be
) 370 . 5 )( 383 . 5 (
907 . 28 889 . 26 4
2
+ +
+ +
s s s
s s
And for 50 % duty cycle the transfer function of the motor comes to be
) 212 . 12 (
) 212 . 12 ( 3
+
+ +
s s
s s
However, by using the data sheet of the motor the transfer function of the motor comes to
be
334 . 0 10 91 . 15 10 89 . 2
5 . 0
3 2 6
+ +
s s
In contrast the selected transfer function of the motor is selected at 50% duty cycle since
the transfer function obtained has equal number of poles and equal number of zeros.
From the transfer function obtained from a 50% duty cycle, students then use MATLAB
(Matrix Laboratory) to obtain the proportional gain of 8.5 and the integral gain of 75 for a
PI controller.
110
Conclusion and Recommendations
After doing this project, it has enabled us broaden our knowledge about robot designing
and has been a great means of gaining experience. It has also allowed a good experience
in this field of work. We have gained a lot of experience in designing PCBs and soldering
the various components to the PCB after checking the continuity of the circuit. We have
soldered the components to the PCB as well as de-soldered the old components from the
previous years robots and projects. And also drilled and filed the PCBs to shape. The
boot loader interfacing board, the sensor PCB was also a new learning curve. We have
also worked on the programming of the robots and testing the robots abilities using PID
control by shaft encoders and motor controllers. We have also learnt a lot about the motor
controller boards and how to program it in order to control the motors by setting the
appropriate duties. The tachometer was used to measure the wheel rotation and chose the
duties for both wheels. After both wheels were rotating at the same speed the robot was
placed on the game field and tested on it. These robots were a two wheel drive robot and
had two castor wheels in the front to allow it to turn around. This course had been a very
interesting experience and a chance to learn a lot about robot designing. We have learnt a
lot from the previous years ROBOCON robots and would be using these skills in future.
We have been able to improve all our skills during this semester due to our commitment
to ROBOCON and the EE300 course. Our work in this course was a very good one to
practice and enhance our skills. What we have noticed during EE300 project is that
students doing hardware projects most of the time have their parts delayed. This causes
the students to fall behind in their work. If this area could be looked at it would further
improve this unit. This course has enabled us to broaden our knowledge about robot
designing and has been a great means of experience gaining. We have been able to
enhance our skills and knowledge in the many ways.
111
References
[1] R .Singh. A Distributed PIC Microcontroller Architecture for AGV Application.
MSc thesis, University of the South Pacific, Suva, Fiji, 2006.
[2] Department of Engineering University of the South Pacific, EN300 Project,
Vehicle platform for non-linear control, 2008
[3] Department of Engineering University of the South Pacific, EE300 Project
Designing, Development and Testing of a PIC Micro-controller based Differential
Drive Line Tracing Vehicle-2 with PID, 2009
[4] Microchip. PIC16F8X Datasheet: 28/40 pin 8-BIT CMOS FLASH
Microcontrollers. Technical Reference Document DS30292C, Microchip
Technology Inc., 2001.
[6] Praneel Chand, Chapter 5, Actuators, EE312, Department of Engineering
University of the South Pacific
[7] http://www.ikalogic.com/sensors.html
[8] From farnel, HEDS 5540 A06 product information
http://de.farnell.com/jsp/search/productdetail.jsp?sku=280940&N=0
(Accessed October, 08)
[9] http://octopart.com/info/Avago/HEDS-5540%23A06
[10] http://www.datasheetcatalog.org/datasheet2/c/0g7eikd8l6augl4oplt2ozda7dfy.pdf
[11] http://www.robotmarketplace.com/products/RP-OSMC.html
[12] Department of Engineering University of the South Pacific, EN300 Project, PIC
Based Generic DC Motor Speed and Position Controller, 2004.
[13] http://www.australia.rs-online.com
[14] http://www.servocity.com/servomotor.com.html
112
Appendix
//This is a master program code
#include <16f877.h>
#device *=16
#use delay (clock=4000000)
#fuses XT,noWDT
#use rs232(baud=9600,parity=N,xmit=PIN_c6,rcv=PIN_c7)
#opt 9
#org 0x1f00,0x1fff void loader16f877(void){}
#include <stdlib.h>
#include <math.h>
#USE STANDARD_IO(a)
#USE STANDARD_IO(e)
#define latch pin_D5 //LATCH
#define clock pin_D6 //CLOCK
#define data pin_D7 //DATA
void xmit();//function declaration
*************************************************
float duty2 = 50,duty1=50;//seconds per revolution
//**********************************function declaration**********
int dir1,cons,i;
unsigned int32 array[23];
unsigned int32 pac,packet;
signed int32 A2=0,dir2=0;
//**********************************************************************
*************
void main(void)
{
set_tris_e(0xff);// this is used for tristate buffers
set_tris_a(0x1f);
set_tris_c(0x00);
xmit();
}
//**********************************************************************
******
void xmit()
{
Cons = 0;
pac = 0;
packet = 0;
printf("\n\rduty2:%ld",duty2); // this displays the duty cycle that has to send
113
pac = (dir1*2)+(dir2*4)+(duty1*256)+(duty2*65536);// max value of the packet
8257536;
printf("\n\rpacket for dc = %lu",pac);
printf("\n\r");
delay_ms(10);
output_high(latch); //enable latch
delay_ms(10);
output_high(clock); //clock signal high
//converting the packet into binary format for sending over the
//data line
for( i=0; i<23; i++)
{
array[i]= pac % 2;
output_high(clock);
printf("%lu",array[i]);
delay_ms(10);
if (array[i]==1) //if the bit is 1 then the data line is high
{
output_high(data); // send data bit 1
delay_ms(10);
}
else if (array[i]==0) //if the bit is 0 then the data line is low
{
output_low(data); // send data bit 0
delay_ms(10);
}
output_low(clock); //clock signal low
pac = pac/2;
}
output_low(latch); //disable latch
}
//Slave 1 codes
#include <16f877.h>
#device *=16
#use delay (clock=4000000)
#fuses XT,noWDT
#use rs232(baud=9600,parity=N,xmit=PIN_c6,rcv=PIN_c7)
#opt 9
#org 0x1f00,0x1fff void loader16f877(void){}
#include <stdlib.h>
#include <math.h>
#define latch pin_e2 //LATCH
114
#define clock pin_e1 //CLOCK
#define data pin_e0 //DATA
//*****************************************Global Declaration of the
variables****************************************************************
****
unsigned int32 dir1, dir2;
float duty2,duty1,freq,spr;
unsigned int32 period, pwm_value;
unsigned int16 req_rpm = 0, mesr_rpm = 0;
signed int16 error=0;
double i_term,p_term,i_state,d_term;
unsigned int16 d_state=0;
unsigned int8 obit7,optodetect=0,counter=0;
unsigned int32 j=0,i=0,g,array[22];
unsigned int32 packet,mult2po;
float correction=0.0;
//**********************************function
declaration***************************************************************
*
void mydelay(); // mydelay function for delays in decimal values
void xmit();
void recieve();
void update_pid();
void stabilise();
//**********************************************************************
***************************************************************
#INT_TIMER1//These directives specify the following function is an interrupt function.
Interrupt functions may not have any parameters.
//Not all directives may be used with all parts.
// See the devices .h file for all valid interrupts for the part or in PCW use the pull
down VIEW | Valid Ints
void timer_overflow_counter()//when the timer is overflow the counter will increase by 1
{
counter++;
}
//**********************************************************************
***************************************************************
#INT_RB //it detects all the interrupts in ports_b
void check_rpm()//the function is used to detect the rpm of the motor
{
int value,nbit7;
obit7 = nbit7;
115
value = input_b(); //read optodetect inputs
nbit7 = value & 0x80; //B7 mask unwanted bits
//*******************************this is used to stabilise the left
motor*********************
If(nbit7 != obit7)
{
optodetect++;
// printf("Optodetect %d",optodetect);
}
if(optodetect==32) //number of interrupts for full rev(8 ups and 8 downs)
{
spr=((counter*0.065536)+(0.000001*get_timer1()));//seconds per rev=tallyed
time(2^16+current time)
//get_timer1 is used to get the time when needed from
timer 1
mesr_rpm = 60/spr;//spr=>rpm;use 60 for full rev and 30 for half
//we divide the counter by 1x10^6 Hz since to seconds per
revolution
set_timer1(0);
counter=0;
optodetect=0;
printf("\n\rDesired Rpm: %lu\n\n\r",req_rpm);
printf("\n\rCurrent Rpm: %lu\n\n\r",mesr_rpm);//is this needed?
error = req_rpm - mesr_rpm; // attain req_rpm from serial cornmswith epp.
update_pid();
//delay_ms(2);//why DELAY
}
}
//******************************************pid is updated now***********
void update_pid()
{
p_term = 8.5*error;
i_state += error;
116
if(i_state >100){
i_state = 100;
}
else if(i_state < -100){
i_state = -100;
}
i_term = 75*i_state;
d_term = (0* (error - d_state));
d_state = error;
correction = p_term + i_term + d_term;
if(correction > 100){
correction=100;
}
else if(correction < -100){
correction = -100;
}
stabiliSe();
}
//**********************************************************************
*************
void stabilise()
{
correction = correction/100;
duty2=duty2+correction;
if(duty2>=100)duty2=100;
else if(duty2<=0)duty2=0; //?20
printf("\n\rThe new duty cycle is: %3.2f", duty2);
}
//**********************************************************************
*************
117
void main(void)
{
freq=500,req_rpm =180;; //Frequency of PWM
setup_ccp2(CCP_PWM);//wire7 //port_c1 generates pwm
set_tris_e(0xff);// this is used for tristate buffers
set_tris_a(0x1f);
set_tris_c(0x00);
recieve(); //it suppose to go the function and wait for the latch to get high
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); //Initializes timer 1.
//The timer value may be read and written to using
SET_TIMER1() and GET_TIMER1()Timer 1 is a 16 bit timer.
//With an internal clock at 20mhz and with the T1_DIV_BY_8
mode, the timer will increment every 1.6us.
//It will overflow every 104.8576ms.
set_timer1(0);//Sets the count value of a real time clock/counter. RTCC and Timer0 are
the same.
//All timers count up. When a timer reaches the maximum value it will flip over
to 0 and continue counting (254, 255, 0, 1, 2...)
while(1)
{
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);//could we put 500 directly into the period formula
period = (float)(4000000/(freq*64))-1;//timer2 resets every 124 us
setup_timer_2(T2_DIV_BY_16,period,1); //set timer2 with t2 DIV set to 16
pwm_value=(float)(duty2*4000000)/(100*freq*16); //assign duty cycle and frequency
for PWM
set_pwm2_duty(pwm_value);
}
}
//**********************************************************************
*************
118
void recieve()
{
i=0;
printf("\n\rwaiting for Latch to enable\n\r");
while(!input(latch)); // if latch become high,
// then !(high) = 0, which means that
// the program jumps out of the while loop
// otherwise hang in and wait here until a high
printf("\n\rLatch enabled\n\r");
while(input(latch)) //latch is high
{
while(input(clock));//clock high
// now we read the data bit for this round
// only 1 bit to be read
while((!input(clock))&&(input(latch))) //clock low
{
array[i]=input(data); // store the value of the data pin
} // in the array at address i
printf("%u",array[i]);
i++; //incrementing i
}
printf("\n\rLatch disabled");
packet = 0;// initialise packet to 0 for
//purpose of clean reconstrcution
for( j=0;j<21;j++) //converting binary to decimal value
{
mult2po = array[j]<<j;
packet = packet + mult2po;
// printf("\n\rarray @ %u is %lu", j,array[j]);
// printf("\tpacket is %lu",packet);
// printf("\tmult2po is %lu",mult2po);
}
}
119
//Slave 2 code
#include <16f877.h>
#device *=16
#use delay (clock=4000000)
#fuses XT,noWDT
#use rs232(baud=9600,parity=N,xmit=PIN_c6,rcv=PIN_c7)
#opt 9
#org 0x1f00,0x1fff void loader16f877(void){}
#include <stdlib.h>
#include <math.h>
#define latch pin_e2 //LATCH
#define clock pin_e1 //CLOCK
#define data pin_e0 //DATA
//*****************************************Global Declaration of the
variables****************************************************************
****
unsigned int32 dir1, dir2;
float duty2,duty1,freq,spr;
unsigned int32 period, pwm_value;
unsigned int16 req_rpm = 0, mesr_rpm = 0;
signed int16 error=0;
double i_term,p_term,i_state,d_term;
unsigned int16 d_state=0;
unsigned int8 obit6,optodetect=0,counter=0;
unsigned int32 j=0,i=0,g,array[22];
unsigned int32 packet,mult2po;
float correction=0.0;
//**********************************function
declaration***************************************************************
*
void mydelay(); // mydelay function for delays in decimal values
void xmit();
void recieve();
void update_pid();
void stablise();
//**********************************************************************
***************************************************************
120
#INT_TIMER1//These directives specify the following function is an interrupt function.
Interrupt functions may not have any parameters.
void timer_overflow_counter()//when the timer is overflow the counter will increase by 1
{
counter++;
}
//**********************************************************************
***************************************************************
#INT_RB //it detects all the interrupts in ports_b
void check_rpm()//the function is used to detect the rpm of the motor
{
int value,nbit6;
obit6 = nbit6;
value = input_b(); //read optodetect inputs
nbit6 = value & 0x40; //B7 mask unwanted bits
//*************************************************this is used to stabilise the
left motor******************************
if(nbit6 != obit6)
{
optodetect++;
// printf("Optodetect %d",optodetect);
}
if(optodetect==32) //number of interrupts for full rev(8 ups and 8 downs)
{
spr=((counter*0.065536)+(0.000001*get_timer1()));//seconds per rev=tallyed
time(2^16+current time)
//get_timer1 is used to get the time when needed from
timer 1
mesr_rpm = 60/spr;//spr=>rpm;use 60 for full rev and 30 for half
121
//we divide the counter by 1x10^6 Hz since to seconds per
revolution
set_timer1(0);
counter=0;
optodetect=0;
printf("\n\rDesired Rpm: %lu\n\n\r",req_rpm);
printf("\n\rCurrent Rpm: %lu\n\n\r",mesr_rpm);//is this needed?
error = req_rpm - mesr_rpm; // attain req_rpm from serial cornmswith epp.
update_pid();
//delay_ms(2);//why DELAY
}
}
//******************************************pid is updated
now**********************************************************
void update_pid()
{
p_term = 8.5*error;
i_state += error;
if(i_state >100){
i_state = 100;
}
else if(i_state < -100){
i_state = -100;
}
i_term = 75*i_state;
d_term = (0* (error - d_state));
d_state = error;
correction = p_term + i_term + d_term;
//intduty = correction;
122
if(correction > 100){
correction=100;
}
else if(correction < -100){
correction = -100;
}
stabliSe();
}
//**********************************************************************
**************************************************************
void stablise()
{
//printf("\n\rStabalising speed now...");//printf("\n\rError = %l",error);
correction = correction/100;
duty2=duty2+correction;
if(duty2>=100)duty2=100;
else if(duty2<=0)duty2=0; //?20
printf("\n\rThe new duty cycle is: %3.2f", duty2);
}
//**********************************************************************
**************************************************************
void main(void)
{
set_tris_e(0xff);// this is used for tristate buffers
set_tris_a(0x1f);
set_tris_c(0x00);
recieve(); //it suppose to go the function and wait for the latch to get high
freq=500; //Frequency of PWM
setup_ccp2(CCP_PWM);//wire7 //port_c1 generates pwm
req_rpm =180;
123
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); //Initializes timer 1.
//The timer value may be read and written to using
SET_TIMER1() and GET_TIMER1()Timer 1 is a 16 bit timer.
//With an internal clock at 20mhz and with the T1_DIV_BY_8
mode, the timer will increment every 1.6us.
//It will overflow every 104.8576ms.
set_timer1(0);//Sets the count value of a real time clock/counter. RTCC and Timer0 are
the same.
//All timers count up. When a timer reaches the maximum value it will flip over
to 0 and continue counting (254, 255, 0, 1, 2...)
while(1)
{
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);//could we put 500 directly into the period formula
period = (float)(4000000/(freq*64))-1;//timer2 resets every 124 us
setup_timer_2(T2_DIV_BY_16,period,1); //set timer2 with t2 DIV set to 16
pwm_value=(float)(duty2*4000000)/(100*freq*16); //assign duty cycle and frequency
for PWM
set_pwm2_duty(pwm_value);
}
}
//**********************************************************************
******************************************************************
void recieve()
{
i=0;
printf("\n\rwaiting for Latch to enable\n\r");
while(!input(latch)); // if latch become high,
// then !(high) = 0, which means that
// the program jumps out of the while loop
// otherwise hang in and wait here until a high
printf("\n\rLatch enabled\n\r");
while(input(latch)) //latch is high
{
124
while(input(clock));//clock high
// now we read the data bit for this round
// only 1 bit to be read
while((!input(clock))&&(input(latch))) //clock low
{
array[i]=input(data); // store the value of the data pin
} // in the array at address i
printf("%u",array[i]);
i++; //incrementing i
}
printf("\n\rLatch disabled");
packet = 0;// initialise packet to 0 for
//purpose of clean reconstrcution
for( j=0;j<21;j++) //converting binary to decimal value
{
mult2po = array[j]<<j;
packet = packet + mult2po;
// printf("\n\rarray @ %u is %lu", j,array[j]);
// printf("\tpacket is %lu",packet);
// printf("\tmult2po is %lu",mult2po);
}
}
125