460 likes | 656 Views
Universiti Teknologi Malaysia Robot Contest. UBOCON ‘02. Bengkel Asas Pembinaan Robot 2. Prepared by Yeong Che Fai. Overview. Micro Controller Circuit Atmel AT89C2051with output Micro Controller Programming Simple Program Compiler Universal Programmer Micro Controller Circuit
E N D
Universiti Teknologi Malaysia Robot Contest UBOCON ‘02 Bengkel Asas Pembinaan Robot 2 Prepared by Yeong Che Fai
Overview • 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
Micro controller circuit (Atmel AT89C2051 with output)
19 18 17 16 15 14 13 12 A T M E L A T 8 9 C 2 0 5 1 1 4 5 11 9 8 7 6 3 2 Vcc 20 10 • 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
19 18 17 16 15 14 13 12 A T M E L A T 8 9 C 2 0 5 1 1 4 5 11 9 8 7 6 3 2 Vcc 20 10 • 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
The circuit is ready, now remove the Atmel and proceed to download your program onto it.
Micro controller Programming (Simple Program, Compiler, Universal Programmer)
Simple 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 ;Always jump back to again delay: ;Delay's Function mov r1,#1 l1: mov r2,#160 l2: mov r3,#255 l3: djnz r3,l3 djnz r2,l2 djnz r1,l1 ret end
Saving Test1.asm file Make sure save as Test1.asm
Compiler • Now, compile the Test1.asm using software available (ie; asm51.exe) • Go to dos and go to the directory with the assembler application (It’s 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.
Universal 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
Step 1 Open All-11 Universal Programmer & Tester
Step 2 Click at device and choose ATMEL
Step 3 Click at MPU/MCU and choose AT89C2051
Step 4 Erase the microcontroller
Step 5 Click run and close after the process.
Step 6 Load a .Hex file
Step 7 Browse to folder and choose on TEST1.HEX
Step 8 Set the settings as shown and click ok
Step 9 Finally, run program… now, your Atmel is downloaded with TEST1.HEX
Video • Try run the circuit with the Atmel. • Press reset and the leds should blinking. • Now, add your circuit with a switch.
Micro controller circuit (Atmel AT89C2051 with output and input)
19 18 17 16 15 14 13 12 A T M E L A T 8 9 C 2 0 5 1 1 4 5 11 9 8 7 6 3 2 Vcc 20 10 Input • 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
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 ;Green LED on ljmp again ;Always loop back to "again" on: mov p1,#00000010b ;Yellow LED on ljmp again ;Always loop back to "again" end
Run the circuit. • LED will switch when the push on button is “On” Not pressed Pressed
Sensor (Infra Detector)
Build circuit below • 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+ > Inp2- ; • out2 will at “HIGH” state • If Inp2+ < Inp2- ; • out2 will at “LOW” state 5 V 14 13 12 11 10 9 8 Out4 Inp4- Inp4+ Gnd Inp3+ Inp3- Out3 Out1 Inp1- Inp1+ Vcc Inp2+ Inp2- Out2 1 2 3 4 5 6 7 L M 2 3 4 5 V 220 ohm 10K Ohm preset 5 V 10K Ohm preset Multi turn preset Normal preset (Cheaper)
Build circuit below 5 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. 14 13 12 11 10 9 8 Out4 Inp4- Inp4+ Gnd Inp3+ Inp3- Out3 Out1 Inp1- Inp1+ Vcc Inp2+ Inp2- Out2 1 2 3 4 5 6 7 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
Different view Side view Top view With white line Without white line
Micro controller (Circuit and Programming) + Sensor (Infra Detector)
19 18 17 16 15 14 13 12 A T M E L A T 8 9 C 2 0 5 1 1 4 5 11 9 8 7 6 3 2 Vcc 20 10 Micro 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
Sensor 5 V 14 13 12 11 10 9 8 Out4 Inp4- Inp4+ Gnd Inp3+ Inp3- Out3 Out1 Inp1- Inp1+ Vcc Inp2+ Inp2- Out2 1 2 3 4 5 6 7 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
Combination • Connect both circuits together Micro controller Sensor Sensor + micro controller Make a connection by simply add a wire To the point shown previously slides.
Video • Use Test2.asm as program for this circuit. • Triggering the infra detector will switch “on” the microcontroller.
DC Motor (Motor driver L293B)
Working in progress Check back on 9th November 2002
Micro controller (Circuit and Programming) + Sensor (Infra Detector) + DC Motor (Motor driver L293B)
Working in progress Check back on 9th November 2002
Conclusion 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”….
Conclusion • 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.
The End!! Check back again on 9th November 2002