Taula de continguts:

La roca: 8 passos
La roca: 8 passos

Vídeo: La roca: 8 passos

Vídeo: La roca: 8 passos
Vídeo: 🤨 CÓMO LEVANTAR UNA SOLA CEJA [En 7 Pasos] ✅ Como THE ROCK / LA ROCA 2024, Desembre
Anonim
La pedra
La pedra

Aquest robot està controlat per un programa visual bàsic (a través del port sèrie) i pot moure’s a tres velocitats diferents mitjançant un senyal modulat d’amplitud d’impuls (PWM) generat per un microcontrolador PIC (16F877). El robot es pot operar en dues modalitats, "control normal" i modes "light tracker". En el mode de control normal, el robot pot transportar objectes de 3 a 18 cm d'un lloc a un altre a menys de 150 m. mentre que en el mode de seguiment de llum, segueix la llum en una habitació fosca. Es van utilitzar molts sensors, com ara sensors de llum; sensor d’inclinació, detecció de corrent de parada, detecció del nivell de la bateria i alguns interruptors de límit i sensors tàctils que s’utilitzen a la mà. Pot mantenir la seva velocitat constant quan va sobre un turó (inclinat) i encén la llum automàticament quan es fa fosc. També per mantenir la seguretat de l’IC, desconnecta el corrent quan s’enganxa i la mà s’atura quan s’aguanta alguna cosa. Es van utilitzar 4 motors de CC controlats per un microcontrolador PIC 16F877 i 3 circuits de controladors de motor. Va trigar uns 4 mesos i costa uns 600 $

Pas 1: dissenyar el projecte

Dissenya el projecte
Dissenya el projecte
Dissenya el projecte
Dissenya el projecte

a la fase inicial, es va proporcionar un disseny del projecte. principalment, definint el diagrama de blocs; veure la figura.

En aquesta etapa es requereix un diagrama de circuits més detallat, però, per facilitar-ho, els principals mòduls identificats van ser: 1. Microcontrolador 2. Sensors 3. Motors 4. Circuit sense fils 5. Programa de PC. També es va fer un disseny en 3D, vegeu la figura.

Pas 2: trieu els dispositius i components

En aquesta etapa, el dissenyador ha de triar els dispositius i components necessaris per construir el robot.

Això inclou: el circuit sense fils (MAX232, LM331, mòduls de transmissor i receptor FM), motors (4 motors de CC), circuit de controladors de motors (pont H), el microcontrolador PIC (16F877), bateria, reguladors de tensió (MC7805), microinterruptors, Fotoresistors, sensor d'inclinació … etc. És important entendre la computabilitat d'aquests dispositius i com funcionen junts.

Pas 3: el microcontrolador

El microcontrolador
El microcontrolador

Aquest pas és el pas més important. al principi, s’han d’identificar els codis que es rebran i transmetran des del PIC.

Comenceu a connectar els components als pins adequats del PIC i programeu el microcontrolador. Això pot requerir construir petits circuits mitjançant reguladors, resistències, sensors … etc.

Pas 4: escriviu el programa de PC

Escriviu el programa de PC
Escriviu el programa de PC
Escriviu el programa de PC
Escriviu el programa de PC

El programa es va escriure en visual basic.

La comunicació es va establir a través del RS-232. Utilitzant MSComm per enviar les dades al microcontrolador configurant els paràmetres (número de port, velocitat de transmissió, paritat de bits de dades, bits d’aturada). He utilitzat dades de 8 bits amb un bit de parada i paritat a una velocitat de transmissió de 9600 bps.

Pas 5: Construeix el cos

Construeix el cos
Construeix el cos
Construeix el cos
Construeix el cos

És important un bon disseny del cos. També escolliu la disposició de les rodes, vegeu la figura.

El robot es va construir després d'assegurar-se que els programes funcionen bé. Aquest pas es pot fer abans de programar també.

Pas 6: Creeu el circuit sense fils

Construeix el circuit sense fils
Construeix el circuit sense fils

