Attachment 'capitulo1f.sgml'

Download

        <sect1 id="adc" xreflabel="adc">
                <title>M&oacute;dulo ADC</title>
                <para>Autor: Santiago Gonzalez</para>
                <para>Correo: santigoro en gmail.com</para>
                <para>
                        Entender la conversi&oacute;n Anal&oacute;gico-Digital: 
                        <ulink url="http://es.wikipedia.org/wiki/Conversion_analogica-digital">aqui</ulink>
                </para>
                <para>Aqu&iacute; se muestran las funciones para trabajar con el modulo ADC 10 bits Interno de los PIC16F87X.
                </para>
                <sect2 id="adcinit" xreflabel="adc_init">
                <title>adc_init</title>
                <para>
                Inicia el m&oacute;dulo ADC con la confiraci&oacute;n establecida 
                en los parametros de entrada: frecuencia de oscilador y configuraci&oacute;n de entradas.
                El m&oacute;dulo ADC quedar&aacute; configurado y listo para usar, pero ser&aacute; activado hasta 
                que se habra un canal para evitar consumo innecesario de corriente.</para>
                <screen>
        void adc_init(unsigned char set_fosc, unsigned char set_channel);
                </screen>
                <para>set_fosc Establece la frecuencia de adc.</para>
                <para>Las posibles opcines son: </para>
                <screen>
        FRECUENCIA DE OSCILADOR ADC:

        FOSC_DIV_2      // Frecuencia de oscilador del PIC / 2
        FOSC_DIV_4      
        FOSC_DIV_8      
        FOSC_DIV_16     
        FOSC_DIV_32     
        FOSC_DIV_64     
        FOSC_RC // Oscilador interno del m&oacute;dulo ADC
                </screen>
                <para>
                set_channel Define que pines se usar&aacute;n como entradas anal&oacute;gicas
                o como Vref externa.
                Cuando solo se define un pin como voltaje de referencia, este ser&aacute; Vref+, 
                referencia positiva y estar&aacute; en RA3, cuando se definen dos entradas como Vref
                la positiva ser&aacute; RA3 y la negativa RA2.</para>
                <para>Las posibles opcines son: </para>
                <screen>
        CONFIGURACION DE ENTRADAS Y Vref(PCFG en ADCON1) 
        
        A8_R0           // 8 entradas Anal&oacute;gicas y 0 como Vref (Vref+ = Vdd , Vref- = Ground)
        A7_R1           // 7 entradas anal&oacute;gicas y Vref+ en AN3
        A5_R0            
        A4_R1   
        A3_R0   
        A2_R1   
        A0_R0   
        A6_R2           // 6 entradas Anal&oacute;gicas, Vref+ en AN3 y Vref- en AN2
        A6_R0
        A5_R1   
        A4_R2   
        A3_R2   
        A2_R2
        A1_R0   
        A1_R2   
                </screen>
                <para>
                Consultar el Datasheet del pic utilizado para ver canales diponibles,
                no se deben inicializar canales no implementados en el modelo de pic a usar,
                por ejemplo, el pic16f876a solo tiene 5 canales ADC, nunca usar A6_R0 en este pic.
                </para>
                </sect2>


                <sect2 id="adcsetchannel" xreflabel="adc_set_channel">
                <title>adc_set_channel</title>
                <para>Establece configuraci&oacute;n de pines de entrada ADC y Vref</para>
                <screen>
        void adc_set_channel(unsigned char set_channel);
                </screen>
                <para>
                set_channel Define que pines se usar&aacute;n como entradas anal&oacute;gicas
                o como Vref externa.
                Cuando solo se define un pin como voltaje de referencia, este ser&aacute; Vref+, 
                referencia positiva y estar&aacute; en RA3, cuando se definen dos entradas como Vref
                la positiva ser&aacute; RA3 y la negativa RA2.</para>
                <para>Las posibles opcines son las mismas que en adc_init: A2_R1 , etc. </para>
                </sect2>


                <sect2 id="adcopen" xreflabel="adc_open">
                <title>adc_open</title>
                <para>Abre canal seleccionado y activa m&oacute;dulo ADC</para>
                <screen>
        void adc_open(unsigned char channel);
                </screen>
                <para>channel Establece el canal ADC a leer</para>
                <para>Las posibles opciones son: </para>
                <para>
                <screen>
        CHANNEL_0  
        CHANNEL_1  
        CHANNEL_2  
        CHANNEL_3  
        CHANNEL_4  
        CHANNEL_5  
        CHANNEL_6  
        CHANNEL_7 
                </screen>
                </para>
                </sect2>


                <sect2 id="adcread" xreflabel="adc_read">
                <title>adc_read</title>
                <para>Lee un canal previamente abierto</para>
                <screen>
        unsigned int adc_read(void);
                </screen>
                </sect2>


                <sect2 id="adcclose" xreflabel="adc_close">
                <title>adc_close</title>
                <para>Cierra m&oacute;dulo ADC.</para>
                <screen>
        void adc_close(void);
                </screen>
                <para>
                La configuraci&oacute;n queda tal como se inicializ&oacute; la &uacute;ltima vez,
                se puede volver a activar el m&oacute;dulo ADC mediante adc_open(channel), 
                sin ejecutar adc_init()
                </para>
                </sect2>


                <sect2 id="ejemploadc" xreflabel="Ejemplo ADC">
                <title>Ejemplo de M&oacute;dulo ADC</title>
                <para> para compilar necesitas los siguientes comandos </para>
                <para>
                <screen>
