Daftar Isi:

Batu: 8 Langkah
Batu: 8 Langkah

Video: Batu: 8 Langkah

Video: Batu: 8 Langkah
Video: BATU 8 STUDIO BONUZ 2024, November
Anonim
Batu
Batu

Robot ini dikendalikan oleh program visual basic (melalui port serial), dan dapat bergerak dalam tiga kecepatan yang berbeda dengan sinyal pulse width modulated (PWM) yang dihasilkan oleh mikrokontroler PIC (16F877). Robot dapat dioperasikan dalam dua mode, mode "kontrol normal" dan "pelacak cahaya". Dalam mode kontrol normal, robot dapat membawa benda berukuran 3 - 18 cm dari satu tempat ke tempat lain dalam jarak 150 m. sedangkan dalam mode light tracker, mengikuti cahaya di ruangan gelap. Banyak sensor yang digunakan, seperti sensor cahaya; sensor kemiringan, penginderaan arus terhenti, penginderaan level baterai, dan beberapa sakelar batas dan sensor sentuh yang digunakan di tangan. Ini dapat menjaga kecepatannya konstan ketika berjalan di atas bukit (miring) dan secara otomatis menyalakan lampu ketika menjadi gelap gelap. Juga untuk menjaga keamanan IC, ia memutuskan arus ketika macet dan tangan berhenti ketika memegang sesuatu.4 Motor DC digunakan dikendalikan oleh mikrokontroler PIC 16F877 dan 3 sirkuit driver motor. Butuh waktu sekitar 4 bulan, dan biaya sekitar 600$

Langkah 1: Rancang Proyek

Desain Proyek
Desain Proyek
Desain Proyek
Desain Proyek

pada tahap awal, desain proyek disediakan. terutama, mendefinisikan diagram blok; lihat gambarnya.

Diagram Sirkuit yang lebih rinci diperlukan pada tahap ini, namun untuk memfasilitasi ini, modul utama yang diidentifikasi adalah: 1. Mikrokontroler 2. Sensor 3. Motor 4. Sirkuit nirkabel 5. Program PC. Sebuah Desain 3d dilakukan juga, lihat gambar.

Langkah 2: Pilih Perangkat dan Komponen

Pada tahap ini, perancang harus memilih perangkat dan komponen yang diperlukan untuk membangun robot.

Ini termasuk: sirkuit nirkabel (MAX232, LM331, modul pemancar dan penerima FM), motor (4 motor DC), sirkuit driver motor (H-bridge), PIC mikrokontroler (16F877), Baterai, Regulator tegangan (MC7805), Microswitch, Fotoresistor, Sensor kemiringan … dll. Penting untuk memahami komputabilitas perangkat ini dan bagaimana mereka bekerja bersama.

Langkah 3: Mikrokontroler

Mikrokontroler
Mikrokontroler

Langkah ini merupakan langkah yang paling penting. di awal, kode yang akan diterima dan dikirimkan dari PIC harus diidentifikasi.

Mulai hubungkan komponen ke pin PIC yang sesuai, dan program mikrokontroler. Ini mungkin memerlukan untuk membangun sirkuit kecil menggunakan regulator, resistor, sensor … dll.

Langkah 4: Tulis Program PC

Tulis Program PC
Tulis Program PC
Tulis Program PC
Tulis Program PC

Program ini ditulis pada visual basic.

Komunikasi dilakukan melalui RS-232. Menggunakan MSComm untuk mengirim data ke mikrokontroler dengan mengkonfigurasi pengaturan (nomor port, baud rate, jumlah paritas bit data, stop bit). Saya menggunakan data 8-bit dengan one stop bit dan parity pada baud rate 9600 bps.

Langkah 5: Bangun Tubuh

Bangun Tubuh
Bangun Tubuh
Bangun Tubuh
Bangun Tubuh

Desain bodi yang bagus itu penting. Juga memilih pengaturan roda, lihat gambar.

Robot ini dibuat setelah memastikan bahwa program bekerja dengan baik. Langkah ini dapat dilakukan sebelum pemrograman juga.

Langkah 6: Bangun Sirkuit Nirkabel

Bangun Sirkuit Nirkabel
Bangun Sirkuit Nirkabel

Membangun sirkuit nirkabel bisa mandiri. Pada tahap awal, saya telah menggunakan kabel untuk menghubungkan PC dengan robot, dan setelah menyelesaikan robot, sirkuit nirkabel terintegrasi.

Langkah 7: Integrasikan

Mengintegrasikan
Mengintegrasikan

Inilah saatnya kami mengintegrasikan komponen kami, dan menguji robot.

Langkah 8: Kode Program Mikrokontroler

;***************FINAL********************************* daftar p=16f877 sertakan radix decidlocs "V"<<8 | "1"; Versi No.config _CP_OFF&_PWRTE_OFF&_WDT_OFF&_XT_OSC;********** variabel utama *************************** cblock 0x20;mulai dari bank 0 ram area INPUT_VAR L1 L2 X SPEED11 SPEED12 SPEED21 SPEED22 MSTOP LDET LR1 LR2 endc;********** start program utama *************** start BSF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X40 MOVWF ADCON1 MOVLW 0XFF;PORT A IS I MOVWF TRISA MOVLW 0X00;PORT B IS O MOVWF TRISB MOVLW 0XF0;PORT C IS I/O MOVWF TRISC MOVLW;PORT 0XF0 TRISD MOVLW 0X07;PORT E IS I MOVWF TRISE BANKSEL OPTION_REG BCF OPTION_REG, T0CS BCF STATUS, RP1 BCF STATUS, RP0;************************* ******************;****************************** ************ TUNGGU BCF PORTB, 1 BCF PORTB, 2 BCF PORTB, 6 CALL PWM1OFF CALL PWM2OFF BCF PORTD, 0 BCF PORTD, 1 BCF PORTD, 2 BCF PORTD, 3 BTFSS LDET, 0 BCF PORTB, 7 MOVLW 0X00 MOVF MSTOP MOVF LDET BANKSEL INTCON BCF INTCON, GIE BANKSEL TXSTA BSF TXSTA, BRGH MOVLW 0X40 MOVWF SPBRG BCF TXSTA, SYNC BANKSEL RCSTA BSF RCSTA, SPEN BTFSC RCSTA, OERR GOTO CLROE BANKSEL PIE1 BSF PIE1, RCIE BANKSEL RCSTA BCF RCSTA, RX9 BSF RCSTA, CRENWAIT1 BANKSEL PORTB PORTB BSF, 3 PORTB BSF, 4 BANKSEL PIR1 BTFSS PIR1, RCIF GOTO WAIT1 PORTB BCF 1, PORTB BCF CALL PWM1OFF CALL PWM2OFF CALL DARKLIGHT BTFSC LDET, 0 BSF PORTB, 7RXDATA;BANKSEL RCSTA;BTFSC RCSTA, OERR;GOTO STOPS CALL PWM1OFF CALL PWM2OFF CALL DARKLIGHT BTFSC LDSELET, 0 BCF BANK PORTB PCR1 CREG BSF BANK PORTB, 7 0;*******************************************;**** *************************************** MOVWF INPUT_VAR MOVLW 0X00 MOVWF RCREG BCF STATUS, RP0 BCF STATUS, RP1 MOVF INPUT_VAR, 0;STOP SUBLW 0X53 STATUS BTFSC, Z GOTO BERHENTI MOVF INPUT_VAR, 0;LIGHT ON SUBLW 0X4E STATUS BTFSC, Z GOTO LON MOVF INPUT_VAR, 0;LIGHT ON SUBLW 0X4E STATUS BTFSC, Z GOTO LON MOVF INPUT_VAR, 0;LIGHT OFF_MOTFSC INPUT_VAR SUBL 0;MOVE FORWARD SLOW SUBLW 0X66 STATUS BTFSC, Z GOTO FSLOW MOVF INPUT_VAR, 0;MOVE RIGHT SLOW SUBLW 0X72 STATUS BTFSC, Z GOTO RSLOW MOVF INPUT_VAR, 0;MOVE LEFT SLOW SUBLW 0 STATUS BTFSC X6C, Z GOTO LSLOW MOVF INPUT_VAR, 0;MOVE BACKWARD SLOW SUBLW 0X62 STATUS BTFSC, Z GOTO BSLOW MOVF INPUT_VAR, 0;MOVE FORWARD MEDIUM SUBLW 0X46 STATUS BTFSC, Z GOTO FMUTED MOVBL STATUS, Z GOTO RMED MOVF INPUT_VAR, 0;MOVE LEFT MEDIUM SUBLW 0X4C STATUS BTFSC, Z GOTO LMED MOVF INPUT_VAR, 0;MOVE BACKWARD MEDIUM SUBLW 0X42 STATUS BTFSC, Z GOTO BMED BMED INPUT_STATUS; Z GOTO FFAST MOVF INPUT_VAR, 0;MOVE RIGHT FAST SUBLW 0X57 STATUS BTFSC, Z GOTO RFAST MOVF INPUT_VAR, 0;MOVE LEFT FAST SUBLW 0X56 STATUS BTFSC, Z GOTO LFAST MOVF INPUT_VAR, Z GOTO LFAST MOVF INPUT_VAR, Z GOTO LFAST MOVF INPUT_VAR, 0DTOVAR FAST; 0 HFAST MOVF INPUT_VAR, 0;HAND CLOSE SUBLW 0X43 STATUS BTFSC, Z GOTO HCLOSE MOVF INPUT_VAR, 0;HAND OPEN SUBLW 0X4F STATUS BTFSC, Z GOTO HOPEN MOVF INPUT_VAR, 0;STUT_ UP; STATUS BTFSC UP;HAND DOWN SUBLW 0X64 BTFSC STATUS, Z GOTO HDOWN MOVF INPUT_VAR, 0;LIGHT FOLOWE R SUBLW 0X54 BTFSC STATUS, Z GOTO LFOLLOW;*************************************** ***;********************************************* GOTO CLROEFSLOW; BANKSEL RCSTA;BCF RCSTA, OERR;BCF RCSTA, CREN;NOP;BSF RCSTA, CREN BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP;BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSCGDAR LDET, 0;BSF PORTB, 7 NORMALSLOW MOVLW 0XFF MOVWF SPEED11 MOVLW 0X66 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X66 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORTD, 1 BSFIRBTF PORTD, 1 BSF PORTD BCF, RCIF GOTO RXDATA GOTO REP3 GOTO CLROE;*************************************** **STATUS BCF LSLOW, RP0 STATUS BCF, RP1;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOPS MOVLW 0X00 MOVWF MSTOP BCF LDET, 0 CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 MOVLWF SWPED12 MOVLWF 0XPEED 0XCF MOVWF SPEED21 MOVLW 0X66 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BSF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BCF POR TB, 2 REP4 BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP4 GOTO CLROE;********************************* **********RSLOW BCF STATUS, RP0 BCF STATUS, RP1;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOPS MOVLW 0X00 MOVWF MSTOP BCF LDET, 0 CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 MOVLW 0XCF MOVWF SPEED11 MOVLW 0X66 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BSF PORTB, BSF PORTB, 2 REP35 BANKSEL ****************************BSLOW BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC 1 MSTOP, 1;GOTO STOPS CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 MOVLW 0XCF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL PWM1B BSF PORT PWM1ON PORTB, 2 REP5 BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP5 GOTO CLROE;****************************** **********F MED BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO BERHENTI CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 NORMALMED MOVLWVWLPE 0X11 MOVL 7 MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BSF PORTB, 2 CALL SDELAY REP6 CALL STALL1 BTFSC MSTOP, 0 GOTO STOPS BANKSEL PIR1 RCDATAIF GOP PIR1 BTFDFSC GOTO REP6 PLUSEMED MOVLW 0XCF MOVWF SPEED11 MOVLW 0XCC MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0XCC MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BSF PORTB BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA BTFSS PORTD, 7 GOTO NORMALMED GOTO REP7 GOTO CLROE;******************************* ************RMED BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOP CALL DARKLIGHT BTFSC LDET, 0;BSF PORT B, 7 MOVLW 0XFF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X66 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BCF PORTB CALL STALLSTOP 1 BSF, 1 PORT BSF BTFSC PIR1, RCIF GOTO RXDATA GOTO REP8 GOTO CLROE;************************************ **** STATUS BCF LMED, RP0 STATUS BCF, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO BERHENTI CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 MOVLWF SWED SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BSF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BCF PORTB, 2 REP9;CALL STALL1;BTFSC MSTOP, 0;BASCGOTO GD REP9 GOTO CLROE;******************************************* STATUS BCF BMED, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOP CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 MOVLW 0XFF MOVWF SPEED11 MOVLW 0X7F MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X7F MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BSF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BCF PORTB, 2 REP10 CALL STALL1 GRX BANKIFOTO PSTOIR, 0 GTFSC M REP10 GOTO CLROE;******************************************* STATUS BCF CEPAT, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0 BSF MSTOP, 4;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO BERHENTI CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 MOVLW MOWF 0EFXEF7 MOVLW MOWFLE 0XEF MOVWF SPEED21 MOVLW 0X7F MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BSF PORTB, 2 CALL SDELAY NORMALFAST MOVLW SPEED11 MOVWFSPEED11 MOVLW MOVLW 0XCC MOVWMV SPEED11 MOVWWF 0XCC MOVWMV PORTD, 0 BCF PORTD, 1 BTFSC LDET, 0 BSF PORTB, 7 BSF PORTB, 1 BSF PORTB, 2 REP11 CALL STALL1 BTFSC MSTOP, 0 GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA NOP BTFSS PORTD, 7 GEFOTO REP AST MOVLW 0XCF MOVWF SPEED11 MOVLW 0XFF MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0XFF MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BSF PORTB, 1 BSF PORTB, RCIF GOTO RXDATA BTFSS PORTD, 7 GOTO NORMALFAST GOTO REP12 GOTO CLROE;********************************* ********RFAST BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOP CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 MOVWFW SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X66 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BSF PORTB, 2 REP13 CALL STALLIR BANK 1 BTFSC GSELIR STALL1 BTFSC GOTO REP13 GOTO CLROE;****************************************** BCF CEPAT STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOP CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 MOVLW 0XFF MOVWF SPEED11 MOVLW 0X66 MOVWF KECEPATAN12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BSF PORTD, 0 BCF PORTD, 1 PORTB SWPE MOWFL BSF, 2 MOWFV PORTB MOWF 0XEF MOVWF SPEED21 MOVLW 0XB3 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BSF PORTD, 0 BCF PORTD, 1 PORTB BSF, 1 BCF PORTB, 2 REP14 CALL STALL1 BTFSC MSTOP, 0 GOTO STOPS BANKSEL PIR1 RCTFSC GOTO PIR1 BTFSC PIR1 BTFSC; ********************************************* STATUS BCF CEPAT, STATUS BCF RP0, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO BERHENTI CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 MOVLW 0XDF MOVWF SPEED11 MOVLW SPEED11 MOVLW 0X99 MOVWFS PWM2ON BSF PORTD, 0 BSF PORTB, 1 BCF PORTB, 1 BCF PORTB, 2 CALL SDELAY MOVLW 0XEF MOVWF SPEED11 MOVLW 0X66 MOVWF SPEED12 MOVLW 0XEF MOVWF SPEED21 MOVLW 0X66 MOVWF SPEED22 CALL PWM2ON BSF CALL PWM2ON PORTD, 0 BSF PORTB, 1 BCF PORTB, 1 BCF PORTB, 2 REP15 CALL STALL1 BTFSC MSTOP, 0 GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP15 GOTO CLROE;************* ******************************TUTUP STATUS BCF, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOP CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 BTFSC PORTD, 5 GOTO STOPS BTFSC PORTD, 6 GOTO STOPS BSF PORTD, 2 BCF PORTD, 3 REP16 BTFSC PORTD, 5 GOTO PORTSTOPS BSF GOTO STOPS CALL SDELAY CALL STALL2 BTFSC MSTOP, 2 GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP16 GOTO CLROE;************************* ******************HARAPKAN STATUS BCF, RP0 STATUS BCF, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOP CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 BTFSC PORTD, 4 GOTO STOPS BCF PORTD, 2 BSF PORTD, 3 REP17 BTFSC PORTD, 4 GOTO STOPS CALL SDELAY CALL STALL2 BTFSC MSTOP, 2 GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO REPDATA GOTO CLROE;****************************************** STATUS HUP BCF, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOP CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 BTFSC PORTC, 4 GOTO STOPS BCF STOPS BTFSC PORTC, 4 GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP18 GOTO CLROE;******************************* ************HDOWN BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOP CALL DARKLIGHT BTFSC LDET, 0;BSF PORTB, 7 BTFSC PORTC, 5 GOTO STOPS BSF PORTC, 0 BCF PORTC, 3 REP19 BTFSC PORTC, 5 GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP19 GOTO CLROE;*************** ****************************LON BSF PORTB, 7 BSF LDET, 0 GOTO CLROE;********** ********************************LOFF BCF PORTB, 7 BCF LDET, 0 GOTO CLROE;****** **************************************IKUTI STATUS BCF, RP0 STATUS BCF, RP1 BCF PORTB, 1 PORTB BCF, 2 PORTB BCF, 6 BCF PORTB, 7 CALL PWM1OFF CALL PWM2OFF BCF PORTD, 0 BCF PORTD, 1 BCF PORTD, 2 BCF PORTD, 3 BSF MSTOP, 6 REPLF;BANKSEL OPTION_REG;BSF OPTION_REG, 3;BSF OPTION_REGOPTION, 3_BSREG OPTION_;, 3;CLRFWDT BCF STATUS, RP0 BCF STATUS, RP1;BANKSEL INTCON;BCF INTCON, T0IE;BCF INTCON, T0IF;BANKSEL PIE1;BCF PIE1, 6;BCF PIE1, 0;BANKSEL INTCON;BCF BANKSEL PCON BIEF BANKSEL PCON, 0 BCF PCON, 1 NOP BSF PCON, 0 BSF PCON, 1 BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP CALL SDELAY CALL LFC1 NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 STATUS BTFOTOSC, Z GALLOTOSC SDELAY CALL LFC1 NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BTFSC STATUS, C GOTO LR2G LR1G STATUS BCF, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP;CALL BUTTLEVEL;BTFSC MOVWL11 STOPSM; 0X66 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BSF PORT, 0 BCF PORT, 1 BSF PORTB, 1 BCF PORTB, 2 LR1GREP;CALL STALL1;BTFSC MGSTOP STALL1;BTFSC MGSTOP OPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA CALL LFC1 NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BTFSC STATUS, Z GOTO REPLF CALL LFC1 NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF GATUS, 0 BTFSS REPLF LR2G BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP;CALL BUTTLEVEL;BTFSC MSTOP, 1;GOTO STOP MOVLW 0XFF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED2 MOVWFL SPEED12 MOVWFLW PORTD, 1 BCF PORTB, 1 BSF PORTB, 2 LR2GREP;CALL STALL1;BTFSC MSTOP, 0;GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA CALL LFC1 NOP CALL LFC2 NOP MOVF LR2, 0 SUBSC GOTO LR1, 0 SUBSC GOTO LR1 REPLF CALL LFC1 NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BTFSC STATUS, C GOTO LR2GREP GOTO REPLF FRONT BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP;CALL BUTTLV MULTEVEL; SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORT D, 0 BCF PORTD, 1 BSF PORTB, 1 BSF PORTB, 2 CALL SDELAY FROREP;CALL STALL1;BTFSC MSTOP, 0;GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA;CALL LDIN;BTFSC MSTOP STOPS, 3; NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BTFSC STATUS, Z GOTO FROREP GOTO REPLF GOTO CLROE;*************************** ****************STOPS BTFSS MSTOP, 4 GOTO STOPA MOVLW 0XCF MOVWF SPEED11 MOVLW 0XB3 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0XB3 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORTD, 1 CALL SDELAY STOPA BCF STATUS, RP0 BCF STATUS, RP1 BCF PORTB, 1 BCF PORTB, 2 BCF PORTB, 6 BTFSS LDET, 0;BCF PORTB, 7 BCF PORTC, 0 BCF PORTC, 3 CALL PWM1OFF CALL PWM2OFF BCF PORTD, PORTD, 1 BCF PORTD, 2 BCF PORTD, 3 MOVLW 0X00 MOVWF MSTOP;******************************* *********CLROE BANKSEL RCSTA BCF RCSTA, CREN BCF RCSTA, FERR BCF RCSTA, OERR BSF RCSTA, CREN BSF INTCON,GIE BSF INTCON, PEIE GOTO WAIT1;****************************************** *********************************************;**** *************************************** STATUS STALL1 BCF, RP0 STATUS BCF, RP1 MOVLW 0X00 MOVWF MSTOP BANKSEL ADCON0 BCF ADCON0, 3 BCF ADCON0, 4 BCF ADCON0, 5 STATUS BCF, RP0 BCF STATUS, RP1 CALL CONVERT MOVF ADRESH, 0 SUBLW 0X70 STATUS BTFSS, C BSF MSTOP, 0 BCF STATUS, RP0 BCF STATUS, STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BANKSEL ADCON0 BSF ADCON0, 3 BCF ADCON0, 4 BCF ADCON0, 5 STATUS BCF, RP0 BCF STATUS, RP1 CALL CONVERT MOVF ADRESH, 0 SUBLW 0X40 STATUS BTFSS, 2 BTFSS STATUS STATUS, RP0 STATUS BCF, RP1 RETURNBUTTLEVEL BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BANKSEL ADCON0 BCF ADCON0, 3 BCF ADCON0, 4 BSF ADCON0, 5 STATUS BCF, RP0 BCF STATUS CONVERT, 0X RP1 CALL CONVERT MOV STATUS BTFSS, C GOTO BL1 GOTO BL2 BL1 BSF MSTOP, 1 BSF PORTB, 6 BL2 RETURN DARKLIGHT BCF STATUS, RP0 BCF STATUS, RP1 BTFSC LDET, 0 GOTO RETFDL BANKSEL ADCON0 BCF ADCON0, 3 BSF ADCON0, 4 BCF ADCON0, 5 BCF STATUS, RP0 BCF STATUS, RP1 CALL CONVERT MOVF ADRESH, 0 SUBLW 0XEE BTFSS STATUS, C BSF PORTB, 7 RETFDL BANKSELWF ADCONVERT ADCONVERT MOVLW 0X49 BCF ADCON0, 7 BSF ADCON0, 6 BSF ADCON0, 0 BSF ADCON0, GO WAITADC BTFSC ADCON0, GO GOTO WAITADC BCF STATUS, RP1 BCF STATUS, RP0 RETURNPWM1ON BANKSEL PR2 MOVLW 0XFF MOVWF PR2 BCF STATUS, RP0 BCF STATUS, RP0 BCF STATUS, RP MOVWF CCP1CON MOVF SPEED12, 0 MOVWF CCPR1L STATUS BSF, RP0 STATUS BCF, RP1 MOVLW 0XF0 MOVWF TRISC STATUS BCF, RP0 STATUS BCF, RP1 BCF T2CON, T2CKPS1 BCF T2CON, T2CONSF, CCPNP2 BCF1 TCONSF, CCPS0 BCFON1 PR2 MOVLW 0XFF MOVWF PR2 STATUS BCF, RP0 STATUS BCF, RP1 KECEPATAN MOVF21, 0 MOVWF CCP2CON KECEPATAN MOVF22, 0 MOVWF CCPR2L STATUS BSF, RP0 STATUS BCF, RP1 MOVLW 0XF0 MOVF0 MOVAT TRISC BSF T2CON, T2CKPS0 BSF T2CON, TMR2ON BSF CCP2CON, 2 BSF CCP2CON, 3 RETURNPW 2 M1OFF BCF CCP1CON, 2 BCF CCP1CON, 3 BSF T2CON, T2CKPS1 BSF T2CON, T2CKPS0 BCF T2CON, TMR2ON MOVLW 0X00 MOVWF CCP1CON MOVLW 0X00 MOVWF CCPR1L BANKSEL PR2 CCP2 MOVLW 0X00 MOVWF PR2 BSC, 3 BSF T2CON, T2CKPS1 BSF T2CON, T2CKPS0 BCF T2CON, TMR2ON MOVLW 0X00 MOVWF CCP2CON MOVLW 0X00 MOVWF CCPR2L BANKSEL PR2 MOVLW 0X00 MOVWF PR2 BCF STATUS, RP1 BCF STATUS ADCON0, BCF0 ADCONRP0 ADCONRP0 BANKSEL PR2, 5 BCF STATUS, RP0 BCF STATUS, RP1 CALL CONVERT MOVF ADRESH, W ANDLW 0XF0 MOVWF LR1 BCF STATUS, RP0 BCF STATUS, RP1 RETURN LFC2 BANKSEL ADCON0 BCF ADCON0, 3 BSF ADCON0, 4 BSF ADCON0, 5 BCF STATUS RP1 CALL CONVERT MOVF ADRESH, 0 ANDLW 0XF0 MOVWF LR2 STATUS BCF, RP0 BCF STATUS, RP1 RETURN LDIN BANKSEL ADCON0 BCF ADCON0, 3 BSF ADCON0, 4 BCF ADCON0, 5 BCF STATUS, RP0 BCF STATUS, CONVERT PANGGILAN MOV RP1 0X4C BTFSC STATUS, C GOTO COMP4 BSF MSTOP, 3 COMP4 BCF STATUS, RP0 BCF STATUS, RP1 RETURN SDELAY CLRF L2 XL3 CLRF L1 XL2 CLRF TMR0 XL1 MOVLW 0XFF SUBWF TMR0, W BTFSS STATUS, C GOTO XL1 MOVLW 0X20 INCF L1 SUBWF L1, W BTFSS STATUS, C GOTO XL2 MOVLW L2, CTFSS LOTO 0X10 IN XL3 RETURN NOP NOPEND

Hadiah Kedua dalam Kontes Robot Instructables dan RoboGames

Direkomendasikan: