bagaimana membina robot anda sendiri
DESCRIPTION
step by step to build own robot especially line following robot. This article in Malay version.TRANSCRIPT
LINE FOLLOWING ROBOT
KENALPASTI OBJEKTIF BINAAN ROBOT KENALPASTI INPUT/OUTPUT PENGHASILAN LITAR ANTARAMUKA
(INTERFACE) MEREKABENTUK ALGORITMA PROGRAM (MENGGUNAKAN CARTA ALIRAN ) PENGUJIAN ALGORITMA PENGUBAHAN PROGRAM/ LITAR
(JIKA DIPERLUKAN)
DEFINASI ROBOT:Robot adalah mesin yang direkabentuk untuk melakukan/ melaksanakan suatu kerja atau lebih berulang kali dengan kelajuan yang tetap dan mempunyai ketepatan yang tinggi.
Kebiasaan mikropengawal (mc) digunakan untuk pengawal robot berskala mikro. Contohnya robot soccer dan line following robot.
Mikropengawal digunakan kerana ia : 1. murah 2. bersaiz
kecil
Apakah yang perlu saya lakukan untuk memulakan pembinaan robot?
Saya tiada pengetahuan asas pengaturcaraan, adakah mampu saya membinanya?
Saya tiada pengetahuan dalam bidang elektronik, bagaimana saya mahu membina litar robot saya sendiri?
Otak
Denyutan jantung Sistem
Perkumuhan
Deria
Pelaksana Arahan
5V DC Supply
Ground Potential
Input Pin Ports Crystal Clock
Current Flows
Central Procession Unit (CPU)
Output Pin Ports
Pengaliran Darah
Degupan Jantung
Otak
Deria Rasa
Makanan
Sistem Perkumuhan
Pelaksana Arahan
5V DC Supply
Ground Potential
Input Pin Ports
Crystal Clock
Current Flows
Central Procession Unit (CPU)
Output Pin Ports
Vdd Supply
Resi
stor
LED
Push Button Ground
Vdd Supply
Resi
stor
LED
Ground
State Of The Push Button
State of LED
Released OFF
Pressed ON
Push Button
Istilah isyarat dalam Sistem Digit
ON
OFF
HIGH
LOW
YES
0
1
NO
Vdd 5V
0V Vss
Vdd
ResistorLED
Push Button
Resistor
Push Button
Vdd
VddVss
LEDTanpa mikro pengawal
Dengan mikropengawal
A2
A3
A4
A5
B0
B1
B2
B3
A1
A0
A7
A6
B7
B6
B5
B4
VddVss
Input Output Pin
PORTA
PORTB
A2
A3
A4
A5
B0
B1
B2
B3
A1
A0
A7
A6
B7
B6
B5
B4
VddVss
Sambungan Input Output Kepada Mikro pengawal
Resistor
Green LED
Resistor
Push Button
Vdd
Resistor
Vdd
A5
Push Button
Resistor
Test LED
B5
0V – 5V
0V - 5V
2V-5V ------- Logic 10V-0.8V -------- Logic 0
1
0
Digital Logic Level
ISYARAT DARI MIKRO PENGAWAL KEPADA LITAR ELEKTRONIK
A2
A3Motor Left
L293 M
oto
r D
river
A0
A1
L293 M
oto
r D
river
Motor Right
Ini antara soalan yang selalu bermain dibenak fikiran anda:
Saya tidak pernah belajar asas pengaturcaraan, bagaimana hendak memulakannya?
Saya tidak pandai pengaturcaraan ini.
Cara mudah untuk memahami suatu rangkaian program dengan menggunakan bantuan gambarajah.
Amat berguna untuk memahami pengaturacaraan.
Merupakan bahasa aras tinggi yang digunakan untuk pengaturcaraan.
Pengaturcaraan C memudahkan sesuatu sruktur pengaturcaraan dilakukan.
#include <pic.h> // to include the contents before compiling (pic168xa.h)__CONFIG(0x3F32); // Configuration Bits
void main(void) // the main function where the program will start operating{// enter your code here}
Main Program
Define IO pin as input or outputExample
TRISB = 0x00000000; // all port C as output
TRISB = 0x00001111; // First 4 bits as input
// The rests as output
A special function register ( in Data Memory)
The content of this register corresponds to the value of electrical signal at its IO pin
PORTB = 0b00000000; // clear the content
// to innitialize
while(expression) { // execute if the expression is true
(1) }
#include <pic.h> // to include the contents before compiling (pic168xa.h)__CONFIG(0x3F32); // Configuration Bits
void main(void) // the main function where the program will start operating{TRISB = 0b00000000;PORTB= 0b00000000; while(1) { RB3=1; // Turn on the TestLED }}
Basic Program to Turn ON Output
Turn on an LED and OFF in a never ending loopwhile(1){
RB3=1;RB3=0;}
Can we see the LED blinking?
Set the value for crystal clock A pre written function provided by
hitech Set the value for crystal clock:
#define _XTAL_FREQ 20000000 A constant used in _delay_ms()
function
#include <pic.h>
__CONFIG(0x3F32);#define _XTAL_FREQ 20000000
void main(void){TRISB =0b00000000;PORTB=0b00000000;
while(1) { RB3=0;
__delay_ms(39);RB3=1; __delay_ms(39);}
}
Connect a push button Define TRISB Draw Schematic
0 B1
while(RB1==1){RB3=1;}
do { //code to run here}while (expression);
for (variable = initial value; expression; variable = variable + value){ //code to run here while expression is true}while (expression)
for (variable = initial value; expression; variable = variable + value){ //code to run here while expression is true}while (expression)
for (x=1; x<9; x= x+1) { RC3 =1}
if ( expression){ //code to run here while expression is true}
if ( RB2==1){ //code to run here while expression is true}
Relational Operators > Greater than
>= Greater than or Equal to< Less than<= Less than or Equal to== Equal to!= Not Equal to
Logical Operations & AND
| OR^ XOR~ 1’s complement>> Right Shift<< Left Shift
Challenge your self 1. Write a program that will make your
robot to move from point A to point B with the fastest time possible.
2. Start with turning on the Green LED and finish by turning on the buzzer.