Manejo del módulo de conversión AD

Embed Size (px)

Citation preview

  • 7/30/2019 Manejo del mdulo de conversin AD

    1/2

    1/12/2012 7:49:46 AMEjemplo13.mbas

    1: program Ejemplo132:3: ' *4: ' * Nombre del Ejemplo5: ' Ejemplpo 126: ' * Autor:7: ' Ing. Pablo Rodas -CTS-

    8: ' * Fecha:9: ' 20120109:10: '11: ' * Descripcion12: ' Conversor AD con dos entradas analogicas13: '14: ' * Configuracion15: ' MCU: P16F88716: ' Archivo Simulacion PROTEUS: Entrenador17: ' Oscillador: HS, 4.0000 MHz18: '19: ' * NOTAS20: ' *

    21: ' SECCION DE DECLARACIONES DE SIMBOLOS22: '*****************************************************************************23:24: ' SECCION DE DECLARACIONES DE VARIABLES25: '**************************************************26:27: dim LCD_RS as sbit at RB2_bit

    28: LCD_EN as sbit at RB3_bit29: LCD_D4 as sbit at RB4_bit30: LCD_D5 as sbit at RB5_bit31: LCD_D6 as sbit at RB6_bit

    32: LCD_D7 as sbit at RB7_bit33:34: LCD_RS_Direction as sbit at TRISB2_bit

    35: LCD_EN_Direction as sbit at TRISB3_bit36: LCD_D4_Direction as sbit at TRISB4_bit37: LCD_D5_Direction as sbit at TRISB5_bit38: LCD_D6_Direction as sbit at TRISB6_bit39: LCD_D7_Direction as sbit at TRISB7_bit40: dim dato as word41: txt as string[12]42: Dim valor as word43:

    44: main:45: ' Main program46: ANSEL = 0x06 ' Configure AN2 y AN1 pin as analog47: ANSELH = 0 ' Configure other AN pins as digital I/O

    48: C1ON_bit = 0 ' Disable comparators49: C2ON_bit = 050:51: TRISA = 0xFF ' PORTA is input52: LCD_INIT()53: ADC_Init()54: while (TRUE)55: valor = ADC_Read(2) ' Get 10-bit results of AD conversion56: wordtostr(valor,txt)57: lcd_out(2,1,txt)

    1/2 mikroBasic Pro for PIC by mikroElektronika

  • 7/30/2019 Manejo del mdulo de conversin AD

    2/2

    1/12/2012 7:49:46 AMEjemplo13.mbas

    58: delay_ms(100)59: valor = ADC_Read(1) ' Get 10-bit results of AD conversion60: wordtostr(valor,txt)

    61: lcd_out(1,1,txt)62: delay_ms(100)63:64: wend

    65: end.

    2/2 mikroBasic Pro for PIC by mikroElektronika