Construir el circuit sense fils pot ser independent. A la fase inicial, he utilitzat un cable per connectar el PC amb el robot i, després de finalitzar el robot, s’ha integrat el circuit sense fils.

Pas 7: integració

Integrar
Integrar

Aquest és el moment en què vam integrar els nostres components i vam provar el robot.

Pas 8: Codi del programa del microcontrolador

; *************** FINAL ********************************* llista p = 16f877 inclou radloc decidlocs "V" << 8 | "1"; Versió núm. Config _CP_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC; ********** variable principal *************************** cblock 0x20; inici de banc 0 àrea RAM INPUT_VAR L1 L2 X SPEED11 SPEED12 SPEED21 SPEED22 MSTOP LDET LR1 LR2 endc; ********** inici del programa principal *************** inici BSF ESTAT, RP0 BCF ESTAT, 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 0 TRISD MOVLW 0X07; PORT E IS I MOVWF TRISE BANKSEL OPTION_REG BCF OPTION_REG, T0CS BCF STATUS, RP1 BCF STATUS, RP0; ************************** ******************; ******************************** ************ ESPERA 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 BCF, BCF LLAMADA PWM1OFF LLAMADA PWM2OFF LLAMADA DARKLIGHT BTFSC LDET, 0 BSF PORTB, 7RXDATA; BANKSEL RCSTA; BTFSC RCSTA, OERR; 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 PARA MOVF INPUT_VAR, 0; LIGHT ON SUBLW 0X4E BTFSC STATUS, Z GOTO LON MOVF INPUT_VAR, 0; LIGHT OFF SUBLW 0X51 BTFSC STAT, 0; MOVE FORWARD 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; MOVE FORWARD MEDIUM SUBLW 0X46 BTFSC STATUS, Z GOTO FMVE MOVF MOVF ESTAT, 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 MOVF INPUT_VAR, 0 Z GOTO FFAST MOVF INPUT_VAR, 0; MOVE DRET FAST SUBLW 0X57 BTFSC STATUS, Z GOTO RFAST MOVF INPUT_VAR, 0; MOVE ESQUERRA FAST SUBLW 0X56 BTFSC STATUS, Z GOTO LFAST MOVF INPUT_VAR, 0US MOVE BAST BFAST MOVF INPUT_VAR, 0; MAN CLOSE 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 UP SUBLW 0X75 BTF, HAND UP SUBLW 0X75 BTF; ESTAT DE MÀ SUBLW 0X64 BTFSC, 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 MSTOP, 1; 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 PORT, RCIF GOTO RXDATA GOTO REP3 GOTO CLROE; ****************************************** ** LSLOW 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 0WFF MOVWF 0XCF MOVWF SPEED21 MOVLW 0X66 MOVWF SPEED22 CONVOCAT PRIA PWM1ON CONVOCAT PRIA 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 CONVOCAT PRIA PWM1ON CONVOCAT PRIA PWM2ON BCF PORTD, 0 BSF PORTD, 1 BCF PORTB, PORTB3 P3 **************************** BSLOW BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA LLAMAR DARKLIGHT BTFSC LDET, 0; PORTB BSF, 7 MOVLW 0XCF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED2 CALL, 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; TRUCADA BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA TRUCADA DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 NORMALMED MOVLWS 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 BF GOTO REP6 PLUSEMED MOVLW 0XCF MOVWF SPEED11 MOVLW 0XCC MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0XCC MOVWF SPEED22 TRUCADA PWM1ON TRUCADA PWM2ON BCF PORTD, 1 BSF PORT, 1 BSF PORT BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA BTFSS PORTD, 7 GOTO NORMALMED GOTO REP7 GOTO CLROE; ******************************* ************ ESTAT BCF RMED, ESTAT BCF RP0, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; TRUCAR BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA LLAMAR DARKLIGHT BTFSC LDET, 0; B, 7 MOVLW 0XFF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X66 MOVWF SPEED22 LLAMADA PWM1ON LLAMADA PWM2ON BCF PORTD, 0 BSF PORTD, 1 PORTBALL STF, 1 BCF PORTB, 1 BCF PORTB, BTFSC PIR1, RCIF GOTO RXDATA GOTO REP8 GOTO CLROE; *************************************** **** ESTAT LMED BCF, RP0 ESTAT BCF, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; TRUCADA BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA TRUCADA DARKLIGHT BTFSC LDET, 0; 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 MSTOPO, BOT REP9 GOTO CLROE; ********************************************* BMED BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XFF MOVWF SPEED11 MOVLW 0X7F MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X7F MOVWF SPEED22 TRUCADA PWM1ON TRUCADA PWM2ON BSF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BCF PORTB, 2 PORTES BOTES 1 REP10 BALL STOP 1 REP10 GOTO CLROE; ******************************************** ESTAT BCF RÀPID, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0 BSF MSTOP, 4; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPS TRUC DARKLIGHT BTFSC LDET, 0; MOVWF SPEED21 MOVLW 0x7F MOVWF SPEED22 CRIDA PWM1ON CRIDA PWM2ON BCF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BSF PORTB, 2 CRIDA SDELAY NORMALFAST MOVLW 0XCF MOVWF SPEED11 MOVLW 0xCC MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0xCC MOVWF SPEED22 CRIDA PWM1ON CRIDA PWM2ON BCF PORTD, 0 BCF PORTD, 1 BTFSC LDET, 0 BSF PORTB, 7 BSF PORTB, 1 BSF PORTB, 2 REP11 STALL DE Trucades1 BTFSC MSTOP, 0 GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA NOP BTFSS PORTD, 7 GOT 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 PORTS, 1 BSF PORTB, 1 BSF PORTB, 1 BSF PORTB, 1 BSF PORTB, 1 BSF PORTB, RCIF GOTO RXDATA BTFSS PORTD, 7 GOTO NORMALFAST GOTO REP12 GOTO CLROE; ********************************** ******** ESTAT RFAST BCF, ESTAT RP0 BCF, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; LLAMADA BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA LLAMAR DARKLIGHT BTFSC LDET, 0; SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X66 MOVWF SPEED22 CONVOCAT PRIA PWM1ON CONVOCAT PRIA PWM2ON BCF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BSF PORTB, 1 REP13 BTP GOTO REP13 GOTO CLROE; ******************************************** LFAST BCF ESTAT, RP0 BCF ESTAT, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; LLAMADA BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA LLAMADA DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XFF MOVWF SPEED11 MOVLW 0X66 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 Trucada PWM1ON TRUCADA PWM2ON BSF PORTD, 0 BCF PORTB, 1 MOV 0XEF MOVWF SPEED21 MOVLW 0XB3 MOVWF SPEED22 LLAMADA PWM1ON LLAMADA PWM2ON BSF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BCF PORTB, 2 REP14 CALL STALL1 BTFSC MSTOP, 0 GOTO STOPS GFP1 GF ****************************************** BFAST BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; LLAMADA BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA LLAMADA DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XDF MOVWF SPEED11 MOVLW 0X99 MOVWF MOVWF MOVWF MOVW PWM2ON BSF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BCF PORTB, 2 TRUCADA SDELAY MOVLW 0XEF MOVWF SPEED11 MOVLW 0X66 MOVWF SPEED12 MOVLW 0XEF MOVWF SPEED21 MOVLW 0X66 MOVWF PWD PORTD, 0 BSF PORTD, 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; ************** ****************************** HCLOSE BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; TRUCADA A NIVELL; BTFSC MSTOP, 1; GOTO STOPS 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 STOPS BT GOTO PARA TROBAR SDELAY TROBAR 2 BTFSC MSTOP, 2 GOTO PARA BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP16 GOTO CLROE; ************************** ****************** ESTAT BCF HOPEN, ESTAT BCF RP0, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO STOPS 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 Trucada SDELAY TALL STAL2 BTFSC MSTOP, 2 GOTO STOPS 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 STOPS CALL DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 BTFSC PORTC, 4 GOTO STOPS BCF PORTC, 0 BTFSC PORTC, 4 GOTO PARES 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 STOPS 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; ***** *************************************** SEGUEIX ESTAT BCF, RP0 BCF ESTAT, 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, 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, BCIE PCCON, GIE BANKS, 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 FRONT, Z GOT 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; TRUCADA BUTTLEVEL; 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 STALLO; 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 LR 1 REPLF LR2G BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP; TRUCADA BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA MOVLW 0XFF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLF MOVLF MOVLF MOVLF 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 LR1, 0 SUBWF LR 1 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 BUTTLE MOVF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CONVOCAT PRIA PWM1ON CONVOCAT PRIA 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, 3; GOTO STOP NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BTFSC STATUS, Z GOTO FROREP GOTO REPLF GOTO CLROE; *************************** **************** PARA BTFSS MSTOP, 4 GOTO STOPA MOVLW 0XCF MOVWF SPEED11 MOVLW 0XB3 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0XB3 MOVWF SPEED2 CALL PWP 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; ******************************************* *; *******************************************; **** *************************************** 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 TRUCAR CONVERTIR MOVF ADRESH, 0 SUBLW 0X70 BTFSS STATUS, C BSF MSTOP, 0 BCF STATUS, RP0 BCF STATUS, RP0 ESTAT, RP0 BCF ESTAT, RP1 MOVLW 0X00 MOVWF MSTOP BANKSEL ADCON0 BSF ADCON0, 3 BCF ADCON0, 4 BCF ADCON0, 5 BCF STATUS, RP0 BCF STATUS, RP1 TRUC CONVERTIR MOVF ADRESH, 0 SUBLW 0X40 BTFS, 0 SUBLW 0X40 BTFS ESTAT, RP0 BCF ESTAT, RP1 RETURNBUTTLEVEL BCF ESTAT, RP0 BCF ESTAT, RP1 MOVLW 0X00 MOVWF MSTOP BANKSEL ADCON0 BCF ADCON0, 3 BCF ADCON0, 4 BSF ADCON0, 5 BCF STATUS, RP0 BCV STF, RP0 BCV STAT, RP0 ESTAT DE BTFSS, C GOTO BL1 GOTO BL2 BL1 BSF MSTOP, 1 PORTB BSF, 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 TRUCAR CONVERTIR MOVF ADRESH, 0 SUBLW 0XEE BTFSS STATUS, C BSF PORTB, 7 RETFEL 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 MOVWFF PR2 BCF, RV1 MOVWF CCP1CON MOVF SPEED12, 0 MOVWF CCPR1L BSF STATUS, RP0 BCF STATUS, RP1 MOVLW 0XF0 MOVWF TRISC BCF STATUS, RP0 BCF STATUS, RP1 BCF T2CON, T2CKPS1 BCF T2CON, BS2CF, BS2 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 BCVFF BCFF RUSC, BCVF2 T2CON, T2CKPS0 BSF T2CON, TMR2ON BSF CCP2CON, 2 BSF CCP2CON, 3 RETURNPW M1OFF CCP1CON BCF, 2 CCP1CON BCF, 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, STATUS RP1 BCF, RP0 RETURNPWM2OFF BCF CCP2CON, CCP2CON 2 BCF, 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, RP1 5 BCF STATUS, RP0 BCF STATUS, RP1 TRUC CONVERTIR 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, 4 BSF ADCON0, 4 BSF ADCON0, RP1 CONVERSA CONVERTIR 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 STATUS, RP0 BCV CONF, RP0 BCF STATUS 0X4C ESTAT BTFSC, C GOTO COMP4 BSF MSTOP, 3 COMP4 ESTAT BCF, RP0 ESTAT BCF, RP1 TORNAR 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 SXF LF2 XL3 TORNAR NOP NOPEND

Accèssit al concurs de robots Instructables i RoboGames

Recomanat: