Sunteți pe pagina 1din 13

UNIVERSITATEA VASILE ALECSANDRI FACULTATEA DE INGINERIE SPECIALIZAREA : TEHNOLOGIA INFORMAIEI

ndrumtor: Studenti: As. univ. drd. ing. Marius ANGHELUT Olaru George

Francu Claudiu

Luca Vlad Grupa: 231B

Sistem de comanda a unei benzi transportoare cu microcontroler 16F877A

DESCRIERE PROIECT
Sa se realizeze un sistem de comanda a unei benzi transportoare cu microcontroler 16F877A. Pentru realizarea proiectului avem nevoie de urmatoarele elemente constructive: -microcontroler PIC 16F877A -quartz 20 Mhz -butoane -optocuploare -tranzistoare -rezistoare -condensatori -motor pas cu pas

DESCRIERE MICROCONTROLER

16F877A este un micronctroler produs de catre compania americana Microchip. Face parte din familia 16F si are 40 de pini. Caracteristici: - arhitectur RISC - adresare direct, indirect i relativ - instruciunile au un format fix de 14 biti - frecvena de lucru maxima 20MHz - memorie de program de tip Flash cu capacitate maxim de 8K*14 bii - memoria de date de tip RAM de maxim 368*8 bii - memorie de date nevolatil (EEPROM) de maxim 256*8 biti - memorie stiv de 8 poziii - 14 surse de ntrerupere - programabil pe o linie serial (pe 2 pini) - contoare: Timer0 (8 bii), Timer1 (16 bii), Timer2 (8 bii) - PWM cu rezoluie pe 10 bii - convertor analog-numeric multicanal pe 10 bii - interfee paralele - Parallel Slave Port (PSP) pe 8-bii; - interfee seriale: (Master mode) i I2C(Master/Slave) interfa sincron - Synchronous Serial Port (SSP) cu SPI interfa asincron - Universal Synchronous Asynchronous Receiver Transmitter

SCHEMA BLOC

OPTOCUPLORI MICROCONTROLER

DRIVER (AMPLIFICATOR)

MOTOR PAS CU PAS SENZORI

Sursa alimentare, generator ceas


Pentru reazlizarea sursei de alimentare se va folosi circuitul integrat 78L05, care asigura o tensiune de iesire de 5V si 100mA. Pe langa acesta se vor mai folosi 4 condensatori cu rol de filtraj.

Pentru realizarea generatorului de ceas se va folosi un cristal de quartz care funtioneaza la frecventa de 20 Mhz, fiind conectat la

pinii 13-14 ai microcontrolerului si doi condensatori ceramici de 22 pF.

SCHEMA LOGICA
START SETARI REGISTRI

PORNESTE MOTORUL LA STANGA

AJUNGE LA CAPAT? DA ASTEAPTA 5 SECUNDE

NU

PORNESTE MOTORUL LA DREAPTA

AJUNGE LA CAPAT?

NU

DA ASTEAPTA 4 SECUNDE

COD SURSA
list p=16f877A ; list directive to define processor #include <p16f877A.inc> ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF ; '__CONFIG' directive is used to embed configuration data within .asm file. ; The lables following the directive are located in the respective .inc file. ; See respective data sheet for additional information on configuration word.

;***** VARIABLE DEFINITIONS w_temp EQU 0x7D status_temp EQU 0x7E pclath_temp EQU 0x7F CBLOCK 0X20 INTR,SEC,SEC1,T1,T2 ENDC

; variable used for context saving ; variable used for context saving ; variable used for context saving

;********************************************************************** ORG 0x000 ; processor reset vector nop goto ORG movwf movf movwf movf movwf MAIN 0x004 w_temp STATUS,w status_temp PCLATH,w pclath_temp ; nop required for icd ; go to beginning of program ; interrupt vector location ; save off current W register contents ; move status register into W register ; save off contents of STATUS register ; move pclath register into w register ; save off contents of PCLATH register

btfsc INTCON,2

CALL INT ; isr code can go here or be located as a call subroutine elsewhere movf pclath_temp,w ; retrieve copy of PCLATH register movwf PCLATH ; restore pre-isr PCLATH register contents movf status_temp,w ; retrieve copy of STATUS register movwf STATUS ; restore pre-isr STATUS register contents swapf w_temp,f swapf w_temp,w ; restore pre-isr W register contents retfie ; return from interrupt INT INCF INTR,F MOVLW .12 MOVWF TMR0 BCF INTCON,2 RETURN MAIN bsf STATUS,RP0 MOVLW B'11000000' MOVWF TRISB MOVLW B'00000111' MOVWF TRISC MOVLW B'10000111' MOVWF OPTION_REG bcf STATUS,RP0 CALL STANGA TEST_BUTOANE BTFSC PORTC,0 CALL STANGA BTFSC PORTC,1 CALL STOP BTFSC PORTB,2 CALL DREAPTA GOTO TEST_BUTOANE STOP CALL TEST_BUTOANE GOTO STOP ; testeaza starea butoanelor stanga, stop si dreapta ;bank1 ;seteaza bitii 7 si 6 ca intrari si restu ca iesiri ; incrementeaza INTR ; atrubui valoarea 12 lui TMR0 ; sterge bitul 2 al registrului INTCON

; atribuie prescalarul lui TMR0 ; bank0

TIMP CLRF INTR CLRF SEC MOVLW .12 MOVWF TMR0 MOVLW B'10100000' MOVWF INTCON MOVF INTR,W SUBLW .80 BTFSS STATUS,Z GOTO $-3 ; sterge cintinutul lui INTR ; sterge continutul lui SEC ; incarca valoarea 12 in TMR0 ; activeaza intreruperile de la TMR0 ; testeaza daca s-au efectuat 80 de intreruperi ; daca nu, sare trei linii mai sus

INCF SEC,F CLRF INTR MOVF SEC,W SUBWF SEC1,W BTFSS STATUS,Z GOTO $-9 RETURN STANGA MOVLW B'00001000' MOVWF PORTB CALL PAS BTFSC PORTB,0 CALL PAUZA1 MOVLW B'00001100' MOVWF PORTB CALL PAS BTFSC PORTB,0 CALL PAUZA1 MOVLW B'00000100' MOVWF PORTB CALL PAS BTFSC PORTB,0 CALL PAUZA1 MOVLW B'00000110' MOVWF PORTB CALL PAS BTFSC PORTB,0 CALL PAUZA1 MOVLW B'00000010' MOVWF PORTB CALL PAS BTFSC PORTB,0 CALL PAUZA1 MOVLW B'00000011' MOVWF PORTB CALL PAS BTFSC PORTB,0 CALL PAUZA1 MOVLW B'00000001' MOVWF PORTB CALL PAS BTFSC PORTB,0 CALL PAUZA1 GOTO STANGA DREAPTA MOVLW B'00001000' MOVWF PORTB CALL PAS BTFSC PORTB,1 CALL PAUZA2 MOVLW B'00001001' MOVWF PORTB CALL PAS BTFSC PORTB,1

; testeaza daca SEC=SEC1 ; daca nu sare noua linii mai sus

; invarte motorul cu jumatate de pas ; pauza intre pasi ; testeaza daca a ajuns la capat ; daca da asteapta 4 secunde

; invarte motorul cu jumatate de pas ; pauza intre pasi ; testeaza daca a ajuns la capat ; daca da asteapta 4 secunde

CALL PAUZA2 MOVLW B'00000001' MOVWF PORTB CALL PAS BTFSC PORTB,1 CALL PAUZA2 MOVLW B'00000011' MOVWF PORTB CALL PAS BTFSC PORTB,1 CALL PAUZA2 MOVLW B'00000010' MOVWF PORTB CALL PAS BTFSC PORTB,1 CALL PAUZA2 MOVLW B'00000110' MOVWF PORTB CALL PAS BTFSC PORTB,1 CALL PAUZA2 MOVLW B'00000100' MOVWF PORTB CALL PAS BTFSC PORTB,1 CALL PAUZA2 GOTO DREAPTA PAUZA1 MOVLW .5 MOVWF SEC1 CALL TIMP GOTO DREAPTA PAUZA2 MOVLW .4 MOVWF SEC1 CALL TIMP GOTO STANGA PAS LOOP CALL TEST_BUTOANE DECFSZ T1,F GOTO LOOP DECFSZ T2,F GOTO LOOP RETURN END ; directive 'end of program'

; asteapta 5 secunde

; asteapta 4 secunde

SCHEMA ELECTRICA

CUPRINS
1. 2. 3. 4. DESCRIERE PROIECT DSCRIERE MICROCONTROLER SCHEMA BLOC SURSA ALIMENTARE, GENERATOR DE CEAS 5. SCHEMA LOGICA 6. COD SURSA 7. SCHEMA ELECTRICA