Índice:

The Rock: 8 Passos
The Rock: 8 Passos

Vídeo: The Rock: 8 Passos

Vídeo: The Rock: 8 Passos
Vídeo: Como tocar Rock em 8 Passos - Parte 1 | Acordes Básicos e Cifras 2024, Novembro
Anonim
A rocha
A rocha

Este robô é controlado por um programa visual básico (através da porta serial), e pode se mover em três velocidades diferentes por um sinal modulado por largura de pulso (PWM) gerado por um microcontrolador PIC (16F877). O robô pode ser operado em dois modos, modos de "controle normal" e "rastreador de luz". No modo de controle normal, o robô pode carregar objetos com tamanhos de 3 a 18 cm de um local para outro dentro de 150 m. enquanto no modo rastreador de luz, ele segue a luz em uma sala escura. Muitos sensores foram usados, como sensores de luz; sensor de inclinação, sensor de corrente de bloqueio, sensor de nível da bateria e alguns interruptores de limite e sensores de toque usados na mão. Ele pode manter sua velocidade constante quando sobe uma colina (inclinado) e liga automaticamente a luz quando escurece. Além disso, para manter o IC seguro, ele desconecta a corrente quando está preso e a mão para ao segurar algo.4 Motores CC foram usados controlados por um microcontrolador PIC 16F877 e 3 circuitos de driver de motor. Demorou cerca de 4 meses e custou cerca de 600 $

Etapa 1: Desenhe o Projeto

Desenhe o Projeto
Desenhe o Projeto
Desenhe o Projeto
Desenhe o Projeto

na fase inicial, foi fornecido um desenho do projeto. principalmente, definindo o diagrama de blocos; veja a figura.

Um Diagrama de Circuito mais detalhado é necessário nesta fase, porém, para facilitar isso, os principais módulos identificados foram: 1. Microcontrolador 2. Sensores 3. Motores 4. Circuito sem fio 5. Programa para PC. Um design 3D também foi feito, veja a figura.

Etapa 2: escolha os dispositivos e componentes

Nesta fase, o projetista deve escolher os dispositivos e componentes necessários para construir o robô.

Isso inclui: o circuito sem fio (MAX232, LM331, módulos de transmissor e receptor FM), motores (4 motores DC), circuito de drivers de motores (ponte H), o microcontrolador PIC (16F877), bateria, reguladores de tensão (MC7805), microinterruptores, Fotorresistores, sensor de inclinação … etc. É importante entender a capacidade de computação desses dispositivos e como eles funcionam juntos.

Etapa 3: o microcontrolador

O Microcontrolador
O Microcontrolador

Esta etapa é a etapa mais importante. no início, devem ser identificados os códigos que serão recebidos e transmitidos do PIC.

Comece conectando os componentes aos pinos apropriados do PIC e programe o microcontrolador. Isso pode exigir a construção de pequenos circuitos usando os reguladores, resistores, sensores … etc.

Etapa 4: escrever o programa de PC

Escreva o programa de PC
Escreva o programa de PC
Escreva o programa de PC
Escreva o programa de PC

O programa foi escrito em visual basic.

A comunicação foi estabelecida através do RS-232. Usando o MSComm para enviar os dados ao microcontrolador, definindo as configurações (número da porta, taxa de transmissão, número de paridade de bits de dados, bits de parada). Usei dados de 8 bits com um bit de parada e paridade a uma taxa de transmissão de 9600 bps.

Etapa 5: construir o corpo

Construa o Corpo
Construa o Corpo
Construa o Corpo
Construa o Corpo

Um bom design do corpo é importante. Escolhendo também a disposição das rodas, veja a figura.

O robô foi construído após garantir que os programas estão funcionando bem. Esta etapa também pode ser realizada antes da programação.

Etapa 6: construir o circuito sem fio

Construa o circuito sem fio
Construa o circuito sem fio

A construção do circuito sem fio pode ser independente. No estágio inicial, usei um fio para conectar o PC ao robô e, após finalizar o robô, o circuito sem fio foi integrado.

Etapa 7: Integrar

Integrar
Integrar

Este é o momento em que integramos nossos componentes e testamos o robô.

Etapa 8: Código do programa do microcontrolador

