informe 6 microcontroladores

18
UNIVERSIDAD POLITÉCNICA SALESIANA FACULTAD DE INGENIERIAS INGENIERIA DE ELECTRÓNICA LABORATORIO DE sistemas Microprocesados PRACTICA pic No. 6 CONVERSIÓN ANÁLOGA DIGITAL Y DIGITAL ANÁLOGA SEXTO ELECTRÓNICA Integrantes: LENIN VELASQUEZ DIEGO DUQUE JONATHAN ECHEVERRÍA

Upload: leninlmv

Post on 06-Apr-2015

522 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: INFORME 6 MICROCONTROLADORES

UNIVERSIDAD POLITÉCNICA SALESIANA

FACULTAD DE INGENIERIAS

INGENIERIA DE ELECTRÓNICA

LABORATORIO DE sistemas

Microprocesados

PRACTICA pic No. 6

CONVERSIÓN ANÁLOGA DIGITAL Y

DIGITAL ANÁLOGA

SEXTO ELECTRÓNICA

Integrantes:

LENIN VELASQUEZ

DIEGO DUQUE

JONATHAN ECHEVERRÍA

Page 2: INFORME 6 MICROCONTROLADORES

OBJETIVOS:

Utilizar los conversores A/D y D/A del microcontrolador PIC.

MATERIALES:

1 Resistencia 10 k

1 Resistencia 330

3 Resistencia 5k

1 LCD

2 Capacitores de 33pF

2 Pulsador normalmente abierto

1 Cristal 4 MHz

LM35

LM741

1 Pic 16f877A

1 Dac 0808

1Potenciometro de 10kΩ

1Potenciometro de 5kΩ

4 Resistencia 1k

1 MCP 3204

2 2N3904

MARCO TEÓRICO:

Las características del Pic 16f887A podemos encontrar como ya sabemos en

los datasheet para poder saber las diferentes conexiones de este

Microcontrolador.

El LM35 es un sensor analógico que devuelve la temperatura en forma de tensión, esta tensión devuelta es proporcional a la temperatura. Su rango comprende desde -55 hasta 150 y el valor devuelto es equivalente a la temperatura dividida para 10, entonces en su salida se obtienen valores como estos.

A continuación mostraremos los circuitos realizados a los circuitos ya

funcionando.

Page 3: INFORME 6 MICROCONTROLADORES

PROGRAMA 1:

Conversión A/D con el microcontrolador PIC 16f877.

Se adquiere la señal de un potenciómetro entre 0 y 5 voltios, y se observa

en el LCD un valor entre 0 y 1024

Código program PRACTICA6 DIM VOLTAJE AS WORD DIM VALOR AS STRING[10] sub procedure init ADCON1=$80 trisa=$ff lcd_config(portb,7,6,5,4,portb,0,1,2) lcd_cmd(lcd_cursor_off) end sub main: init While TRUE VOLTAJE=Adc_read(0) wordtostr(voltaje,valor) lcd_cmd(lcd_clear) lcd_out(1,1,valor) delay_ms(300) wend end. 'Fin de programa

SIMULACIÓN:

Page 4: INFORME 6 MICROCONTROLADORES
Page 5: INFORME 6 MICROCONTROLADORES

FLUJO GRAMA:

Inicio

Configurar

puerto A como

entrada

Sub procedure adcon1=$80

Configuracion del LCD lcd_config(portb,7,6,5,4,portb,0,1,2) lcd_cmd(lcd_cursor_off)

Condición del while

Dim voltaje as Word

Dim valor as string

Fin

Lazo

while

Retardo de 0.3

segundos

Page 6: INFORME 6 MICROCONTROLADORES

PROGRAMA 2:

Conversión A/D con el microcontrolador PIC 16f877.

Se adquiere un valor entre 0 y 5 voltios y se observa, en el LCD el valor

entre 0 y 5 voltios.

Código program PRACTICA62 dim voltaje as float dim valor as string[10] sub procedure init option_reg=$80 adcon1=$80 trisa=$ff lcd_config(portb,7,6,5,4,portb,0,1,2) lcd_cmd(lcd_cursor_off) end sub main: init while true voltaje=adc_read(0) voltaje=(voltaje*5)/1024 floattostr(voltaje,valor) lcd_cmd(lcd_clear) lcd_out(1,1,valor) delay_ms(300) wend end. 'Fin de programa

SIMULACIÓN:

Page 7: INFORME 6 MICROCONTROLADORES
Page 8: INFORME 6 MICROCONTROLADORES

FLUJO GRAMA:

Inicio

Configurar

puerto A como

entrada

Option_reg=$80 Sub procedure adcon1=$80

Configuracion del LCD lcd_config(portb,7,6,5,4,portb,0,1,2) lcd_cmd(lcd_cursor_off)

Condición del while

Dim voltaje as float

Dim valor as string

Fin

Lazo

while

Retardo de 0.3

segundos

Page 9: INFORME 6 MICROCONTROLADORES

PROGRAMA 3:

Elabore un programa que utilice el timer en modo de contador externo, y

se visualice el incremento en un display de 7 segmentos.

Código program PRACTICA63 'lm35 dim temp_res as word resultado as word outtxt as byte[5] main: adcon1=%10001110 'Configuración Vref y AN0 trisa=%00000001 'Porta.0 como salida trisb=0 'Portb como salida lcd_config(portb,7,6,5,4,portb,0,1,2) 'Configuración LCD en el puerto B lcd_cmd(lcd_cursor_off) 'Eliminamos el cursor lcd_cmd(lcd_clear) 'Limpiamos el LCD lcd_out(1,1,"Temp:") 'Mostramos ”Temp:” en el LCD while true temp_res=adc_read(0) 'Lectura de la entrada analógica resultado=temp_res*48 'Conversión ADC/Temperatura wordtostr(resultado,outtxt) 'Convertimos la variable resultado a texto lcd_chr(1,6,outtxt[0]) 'Presentamos cada carácter en el LCD lcd_chr(1,7,outtxt[1]) lcd_chr(1,8,outtxt[2]) lcd_chr(1,9,".") lcd_chr(1,10,outtxt[3]) lcd_chr(1,11,outtxt[4]) delay_ms(1000) 'Retraso de un segundo wend end. 'Fin de programa

SIMULACIÓN:

Page 10: INFORME 6 MICROCONTROLADORES
Page 11: INFORME 6 MICROCONTROLADORES

FLUJO GRAMA:

Inicio

Configurar puerto A

como entrada t el

puerto B como

salida

adcon1=%10001110

Configuracion del LCD lcd_config(portb,7,6,5,4,portb,0,1,2) lcd_cmd(lcd_cursor_off)

Condición del while

Dim temp_res as Word Dim resultado as word Dim OutTxt as word

Fin

Lazo

while

Retardo de 1

segundos

Page 12: INFORME 6 MICROCONTROLADORES

PROGRAMA 4:

Conversión digital análoga.

program PRACTICA64

sub procedure init

trisd=0

end sub

dim i as byte

dim a as byte

a=0

i=0

main:

while true

init

for i=1 to 255

a=a+1

portd=a

next i

delay_ms(100)

wend

end. 'Fin de programa

SIMULACIÓN:

Page 13: INFORME 6 MICROCONTROLADORES
Page 14: INFORME 6 MICROCONTROLADORES

FLUJO GRAMA:

Configurar

puerto D como

salida

Sub procedure init

a=0 i=0

Condición del while

Dim i as byte Dim a as byte

Fin

Lazo

while

Retardo de 0.1

segundos

Inicio

Page 15: INFORME 6 MICROCONTROLADORES

PROGRAMA 5:

Convertidor análogo digital de 12 bits.

program Practica65

dim i,j as byte

dim k as word

dim l as float

dim txt1, txt2 as string[6]

sub procedure ret1 delay_ms(1000) end sub

sub procedure tx

k=i<<8

k=k+j

k=k and %1111111111111000

wordtostr(k,txt1)

l=k

floattostr(l,txt1)

end sub

main:

trisb=0

spi_init

lcd_config(portb,3,2,1,0,portb,5,6,4)

lcd_cmd(lcd_cursor_off)

lcd_out(1,1," Conversor ")

lcd_out(2,1," ")

trisc=trisc and $FB

portc.2=1

while true

portc.2=0

spi_write(%1011)

i=spi_read(i)

j=spi_read(j)

portc.2=1

tx

ret1

lcd_out(1,7,txt1)

lcd_out(2,11," ")

wend

end. 'Fin de programa

SIMULACIÓN:

Page 16: INFORME 6 MICROCONTROLADORES
Page 17: INFORME 6 MICROCONTROLADORES

FLUJO GRAMA:

Configurar

puerto B como

salida

sub procedure ret1

delay_ms(1000) end sub

k=i<<8

k=k+j

k=k and %1111111111111000

wordtostr(k,txt1)

l=k

floattostr(l,txt1)

Condición del while

Fin

Lazo

while

Inicio

Dim i, as byte Dim j as byte Dim k as word Dim l as float Dim txt1 as string Dim txt2 as string

sub procedure tx

Standard configuración

Configuracion del LCD lcd_config(portb,7,6,5,4,portb,0,1,2) lcd_cmd(lcd_cursor_off)

Page 18: INFORME 6 MICROCONTROLADORES

CONCLUSIONES:

Aprendimos la utilización de los temporizadores de los

microcontroladores de un Pic 16f887A.

Utilizamos contadores externos para realizar conteos desde un pulsador

controlando el microcontrolador.

La educación es un proceso interminable, puesto que cada día se

aprende cosas nuevas o se actualizan las ya conocidas o aprendidas, es

por eso que la familiarización con otro pic nos amplia nuestro campo

expectativa hacia nuevas metas y propósitos de alcance.

BIBLIOGRAFÍA:

Internet:

Enlace realizado desde Google: “datasheet Pic 16f887A”, fecha de

enlace: 29/Noviembre/2010, enlace web:

http://www.datasheetcatalog.org/datasheet/fairchild/16f887A.pdf

Enlace realizado desde Google: “datasheet LM741”, fecha de enlace:

29/Noviembre/2010, enlace web:

http://www.datasheetcatalog.org/datasheet/fairchild/LM741.pdf

Enlace realizado desde Google: “datasheet LM35 fecha de enlace:

29/Noviembre/2010, enlace web:

http://www.datasheetcatalog.org/datasheet/fairchild/LM35.pdf

Información otorgada por el Ing. Luis Oñate Universidad Politécnica Salesiana. Microcontroladores PIC Programación en Basic, Carlos A. Reyes Segunda

Edición 2006, Pág. 210-216.