Indholdsfortegnelse:

Klippen: 8 trin
Klippen: 8 trin

Video: Klippen: 8 trin

Video: Klippen: 8 trin
Video: Израиль | Масада | Крепость в Иудейской пустыне 2024, November
Anonim
Stenen
Stenen

Denne robot styres af et visuelt grundlæggende program (gennem den serielle port) og kan bevæge sig i tre forskellige hastigheder af et pulsbreddemoduleret (PWM) signal genereret af en PIC -mikrokontroller (16F877). Robotten kan betjenes i to tilstande, "normal kontrol" og "lyssporing". I normal kontroltilstand kan robotten transportere objekter i størrelse 3 - 18 cm fra sted til en anden inden for 150 m. der henviser til, at den i lyssporingstilstanden følger lyset i et mørkt rum. Mange sensorer blev brugt, f.eks. lyssensorer; vippesensor, staldstrømføling, batteriniveauregistrering og nogle grænsekontakter og berøringssensorer, der bruges i hånden. Den kan holde sin hastighed konstant, når den går på en bakke (vippes) og tænder automatisk lyset, når det bliver mørkt mørkt. Også for at holde IC'en sikker afbryder den strømmen, når den sidder fast, og hånden stopper, når den holder noget. 4 DC -motorer blev brugt styret af en PIC -mikrokontroller 16F877 og 3 motordriverkredsløb. Det tog omkring 4 måneder og koster omkring 600 $

Trin 1: Design projektet

Design projektet
Design projektet
Design projektet
Design projektet

i den indledende fase blev der udarbejdet et design af projektet. hovedsageligt at definere blokdiagrammet; se figuren.

Et mere detaljeret kredsløbsdiagram er påkrævet på dette trin, men for at lette dette var de identificerede hovedmoduler: 1. Mikrocontroller 2. Sensorer 3. Motorer 4. Trådløst kredsløb 5. PC -program. Der blev også udført et 3d -design, se figuren.

Trin 2: Vælg enheder og komponenter

På dette stadium skal designeren vælge de enheder og komponenter, der kræves for at bygge robotten.

Dette inkluderer: det trådløse kredsløb (MAX232, LM331, FM-sender og modtagermoduler), motorer (4 DC-motorer), motordriverkredsløb (H-bro), mikrokontrolleren PIC (16F877), batteri, spændingsregulatorer (MC7805), mikrokontakter, Fotoresistorer, Tilt sensor … osv. Det er vigtigt at forstå beregningen af disse enheder og hvordan de fungerer sammen.

Trin 3: Mikrokontrolleren

Mikrokontrolleren
Mikrokontrolleren

Dette trin er det vigtigste trin. i begyndelsen skal de koder, der vil blive modtaget og transmitteret fra PIC, identificeres.

Start tilslutning af komponenterne til de relevante stifter på PIC'en, og programmer mikrokontrolleren. Dette kan kræve at bygge små kredsløb ved hjælp af regulatorer, modstande, sensorer … osv.

Trin 4: Skriv pc -programmet

Skriv pc -programmet
Skriv pc -programmet
Skriv pc -programmet
Skriv pc -programmet

Programmet blev skrevet på visual basic.

Kommunikationen blev etableret gennem RS-232. Brug af MSComm til at sende dataene til mikrokontrolleren ved at konfigurere indstillingerne (portnummer, baudrate, paritet antal databit, stopbits). Jeg brugte 8-bit data med en stopbit og paritet med en baudhastighed 9600 bps.

Trin 5: Byg kroppen

Byg kroppen
Byg kroppen
Byg kroppen
Byg kroppen

Et godt design af kroppen er vigtigt. Også valg af hjularrangement, se figuren.

robotten blev bygget efter at have sikret, at programmerne fungerer fint. Dette trin kan også udføres inden programmering.

Trin 6: Byg det trådløse kredsløb

Byg det trådløse kredsløb
Byg det trådløse kredsløb

Opbygning af det trådløse kredsløb kan være uafhængigt. I den indledende fase har jeg brugt en ledning til at forbinde pc'en med robotten, og efter færdiggørelse af robotten blev det trådløse kredsløb integreret.

Trin 7: Integrer

Integrere
Integrere

Dette er øjeblikket, hvor vi integrerede vores komponenter og testede robotten.

Trin 8: Programkode til mikrokontroller