; **************** ******************************** lista p = 16f877 inclui decidlocs radix "V" << 8 | "1"; Versão No.config _CP_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC; ********** variável principal ***************************** cblock 0x20; início de banco 0 área ram INPUT_VAR L1 L2 X SPEED11 SPEED12 SPEED21 SPEED22 MSTOP LDET LR1 LR2 endc; ********** início do programa principal *************** iniciar BSF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X40 MOVWF ADCON1 MOVLW 0XFF; PORTA A IS I MOVWF TRISA MOVLW 0X00; PORTA B IS O MOVWF TRISB MOVLW 0XF0; PORTA C IS I / O MOVWF TRISC MOVLW 0X00; PORTA B IS O MOVWF TRISB MOVLW 0XF0; PORTA C IS I / O MOVWF TRISC MOVLW 0X00; PORTA B IS O MOVWF TRISB MOVLW 0XF0; PORTA C IS I / O MOVWF TRISC MOVLW 0X00; TRISD MOVLW 0X07; PORTO E IS I MOVWF TRISE BANKSEL OPTION_REG BCF OPTION_REG, T0CS BCF STATUS, RP1 BCF STATUS, RP0; **************************** *******************; ****************************** ************ WAIT 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, 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 BT BCFSS PIR1, RCIF PORTB GOTO WAIT1 3 BCF MSTOP, 0 CHAMADA PWM1OFF CHAMADA PWM2OFF CHAMADA DARKLIGHT BTFSC LDET, 0 BSF PORTB, 7RXDATA; BANKSEL RCSTA; BTFSC RCSTA, OERR; GOTO PÁRA CHAMADA PWM1OFF CHAMADA PWM2OFF CHAMADA DARKLIGHT BTFSC LDET, 0 BSF PORTB, 7 BANKSEL PIR1 BCF PIR1, RCIF BANKSEL RCREG MOVF RCREG, 0; ********************************************; **** **************************************** MOVWF INPUT_VAR MOVLW 0X00 MOVWF RCREG BCF STATUS, RP0 BCF STATUS, RP1 MOVF INPUT_VAR, 0; PARAR SUBLW 0X53 BTFSC STATUS, Z GOTO PARAR MOVF INPUT_VAR, 0; LUZ ACESA SUBLW 0X4E BTFSC STATUS, Z GOTO LON MOVF ENTRADA_FFAR, 0; LUZ DESLIGADA MOVF ENTRADA_VAR, 0; LUZ ACESA SUBLW 0X4E BTFSC STATUS, Z GOTO LON MOVF ENTRADA_FFAR, 0; LUZ DESLIGADA MOVF SUBLW ENTRADA 0X51 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; MOVER PARA TRÁS LENTO SUBLW 0X62 BTFSC STATUS, Z GOTO BSLOW MOVF INPUT_VAR, 0; MOVER PARA A FRENTE MEDIUM SUBLW 0X46 BTFSC STATUS, Z GOTO FMED MOVF INPUT_VAR, 0; MOVER PARA A FRENTE MEDIUM SUBLW 0X46 BTFSC STATUS, Z GOTO FMED MOVF ENTRADA_VAR, 0; STATUS, Z GOTO RMED MOVF INPUT_VAR, 0; MOVER LEFT MEDIUM SUBLW 0X4C BTFSC STATUS, Z GOTO LMED MOVF INPUT_VAR, 0; MOVER BACKWARD MEDIUM SUBLW 0X42 BTFSC STATUS, Z GOTO BMED MOVF INPUT_VAR, 0; MOVER BACKWARD MEDIUM SUBLW 0X42 BTFSC STATUS, Z GOTO BMED MOVF INPUT_VAR, 0; MOVER PARA TRÁS MEDIUM SUBLW 0X42 BTFSC STATUS, Z GOTO BMED MOVF INPUT_VAR, 0; Z GOTO FFAST MOVF INPUT_VAR, 0; MOVER RIGHT FAST SUBLW 0X57 BTFSC STATUS, Z GOTO RFAST MOVF INPUT_VAR, 0; MOVER LEFT FAST SUBLW 0X56 BTFSC STATUS, Z GOTO LFAST MOVF INPUT_VAR, 0; bFast MOVF INPUT_VAR, 0; mão Close SUBLW 0x43 BTFSC STATUS, Z GOTO HFeche MOVF INPUT_VAR, 0; MÃO ABERTA SUBLW 0x4F BTFSC STATUS, Z GOTO HOPEN MOVF INPUT_VAR, 0; MÃO UP SUBLW 0X75 BTFSC STATUS, Z GOTO HUP 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 MSTOP MSTOP BOM CALL; BTFSC DARK STOP, 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 MOVLW 0X66 MOVWF SPEED12 MOVLW 0XFF MOVWF SPEED21 MOVLW 0X66 MOVWF SPEED22 CALL PWM1ON CALL PORT PWM2ON BF1 BFIR PWM2ON BF1 BF BIR PORT 1 BFIR BF1 BF1 BF PORTA PWM2ON3 BF1 BF1 BF1 BF PORT PWM2ON BT1, 0 BF1 BF BIR PORT 1 BF1 BF BF BORR PWM2ON, 0 BF1 BF1 BF PORT PWM2ON3 BF1 BF1 BF PORTA PWM 2, RCIF GOTO RXDATA GOTO REP3 GOTO CLROE; **************************************** ** LSLOW BCF STATUS, RP0 BCF STATUS, RP1; CHAMADA BUTTLEVEL; BTFSC MSTOP, 1; GOTO PÁRA MOVLW 0x00 MOVWF MSTOP BCF LDET, 0 CHAMADA DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0xFF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 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 PARA 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 CLTOTO, 1 BSF * GO BANCO RAP BANKS 1 BSF BANCO REPR. ***************************** BSLOW BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA A CHAMADA DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XCF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0X99 MOVLW 0XCF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0X99 BORTE MOVWF VELOC 1 BORTE 1, BORDA CALL PWM 2 CALL, BCWD 1 MOVWF 0X99 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLWD 1 BOMBALL CALL, BCWD 1 PORTON 1 BOM VEL 2 CALL, BORTE 1 BFWMD 2 CALLD 2 BCWD, BORTE 2 CALLMD 2 BCWMD 2 BOMBD2 BCWMD, BCWD 2 CALLDWM 2 MOVLW; 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 PARA A CHAMADA LUZ NEGRA BTFSC LDET, 0; BSF PORTB, 7 NORMALMED MOVLWV MOVLW12 MOVLW11 MOVLWFVL 0XVW11 NORMALMED MOVLWV 0XFFW11 MOVLW11 MOVLWFVL 0XVW11 NORMALMED MOVLWVL 0XVW11 MOVLW11 MOVLW11 MOVLWFVLW11 NORMALMED 0XFFEVLW11 MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BSF PORTB, 2 CHAMADAS SDELAY REP6 CALL STALL1 BTFSC MSTOP, 0 GOTO STOPPS BANKSEL 1 BTDTOFS, BANKSEL BANKSEL PIRS 1 BTDTAX, BTDTOF PIRS 1 BTDTAX, BANKSEL PIRS 1 BTDTAX 1 BTDTAX BANKSEL PIRS 1 BTDTAX 1 BTDTAF PIRS PIRs GOTO REP6 PLUSEMED MOVLW 0XCF MOVWF SPEED11 MOVLW 0xCC MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0xCC MOVWF SPEED22 CHAMADA PWM1ON CHAMADA PWM2ON BCF PORTD, 0 BCF PORTD, um BSF PORTB, um BSF PORTB, 2 CHAMADA SDELAY REP7 CHAMADA STALL1 BTFSC MSTOP, 0 GOTO PÁRA 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 PARA A CHAMADA 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 BSF BORTE DE BORDO, 1 BSF BIR STBALL, 1 BSF1 BOPST BOP, 1 BSF1 PONTE DE BORDO, 1 BSF1 BORTE PONTOS 1 BSF1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP8 GOTO CLROE; ***************************************** **** STATUS LMED BCF, RP0 STATUS BCF, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA A CHAMADA LUZ ESCURA BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XFFED 0XFF MOVWFVLVL 0X MOVWF11 VELOCIDADE12 MOVLW 0XFF MOVWF VELOCIDADE21 MOVLW 0X99 MOVWF VELOCIDADE22 CALL PWM1ON CALL PWM2ON BSF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BCF PORTB, 2 REP9; CALL STALL1; BTFSC MSTOPTO, 0; BSF PORTD, 0 BSF PORTD, 1 BSF PORTB, 1 BCF PORTB, 2 REP9; REP9 GOTO CLROE; ******************************************* STATUS BMED BCF, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA CHAMADA DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XFF MOVWF SPEED11 MOVLW 0x7F MOVWF SPEED12 MOVLW 0xFF MOVWF SPEED21 MOVLW 0x7F MOVWF SPEED22 CHAMADA PWM1ON CHAMADA PWM2ON BSF PORTD, 0 BSF PORTD, um BCF PORTB, um BCF PORTB, 2 REP10 CHAMADA STALL1 BTFSC MSTOP, 0 GOTO PÁRA BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RxData GOTO 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 PARA A CHAMADA LUZ ESCURA BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XEF MOVWF7 MOVWFEFVLWFVL 0XEF MOVWF7 SPEF 0XEF MOVWF7 MOVWF11 SPEF2 MOVWF SPEED21 MOVLW 0x7F MOVWF SPEED22 CHAMADA PWM1ON CHAMADA PWM2ON BCF PORTD, 0 BCF PORTD, um BSF PORTB, um BSF PORTB, 2 CHAMADA SDELAY NORMALFAST MOVLW 0XCF MOVWF SPEED11 MOVLW 0xCC MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0xCC MOVWF SPEED22 CHAMADA PWM1ON CHAMADA 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 PARA BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA NOP BTFSS PORTD, 7 GOTO REP11 PLUSEF AST MOVLW 0XCF MOVWF SPEED11 MOVLW 0XFF MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0XFF MOVWF SPEED22 CALL PWM1ON CALL PWM2ON BCFALLD, 0 BCF PORTD, 1 BSF CALL BIRST, 1 BSF CALL BIRST, 1 BSF CALL STOED, 1 BSF CALL BIRST1, 1 BSF CALL BIRST 1 BFS PBCS1 BFS 1 BFS PIRST 1, 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 PARA A CHAMADA DARKLIGHT BTFSC LDET, 0; BSFP PORTB, 7 MOVLW 0XFF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0xFF MOVWF SPEED21 MOVLW 0x66 MOVWF SPEED22 CHAMADA PWM1ON CHAMADA PWM2ON BCF PORTD, 0 BSF PORTD, um BCF PORTB, um BSF PORTB, 2 rep13 CHAMADA STALL1 BTFSC MSTOP, 0 GOTO PÁRA BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RxData GOTO REP13 GOTO CLROE; ****************************************** LFAST BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA A CHAMADA DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0xFF MOVWF SPEED11 MOVLW 0x66 MOVWF SPEED12 MOVLW 0xFF MOVWF SPEED21 MOVLW 0X99 MOVWF SPEED22 CHAMADA PWM1ON CHAMADA PWM2ON BSF PORTD, 0 BCF PORTD, um BSF PORTB, 1 PORTB BCF, 2 CHAMADA SDELAY MOVLW 0xFF MOVWF SPEED11 MOVLW 0x4C MOVWF SPEED12 MOVLW 0XEF MOVWF SPEED21 MOVLW 0XB3 MOVWF SPEED22 CHAMADA PWM1ON CHAMADA PWM2ON BSF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BCF PORTB, 2 REP14 CALL STALL1 BTFSC MSTOP, 0 GOTO STIRPS BTO CLIPE GOIFRO PIR1, BT CLF GOIFRO PIR1 R14; ******************************************* STATUS BFAST BCF, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA A CHAMADA DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 MOVLW 0XDF MOVWF SPEED11 MOVLW21 0X99 MOVWF MOVWF CALLWLW21 0X99 MOVWF MOVWF CALLFW12 CALLWFVL 0X99 MOVWF VELOC 1 CDFLVL 0X99 MOVWFV CALLWED2 0X99 MOVWFV CALLFVL CEDVL 0 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 MOVWF SPEED11 MOVLW 0X66 MOVWF SPEED12 MOVLW 0XEF MOVWF SPEED21 MOVLW 0X66 MOVWF VELOC. 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; CALL BUTTLEVEL; 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 BTFSC PORTD, 6 GOTO STOPS CALL SDELAY CALL STALL2 BTFSC MSTOP, 2 GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA GOTO REP16 GOTO CLROE; *************************** ******************* STATUS HOPEN BCF, RP0 STATUS BCF, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA LIGAR LUZ ESCURO 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 RXDATA GOTO REP17 GOTO CLROE; ******************************************** HUP BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP BCF LDET, 0; CALL BUTTLEVEL; BTFSC MSTOP, 1; GOTO PARA CHAMADA DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 BTFSC PORTC, 4 GOTO STOPS BCF PORTC, 0 BSF 18 REP BTFSC PORTC, 4 GOTO PARA 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 PARA A CHAMADA DARKLIGHT BTFSC LDET, 0; BSF PORTB, 7 BTFSC PORTC, 5 GOTO PARA BSF PORTC, 0 BCF PORTC, 3 REP19 BTFSC PORTC, 5 GOTO PARA 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 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_REG, 3; BSF OPTION_REG, 3; BSF OPTION_REG, 3; BSF OPTION_REG, 3;, 3; CLRFWDT BCF STATUS, RP0 BCF STATUS, RP1; BANKSEL INTCON; BCF INTCON, T0IE; BCF INTCON, T0IF; BANKSEL PIE1; BCF PIE1, 6; BCF PIE1 BCF BCF, 0; BANKSEL INTCON, T0IE; BCF INTCON, T0IF; BANKSEL PIE1; BCF PIE1, 6; BCF PIE1 BCF, 0; BANKSEL INTCON; BCF INTCON, T0IF;, 0 BCF PCON, 1 NOP BSF PCON, 0 BSF PCON, 1 BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0X00 MOVWF MSTOP CHAMADA SDELAY CHAMADA LFC1 NOP CHAMADA LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BT GOTO CALL FRONT 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 BUTTTOVEL; 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 STALL PWM2ON BSF PORTD, 0 BCF PORTD, 1 BSF PORTB, 1 BCF PORTB, 2 LR1GREP; OPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA CHAMADA LFC1 NOP CHAMADA LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BTFSC STATUS, Z GOTO REPLF CHAMADA LFC1 NOP CHAMADA LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BTFSC STATUS, Z GOTO REPLF CHAMADA LFC1 NOP CHAMADA LFC2 NOP MOVF LRTOS, 0 SUBWF LR1, 0 BTFSC STATUS, Z GOTO REPLF CHAMADA LFC1 NOP CHAMADA LFC2 NOP MOVF LRTO, 0 SUBWF GO LR1, 0 SUBWF CALL LRT 0 REPLF LR2G BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0x00 MOVWF MSTOP; BUTTLEVEL CHAMADA; BTFSC MSTOP, 1; GOTO PÁRA MOVLW 0xFF MOVWF SPEED11 MOVLW 0X99 MOVWF SPEED12 MOVLW 0xFF MOVWF SPEED21 MOVLW 0x66 MOVWF SPEED22 CHAMADA PWM1ON CHAMADA PWM2ON BCF PORTD, 0 BSF PORTD, 1 BCF PORTB, 1 BSF PORTB, 2 LR2GREP; CALL STALL1; BTFSC MSTOP, 0; GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA CHAMADA LFC1 NOP CHAMADA LFC2 NOP MOVF LR2, 0 SUBWF 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 STATUS BCF, 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 MSTOP, 3; GOTO STOPS BANKSEL PIR1 BTFSC PIR1, RCIF GOTO RXDATA; CALL LDIN; BTFSC MSTOP, 3; NOP CALL LFC2 NOP MOVF LR2, 0 SUBWF LR1, 0 BTFSC STATUS, Z GOTO FROREP GOTO REPLF GOTO CLROE; *************************** **************** PÁRA BTFSS MSTOP, 4 GOTO STOPA MOVLW 0XCF MOVWF SPEED11 MOVLW 0XB3 MOVWF SPEED12 MOVLW 0XCF MOVWF SPEED21 MOVLW 0XB3 MOVWF SPEED22 CHAMADA PWM1ON CHAMADA PWM2ON BCF PORTD, 0 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, 0 BCF 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 CHAMADA CONVERTER MOVF ADRESH, 0 SUBLW 0X70 BTFSS STATUS, C BSF MSTOP BCF, 0 BCF STATUS BCF, RP0 STATUS, RP1 CALL CONVERT MOVF ADRESH, 0 SUBLW 0X70 BTFSS STATUS, C BSF MSTOP BCF2, 0 STATUS DE RP1 FAT, RPSTF DEF2, STATUS DE RP1, RP1 FTA, 0 STATUS RPSTF, 0 STATUS DE BCF2, RPF2F STATUS, 0 STATUS DE BCF2F1, RPF2F STATUS, 0 STATUS DE BCF1, RPSTF2F STATUS, 0 STATUS DE RP1 FT, 0X70 BTFSS STATUS, C BSF MSTOP BC2F, RP1 STATUS, RP0 STATUS, RP0 STATUS, 0 SUBLW 0X70 BTFSS STATUS. STATUS, RP0 STATUS BCF, RP1 MOVLW 0X00 MOVWF MSTOP BANKSEL ADCON0 BSF ADCON0, 3 BCF ADCON0, 4 BCF ADCON0, 5 BCF STATUS, RP0 STATUS BCF, RP1 CALL CONVERT MOVF ADRESH, 0 SUBLW 0X40 CFS BANKSEL, 0 SUBLW 0X40 CFS ADCON0 Situação, RP0 BCF STATUS, RP1 RETURNBUTTLEVEL BCF STATUS, RP0 BCF STATUS, RP1 MOVLW 0x00 MOVWF MSTOP BANKSEL ADCON0 BCF ADCON0, 3 ADCON0 BCF, 4 BSF ADCON0, 5 BCF STATUS, RP0 BCF STATUS, RP1 CHAMADA CONVERTER MOVF ADRESH, 0 SUBLW 0x7F BTFSS STATUS, C GOTO BL1 GOTO BL2 BL1 BSF MSTOP, 1 BSF PORTB, 6 BL2 RETURN DARKLIGHT BCF STATUS, RP0 STATUS BCF, RP1 BTFSC LDET, 0 GOTO RETFDL BANKSEL ADCON0 BCF ADCON0, 3 BSF ADCON0, 4 BCF ADCON0, 5 BCF STATUS, RP0 BCF STATUS, RP1 CHAMADA CONVERTER MOVF ADRESH, 0 SUBLW 0XEE BTFSS STATUS, C BSF PORTB, 7 RETFDL MOVF CONVERT 1 BCONWONVERT 0 CONVERT ADRESH MOVF ADRESH 0 SUBLW 0XEE 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 BCF MOVLW 0XFF MOVWF RPF STATUS PR2, SPE STATUS MOVWF PR2, SPE MOVWF PR0 STATUS 0 MOVWF CCP1CON MOVF SPEED12, 0 MOVWF CCPR1L BSF STATUS, RP0 BCF STATUS, RP1 MOVLW 0xF0 MOVWF TRISC BCF STATUS, RP0 BCF STATUS, T2CON RP1 BCF, T2CKPS1 BCF T2CON, T2CKPS0 BSF T2CON, TMR2ON BSF CCP1CON, CCP1CON 2 BSF, 3 RETURNPWM2ON BANKSEL 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 MOVWF TRISC BCF STATUS, RP0 BCF STATUS, RP1 BCF T2CON, T2CKPS1 BCF 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, RP1 BCF STATUS, 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 RP STATUS, RPFC1F BCON 1 BCON, ADSF BCON, ADSF 4 BANCOS, ADSF BCON 1 BCON, ADSF 3 STATUS, BCON 1 ADF0 STATUS, ADSF BCON 1 BCON, ADSF 0 STATUS, BCON 1 ADSF, 4 BANCOS ADF0, ADSF BCONL0 STATUS, ADSF BCON 1 5 BCF STATUS, RP0 BCF STATUS, RP1 CALL CONVERT MOVF ADRESH, W ANDLW 0XF0 MOVWF LR1 BCF STATUS, RP0 STATUS BCF, RP1 RETORNAR LFC2 BANKSEL ADCON0 BCF ADCON0, 3 BSF ADCON0 STATUS, RP0 BCF STATUS, RP1 RETURN LFC2 BANKSEL ADCON0 BCF ADCON0, 3 BSF ADCONT STATUS, 4 BSF ADCONT STATUS, 5 RP1 CALL CONVERT MOVF ADRESH, 0 ANDLW 0XF0 MOVWF LR2 BCF STATUS, RP0 BCF STATUS, RP1 RETORNAR LDIN BANKSEL ADCON0 BCF ADCON0, 3 BSF ADCON0, 4 BCF ADCON0, 5 BCF STATUS, RP0 BCF STATUS 0 0X4C BTFSC STATUS, C GOTO COMP4 BSF MSTOP, 3 COMP4 BCF STATUS, RP0 BCF STATUS, RP1 RETORNAR 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 STATUS, C GOTO XL1 MOVLW 0X20 INCF L1 SUBWF L1, W BTFSS STATUS, C GOTO XL2 MOVLW STATUS, C GOTO XL1 MOVLW 0X20 INCF L1 SUBWF L1, W BTFSS STATUS, C GOTO XL2 MOVLW, WFS CUT LTO INCF2, BT FTO LTO 2 INCF2 INCF. XL3 RETURN NOP NOPEND

Segundo Prêmio no Concurso de Robôs Instructables e RoboGames

Recomendado: