ADSense1

Mostrando postagens com marcador Aplicação com PIC. Mostrar todas as postagens
Mostrando postagens com marcador Aplicação com PIC. Mostrar todas as postagens

quinta-feira, 30 de outubro de 2014

eBook online sobre o PIC16F877 abordando linguagem assembly (inglês)

Este livro é uma coleção de notas de aulas do Prof. Dr. Charles Kim, sobre programação em linguagem assembly com o PIC16F877 e suas aplicações em robôs autônomos, controladores de braços robóticos e outros projetos interessantes.













Capítulos em pdf:

0. Chapter 0: Book Cover, Table of Contents, and Preface

1. Chapter 1Introduction.
3. Chapter 3: Instructions Sets 
4. Chapter 4: Coding Environment 
5. Chapter 5: Serial Communication
11. Chapter 11: Voice Synthesizer Project

12.. Chapter 12: Internal EEPROM Access
13. Chapter 13: CCP Module and PWM
15. Chapter 15: Armatron Control 


quinta-feira, 26 de junho de 2014

Ebook sobre Microcontroladores PIC, com foco no PIC16F887 da MikroElektronika

Livro disponibilizado para acesso gratuito on-line, disponibilizado pela MikroElektronika.








Table of Contents

quarta-feira, 19 de março de 2014

Apostila Aplicações práticas com o SANUSB e programação C com o Compilador MPLabX

Esta apostila aborda aplicações práticas com microcontroladores PICMicro da família PIC18 da Microchip, Utilizando a plataforma de desenvolvimento SANUSB. Nesta apostila é abordado o uso do compilador C MPLabX C18.
Esta apostila foi elaborada pelos  Profs. Sandro César Silveira Jucá, professor da área de telemática do IFCE, e Renata Imaculada Soares Pereira.







Sumário

Apostila Aplicações práticas com o SANUSB e programação C com o Compilador CCS


Esta apostila aborda aplicações práticas com microcontroladores PICMicro da família PIC18 da Microchip, Utilizando a plataforma de desenvolvimento SANUSB. Esta apostila foi elaborada pelos  Profs. Sandro César Silveira Jucá, professor da área de telemática do IFCE, e Renata Imaculada Soares Pereira.





Sumário

sábado, 1 de fevereiro de 2014

PIC Microcontrollers - Programming in C

domingo, 20 de outubro de 2013

Apostila Mini Curso Microcontrolador 18F452 com Proteus

Apostila Mini Curso Microcontrolador 18F452 utilizando o ECAD Proteus.


segunda-feira, 30 de setembro de 2013

Editor, Simulador e comilador de Lógica Ladder para Microcontraladores PIC16 e AVR

LDmicro é um editor, simulador e compilador de lógica ladder para microcontroladores de 8 bits, gerando código nativo para para os microcontroladores Microchip linha PIC16 e Atmel AVR, a partir do diagrama ladder: 