; **************** ENDELIG ********************************* liste p = 16f877 inkluderer radix decidlocs "V" << 8 | "1"; Version nr. Konfiguration _CP_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC; ********** hovedvariabel ************************** cblock 0x20; start på bank 0 ram område INPUT_VAR L1 L2 X SPEED11 SPEED12 SPEED22 SPEED22 MSTOP LDET LR1 LR2 endc; ********** start af hovedprogrammet *************** 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 MOVL TRISD MOVLW 0X07; PORT E IS I MOVWF TRISE BANKSEL OPTION_REG BCF OPTION_REG, T0CS BCF STATUS, RP1 BCF STATUS, RP0; ************************* ******************; ******************************* ************ VENT 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 BSF PORTB, 3 BSF PORTB, 4 BANKSEL PIR1 BTFSS PIR1, RCIF GOTO WAIT1, RCIF GOTO WAIT CALL PWM1OFF CALL PWM2OFF CALL DARKLIGHT BTFSC LDET, 0 BSF PORTB, 7RXDATA; BANKSEL RCSTA; BTFSC RCSTA, OERR; GOTO STOP CALL PWM1OFF CALL PWM2OFF CALL DARKLIGHT BTFSC LDET, 0 BSF 0; ******************************************* **** ************************************* MOVWF INPUT_VAR MOVLW 0X00 MOVWF RCREG BCF STATUS, RP0 BCF STATUS, RP1 MOVF INPUT_VAR, 0; STOP SUBLW 0X53 BTFSC STATUS, Z GOTO STOPS MOVF INPUT_VAR, 0; LIGHT ON SUBLW 0X4E BTFSC STATUS, Z GOTO LON MOVF INPUT_VAR, 0; LIGHT OFF5 VVS, 0, LOTAT5 SUBX, SHOW5 SATS, 0; LIGHT OFF5 SATS, 0, LOT OFF5 SATS, GANG 5 SÆT, Sluk 5 GASLUX5, SET UDGANG 5, LYD FRA 5, LYD ST5 0; FLYT FREM SLOW SUBLW 0X66 BTFSC STATUS, Z GOTO FSLOW MOVF INPUT_VAR, 0; MOVE RIGHT SLOW SUBLW 0X72 BTFSC STATUS, Z GOTO RSLOW MOVF INPUT_VAR, 0; MOVE LEFT SLOW SUBLW 0 X6C BTFSC STATUS, Z GOTO LSLOW MOVF INPUT_VAR, 0; MOVE BACKWARD SLOW SUBLW 0X62 BTFSC STATUS, Z GOTO BSLOW MOVF INPUT_VAR, 0; FLYT FORVARD MEDIUM SUBLW 0X46 BTFSC STATUS, Z GOTO FMX, ROTO FMX, ZVOTO FMX, ROTO FMX, RADIO MOVI, RADIO, RADIO, RADIO, RADIO, RADIO, RADIO, RADIO, RADIO, RADIO, RADIO, RADIO, RADIO STATUS, Z GOTO RMED MOVF INPUT_VAR, 0; MOVE LEFT MEDIUM SUBLW 0X4C BTFSC STATUS, Z GOTO LMED MOVF INPUT_VAR, 0; MOVE BACKWARD MEDIUM SUBLW 0X42 BTFSC STATUS, Z GOTO BMED MOVF Z GOTO FFAST MOVF INPUT_VAR, 0; MOVE RIGHT FAST SUBLW 0X57 BTFSC STATUS, Z GOTO RFAST MOVF INPUT_VAR, 0; MOVE LEFT FAST SUBLW 0X56 BTFSC STATUS, Z GOTO LFAST MOVF INPUT_VARW, FOTO BUTWX, 0 MOTO BOTO BFAST MOVF INPUT_VAR, 0; HÅND LUKKE SUBLW 0X43 BTFSC STATUS, Z GOTO HCLOSE MOVF INPUT_VAR, 0; HAND OPEN SUBLW 0X4F BTFSC STATUS, Z GOTO HOPEN MOVF INPUT_VAR, 0 HVED STOP 0, HVED STOP 0, HVED STOP 0, HVED OP, HVAD HVED 0, HVED OP, HVED STOP 0, HVED OP, HVAD STOP 0, HVED OP, HVÆRK 0, HVED OP, HVÆRK 0, HVED OP, HVED STOP 0, HVED OP, HVÆRK 0, HVED OP HVÆRK 0, HVED OP HVÆRK 0, HVED OP HVAD STV; 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 MSTOPLIGHT, 1; GFSOTS 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 PWF2 PORTBURG 1 PORTBURG 1 PORTBURG 1 PORT BFD PORT 1 PORT 1 PORT 1 PORT 2 PORT 2 PORT 2 PORT 3 PORT 2 PORT 2 PORT 3 PORT 2 PORT 3 PORT 2 PORT 2 PORT 2, RCIF GOTO RXDATA GOTO REP3 GOTO CLROE; ***************************************** ** LSLOW BCF STATUS, RP0 BCF STATUS, RP1; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOP MOVLW 0X00 MOVWF MSTOP BCF LDET, 0 CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XW MOVW MOVLW 0XW MOVW 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 STOP 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, 2 REP35 BANKSEL PIR1 BTFSC PIR1, Rcif GOTO RXDATA GOTO REP35 GOTO CLROE; * *************************** BSLOW BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XCF MOVWF HASTIGHED 11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL 1 PALLER 1 POLER 2 POLER 1 POLER 1 POLER 1 POLER 2 POLER 1 POLER 1 POLER 2 POLER 1 POLER 1 PACK 2 POLER 1 PACK 2 POLER 1 PACK 2 PACK 2 POLER 1 PACK 2 PACK 2 PV 1 2 P 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 STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 NORMALMED MOVLW 0XWW MOXL 0XWW MOVL 0XWW MOX 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 BIRD BFSD 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, 2 CALL SDELAY REP7 CALL STALL1 BTFSC mSTOP, 0 GOTO STOPS 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 STOPPS 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 PORTO, 1 BSF PORTB, 1 BSF PORTB, 1 BSF PORTO, 1 BSF PORTO, 1 BCF PORTO, 1 BSF PORTO, 1 BSF PORTB, 1 BST PORTO, 1 BSF PORTO, 1 BSF PORTO, 1 BCF PORTO, 1 BCF PORTO, 1 BSF PORTO, 1 BSF PORTO, 1 BSF PORTO, 1 BSF PORTO, 1 BCFPORT BTFSC PIR1, RCIF GOTO RXDATA GOTO REP8 GOTO CLROE; ************************************** **** LMED BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XFF MOVW 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, POTO, GIRO REP9 GOTO CLROE; ****************************************** BMED BCF -STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XFF MOVWF SPEED11 MOVLW 0X7F MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X7F MOVWF SPEED22 OPKALD PWM1ON CALL PWM2ON BSF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BCF PORTBORG 1 STK GALLERI, 2 BETALER GALLERI, 2 BETALINGER GALLERI, 2 BERLEDE GALLERIER, 2 BETALINGER GALLERI, 2 BETALINGER GALLERIER, 2 BETALINGER, GALLERIER, 2 BETJENINGER GALLERIER REP10 GOTO CLROE; ****************************************** FFAST BCF -STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0 BSF MSTOP, 4; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XEF MOVWFXW MOVWFXW MOVWFXW MOVWFXW MOVV 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 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 BTFSC LDET, 0 BSF PORTB, 7 BSF PORTB, 1 BSF PORTB, 2 REP11 CALL STALL1 BTFSC MSTOP, 0 GOTO STOP BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA NOP BTFSS PORTP, 7 GOTO 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, 2 REP12 CALL STALL1 BTFSC mSTOP, 0 GOTO STOPS BANKSEL PIR1 BTFSC PIR1, 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 STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0X 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, 1 BSF PORTO, 2 BSP1 BUTO STOP, 2 BSP1 GALLERIER, 2 REP13 BALLS STOPPER, 2 BERLEDE 1, BFS1 PORTO, 2 BETALINGER 1, BFS 1 PORTO, 2 BEMÆRKNINGER PORTBALLS, 2 BEMÆRKNINGER 1 STK PORTBLUKKE GOTO REP13 GOTO CLROE; ****************************************** LFAST BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XFF MOVWF HASTIGHED11 MOVLW 0X66 MOVWF SPEED12 MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL PWM2ON BSF PVD 0XEF MOVWF SPEED21 MOVLW 0XB3 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BSF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BCF PORTB, 2 REP14 CALL STALL1 BTFSC MSTOP, 0 GOTO STOP BANKSEL1 BANKSEL PIRO, BOTSEL GIRO BOTSEL GIRO PORTO, GOTO STOP BANK *************************************** BFAST BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MStOP, 1 PWM2ON BSF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BCF PORTB, 2 CALL SDELAY MOVLW 0XEF MOVWF SPEED11 MOVLW 0X66 MOVWF SPEED12 MOVLW 0XEF MOVWF SPEED21 MOVLW 0X66 MOVWFWE SPEED PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BCF PORTB, 2 REP15 CALL STALL1 BTFSC MSTOP, 0 GOTO STOPPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP15 GOTO CLROE; ***************** **************************** HCLOSE 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 PORTD, 5 GOTO STOPPS BTFSC PORTD, 6 GOTO STOP BSF PORTD, 2 BCF PORTD, 3 REP16 BTFSC PORTD, 5 GOTO STOPS GOTO STOP CALL SDELAY CALL STALL2 BTFSC MSTOP, 2 GOTO STOP BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP16 GOTO CLROE; ************************** ******************* HOPEN BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 BTFSC PORTD, 4 GOTO STOPPS BCF PORTD, 2 BSF PORTD, 3 REP17 BTFSC PORTD, 4 GOTO STOP CALL SDELAY CALL STALL2 BTFSC MSTOP, 2 GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIFOTO GOTO CLROE; ****************************************** HUP BCF -STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 BTFSC PORTC, 4 GOTO STOPS BCF PORTC, 4 GOTO STOPS BCF PORTC 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; ***** ************************************ LFOLLOW BCF STATUS, RP0 BCF STATUS, RP1 BCF PORTB, 1 BCF PORTB, 2 BCF PORTB, 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_REG, 3; BSF 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 INTCON, PCF BANK, 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 BTFSC STATUS SDELAY CALL LFC1 NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BTFSC STATUS, C GOTO LR2G LR1G BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF mSTOP, CALL BUTTLEVEL, BTFSC mSTOP, 1; GOTO STOPS MOVLW 0xFF MOVWF SPEED11 MOVLW 0X66 MOVWF 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 LR1GREP; CALL STALL1, BTFS; 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 LFS 2 ROTO REPLF LR2G BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPS MOVLW 0XFF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVW MOVL MOVW MOVW MOVL MOVW MOVW MOVL MOVL PORTD, 1 BCF PORTB, 1 BSF PORTB, 2 LR2GREP; CALL STALL1; BTFSC MSTOP, 0; GOTO STOPPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA CALL LFC1 NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF LFS, 0 SUBWF LFS 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; 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 MSTOPPS, 3; GOTO STOPPS NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BTFSC STATUS, Z GOTO FROREP GOTO REPLF GOTO CLROE; ************************** **************** STOP BTFSS MSTOP, 4 GOTO STOPA MOVLW 0XCF MOVWF SPEED11 MOVLW 0XB3 MOVWF HASTIGHED 12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0XB3 MOVWF SPEED22 CALL PWM2 PALLET POLYM2 PALLET POLYM2 PALLET FRA P2 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 PORT 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; ****************************************** *; ******************************************; **** ************************************* STALL1 BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BANKSEL ADCON0 BCF ADCON0, 3 BCF ADCON0, 4 BCF ADCON0, 5 BCF STATUS, RP0 BCF STATUS, RP1 CALL CONVERT MOVF ADRESH, 0 SUBLW 0X70 BTFSS STATUS, C BSF MSTOP, 0 BCF STATUS, 0 BCFSTAT STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BANKSEL ADCON0 BSF ADCON0, 3 BCF ADCON0, 4 BCF ADCON0, 5 BCF STATUS, RP0 BCF STATUS, RP1 CALL CONVERT MOVF ADRESH, 0 SUBL BSF, 0 SUBL STATUS, RP0 BCF STATUS, RP1 RETURNBUTTLEVEL BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BANKSEL ADCON0 BCF ADCON0, 3 BCF ADCON0, 4 BSF ADCON0, 5 BCF STATUS, RF 0 STK BTFSS STATUS, 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, 0 RETURN ADVONCERN 0, RETURN ADVERSION 0, RETURN ADVERSION 0, RETURN ADVANC 1 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 MOVW, RX MOVLF 0XFF MOV MOVWF CCP1CON MOVF HASTIGHED, 0 MOVWF CCPR1L BSF STATUS, RP0 BCF STATUS, RP1 MOVLW 0XF0 MOVWF TRISC BCF STATUS, RP1 BCF T2CON, T2CPP PR2 MOVLW 0XFF MOVWF PR2 BCF STATUS, RP0 BCF STATUS, RP1 MOVF SPEED21, 0 MOVWF CCP2CON MOVF SPEED22, 0 MOVWF CCPR2L BSF STATUS, RP0 BCF STATUS, RP1 MOVLW 0XF0 MOVLF 0XF0 MOVL T2CON, T2CKPS0 BSF T2CON, TMR2ON BSF CCP2CON, 2 BSF CCP2CON, 3 RETURNPW 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 MOVLW 0X00 MOVWF PR2 BCF STATUS, RP1 BCF STATUS, RP0 RETURNPWM2OFF BCF CCP2CON, 2 BCF CCP2CON, 3 BSF T2CON, T2CKPS1 BSF T2CON, T2CKPS0 BCF T2CON, TMR2ON MOVLW 0X00 MOVWF CCP2CON MOVLW 0X00 MOVWF CCPR2L BANKS ADC0 ADP, R0 BCF 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, 5 BSF ADCON0, 5 BSF ADCON0 RP1 CALL CONVERT MOVF ADRESH, 0 ANDLW 0XF0 MOVWF LR2 BCF STATUS, RP0 BCF STATUS, RP1 RETURN LDIN BANKSEL ADCON0 BCF ADCON0, 3 BSF ADCON0, 4 BCF ADCON0, 5 BCF STV, RP0 ADV 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 0X10 WSW XL3 RETURN NOP NOPEND

Anden pris i Instructables og RoboGames Robot Contest

Anbefalede: