bagaimana membina robot anda sendiri

40
LINE FOLLOWING ROBOT

Upload: taufikrezza85

Post on 10-Apr-2015

1.154 views

Category:

Documents


5 download

DESCRIPTION

step by step to build own robot especially line following robot. This article in Malay version.

TRANSCRIPT

Page 1: Bagaimana Membina Robot Anda Sendiri

LINE FOLLOWING ROBOT

Page 2: Bagaimana Membina Robot Anda Sendiri

KENALPASTI OBJEKTIF BINAAN ROBOT KENALPASTI INPUT/OUTPUT PENGHASILAN LITAR ANTARAMUKA

(INTERFACE) MEREKABENTUK ALGORITMA PROGRAM (MENGGUNAKAN CARTA ALIRAN ) PENGUJIAN ALGORITMA PENGUBAHAN PROGRAM/ LITAR

(JIKA DIPERLUKAN)

Page 3: Bagaimana Membina Robot Anda Sendiri

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

Page 4: Bagaimana Membina Robot Anda Sendiri

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?

Page 5: Bagaimana Membina Robot Anda Sendiri

Otak

Denyutan jantung Sistem

Perkumuhan

Deria

Pelaksana Arahan

Page 6: Bagaimana Membina Robot Anda Sendiri

5V DC Supply

Ground Potential

Input Pin Ports Crystal Clock

Current Flows

Central Procession Unit (CPU)

Output Pin Ports

Page 7: Bagaimana Membina Robot Anda Sendiri

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

Page 8: Bagaimana Membina Robot Anda Sendiri

Vdd Supply

Resi

stor

LED

Push Button Ground

Page 9: Bagaimana Membina Robot Anda Sendiri

Vdd Supply

Resi

stor

LED

Ground

State Of The Push Button

State of LED

Released OFF

Pressed ON

Push Button

Page 10: Bagaimana Membina Robot Anda Sendiri

Istilah isyarat dalam Sistem Digit

ON

OFF

HIGH

LOW

YES

0

1

NO

Vdd 5V

0V Vss

Page 11: Bagaimana Membina Robot Anda Sendiri

Vdd

ResistorLED

Push Button

Resistor

Push Button

Vdd

VddVss

LEDTanpa mikro pengawal

Dengan mikropengawal

Page 12: Bagaimana Membina Robot Anda Sendiri

A2

A3

A4

A5

B0

B1

B2

B3

A1

A0

A7

A6

B7

B6

B5

B4

VddVss

Input Output Pin

PORTA

PORTB

Page 13: Bagaimana Membina Robot Anda Sendiri

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

Page 14: Bagaimana Membina Robot Anda Sendiri

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

Page 15: Bagaimana Membina Robot Anda Sendiri
Page 16: Bagaimana Membina Robot Anda Sendiri
Page 17: Bagaimana Membina Robot Anda Sendiri

A2

A3Motor Left

L293 M

oto

r D

river

A0

A1

L293 M

oto

r D

river

Motor Right

Page 18: Bagaimana Membina Robot Anda Sendiri

Ini antara soalan yang selalu bermain dibenak fikiran anda:

Saya tidak pernah belajar asas pengaturcaraan, bagaimana hendak memulakannya?

Saya tidak pandai pengaturcaraan ini.

Page 19: Bagaimana Membina Robot Anda Sendiri

Cara mudah untuk memahami suatu rangkaian program dengan menggunakan bantuan gambarajah.

Amat berguna untuk memahami pengaturacaraan.

Page 20: Bagaimana Membina Robot Anda Sendiri

Merupakan bahasa aras tinggi yang digunakan untuk pengaturcaraan.

Pengaturcaraan C memudahkan sesuatu sruktur pengaturcaraan dilakukan.

Page 21: Bagaimana Membina Robot Anda Sendiri

#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

Page 22: Bagaimana Membina Robot Anda Sendiri

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

Page 23: Bagaimana Membina Robot Anda Sendiri

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

Page 24: Bagaimana Membina Robot Anda Sendiri

while(expression) { // execute if the expression is true

(1) }

Page 25: Bagaimana Membina Robot Anda Sendiri

#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

Page 26: Bagaimana Membina Robot Anda Sendiri

Turn on an LED and OFF in a never ending loopwhile(1){

RB3=1;RB3=0;}

Can we see the LED blinking?

Page 27: Bagaimana Membina Robot Anda Sendiri

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

Page 28: Bagaimana Membina Robot Anda Sendiri

#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);}

}

Page 29: Bagaimana Membina Robot Anda Sendiri

Connect a push button Define TRISB Draw Schematic

0 B1

Page 30: Bagaimana Membina Robot Anda Sendiri

while(RB1==1){RB3=1;}

Page 31: Bagaimana Membina Robot Anda Sendiri

do { //code to run here}while (expression);

Page 32: Bagaimana Membina Robot Anda Sendiri

for (variable = initial value; expression; variable = variable + value){ //code to run here while expression is true}while (expression)

Page 33: Bagaimana Membina Robot Anda Sendiri

for (variable = initial value; expression; variable = variable + value){ //code to run here while expression is true}while (expression)

Page 34: Bagaimana Membina Robot Anda Sendiri
Page 35: Bagaimana Membina Robot Anda Sendiri

for (x=1; x<9; x= x+1) { RC3 =1}

Page 36: Bagaimana Membina Robot Anda Sendiri

if ( expression){ //code to run here while expression is true}

Page 37: Bagaimana Membina Robot Anda Sendiri

if ( RB2==1){ //code to run here while expression is true}

Page 38: Bagaimana Membina Robot Anda Sendiri

Relational Operators > Greater than

>= Greater than or Equal to< Less than<= Less than or Equal to== Equal to!= Not Equal to

Page 39: Bagaimana Membina Robot Anda Sendiri

Logical Operations & AND

| OR^ XOR~ 1’s complement>> Right Shift<< Left Shift

Page 40: Bagaimana Membina Robot Anda Sendiri

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.