"Making Microcomputer Controlled Line Tracing Robot"
Edited by
Shibaura Institute of Technology,
Center for Lifelong Learning and Extension Programs
S.I.T LTR04 Line Tracing Robot
Hardware & Software Manual
Shibaura Institute of Technology
Center for Lifelong Learning and Extension Programs
Ver.0.2 for UCI
Summer Session
Preface
Recently, various topics on robot are frequently appearing in TV. Though people are
increasingly interested in the robot, there is a little chance to learn how to make robots by
themselves.
Since Shibaura Institute of Technology (SIT) has experiences in the making of micro mouse
robot, we developed the educational robotics workshop program using the new line tracing
robot (S.I.T LTR01) with digital logic circuit for celebrating the 70th anniversary of Shibaura
Institute of Technology in 1997.
After this, we developed variety of robots and programs for the workshops. Based on these
experiences, we began to develop the microprocessor controlled line tracing robot again in 2000,
and developed the line tracing robot (S.I.T LTR02) in 2001.
It was a robot with a simple structure for easy understanding of electronics, computer
system and control mechanism, and the line tracing robot (S.I.T LTR03) was improved based
on the experiences of the workshops over several times in 2002, and started a line tracing robot
workshops every year. After this, robot has been improved and completed as the S.I.T LTR04
course. This lecture will use a line tracing robot that contains all three elements that make up
robot “Sensor”, “Microcomputer processing”, “Motor drive control”. And this purpose is to get a
deep understanding of the mechanism by making every student make a robot mechanism and
electronics circuit as well as writing and debugging control programs to control the robot
actually.
The robot is composed of as few parts as possible for the purpose of understanding the
principle of control program as well as the configuration of the circuit behavior. Therefore, you
also will notice principle of the device you are using in the circuit.
The one-chip microprocessor is used for computer which provides intelligence to the robot.
The microprocessor contains all the features of the computers, and is an affordable material to
understand the principle of operation of the computer and programming.
We think you will have many difficulties in the workshop, however are confident that you
will reach the confidence that “I can control anything using a microcomputer” by the end.
Finally, we would express our gratitude for manual editing to many members of each
laboratory including Mr. Koji Noda.
July 25, 2005
Shibaura Institute of Technology, Center for Lifelong Learning and Extension Programs
Robot Seminar Group
Shibaura Institute of Technology, College of Engineering, Dept. of Electrical Engineering
Human Robot Interaction Laboratory Professor Makoto Mizukawa
Robotics Laboratory Associate Professor Yoshinobu Ando
Shibaura Institute of Technology
Professor Emeritus Chie Kasuga
Ftech Co.,LTD
Yasuo Ogawa
English version was prepared for UC Summer Session in S.I.T. in 2012 with the support
from following professors.
Shibaura Institute of Technology, College of Design Engineering, Dept. of Design Engineering
Robotics Laboratory Professor Yoshinobu Ando
Shibaura Institute of Technology, College of Engineering, Dept. of Electrical Engineering
Robot Task & System Laboratory Professor Takashi Yoshimi
Micro-Mechatronics Laboratory Associate Professor Tadahiro Hasegawa
Human Robot Interaction Laboratory Professor/Dean, College of Engineering
Makoto Mizukawa
July, 8th, 2012
Table of contents
Chapter 1 Introduction ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・1
Chapter 2 Configuration of the line tracing robot kit ・・・・・・・・・・・・・・・・・・・・・・2
2.1 A circuit diagram, a printed circuit board, and a part list ・・・・・・・・・・・・・・2
2.2 Drawing aluminum bracket, figure aluminum mounting for cart ・・・・・・・・・・6
Chapter 3 Assembly・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・8
3.1 Printed circuit board assembly procedure ・・・・・・・・・・・・・・・・・・・・・8
3.2 Parts mounting procedure・・・・・・・・・・・・・・・・・・・・・・・・・・・・23
Chapter 4 Program development・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・26
4.1 Port Assignments ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・26
4.2 Program development by assembly language・・・・・・・・・・・・・・・・・・・27
4.2.1 Assembly ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・27
4.2.2 Flashing LED, switch operation ・・・・・・・・・・・・・・・・・・・・・28
4.2.3 Straight, curve・・・・・・・・・・・・・・・・・・・・・・・・・・・・・37
4.2.4 How to detect the line using the photo sensor ・・・・・・・・・・・・・・・42
4.2.5 How to follow the line ・・・・・・・・・・・・・・・・・・・・・・・・・43
4.3 Sample program using assembly language・・・・・・・・・・・・・・・・・・・・68
4.3.1 Turn on and off LEDs ・・・・・・・・・・・・・・・・・・・・・・・・・68
4.3.2 Go straight ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・71
4.3.3 Line trace1・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・74
4.3.4 Line trace2・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・78
4.4 Program development by C language・・・・・・・・・・・・・・・・・・・・・・・86
4.4.1 Flow of program development ・・・・・・・・・・・・・・・・・・・・・・86
4.4.2 Blinking of LED, Switch operation ・・・・・・・・・・・・・・・・・・・86
4.4.3 Go straight,Turn ・・・・・・・・・・・・・・・・・・・・・・・・・・・92
4.4.4 Method of detecting the line by sensor ・・・・・・・・・・・・・・・・・・100
4.4.5 How to trace a line・・・・・・・・・・・・・・・・・・・・・・・・・・・102
4.5 Example Program by C Language ・・・・・・・・・・・・・・・・・・・・・・・ 110
4.5.1 Blinking LED ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・110
4.5.2 Go straight ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・112
4.5.3 Line Trace(for beginners)・・・・・・・・・・・・・・・・・・・・・・・113
4.5.4 Line Trace(for middle level)・・・・・・・・・・・・・・・・・・・・・・116
4.5.5 Line Trace(for advanced level)・・・・・・・・・・・・・・・・・・・・・119
1
Chapter 1 Introduction
【Background and features of production kit】
In 1997, the line tracing robot “S.I.T LTR01” was developed to celebrate the 70th Anniversary of
Shibaura Institute of Technology (SIT). Afterwards, we have been working on the development of
various robots, such as multi-legged walking robot for the robot seminar. In 2001, we designed line
tracing robot again with the “S.I.T LTR02”. From this experience, we continued to make
“S.I.T LTR03” in 2002. It was awarded the Good Design Award in 2003. After that, “S.I.T LTR04”
was developed with improvements to increase robot’s speed.
S.I.T LTR series are designed with a minimum number of elements that make up the robot, so it
can be easily assembled in a short time even by beginners and can be used as the material for
introduction to microcomputer. Moreover, it carefully supports the creation of robot for beginners.
For reference in case you cannot participate in the seminar, the content of the lectures is included
in CD-ROM provided with this textbook.
【Kit Contents】
Main components of S.I.T LTR04:
1. Microcomputer board: 1x PIC16F84 (20MHz) microcomputer and peripheral circuits.
2. Detection sensor line: 3x LED and phototransistor pairs.
3. Gear motor: 1x double gear box.
4. Power supply circuit and battery box.
Figure 1.1 Line tracing robot S.I.T LTR04
2
Chapter 2 Configuration of the line tracing robot kit
2.1 Circuit diagram, printed circuit board (PCB), and part list
The following figures and table show configuration of S.I.T LTR04 robot kit.
• Figure 2.1: circuit diagram.
• Figure 2.2: PCB top layer.
• Figure 2.3: PCB bottom layer.
• Figure 2.4: PCB pattern (top layer).
• Figure 2.5: PCB pattern (bottom layer).
• Table 2.1: part list (bill of material – BOM).
Figure 2.1 S.I.T LTR04 schematic diagram
3
Figure 2.2 S.I.T LTR04 printed circuit board (Top)
Figure 2.3 S.I.T LTR04 printed circuit board (Bottom)
4
Figure 2.4 S.I.T LTR04 PCB pattern (Top)
Figure 2.5 S.I.T LTR04 PCB pattern (Bottom)
5
Table2.1 S.I.T-LTR04 BOM
No. NAME Component
arrangement number
Part name Part number Number
1 Monolithic Ceramic
Chip Capacitors
C2,C3,C5,C6,C7,C8C9 0.1μ 7
2 Electrolytic Capacitor C4 10220(E) 1
3 Electrolytic Capacitor C1 50V10(E) 1
4 Diode D1,D2 1SS133 1SS133 2
5 Diode D3,D4 11EQS03L 11EQS03L 2
6 Transistor Q4,Q5 Tr 2SD2106 2
7 One-Chip
Microcomputer
IC1 PIC16F84 PIC16F84A-20/P 1
8 LED(Green) LED1 LED GL3KG8 1
9 LED(RED) LED2,LED3,LED4 LED GL3PR8 3
10 IR LED LED2,LED3,LED4 TLRE180AP(F) TLRE180AP(F) 3
11 Photo transistor Q1,Q2,Q3 TPS615(F) TPS615(F) 3
12 Resistor(O,O,Bl,Bl,Br)* R8,R9,R10 100 100R0 3
13 Resistor(Br,Bl,Bl,R,Br)* R4,R19,R20 10
K
1002 3
14 Resistor(O,O,Bl,Go,Br)* R6,R7 1
K
1001 2
15 Resistor(B,G,Bl,Bl,Br)* R1 680 6800 1
16 Resistor(Br,Bl,Bl,Br,Br)* R3,R11,R12,R13,R14 1
K
1001 9
17 Resistor(O,Bl,Bl,R,Br)* R2 30
K
3002 1
18 Resistor(R,Bl,Bl,O,Br)* R5 200
K
2003 1
19 Mechatronics Key
Switch
SW1,SW2 B3F-1052 B3F-1052 2
20 Toggle Switch SW3 SW(POWER) 1
21 Pre-Set Variable
Resistor
VR1,VR2,VR3 50
K
3
22 Connector CN1 S5B-XH-
A
1
23 CERALOC
K
X1 20MHz 1
24 IC Socket DIP-18P IC
Socket(18P)
1
25 Battery Holder Battery Box MC-304-3 1
26
A
luminum Chassis
A
luminum
Chassis
1
27 NabeM3-10 screw thread 4
28 NabeM2-6 Brass screw thread 2
29 Sara M3-6 Brass Nickel screw thread 2
30 Nylon Spacer Spacer 3×3 4
31 Caster Dokodemo
Caster
1
32 circuit board F0278 1
33 Double Gear
BOX
NO.168 1
34 Tire Track Tire Set NO.101 2
35 M2Nat 2
36 M3nat 6
37 φ3 Spring washer 4
Resister is 5-digit display, with tolerance of ±1%. In case of 4-digit display, see p.150 of reference book [1].
*Resistor color code: Black Bl, Brown Br, Red R, Orange O, Blue B, Grey G, Gold Go,
6
2.2 Drawings of aluminum frame and robot assembly
Figure 2.6 shows the drawing of aluminum frame and figure 2.7 shows assembly drawing of
S.I.T.LTR04.
Figure 2.6 Drawing of aluminum frame.
7
Figure 2.7 Assembly drawing
8
Chapter 3 Assembling
3.1 Printed circuit board assembly procedure
(a) Resistor・・・20pcs
Refer to the BOM in Table 2.1 for value of each resistor and resistor color code.
(a)Enlarged view (b) A real resistor (c) Schematic symbol
Figure 3.1 Resistor
<Characteristics >
・No polarity, no need to worry about orientation when assembling.
・Be careful with color code. Reference 1.
Figure 3.2 Mounting position of resistor
9
(b) Diode・・・4pcs
D1, D2・・・2pcs
D3, D4・・・2pcs
(a) Enlarged (b) 1SS133 (c) 11EQS03L (d) PCB symbol
Diode Diode
Figure 3.3
<Characteristics >
・Cathode is marked by a yellow line.
・Be careful with the orientation of diodes.
Figure 3.4 Mounting position of diodes
10
(c) Light-emitting diode・・・4pcs
LED1 (power indicator) green・・・1pcs
LED5~7 (sensor indicator) red・・・3pcs
(a) Enlarged view (b) Actual LED (c) PCB symbol
Figure 3.5 Light-emitting diode (LED)
<Characteristics >
・By lead length: the longer lead is “+”, the shorter lead is “-”.
・By electrode size: the smaller one is ”+”, the larger one is “-“.
・Checking with multimeter: when the minus rod (black) is attached to LED’s anode (+) and the plus
rod (red) is attached to LED’s cathode, multimeter’s needle will swimg.
Figure 3.6 Mounting position of LEDs
11
(d) Multilayer ceramic capacitor ・・・7pcs
C2, C3, C5, C6, C7, C8, C9 0.1[μF]・・・7pcs
(a) Enlarged view (b) Actual capacitor (c) PCB symbol
Figure 3.7 Multilayer ceramic capacitor
<Characteristics >
・Function: eliminating the noise from motors and other parts.
・No polarity, no need to worry about direction when assembling.
Figure 3.8 Mounting position of multilayer ceramic capacitors.
12
(e) DIP-18P IC socket (18 pin socket)・・・1pcs
(a)Enlarged view (b) Actual socket (c) PCB symbol
Figure 3.9 DIP-18P IC socket
<Characteristics >
・Fit the Notch in socket and the Notch in schematic symbol
1. When soldering a socket, firstly fix it with some tape (Figure 3.10).
2. Temporary solder from pin 1 to pin 10 (Figure 3.11).
3. With your finger pressing the socket, use the soldering iron to thoroughly melt the solder
at each pin.
(3.10) Attaching socket (1) (3.11) Attaching socket (2) (3.12)Attaching socket (3)
Time-saver
13
(f) CERALOCK ・・・1pcs
CERALOCK (ceramic resonator) 20[MHz]・・・1pcs
(a) Enlarged view (b) Actual ceralock (c) PCB symbol
Figure 3.13 CERALOCK
<Characteristics >
・”GND” is the center pin.
・No polarity, no need to worry about orientation when assembling.
Figure 3.14 Mounting position of CERALOCK
14
(g) Mechanical key switch ・・・2pcs
SW1 (Reset)・・・1pcs
SW2 (Start)・・・1pcs
(a) Actual switch (b) PCB symbol
Figure 3.15 Mechanical key switch
<Characteristics>
・No polarity, no need to worry about orientation when assembling.
・Press the switch’s shoulders to plug it in a parallel basis(3.15(a)).
Figure 3.16 Mounting position of mechanical key switches
15
(h) Semi-fixed variable resistor・・・3pcs
VR1~VR3 50[kΩ]・・・3pcs
(a) Actual one (Top view) (b) PCB symbol
Figure 3.17 Semi-fixed variable resistor
<Characteristics >
・Resistance value changes from 0[kΩ] to 50[kΩ] by turning the knob in the center.
・Mounting is uniquely determined because of special pin arrangement.
<Tips for mounting>
・Solder one pin first to fix the part’s position and keep it from floating.
・ Then solder the last two pins when position is fixed.
Figure 3.18 Mounting position of semi-fixed variable resistor
16
(i) Electrolytic capacitor … 2pcs
C1 10[μF] … 1pcs
C4 220[μF] … 1pcs
(a) Enlarged view (b) Actual capacitor (c) PCB symbol
Fig 3.19 Electrolytic capacitor
<Characteristics >
・ Attach “ + ” of part to “ + ” on schematic symbol.
・ In actual capacitor, the polarity of “ - ” marked lead is minus.
・ In case of no “-“ mark found, the polarity of longer lead is “ + ”.
Fig 3.20 Position of electrolytic capacitors
Pay attention to
the polarity !
Marked by
“-” sign
1
C1,C4
17
(j) Switching transistor
Q4, Q5 … 2pcs
(a) Actual transistor (b) PCB symbol (c) Schematic symbol
Fig 3.21 Transistor
<Characteristics>
・ From the front, left to right, the order of three leads is B (base), C (collector), and E (emitter).
Fig 3.22 Positions of transistors.
B
E
C
B C E
Heatsink
B
C
E
B
C
E
2SD2106
or 2SD560
Q4,Q5
18
(k) Toggle switch 3P … 1pcs
SW3 … 1pcs
(a) Actual switch (b) PCB symbol (c) Position
Fig 3.23 Toggle switch 3P
(l) S5B-XH-A downloader connector … 1pcs
CN1 … 1pcs
Caution) This connector must be soldered to PCB’s bottom layer.
Fig 3.24 Connector and attachment position
Switch’s terminals
are symmetrical.
It can be assembly
i ith di ti
Carefully check
orientation!!
Solder to bottom layer.
19
(m) Phototransistor … 3pcs
Q1, Q2, Q3 … 3pcs
Caution) Phototransistors Q1, Q2, Q3 must be soldered to PCB’s bottom layer.
(a) Enlarged view (b) Side view (d) PCB symbol
Fig 3.25 Phototransistor
<Characteristics>
・ Phototransistors receive reflecting light from the floor.
・ Be careful with the polarity of emitter and collector.
Fig 3.26 Position of phototransistors
Emitter Collector
PCB
Caution!
Solder firml
y
to PCB.
The
longer
ld
The
shorter
ld
Collector
Emitter
E C
The
shorter
lead
The
longer
lead
The smaller one
Q1~3
Solder to bottom
layer.
Caution!
Push all the way down to PCB.
Solder to bottom layer.
20
(n) Red LED … 3pcs
LED2, LED3, LED4 … 3pcs
Caution) LED2-4 must be soldered to PCB’s bottom layer.
(a) Enlarged view (b) Side view (d) PCB symbol
Fig 3.27 Red LED
<Characteristics>
・ Emit red light to the floor under robot.
・ Be careful with the polarity of anode and cathode.
Fig 3.28 Position of red LEDs
Anode
Cathode
Anode
Cathode
K
A
PCB
Caution!
Solder firmly to PCB.
The larger one
The
longer
lead
The
shorter
lead
K A
The longer lead
The shorter lead
LED2~4
Solder to bottom layer.
Caution!
Push all the way down to PCB.
Solder to bottom layer.
21
(o) Battery box … 1pcs
(a) (b) PCB symbol
Fig 3.29 Battery box
Caution) Thread the wires through the hole near battery connection points before
soldering.
Fig 3.30 Position of battery box connection
PCB
Solder
Hole
Wires
Vcc
GND
Red wire
Black wire
BATTERY
Thread wires
through the
hole