Ejemplo de compilacion : ./compila.sh ej_adc_87Xa.c 16f877a
                </screen>
                </para>
                <para> ej_adc_87Xa.c </para>
                <screen>
/*
Ejemplo de utilizaci&oacute;n de las funciones del m&oacute;dulo ADC.
v&aacute;lido para la familia 16f87Xa,
Se utiliza el canal 0, 
conectar los voltajes a convertir a RA0,
conectar un led u otra salida a RB7.
RB7 se pondr&aacute; en estado alto (Vdd) cuando la tensi&oacute;n en RA0 sea mayor que 1/2 Vdd.
*/
#include &lt;pic/p16f877a.h>
#include &lt;adc.h>

int main(void) 
{       
        TRISAbits.TRISA0 = 1;                   // A0 como entrada
        TRISBbits.TRISB7 = 0;                   // B7 como salida

        adc_init( FOSC_DIV_32, A1_R0);          // Inicializa m&oacute;dulo ADC
        adc_open(CHANNEL_0);                    // Abre canal 0 ADC

        while (1)
        {       
                if (adc_read() > 512 )
                        PORTBbits.RB7 = 1;      // Enciende led
                else
                        PORTBbits.RB7 = 0;      // Apaga led
        }       
}
        </sect1>

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-03-02 21:07:01, 0.5 KB) [[attachment:GenerarDoc.sh]]
  • [get | view] (2009-03-02 21:49:40, 642.0 KB) [[attachment:GtkPicGccAbout.eps]]
  • [get | view] (2009-03-02 21:50:10, 28.2 KB) [[attachment:GtkPicGccAbout.png]]
  • [get | view] (2009-03-02 21:47:10, 4.9 KB) [[attachment:adc.eps]]
  • [get | view] (2009-03-02 21:47:24, 0.9 KB) [[attachment:adc.png]]
  • [get | view] (2009-03-02 21:00:02, 0.1 KB) [[attachment:capitulo1.sgml]]
  • [get | view] (2009-03-02 21:00:35, 1.7 KB) [[attachment:capitulo1a.sgml]]
  • [get | view] (2009-03-02 21:00:50, 1.7 KB) [[attachment:capitulo1b.sgml]]
  • [get | view] (2009-03-02 21:01:15, 2.8 KB) [[attachment:capitulo1c.sgml]]
  • [get | view] (2009-03-02 21:01:25, 7.0 KB) [[attachment:capitulo1d.sgml]]
  • [get | view] (2009-03-02 21:01:33, 5.0 KB) [[attachment:capitulo1e.sgml]]
  • [get | view] (2009-03-02 21:01:41, 4.9 KB) [[attachment:capitulo1f.sgml]]
  • [get | view] (2009-03-02 21:02:02, 5.7 KB) [[attachment:capitulo1g.sgml]]
  • [get | view] (2009-03-02 21:02:26, 12.8 KB) [[attachment:capitulo1h.sgml]]
  • [get | view] (2009-03-02 21:02:37, 4.4 KB) [[attachment:capitulo1i.sgml]]
  • [get | view] (2009-03-02 21:02:46, 6.3 KB) [[attachment:capitulo1j.sgml]]
  • [get | view] (2009-03-02 21:02:54, 4.3 KB) [[attachment:capitulo1k.sgml]]
  • [get | view] (2009-03-02 21:03:01, 1.6 KB) [[attachment:capitulo1l.sgml]]
  • [get | view] (2009-03-02 21:03:14, 0.2 KB) [[attachment:capitulo2.sgml]]
  • [get | view] (2009-03-02 21:03:32, 2.6 KB) [[attachment:capitulo2a.sgml]]
  • [get | view] (2009-03-02 21:03:44, 2.8 KB) [[attachment:capitulo2b.sgml]]
  • [get | view] (2009-03-02 21:04:00, 22.0 KB) [[attachment:capitulo2c.sgml]]
  • [get | view] (2009-03-02 21:04:22, 0.3 KB) [[attachment:capitulo3.sgml]]
  • [get | view] (2009-03-02 21:04:59, 0.9 KB) [[attachment:capitulo3a.sgml]]
  • [get | view] (2009-03-02 21:05:11, 0.2 KB) [[attachment:capitulo4.sgml]]
  • [get | view] (2009-03-02 21:05:21, 1.4 KB) [[attachment:capitulo4a.sgml]]
  • [get | view] (2009-03-02 21:05:33, 2.7 KB) [[attachment:capitulo4b.sgml]]
  • [get | view] (2009-03-02 21:05:51, 5.6 KB) [[attachment:capitulo4c.sgml]]
  • [get | view] (2009-03-02 21:06:00, 0.2 KB) [[attachment:capitulo5.sgml]]
  • [get | view] (2009-03-02 21:06:20, 9.1 KB) [[attachment:capitulo5a.sgml]]
  • [get | view] (2009-03-02 21:49:04, 5.6 KB) [[attachment:compare.eps]]
  • [get | view] (2009-03-02 21:46:31, 1.1 KB) [[attachment:compare.png]]
  • [get | view] (2009-03-02 21:49:17, 7.6 KB) [[attachment:eeprom.eps]]
  • [get | view] (2009-03-02 21:48:01, 1.2 KB) [[attachment:eeprom.png]]
  • [get | view] (2009-03-02 21:06:33, 0.8 KB) [[attachment:ejemplos.sgml]]
  • [get | view] (2009-03-02 21:06:48, 1.7 KB) [[attachment:faq.sgml]]
  • [get | view] (2009-03-02 21:48:51, 6.3 KB) [[attachment:flash.eps]]
  • [get | view] (2009-03-02 21:50:20, 1.0 KB) [[attachment:flash.png]]
  • [get | view] (2009-03-02 21:50:40, 5.0 KB) [[attachment:i2c.eps]]
  • [get | view] (2009-03-02 21:50:50, 0.9 KB) [[attachment:i2c.png]]
  • [get | view] (2009-03-02 21:50:59, 8.8 KB) [[attachment:interrupt.eps]]
  • [get | view] (2009-03-02 21:51:09, 1.2 KB) [[attachment:interrupt.png]]
  • [get | view] (2009-03-02 21:07:16, 0.6 KB) [[attachment:introduccion.sgml]]
  • [get | view] (2009-03-02 21:07:33, 1.8 KB) [[attachment:introducciona.sgml]]
  • [get | view] (2009-03-02 21:07:43, 1.1 KB) [[attachment:introduccionb.sgml]]
  • [get | view] (2009-03-02 21:08:06, 1.6 KB) [[attachment:introduccionc.sgml]]
  • [get | view] (2009-03-02 21:08:17, 27.5 KB) [[attachment:introducciond.sgml]]
  • [get | view] (2009-03-02 21:08:29, 1.0 KB) [[attachment:introduccione.sgml]]
  • [get | view] (2009-03-02 21:08:42, 64.9 KB) [[attachment:introduccionf.sgml]]
  • [get | view] (2009-03-02 21:51:21, 6.1 KB) [[attachment:pinio.eps]]
  • [get | view] (2009-03-02 21:51:39, 1.0 KB) [[attachment:pinio.png]]
  • [get | view] (2009-03-02 21:51:54, 4.8 KB) [[attachment:pwm.eps]]
  • [get | view] (2009-03-02 21:52:03, 0.9 KB) [[attachment:pwm.png]]
  • [get | view] (2009-03-02 21:09:06, 1.1 KB) [[attachment:referencias.sgml]]
  • [get | view] (2009-03-02 22:26:32, 4.8 KB) [[attachment:spi.eps]]
  • [get | view] (2009-03-02 22:26:54, 0.8 KB) [[attachment:spi.png]]
  • [get | view] (2009-03-02 22:27:21, 7.6 KB) [[attachment:system.eps]]
  • [get | view] (2009-03-02 22:27:31, 1.2 KB) [[attachment:system.png]]
  • [get | view] (2009-03-02 22:27:42, 7.3 KB) [[attachment:timer0.eps]]
  • [get | view] (2009-03-02 22:28:00, 1.1 KB) [[attachment:timer0.png]]
  • [get | view] (2009-03-02 22:28:32, 7.1 KB) [[attachment:timer1.eps]]
  • [get | view] (2009-03-02 22:28:12, 1.0 KB) [[attachment:timer1.png]]
  • [get | view] (2009-03-02 22:28:45, 7.4 KB) [[attachment:timer2.eps]]
  • [get | view] (2009-03-02 22:28:55, 1.1 KB) [[attachment:timer2.png]]
  • [get | view] (2009-03-02 22:26:07, 587.2 KB) [[attachment:tutorial.pdf]]
  • [get | view] (2009-03-02 22:25:35, 2215.3 KB) [[attachment:tutorial.ps]]
  • [get | view] (2009-03-02 21:09:56, 4.4 KB) [[attachment:tutorial.sgml]]
  • [get | view] (2009-03-02 22:29:05, 5.3 KB) [[attachment:uart.eps]]
  • [get | view] (2009-03-02 22:29:16, 0.9 KB) [[attachment:uart.png]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.

Heberge par Ikoula