Innholdsfortegnelse:

The Rock: 8 trinn
The Rock: 8 trinn

Video: The Rock: 8 trinn

Video: The Rock: 8 trinn
Video: AQUARIUM HARDSCAPE TUTORIAL FOR BEGINNERS - ROCK AND WOOD DECORATION IN PLANTED TANKS 2024, November
Anonim
Steinen
Steinen

Denne roboten styres av et visuelt grunnprogram (gjennom serieporten), og kan bevege seg i tre forskjellige hastigheter med et pulsbreddemodulert (PWM) signal generert av en PIC -mikrokontroller (16F877). Roboten kan betjenes i to moduser, "normal kontroll" og "lyssporing". I normal kontrollmodus kan roboten bære objekter i størrelse 3 - 18 cm fra sted til et annet innen 150 m. mens det i lyssporingsmodus følger lyset i et mørkt rom. Mange sensorer ble brukt, for eksempel lyssensorer; vippesensor, stallstrømføling, batterinivåmåling og noen grensebrytere og berøringssensorer som brukes i hånden. Den kan holde hastigheten konstant når den går på en bakke (vippet) og slår automatisk på lyset når det blir mørkt mørkt. Også for å holde IC'en trygg, kobler den fra strømmen når den sitter fast og hånden stopper når du holder noe. 4 DC -motorer ble brukt kontrollert av en PIC -mikrokontroller 16F877 og 3 motordriverkretser. Det tok omtrent 4 måneder og koster omtrent 600 $

Trinn 1: Design prosjektet

Design prosjektet
Design prosjektet
Design prosjektet
Design prosjektet

i den innledende fasen ble det gitt et design av prosjektet. hovedsakelig definere blokkdiagrammet; se figuren.

Et mer detaljert kretsdiagram er nødvendig på dette stadiet, men for å lette dette var hovedmodulene identifisert: 1. Mikrokontroller 2. Sensorer 3. Motorer 4. Trådløs krets 5. PC -program. En 3d -design ble også gjort, se figuren.

Trinn 2: Velg enheter og komponenter

På dette stadiet bør designeren velge enhetene og komponentene som kreves for å bygge roboten.

Dette inkluderer: den trådløse kretsen (MAX232, LM331, FM-sender og mottakermoduler), motorer (4 likestrømsmotorer), motordriverkrets (H-bro), mikrokontrolleren PIC (16F877), batteri, spenningsregulatorer (MC7805), mikrobrytere, Fotoresistorer, Tilt -sensor … etc. Det er viktig å forstå beregningen av disse enhetene og hvordan de fungerer sammen.

Trinn 3: Mikrokontrolleren

Mikrokontrolleren
Mikrokontrolleren

Dette trinnet er det viktigste trinnet. i begynnelsen bør kodene som vil bli mottatt og overført fra PIC identifiseres.

Begynn å koble komponentene til de riktige pinnene på PIC, og programmer mikrokontrolleren. Dette kan kreve å bygge små kretser ved hjelp av regulatorer, motstander, sensorer … etc.

Trinn 4: Skriv PC -programmet

Skriv PC -programmet
Skriv PC -programmet
Skriv PC -programmet
Skriv PC -programmet

Programmet ble skrevet på visual basic.

Kommunikasjonen ble etablert gjennom RS-232. Bruke MSComm til å sende dataene til mikrokontrolleren ved å konfigurere innstillingene (portnummer, overføringshastighet, paritetstall for databiter, stoppbiter). Jeg brukte 8-biters data med en stoppbit og paritet med en baudhastighet 9600 bps.

Trinn 5: Bygg kroppen

Bygg kroppen
Bygg kroppen
Bygg kroppen
Bygg kroppen

En god utforming av kroppen er viktig. Også valg av hjularrangement, se figuren.

roboten ble bygget etter å ha forsikret om at programmene fungerer bra. Dette trinnet kan også gjøres før du programmerer.

Trinn 6: Bygg den trådløse kretsen

Bygg den trådløse kretsen
Bygg den trådløse kretsen

Å bygge den trådløse kretsen kan være uavhengig. I den første fasen har jeg brukt en ledning for å koble PC -en til roboten, og etter å ha fullført roboten ble den trådløse kretsen integrert.

Trinn 7: Integrer

Integrere
Integrere

Dette er øyeblikket da vi integrerte komponentene våre og testet roboten.

Trinn 8: Programkode for mikrokontroller

