Anda di halaman 1dari 9

ESCUELA POLITCNICA NACIONAL

DEPARTAMENTO DE CONTROL Y AUTOMATIZACIN

LABORATORIO DE SISTEMAS MICROPROCESADOS PREPARATORIO

TEMA: Barrido de displays. PRCTICA: 7

REALIZADO POR: Nathaly Johanna Daz Enrquez GRUPO: GR2/04 HORARIO: Lunes, 11-13h FECHA DE ENTREGA: 2014-04-14

PRCTICA N7 1. TEMA: Barrido de displays 2. OBJETIVO: Disear un circuito, y el software asociado para manejar 4 display de 7 segmentos usando la tcnica de barrido. 3. PREPARATORIO:

Consulte la distribucin de pines de los display de 7 segmentos a ser utilizados

Fig1. Distribucin de segmentos y polarizacin de displays de 7 segmentos

Disee un circuito de barrido de 4 display con el micro controlador MEGA164p usando solamente dos puertos, pues los otros dos puertos son usados para el ingreso de los datos. El circuito a construir debe obligatoriamente incorporar los elementos que considere necesarios para manejar los display (tomar en cuenta la capacidad de corriente de salida de los pines del micro controlador para no excederla, e incorporar los transistores o amplificadores de corriente para proveer la suficiente corriente a los display), y adems nunca debe olvidar las resistencias limitadoras de corriente para cada uno de los segmentos. Como referencia se incluye un circuito con los elementos adicionales ms comunes. Cabe indicar que dado que los segmentos van a trabajar solamente 1/4 del tiempo, se debe hacer pasar por ellos pulsos de corriente de mayor valor para obtener una corriente media suficiente; esta es la razn por la que no se recomienda manejar directamente los segmentos desde los puertos del ATMega164p. En el caso del diseo de ejemplo se ha colocado un arreglo de transistores darlington NPN (el ULN2003), pero puede ser reemplazado por 7 transistores NPN. Los transistores PNP del diseo sirven para activar cada uno de los dgitos. En el peor de los casos pueden estar encendidos todos los segmentos y la suma de estas corrientes entra por el terminal del nodo comn del display; por lo que de ninguna manera puede ser conectado directamente a una salida del microcontrolador. Conviene recordar que la corriente que puede manejar cada pin del microcontrolador est alrededor de 20mA, y que hay otras limitantes como la que la suma total de corriente que puede manejar un puerto no debera sobrepasar de unos 100 mA, adems de otras limitantes que se pueden ver en el manual en la parte de "Caractersticas Elctricas".

Vcc

R7
1k

R8
1k

R9
1k

R10
1k

Q4 R6 Q3
2N3905 560

R5 Q2
2N3905 560

R4 Q1
2N3905 560

R3
560

2N3905

U3

0 1 0 1 0 0 1 0 1 0 1 0 1 0

40 41 42 43 44 1 2 3 9 10 11 12 13 14 15 16 29 27 4

PB0/XCK0/T0/PCINT8 PB1/T1/CLKO/PCINT9 PB2/AIN0/INT2/PCINT10 PB3/AIN1/OC0A/PCINT11 PB4/SS/OC0B/PCINT12 PB5/MOSI/PCINT13 PB6/MISO/PCINT14 PB7/SCK/PCINT15 PD0/RXD0/PCINT24 PD1/TXD0/PCINT25 PD2/INT0/RXD1/PCINT26 PD3/INT1/TXD1/PCINT27 PD4/OC1B/XCK1/PCINT28 PD5/OC1A/PCINT29 PD6/ICP/OC2B/PCINT30 PD7/OC2A/PCINT31 AREF AVCC RESET ATMEGA164P

PA0/ADC0/PCINT0 PA1/ADC1/PCINT1 PA2/ADC2/PCINT2 PA3/ADC3/PCINT3 PA4/ADC4/PCINT4 PA5/ADC5/PCINT5 PA6/ADC6/PCINT6 PA7/ADC7/PCINT7 PC0/SCL/PCINT16 PC1/SDA/PCINT17 PC2/TCK/PCINT18 PC3/TMS/PCINT19 PC4/TDO/PCINT20 PC5/TDI/PCINT21 PC6/TOSC1/PCINT22 PC7/TOSC2/PCINT23 XTAL1 XTAL2

37 36 35 34 33 32 31 30 19 20 21 22 23 24 25 26 8 7

0 1 0 0 0 0 0 0 0
U1
1 2 3 4 5 6 COM 1B 2B 3B 4B 5B 6B 7B ULN2003A 1C 2C 3C 4C 5C 6C 7C 9 16 15 14 13 12 11 10 1 2 3 4 5 6 7 8 RX8

RN1
16 15 14 13 12 11 10 9

R2
4.7k

C1

10n Vcc

R1
1.5k

Fig2. Diseo a implementar

Escribir una rutina para convertir de binario a BCD. Con 4 dgitos decimales el nmero ms grande a convertir es el 9999, ese dato requiere 14 bits en binario para ser almacenado,esto debe tomarse en consideracin en su rutina. /* * barrido_anodo.asm * * Created: 13/04/2014 5:36:24 * Author: Nathy */ .INCLUDE "M164PDEF.INC" .DEF TEMPO=R16 .DEF NUMERO=R17 .DEF COD=R18 .DEF CENTENA=R19 .DEF DECENA=R20 .DEF UNIDAD=R21 .DEF AUX=R23 .ORG 0X00 LDI R22,HIGH(RAMEND) OUT SPH,R22 LDI R22,LOW(RAMEND) OUT SPL,R22 LDI TEMPO,0B00000000 OUT DDRA,TEMPO LDI TEMPO,0B01111111 OUT DDRB,TEMPO OUT DDRC,TEMPO OUT DDRD,TEMPO

SALTO: IN NUMERO,PINA MOV TEMPO,NUMERO BCD: CLR UNIDAD CLR DECENA CLR CENTENA BCD_CENTENA: SUBI TEMPO,100 BRCS BCD_PRIMERO INC CENTENA RJMP BCD_CENTENA BCD_DECENA: SUBI TEMPO,10 BRCS BCD_SEGUNDO INC DECENA RJMP BCD_DECENA BCD_PRIMERO: LDI AUX,100 ADD TEMPO,AUX RJMP BCD_DECENA BCD_SEGUNDO: LDI AUX,10 ADD TEMPO,AUX MOV UNIDAD,TEMPO MOV COD,UNIDAD RCALL SEGUND OUT PORTD,COD MOV COD,DECENA RCALL SEGUND OUT PORTC,COD MOV COD,CENTENA RCALL SEGUND OUT PORTB,COD RJMP SALTO SEGUND: LDI ZL,LOW(TABLA<<1) LDI ZH,HIGH(TABLA<<1) ADD ZL,COD CLR COD ADC ZH,COD LPM COD,Z RET TABLA: .db 0b01000000,0b01111001 ;0,1 .db 0b00100100,0b00110000 ;2,3 .db 0b00011001,0b00010010 ;4,5 .db 0b00000010,0b01111000 ;6,7 .db 0b00000000,0b00010000 ;8,9 .db 0b00001000,0b00000011 ;10 .db 0b01000110,0b00100001 ;12 .db 0b00000110,0b00001110 ;14

Escribir un programa que permita multiplicar dos nmeros en binario que son ingresados por medio de interruptores a dos puertos; cada uno de los nmeros puede variar de 0 a 99. Aumentar al circuito de barrido de display un interruptor, el que si est en 0L, debe mostrar en base 10 en los dos primeros display el primer nmero a multiplicar, en los dos restantes el otro nmero. Si el interruptor est en 1L debe mostrar el resultado de la multiplicacin en base 10 ocupando los 4 diplay.

/* * multiplicacion.asm * * Created: 13/04/2014 1:35:17 * Author: Nathy */ .include "m164pdef.inc" .def tempo1=r16 .def tempo2=r17 .def tempo3=r18 .def tempo4=r19 .def tempo5=r20 .def dig0=r21 .def dig1=r22 .def aux1=r23 .def aux2=r24 .def aux3=r25 .def aux4=r26 .def aux5=r27 .def aux6=r28 .def aux7=r29 .org 0x00 clr tempo1 out ddra,tempo1 out ddrb,tempo1 ldi tempo1,0b01111111 out ddrc,tempo1 ldi tempo1,0b00001111 out ddrd,tempo1 ser tempo1 out porta,tempo1 out portb,tempo1 ldi tempo1,0b10000000 out portc,tempo1 ldi tempo1,0b11110000 out portd,tempo1 in tempo1,mcucr andi tempo1,0b11101111 out mcucr,tempo1 ldi tempo1,low(ramend) out spl,tempo1 ldi tempo1,high(ramend) out sph,tempo1 lazo: in tempo1,pina sbrs tempo1,7 rjmp operacion1 rjmp operacion2 operacion1: in tempo2,pina andi tempo2,0b01111111 rcall binbcd mov tempo2,dig0 rcall bcd7seg out portc,tempo2 ldi tempo1,0b00000001 out portd,tempo1 rcall retardo clr tempo1 out portd,tempo1 mov tempo2,dig1 rcall bcd7seg

operacion2:

out ldi out rcall clr out in andi rcall mov rcall out ldi out rcall clr out mov rcall out ldi out rcall clr out rjmp in andi in andi mul mov mov rcall mov rcall out ldi out rcall clr out mov rcall out ldi out rcall clr out mov rcall out ldi out rcall clr out mov rcall

portc,tempo2 tempo1,0b00000010 portd,tempo1 retardo tempo1 portd,tempo1 tempo2,pinb tempo2,0b01111111 binbcd tempo2,dig0 bcd7seg portc,tempo2 tempo1,0b00000100 portd,tempo1 retardo tempo1 portd,tempo1 tempo2,dig1 bcd7seg portc,tempo2 tempo1,0b00001000 portd,tempo1 retardo tempo1 portd,tempo1 lazo tempo1,pina tempo1,0b01111111 tempo2,pinb tempo2,0b01111111 tempo1,tempo2 tempo2,r1 tempo1,r0 binbcd_16 tempo2,aux1 bcd7seg portc,tempo2 tempo1,0b00000001 portd,tempo1 retardo tempo1 portd,tempo1 tempo2,aux2 bcd7seg portc,tempo2 tempo1,0b00000010 portd,tempo1 retardo tempo1 portd,tempo1 tempo2,aux3 bcd7seg portc,tempo2 tempo1,0b00000100 portd,tempo1 retardo tempo1 portd,tempo1 tempo2,aux4 bcd7seg

binbcd_16:

out ldi out rcall clr out rjmp rcall mov mov ldi mul mov rcall mov mov ldi mul mov rcall add mov mov rcall mov add ldi mul mov rcall add mov mov rcall mov add mov ldi mul mov rcall mov mov ldi mul mov rcall add mov mov rcall mov add ldi mul mov rcall add mov mov

portc,tempo2 tempo1,0b00001000 portd,tempo1 retardo tempo1 portd,tempo1 lazo binbcd tempo3,dig0 tempo4,dig1 tempo2,6 tempo2,tempo3 tempo2,r0 binbcd aux1,dig0 tempo5,dig1 tempo2,5 tempo2,tempo3 tempo2,r0 binbcd dig0,tempo5 tempo2,dig0 tempo5,dig1 binbcd aux2,dig0 tempo5,dig1 tempo2,2 tempo2,tempo3 tempo2,r0 binbcd dig0,tempo5 tempo2,dig0 tempo5,dig1 binbcd aux3,dig0 tempo5,dig1 aux4,tempo5 tempo2,6 tempo2,tempo4 tempo2,r0 binbcd aux5,dig0 tempo5,dig1 tempo2,5 tempo2,tempo4 tempo2,r0 binbcd dig0,tempo5 tempo2,dig0 tempo5,dig1 binbcd aux6,dig0 tempo5,dig1 tempo2,2 tempo2,tempo4 tempo2,r0 binbcd dig0,tempo5 tempo2,dig0 tempo5,dig1

binbcd:

lazo_10:

unidades:

bcd7seg:

retardo: salto1: salto2:

rcall mov add mov rcall mov mov add add mov rcall mov mov add add mov rcall mov add mov rcall mov mov add add mov rcall mov add ret push push in push ldi subi brcs inc rjmp ldi add mov pop out pop pop ret ldi ldi add clr adc lpm ret ldi ldi dec brne dec brne

binbcd aux7,dig0 aux2,aux5 tempo2,aux2 binbcd aux2,dig0 tempo5,dig1 aux3,aux6 aux3,tempo5 tempo2,aux3 binbcd aux3,dig0 tempo5,dig1 aux4,aux7 aux4,tempo5 tempo2,tempo1 binbcd tempo1,dig1 aux1,dig0 tempo2,aux1 binbcd aux1,dig0 tempo5,dig1 aux2,tempo1 aux2,tempo5 tempo2,aux2 binbcd aux2,dig0 aux3,dig1 tempo2 tempo1 tempo1,sreg tempo1 dig1,0 tempo2,10 unidades dig1 lazo_10 tempo1,10 tempo2,tempo1 dig0,tempo2 tempo1 sreg,tempo1 tempo1 tempo2 zl,low(tabla*2) zh,high(tabla*2) zl,tempo2 tempo2 zh,tempo2 tempo2,z tempo1,1 tempo2,255 tempo2 salto2 tempo1 salto1

tabla:

ret .db 0b11000000,0b11111001 .db 0b10100100,0b10110000 .db 0b10011001,0b10010010 .db 0b10000010,0b11111000 .db 0b10000000,0b10011000

Construya el circuito diseado, el mismo que deber ser llevado al laboratorio el da de la prctica. Realice un modelo de simulacin en proteus del circuito pedido y pruebe el funcionamiento de todos los programas solicitados.

4. BIBLIOGRAFA:

ATMEL, 8-bit AVR Microcontroller with 16k/32k/64k bytes In-System Programmable Flash.. ATMEL, 8-bit AVR Instruction Set, ATmega164p. Ana Rodrguez, Sistemas Microprocesados, Apuntes de clase, 2014, EPN. Jaime Velarde, Sistemas Digitales, Apuntes de clase, 2013, EPN.

Anda mungkin juga menyukai