Suportados e Testados:

  • PIC16F877
  • PIC16F876
  • PIC16F628
  • ATmega64
  • ATmega128


  • Suportados mas não-testados
    • PIC16F88
    • PIC16F819
    • ATmega162
    • ATmega32
    • ATmega16
    • ATmega8
    O LDmicro (Copyright 2005-2010 Jonathan Westhues), é livre e distribuído em conformidade GNU General Public License v3


    Após desenhar o circuito em lógica ladder no editor, ter funcionado na simulação, deve-se associar os pinos do microcontrolador para as entradas e saídas e gerar o código para o PIC ou AVR selecionado. A geração do código não é difícil.  Para o AVR, um bom alocador de registradores proverá uma maior velocidade. Se você quer ter uma otimização de código ainda mais apurada, poderá aplicar algumas regras de redução de algoritmos, e talvez redução de estados também. Isso seria muito mais difícil.
    Mesmo ignorando isso, meu código gerador para os AVRs é muito pobre. O "back end" AVR ainda gera código PIC... por exemplo, ele não tira vantagem do fato do AVR ter mais de um registrador. Muitos dos códigos gerados ficam pouco otimizados. O "back end" para PIC é melhor, e não é muito grande. Mas nada disso importa muito se você estiver tentando rodar algumas dezenas de degraus de uma lógica ladder com tempo de ciclo rápido.
    Há suporte para conversor A/D, unidade PWM e UART nos microcontroladores utilizados. Isso significa que você pode escrever lógica ladder que leia uma entrada analógica, e que possa enviar e receber caracteres pela serial (por exemplo, para um PC, se você adicionar um MAX232, ou um display LCD de caracteres). Isso é possível mandando seqüência de caracteres através da serial, assim como o valor de variáveis inteiras, como texto ASCII. E por último, fora adicionado suporte a variáveis em EEPROM; Você pode indicar que  uma variável específica irá ser salva automaticamente em uma área de memória não volátil, que será mantida ao se desconectar a energia. (texto traduzido do site do LDmicro por Daniel Corteletti)


    Exemplos

    terça-feira, 6 de agosto de 2013

    Apostila de Sistemas Embutidos com Microcontroladores PIC (SENAI/RS)

    Deixo aqui, os links do material da disciplina de programação de microcontroladores PIC, abordando assembly e  linguagem C embarcada, com uso do compilador CCS.

    Parte 1 =>  INTRODUÇÃO A PROGRAMAÇÃO DE MICROCONTROLADORES : Uma breve introdução a programação de microcontroladores, conhecendo os principais aspectos da programação em baixo nível.

    Parte 2 => LINGUAGEM C : Uso de uma linguagem de mais alto nível para desenvolvimento de aplicações dedicadas, visando o reaproveitamento de código e a facilidade em utilizar os recursos do microcontrolador.
    Parte 3 =>LINGUAGEM C : Prática e recursos avançados

    Material de apoio
    Programas exemplos em linguagem C

    sexta-feira, 26 de julho de 2013

    Microcontroladores PIC - Abordando a IDE MPLABX e o Compilador XC8


    Vídeos Tutoriais sobre programação em C para microcontroladores PIC, Abordando a IDE MPLABX e o Compilador XC8. Estes vídeos foram produzidos por Ezequiel Donhauser

    Clique nos links para assistir:
    <Uma Geral - parte 1>  <Uma Geral - parte 2>  <Delays> <Arquivos de Código e Simulação AQUI>  <Display 16x2> <Arquivos de Código e Simulação AQUI>


    domingo, 21 de julho de 2013

    Material para trabalhar com o PIC16F877A, LCD 2x16 e Conversor AD

    File Manual do LCD

    File Simulador do LCD
    Este arquivo permite a instalação de um simulador do LCD que auxilia a entender como este dispositivo funciona
    File Arquivo com circuito para simulação do LCD
     
    Page Exemplo de programa em C para uso do LCD
     
    File Apostila sobre Conversores Digitais
     
    Page Programa com ADC e LCD
     
    File Arquivo com circuito para simulação do ADC e LCD

    Créditos à Prof. Rosângela Winter da UTFP (Univer. Tec. Federal do Paraná)
     

    sábado, 20 de julho de 2013

    Driver do Display Gráfico Everbouquet MG1903A (192x32 com ST7920) para CCS C / PIC

    Driver para o Display Everbouquet MG1903A (192x32 com ST7920)

    #byte PORTA = 0xF80 
    #bit RA0   = PORTA.0 
    #bit RA1   = PORTA.1 
    #bit RA2   = PORTA.2 
    #bit RA3   = PORTA.3 
    #bit RA4   = PORTA.4 
    #bit RA5   = PORTA.5 
    #bit RA6   = PORTA.6 
    #bit RA7   = PORTA.7 

    #byte PORTB = 0xF81 
    #bit RB0   = PORTB.0 
    #bit RB1   = PORTB.1 
    #bit RB2   = PORTB.2 
    #bit RB3   = PORTB.3 
    #bit RB4   = PORTB.4 
    #bit RB5   = PORTB.5 
    #bit RB6   = PORTB.6 
    #bit RB7   = PORTB.7 

    #byte PORTC = 0xF82 
    #bit RC0   = PORTC.0 
    #bit RC1   = PORTC.1 
    #bit RC2   = PORTC.2 
    #bit RC3   = PORTC.3 
    #bit RC4   = PORTC.4 
    #bit RC5   = PORTC.5 
    #bit RC6   = PORTC.6 
    #bit RC7   = PORTC.7 

    #byte PORTE = 0xF84 
    #bit RE3   = PORTE.3 


    ///////////////////////////////////////////////////////////////////////// 
    ////                           mg1903a.h                             //// 
    ////                                                                 //// 
    //// This file contains drivers for using a Everbouquet MG1903A with //// 
    //// a ST7920 display controller. The MG1903A is 192 by 32 pixels.   //// 
    //// The driver treats the upper left pixel as (0,0).                //// 
    ////                                                                 //// 
    ///////////////////////////////////////////////////////////////////////// 
    ////                                                                 //// 
    //// LCD Pin connections:                                            //// 
    ////  * 1: VSS is connected to GND                                   //// 
    ////  * 2: VDD is connected to +5V                                   //// 
    ////  * 3: V0  - LCD operating voltage (Constrast adjustment)        //// 
    ////  * 4: R/S - Data or Instruction is connected to C7              //// 
    ////  * 5: R/W - Read or Write is connected to C6                    //// 
    ////  * 6: Enable is connected to C5                                 //// 
    ////  * 7-14: Data Bus 0 to 7 is connected to port B                  //// 
    ////  * 15: Positive voltage for LED backlight is connected to +5V    //// 
    ////  * 16: Negavtive voltage for LED backlight is connected to GND   //// 
    ////                                                                 //// 
    ///////////////////////////////////////////////////////////////////////// 
    ////                                                                 //// 
    ////  glcd_init ()                                                   //// 
    ////     * Must be called before any other function.                 //// 
    ////                                                                 //// 
    ////  glcd_pixel (x,y,color)                                         //// 
    ////     * Sets the pixel to the given color.                        //// 
    ////       - color can be ON or OFF                                  //// 
    ////                                                                 //// 
    ////  glcd_fillScreen (color)                                        //// 
    ////     * Fills the entire LCD with the given color.                //// 
    ////       - color can be ON or OFF                                  //// 
    ////                                                                 //// 
    ///////////////////////////////////////////////////////////////////////// 

    #define GLCD_RS      RC7   // Display Data / Control Data. 
    #define GLCD_RW      RC6   // Read / Write 
    #define GLCD_E      RC5   // Enable Signal. 

    #define GLCD_WIDTH   192 

    #define RS_FUNCTION   0 
    #define RS_DATA      1 
    #define RW_WRITE   0 
    #define RW_READ      1 
    #define TRIS_READ   0xFF 
    #define TRIS_WRITE   0x00 

    // Valores de color: 
    #define ON   1 
    #define OFF   0 

    typedef union 

      int16 word; 
      BYTE byte[2]; 
    } Dots; 

    typedef struct 

      BOOLEAN refrescar; 
      Dots dots[32][12];   // Diemensiones máximas del display (x,y) = (191,31). 
    } GDRAM;      // El punto (0,0) corresponde a la esquina superior izquierda. 

    GDRAM gdram; 


    /*----------------------------------------------------------------------------------------- 
     * Nombre:   glcd_readByte 
     * 
     * Propósito:   Reads a byte of data from the LCD. 
     * 
     * In/Out:       
     * 
     * Return:   A byte of data read from the LCD. 
     * 
     * Requisitos:    
     * 
     * Descripción:    
     *----------------------------------------------------------------------------------------*/ 

    BYTE glcd_readByte (BYTE address) 

      BYTE data;   // Stores the data read from the LCD 

      set_tris_b (TRIS_READ);   // Set PORTB to input 
      GLCD_RS = address; 
      delay_cycles(1); 
      GLCD_RW = RW_READ;      // Set for reading 
      delay_cycles (1); 
      GLCD_E = 1;      // Pulse the enable pin 
      delay_cycles (1); 
      data = PORTB;      // Get the data from the display's output register 
      GLCD_E = 0; 
      return data; 



    /*------------------------------------------------------------------------------------------ 
     * Nombre:   glcd_writeByte 
     * 
     * Propósito:   Write a byte of data to the LCD. 
     * 
     * In/Out:       
     * 
     * Return: 
     *   - data   (in): the byte of data to write. 
     * 
     * Requisitos:    
     * 
     * Descripción:    
     * 
     *----------------------------------------------------------------------------------------*/ 

    void glcd_writeByte (BYTE address, BYTE data) 

      GLCD_RS = RS_FUNCTION; 
      while ( bit_test (glcd_readByte(RS_FUNCTION), 7) ) ;   // Whait Busy Flag = FALSE! 
      set_tris_b (TRIS_WRITE);   // Set PORTB to output 
      GLCD_RS = address; 
      delay_cycles(1); 
      GLCD_RW = RW_WRITE;      // Set for writing 
      delay_cycles(1); 
      GLCD_E = 0; 
      PORTB = data;         // Put the data on the port 
      delay_cycles (1); 
      GLCD_E = 1;         // Pulse the enable pin 
      delay_cycles(5); 
      GLCD_E = 0; 



    /*------------------------------------------------------------------------------------------ 
     * Nombre:   glcd_fillScreen 
     * 
     * Propósito:   Fill the LCD screen with the passed in color. 
     * 
     * In/Out: 
     *   - color   (in): 
     *          ON  - turn all the pixels on. 
     *         OFF - turn all the pixels off. 
     * 
     * Return:       
     * 
     * Requisitos:    
     * 
     * Descripción:   Sólo trabaja sobre la caché del display. 
     * 
     *----------------------------------------------------------------------------------------*/ 

    void glcd_fillScreen (BYTE color) 

      int8 v, h; 
      int16 d; 

      d = (color == ON ? 0xFFFFL : 0x0000L); 

      for (v=0; v<32; v++) 
      { 
        for (h=0; h<12; h++) 
        { 
          gdram.dots[v][h].word = d; 
        } 
      } 
      gdram.refrescar = TRUE; 



    /*------------------------------------------------------------------------------------------ 
     * Nombre:   glcd_update 
     * 
     * Propósito:   Update the LCD with data from the display cache. 
     * 
     * In/Out: 
     * 
     * Return:       
     * 
     * Requisitos:    
     * 
     * Descripción:    
     *----------------------------------------------------------------------------------------*/ 

    void glcd_update () 

      int8 v, h; 

      if (gdram.refrescar) 
      { 
        for (v=0; v<32; v++) 
        { 
          glcd_writeByte (RS_FUNCTION, 0x80 | v);   // Set Vertical Address. 
          glcd_writeByte (RS_FUNCTION, 0x80 | 0);   // Set Horizontal Address. 

          for (h=0; h<12; h++) 
          { 
            glcd_writeByte (RS_DATA, gdram.dots[v][h].byte[1]);   // Write High Byte. 
            glcd_writeByte (RS_DATA, gdram.dots[v][h].byte[0]);   // Write Low Byte. 
          } 
        } 
        gdram.refrescar = FALSE; 
      } 



    /*------------------------------------------------------------------------------------------ 
     * Nombre:   glcd_init 
     * 
     * Propósito:   Inicialza el LCD. 
     * 
     * In/Out: 
     *   - mode   (in): OFF/ON - Turns the LCD off/on. 
     * 
     * Return:       
     * 
     * Requisitos:   Call before using any other LCD function. 
     * 
     * Descripción:    
     *----------------------------------------------------------------------------------------*/ 

    void glcd_init () 

      set_tris_b (TRIS_WRITE);   // PORTB as output. 
      GLCD_RS = RS_FUNCTION; 
      GLCD_RW = RW_WRITE; 
      GLCD_E = 0; 
      delay_ms (40); 

      glcd_writeByte (RS_FUNCTION, 0x30);    // Specify 8 bit interface and basic instruction set. 
      delay_us (100); 
      glcd_writeByte (RS_FUNCTION, 0x30);    // Specify 8 bit interface and basic instruction set. 
      delay_us (37); 
      glcd_writeByte (RS_FUNCTION, 0x0C);    // Specify Display on, Cursor off and Blink off. 
      delay_us (100); 
      glcd_writeByte (RS_FUNCTION, 0x01);    // Display clear. 
      delay_ms (10); 
      glcd_writeByte (RS_FUNCTION, 0x06);    // AC Increase (cursor move right), don't shift the display. 
      delay_us (72); 
      glcd_writeByte (RS_FUNCTION, 0x34);    // Select extended instruction set. 
      delay_us (72); 
      glcd_writeByte (RS_FUNCTION, 0x36);    // Graphic display ON. 

      glcd_fillScreen (OFF); 
      glcd_update (); 



    /*------------------------------------------------------------------------------------------ 
     * Nombre:    
     * 
     * Propósito:   Turn a pixel on a graphic LCD on or off. 
     * 
     * In/Out: 
     *   - x   (in): the x coordinate of the pixel. 
     *   - y   (in): y - the y coordinate of the pixel. 
     *   - color   (in): ON or OFF. 
     * 
     * Return:       
     * 
     * Requisitos:    
     * 
     * Descripción:    
     *----------------------------------------------------------------------------------------*/ 

    void glcd_pixel(int8 x, int8 y, int1 color) 

      int8 v, h, b; 

      v = y; 
      h = x/16; 
      b = 15 - (x%16); 

      // Modify the actual word. 
      if (color == ON) bit_set (gdram.dots[v][h].word, b); 
      else bit_clear (gdram.dots[v][h].word, b); 
      
      gdram.refrescar = TRUE; 
    }


    main example

    #include "mg1903a.h" 
    #include "graphics.h" 

    #include <math.h> 


    #pragma zero_ram 
    void main() 

      int1  warn = FALSE; 
      int16  adc = 0L, adc_old = 0L; 
      char  voltText[] = "Volts", warning[] = "Warning", W[] = "W"; 
      float theta = 0; 

      inicializarMicro ();   // Inicializa los registros de configuración del MCU y perifericos. 
      inicializarSD ();   // Inicializa las estructuras de datos utilizadas por el programa. 
      activarSalidas ();   // Inicializar las salidas. 

      glcd_rect(1, 5, 126, 15, NO, ON);   // Outline the bar 
      glcd_text57(30, 18, voltText, 1, ON);   // Display "Volts" 
      glcd_circle(145, 16, 10, NO, ON);   // Draw the clock circle 

      while (TRUE) 
      { 
        adc = entradaAnalogica.valor;   // Read a value from the ADC 
        displayVoltage (adc);      // Display the reading 
        adc = (adc > 249L) ? 249L : adc;   // Keep the value 249 or less 

        if(adc != adc_old) 
        { 
          glcd_rect (adc/2+1, 6, adc_old/2+1, 14, YES, OFF);   // Clears the old bar 
          glcd_rect (1, 6, adc/2+1, 14, YES, ON);         // Draws a new bar 
          adc_old = adc;                  // Set old value to new 

          if (adc > 200 && !warn)   // Check if over 4 volts. 
          { 
            glcd_rect (68, 20, 110, 28, YES, ON);   // Draw a filled black rectangle 
            glcd_text57 (70, 21, warning, 1, OFF);   // Write "Warning" on the LCD 
            glcd_text57 (165, 10, W, 2, ON);   // Escribir una W con el doble de tamaño. 
            warn = TRUE; 
          } 
          else if (adc <= 200 && warn) 
          { 
            glcd_rect (68, 20, 110, 28, YES, OFF);   // Draw a filled white rectangle 
            glcd_rect (165, 10, 180, 28, YES, OFF);   // Draw a filled white rectangle 
            warn = FALSE; 
          } 
        } 

        // The following 3 lines make the clock hand spin around 
        glcd_line (145, 16, 145+(int)(8*sin(theta)+.5), 16-(int)(8*cos(theta)+.5), OFF); 
        theta = (theta > 5.9) ? 0 : (theta += .3); 
        glcd_line (145, 16, 145+(int)(8*sin(theta)+.5), 16-(int)(8*cos(theta)+.5), ON); 

        glcd_update (); 
    //    delay_ms(100);    // Reduces flicker by allowing pixels to be on much longer than off. 
      } 
    }


    Fonte: http://www.ccsinfo.com/forum/viewtopic.php?t=32819&highlight=st7920

    LinkWithin

    Related Posts Plugin for WordPress, Blogger...