; **************** ENDELIG ********************************* liste p = 16f877 inkluderer radix decidlocs "V" << 8 | "1"; Versjon nr. Konfigurasjon _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 av 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 STOPPS 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 STOPPS MOVF INPUT_VAR, 0; LIGHT ON SUBLW 0X4E BTFSC STATUS, Z GOTO LON MOVF INPUT_VAR, 0; LIGHT OFF5 SUBX 0; FLYTT FORSLÅ SAKT SUBLV 0X66 BTFSC STATUS, Z GOTO FSLOW MOVF INPUT_VAR, 0; FLYT HØYRE SLANG SUBLV 0X72 BTFSC STATUS, Z GOTO RSLOW MOVF INPUT_VAR, 0; FLYT VENSTRE 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; FLYTTE FORVARD MEDIUM SUBLW 0X46 BTFSC STATUS, Z GOTO FMX, ZVOTO FMX, ZVOTO FMX, ZVOTO FMX, ZVOTO FMX, ZVOTO FMX, ZVOTO FMX 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 GATS FOTO 0, MOTORBUTX, 0 GATS FOTO MOTO BFAST MOVF INPUT_VAR, 0; HAND 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; 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 MSTOPO, 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 PWB2 PORT BORT 1, BCF PORT 1, BCF PORT 1, RCIF GOTO RXDATA GOTO REP3 GOTO CLROE; ***************************************** ** LSLOW BCF STATUS, RP0 BCF STATUS, RP1; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPPS MOVLW 0X00 MOVWF MSTOP BCF LDET, 0 CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XW MOVW MOVLW 0XFF MOV 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 STOPPS 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 SPEED11 MOVLW 0X99 MOVWF HASTIGHET12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL 1 PALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 1 BALLER 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 MOVLW 0XW 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 STOPPS BIRD GOTO REP6 PLUSEMED MOVLW 0XCF MOVWF SPEED11 MOVLW 0XCC MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0XCC MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORT, 1 BCP PORT 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 PORTB, 1 BSF PORTO, 1 BSF PORTB, 1 BSF PORTO, 1 BSF PORTO, 1 BCF PORTO, 1 BCF PORTO, 1 BSF PORTO, 1 BSF PORTO, 1 BSF PORTO, 1 BCF PORTO, 1 BCF PORT 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 MOTOPP, GIRK, GIRK 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 CALL PWM1ON CALL PWM2ON BSF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BCF PORTBORG, 1 BTF GALLERI, GALLERI GALLERI, 2 BETALER GALLERI, 2 BETALINGER GALLERI, GALLERI 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 MOVW 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 STOPPS 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 PORTBURG, 1 BSF1 PORTBUTIKK, 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 MOVLWX 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 PORTBACK, 1 BSF PORTBALL, 2 BUD1 STOPPER, 1 BFS1 PORTO, 2 RP13 BUTCH STOPPER, 2 BUD1 STOPPER, 2 BETALINGER 1 STK GALLERI, 2 BETALINGER 1 STK GALLERIER 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 HASTIGHET11 MOVLW 0X66 MOVWF HASTIGHET 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 STOPPER BANKS1 GIRSKO GIRCO, GOTO STOPPER BANKSEL1, GOTO STOPPER BANKSEL1, GOTO STOPP BANK *************************************** BFAST 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 0XDF MOVWF SPEED11 MOVLW 0X99 MOVD 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 SP2 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 STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 BTFSC PORTD, 5 GOTO STOPPS BTFSC PORTD, 6 GOTO STOPPS BSF PORTD, 2 BCF PORTD, 3 REP16 BTFSC PORTD, 5 GOTO STOPS GOTO STOPPS CALL SDELAY CALL STALL2 BTFSC MSTOP, 2 GOTO STOPPS 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 STOPPS CALL SDELAY CALL STALL2 BTFSC MSTOP, 2 GOTO STOPPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO 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 BTFSC PORTC, 4 GOTO STOPPS 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 STOPPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 BTFSC PORTC, 5 GOTO STOPPS 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, BCF 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 FRONT, Z 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 GANGSTOPP; 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, 0 SAT REPLF LR2G BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPPER MOVLW 0XFF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVW MOVEN MOVL MOVEN FRA 0 KJØP MELLOM 0 KJØR MELLOM 0 KJØR MELLOM 0 KJØR MELLOM 0 KJØR MELLOM 0 KJØP MELLOM 0 KJØR MELLOM 0 KJØP MELLOM 0 KJØP MELLOM 0 KJØP MELLOM 0 KJØP MELLOM MOTORKJØR MELLOM 0 KJØP MØRK LYK FØR MÅL 0 KJØP MELLOM MELLOM 0 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 SUBWF LFS, 0 SATWF 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; ************************** **************** STOPPER BTFSS MSTOP, 4 GOTO STOPA MOVLW 0XCF MOVWF SPEED11 MOVLW 0XB3 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0XB3 MOVWF SPEED22 CALL PALL2 PALLMOTOR POLYM2 PALLMOTOR POLYM2 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 RST 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 CFS 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 STF 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 ADRONS 1 RETURN ADRONS 1 RETURN ADRONS ADVANC 1 RETURN ADRON 1 RETURG 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, XV MOVLF 0XFF MOVW MOVWF CCP1CON MOVF SPEED12, 0 MOVWF CCPR1L BSF STATUS, RP0 BCF STATUS, RP1 MOVLW 0XF0 MOVWF TRISC BCF STATUS, RP1 BCF T2CON, T2CON, T2C 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 MOVW 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 BANKSEL 0X00 MOVWF PR2 BC0 STK 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 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 ADF 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 MOVFW 0X10 WAT XL3 RETURN NOP NOPEND

Andre pris i Instructables og RoboGames Robot Contest

Anbefalt: