Title: Bengkel Asas Pembinaan Robot 2
1Universiti Teknologi Malaysia Robot Contest
UBOCON 02
- Bengkel Asas Pembinaan Robot 2
Prepared by Yeong Che Fai
2Overview
- Micro Controller Circuit
- Atmel AT89C2051with output
- Micro Controller Programming
- Simple Program
- Compiler
- Universal Programmer
- Micro Controller Circuit
- Atmel AT89C2051 with output and input
- Sensor
- Infra red detector
- Micro Controller Circuit Sensor
- Motor Driver
- L293B
- Micro Controller Circuit Sensor Motor Driver
- Conclusion
3 Micro controller circuit (Atmel AT89C2051 with
output)
4- Build a basic micro controller system as shown
below. - 3 majors component to connect to micro
controller power, oscillator and reset circuit.
5 V
10uF
P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0
Reset
10K ohm
33pF
Oscillator
12Mhz crystal
P3.7 P3.5 P3.4 P3.3 P3.2 P3.1 P3.0
33pF
Gnd
5Basic micro controller system
6- Now, connect LEDs to pin as shown below
5 V
10uF
5 V
P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0
Reset
10K ohm
220 ohm
LED
33pF
Oscillator
12Mhz crystal
LED
220 ohm
P3.7 P3.5 P3.4 P3.3 P3.2 P3.1 P3.0
33pF
Gnd
7- The circuit is ready, now remove the Atmel and
proceed to download your program onto it.
8 Micro controller Programming (Simple Program,
Compiler, Universal Programmer)
9Simple program
- Write program as below and save as Test1.asm
Test 1 Led Blinking mod51 org
0h again mov p1,00000001b On LED at
p1.1 acall delay delay mov p1,00000010b On
LED at p1.0 acall delay delay ljmp again Alway
s jump back to again delay Delay's
Function mov r1,1 l1 mov r2,160 l2 mov r3,25
5 l3 djnz r3,l3 djnz r2,l2 djnz r1,l1 ret end
10Saving Test1.asm file
Make sure save as Test1.asm
11Compiler
- Now, compile the Test1.asm using software
available (ie asm51.exe) - Go to dos and go to the directory with the
assembler application (Its better if your
program save in the same folder). - Type asm51 Test1.asm
- This function will generate Test1.hex and
Test1.lst. - Text1.hex is machine code which is needed to
download to Atmel.
12Compiler
13Universal Programmer
- 3 major things to be done using the programmer
- Erase the microcontroller
- Load Hex file onto the microcontroller
- Program and verify the microcontroller
- Next few slides show the steps using the
Universal Programmer
14Step 1 Open All-11 Universal Programmer Tester
15Step 2 Click at device and choose ATMEL
16Step 3 Click at MPU/MCU and choose AT89C2051
17Step 4 Erase the microcontroller
18Step 5 Click run and close after the process.
19Step 6 Load a .Hex file
20Step 7 Browse to folder and choose on TEST1.HEX
21Step 8 Set the settings as shown and click ok
22Step 9 Finally, run program now, your Atmel is
downloaded with TEST1.HEX
23Video
- Try run the circuit with the Atmel.
- Press reset and the leds should blinking.
- Now, add your circuit with a switch.
24 Micro controller circuit (Atmel AT89C2051 with
output and input)
25Input
- Add a push on switch circuit as shown below
5 V
10uF
5 V
P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0
Reset
10K ohm
220 ohm
LED (Red)
33pF
Oscillator
12Mhz crystal
LED(Green)
220 ohm
P3.7 P3.5 P3.4 P3.3 P3.2 P3.1 P3.0
33pF
220 ohm
Gnd
Push on Button
26- Now write source code below and save as Test2.asm
- Redo the previously step of compiling and load
onto atmel.
Test2.asm Input Push on button Output
LEDs mod51 org 0h mov p3,10000000b Set
pin p3.7 as input again jnb p3.7,on Jump to
"on" if switch is pressed mov p1,00000001b Gre
en LED on ljmp again Always loop back
to "again" on mov p1,00000010b Yellow LED
on ljmp again Always loop back to "again" end
27- Run the circuit.
- LED will switch when the push on button is On
Not pressed
Pressed
28Video
29Sensor (Infra Detector)
30- Set the 10K ohm preset for input 2- to middle
position. - By tuning the 10K ohm preset for input 2 will
trigger the output2. - If input 2 is tuned to max, led will light on
and vice versa when input 2 is tuned to minimum. - If Inp2 gt Inp2-
- out2 will at HIGH state
- If Inp2 lt Inp2-
- out2 will at LOW state
5 V
Out4 Inp4- Inp4 Gnd Inp3 Inp3- Out3
14 13 12 11 10 9 8
1 2 3 4 5 6 7
Out1 Inp1- Inp1 Vcc Inp2 Inp2- Out2
L M 2 3 4
5 V
220 ohm
10K Ohm preset
5 V
10K Ohm preset
Multi turn preset
Normal preset (Cheaper)
315 V
- Now, modify your inp2 with ir sensor as shown
below. - Moving a pierce of paper (any white surface
material) on top of the sensor will trigger the
output.
Out4 Inp4- Inp4 Gnd Inp3 Inp3- Out3
14 13 12 11 10 9 8
1 2 3 4 5 6 7
Out1 Inp1- Inp1 Vcc Inp2 Inp2- Out2
L M 2 3 4
5 V
220 ohm
IR Transmitter
5 V
10K Ohm preset
3.7K ohm
IR Detector
IR Detector
IR Transmitter
5 V
32Different view
Side view
Top view
With white line
Without white line
33Video
34Micro controller (Circuit and Programming) Senso
r (Infra Detector)
35Micro controller
Connect the micro controller and sensor together
by red point shown in picture below.
5 V
10uF
5 V
P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0
Reset
10K ohm
220 ohm
LED
33pF
Oscillator
12Mhz
LED
220 ohm
P3.7 P3.5 P3.4 P3.3 P3.2 P3.1 P3.0
33pF
220 ohm
Gnd
Push on Button
Connect to sensor circuit
36Sensor
5 V
Out4 Inp4- Inp4 Gnd Inp3 Inp3- Out3
14 13 12 11 10 9 8
1 2 3 4 5 6 7
Out1 Inp1- Inp1 Vcc Inp2 Inp2- Out2
L M 2 3 4
5 V
220 ohm
5 V
10K Ohm preset
3.7K ohm
IR Detector
IR Transmitter
Connect to Micro controller circuit
5 V
37Combination
- Connect both circuits together
Micro controller
Sensor
Sensor micro controller
Make a connection by simply add a wire To the
point shown previously slides.
38Video
- Use Test2.asm as program for this circuit.
- Triggering the infra detector will switch on
the microcontroller.
39DC Motor (Motor driver L293B)
40Working in progress Check back on 9th November
2002
41Micro controller (Circuit and Programming) Senso
r (Infra Detector) DC Motor (Motor driver L293B)
42Working in progress Check back on 9th November
2002
43Conclusion
44Conclusion
Power Supply
DC Motors
Start and stop switch
Line Sensors
- Now, put everything in one piece of PCB in a
structure manner. - Make it robust as it can be modified anytime.
- Circuit above is only hiasan.
45Conclusion
- Learn how to build a basic Atmel system.
- Learn how to build a simple white detector
sensor. - Learn how to combine the sensors to the
microcontroller. - Hope, you can proceed with blah blah..blah.
- CHECK BACK ON 9TH NOVEMBER 2002 FOR A COMPLETE
AND CORRECT VERSION.
46 The End!! Check back again on 9th November
2002