Tacômetro ( conta-giros )
Autor: Jeferson Alves Oliveira | Publicado: 2013-08-26T18:45:00-07:00







O Tacômetro é um instrumento que tem como função básica medir o número de voltas que um eixo irá realizar em determinado tempo. O tacômetro pode ser chamado também de conta-rotações, conta-voltas ou conta-giros. Em aplicações industriais ou mesmo no projeto de determinados tipos de equipamentos eletrônicos de medida é necessário saber a velocidade com que gira um eixo, uma engrenagem ou qualquer outra peça.



A unidade RPM (Rotações Por Minuto), é utilizada de modo geral, para máquinas rotativas de qualquer natureza e ainda pra máquinas geradoras ou motoras. Trata-se de uma unidade prática. De fato, a unidade SI equivalente é o radiano por segundo.



O projeto consiste em um microcontrolador PIC16f628A fabricado pela Microchip Technology, que verifica quantos pulsos são gerados pelo sensor. Para isso é utilizado o modulo CPP, configurado para fazer a captura a cada borda de subida durante 1 (um) segundo. Para definir este 1 segundo com precisão, utilizamos o modulo TIMER1, configurado no modo temporizador. Assim temos o numero de pulsos ocorridos em um segundo, que multiplicados por 60 (sessenta), obtemos o numero de eventos ocorridos durante um minuto. De posse deste valor utilizamos um simples Display LCD 16x2, no qual exibimos a cada 1 (um) segundo, o numero de rotações por minuto.



O Display LCD 16x2 torna o projeto muito mais amigável ao usuário, além de aumentar a gama de funções e operações com um custo relativamente baixo.
Por ultimo temos os sensores que neste caso foi desenvolvido de duas maneiras: detecção por reflexão e detecção por interrupção de feixe. Para maiores informações acesse: Sensor Infravermelho
&nbsp;


 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:"Tabela normal";
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-priority:99;
 mso-style-qformat:yes;
 mso-style-parent:"";
 mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
 mso-para-margin-top:0cm;
 mso-para-margin-right:0cm;
 mso-para-margin-bottom:10.0pt;
 mso-para-margin-left:0cm;
 line-height:115%;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:"Times New Roman";
 mso-fareast-theme-font:minor-fareast;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;}
table.MsoTableGrid
 {mso-style-name:"Tabela com grade";
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-priority:59;
 mso-style-unhide:no;
 border:solid windowtext 1.0pt;
 mso-border-alt:solid windowtext .5pt;
 mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
 mso-border-insideh:.5pt solid windowtext;
 mso-border-insidev:.5pt solid windowtext;
 mso-para-margin:0cm;
 mso-para-margin-bottom:.0001pt;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;
 mso-fareast-language:EN-US;}





 

  
Dados
  técnicos

 

  
Designação

  
Tacômetro
  Digital

 

  Mostrador
  Display LCD 16x2&nbsp;
 

  Faixa de velocidades de
  rotação
  Modo óptico: 60 a 60.000
  rpm 
  (ou equivalente mecânico)
 

  Fonte de alimentação
  6 a 30 Volts (possui regulador
  interno)
 

  Sensor
  Reflexão e Interrupção
 




A lista de componentes necessários:


 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:"Tabela normal";
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-priority:99;
 mso-style-qformat:yes;
 mso-style-parent:"";
 mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
 mso-para-margin-top:0cm;
 mso-para-margin-right:0cm;
 mso-para-margin-bottom:10.0pt;
 mso-para-margin-left:0cm;
 line-height:115%;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:"Times New Roman";
 mso-fareast-theme-font:minor-fareast;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;}
table.MsoTableGrid
 {mso-style-name:"Tabela com grade";
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-priority:59;
 mso-style-unhide:no;
 border:solid windowtext 1.0pt;
 mso-border-alt:solid windowtext .5pt;
 mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
 mso-border-insideh:.5pt solid windowtext;
 mso-border-insidev:.5pt solid windowtext;
 mso-para-margin:0cm;
 mso-para-margin-bottom:.0001pt;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;
 mso-fareast-language:EN-US;}





 

  
Componentes somente
  para Tacômetro

 

  
Quantidade

  
Componente

  
Código

 

  
1

  
Capacitor

  
100 uF / 50v

 

  
1

  
Conector

  
Jack J4 (2,1 x 5,5 mm)

 

  
1

  
Placa

  
6 x 10 cm

 

  
1

  
Regulador

  
LM 7805

 

  
1

  
Trimpot

  
10 K ohms

 

  
2

  
Capacitor

  
0.1 uF

 

  
2

  
Led

  
5 mm

 

  
1

  
Diodo

  
1N4004

 

  
1

  
Microcontrolador

  
PIC16f628A

 

  
1

  
Cristal

  
4 MHz

 

  
2

  
Capacitor

  
22 pF

 

  
2

  
Resistor

  
470 ohms

 

  
1

  
Resistor

  
150 ohms

 

  
2

  
Resistor

  
10 K ohms

 

  
2

  
Push-button

  
5
  mm

 

  
1

  
Soquete
  de Barra

  
180
  Graus 2,54mm

 

  
1

  
Barra
  de Pinos

  
11,2mm
  180 graus

 

  
1

  
Conector

  
KK
  3 Vias Macho

 

  
1

  
Display

  
Display
  LCD 16x2

 

  
Componentes somente
  para sensor ( reflexão )

 

  
Quantidade

  
Componente

  
Código

 

  
1

  
Resistor

  
470 ohms

 

  
1

  
Resistor

  
47 K ohms

 

  
1

  
Receptor
  infra-red

  
TIL78
  ( 5mm )

 

  
1

  
Emissor
  infra-red

  
TIL32
  ( 5mm )

 

  
1

  
Capacitor

  
1 nF

 

  
Componentes somente
  para sensor ( interrupção )

 

  
Quantidade

  
Componente

  
Código

 

  
1

  
Resistor

  
470 ohms

 

  
1

  
Resistor

  
47 K ohms

 

  
1

  
Capacitor

  
1 nF

 

  
1

  
Sensor

  
Phct203 ou Itr8102

 




E por fim o esquemático, para isso foi utilizado o&nbsp;

EAGLE Software Design PCB disponivel para download no site:

&nbsp;www.cadsoftusa.com&nbsp;

Ferramenta fácil de usar, e muito poderosa para projetar placas de circuito impresso.


&nbsp;Este é o Schematic do Tacômetro ( conta-giros ) elaborado no&nbsp;

EAGLE
Version 5.10.0 ou superior.&nbsp;

&nbsp;



&nbsp; 

E assim ficou o Tacômetro ( conta-giros )&nbsp;











&nbsp;
Com as seguintes dimensões:&nbsp;
Altura: 28 mm&nbsp;
Largura: 59 mm&nbsp;
Comprimento: 98 mm&nbsp;

















Se desejar, veja o vídeo abaixo com o Tacômetro ( conta-giros ) em funcionamento.








Para
 este projeto é recomendado a utilização do seguinte display: Powertip 
PC 1602-F ou similar desde que possua a mesma sequencia de conexão.


Segue abaixo as configurações da conexão do display









Sensor - 01 (Detecção por Interrupção )






Com as seguintes dimensões:

Altura: 10 mm

Largura: 20 mm

Comprimento: 40 mm&nbsp;


Este é o Schematic do Sensor - 01 (Detecção por Interrupção )  elaborado no&nbsp;



EAGLE
Version 5.10.0 ou superior&nbsp;














Sensor – 02 (Detecção por Reflexão)&nbsp;





Com as seguintes dimensões:

Altura: 10 mm

Largura: 17 mm

Comprimento: 35 mm&nbsp;


Este é o Schematic do Sensor – 02 (Detecção por Reflexão) elaborado no&nbsp;



EAGLE
Version 5.10.0 ou superior

&nbsp;












Se quiser  ter acesso ao arquivo basta clicar em download:
Código-fonte. Compilador: mikroC PRO for PIC ver 5.60 ou superior.



Download


Se quiser ter acesso ao arquivo basta clicar em download:
CONTEÚDO COMPLETO&nbsp;elaborado no EAGLE - Version 5.10.0 ou superior.&nbsp;

Download




Segue abaixo o código-fonte. Compilador utilizado: mikroC PRO for PIC ver 5.60 ou superior. 
pre.cpp1 {
font-family:arial;
font-size:12px;
border:none;
width:auto;
height:auto;
overflow:auto;
background:#f0f0f0;
line-height:21px;
background-image:URL(http://4.bp.blogspot.com/-IF5M58Rd2XE/UkeRjPGCocI/AAAAAAAAAH0/6db2uyxMHhc/s1600/codigo_fonte.png);
padding: 0px 0px 0px 50px;
text-align:left;
}
.cpp1-activecomment { color: #3399FF; }
.cpp1-assembler { color: #FF0000; }
.cpp1-binary { color: #800000; }
.cpp1-character { color: #808000; }
.cpp1-comment { color: #008000; }
.cpp1-float { color: #800000; }
.cpp1-hexadecimal { color: #008000; }
.cpp1-identifier { color: #000000; }
.cpp1-illegalchar { color: #FF0000; }
.cpp1-imagelink { color: #800080; }
.cpp1-number { color: #008000; }
.cpp1-octal { color: #0000FF; }
.cpp1-preprocessor { color: #8000FF;  }
.cpp1-reservedword { color: #000000;  }
.cpp1-space { color: #F0F0F0; }
.cpp1-string { color: #0000FF; }
.cpp1-symbol { color: #000000; }
.cpp1-weblink { color: #3399FF;  }



////////////////////////////////////////////////////////////////////////////////
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Programa&nbsp;Projeto&nbsp;Tacômetro&nbsp;(&nbsp;Conta-giros&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Microcontrolador&nbsp;PIC16f628A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Compilador&nbsp;mikroC&nbsp;PRO&nbsp;for&nbsp;PIC&nbsp;ver&nbsp;5.60&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Autor:&nbsp;Jeferson&nbsp;Alves&nbsp;Oliveira&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Site:&nbsp;http://eletricamentefalando.blogspot.com.br/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//
////////////////////////////////////////////////////////////////////////////////

//&nbsp;Declara&nbsp;as&nbsp;Variáveis&nbsp;Globais&nbsp;************************************************
sbit&nbsp;LCD_RS&nbsp;at&nbsp;RB1_bit;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Determina&nbsp;o&nbsp;bit&nbsp;de&nbsp;instruções&nbsp;ou&nbsp;dado
sbit&nbsp;LCD_EN&nbsp;at&nbsp;RB2_bit;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Determina&nbsp;o&nbsp;bit&nbsp;de&nbsp;"enable"&nbsp;do&nbsp;LCD
sbit&nbsp;LCD_D4&nbsp;at&nbsp;RB7_bit;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Determina&nbsp;pino&nbsp;de&nbsp;dados&nbsp;do&nbsp;LCD
sbit&nbsp;LCD_D5&nbsp;at&nbsp;RB6_bit;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Determina&nbsp;pino&nbsp;de&nbsp;dados&nbsp;do&nbsp;LCD
sbit&nbsp;LCD_D6&nbsp;at&nbsp;RB5_bit;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Determina&nbsp;pino&nbsp;de&nbsp;dados&nbsp;do&nbsp;LCD
sbit&nbsp;LCD_D7&nbsp;at&nbsp;RB4_bit;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Determina&nbsp;pino&nbsp;de&nbsp;dados&nbsp;do&nbsp;LCD

sbit&nbsp;LCD_RS_Direction&nbsp;at&nbsp;TRISB1_bit;&nbsp;//&nbsp;Direção&nbsp;dos&nbsp;pinos&nbsp;do&nbsp;LCD
sbit&nbsp;LCD_EN_Direction&nbsp;at&nbsp;TRISB2_bit;&nbsp;//&nbsp;Direção&nbsp;dos&nbsp;pinos&nbsp;do&nbsp;LCD
sbit&nbsp;LCD_D4_Direction&nbsp;at&nbsp;TRISB7_bit;&nbsp;//&nbsp;Direção&nbsp;dos&nbsp;pinos&nbsp;do&nbsp;LCD
sbit&nbsp;LCD_D5_Direction&nbsp;at&nbsp;TRISB6_bit;&nbsp;//&nbsp;Direção&nbsp;dos&nbsp;pinos&nbsp;do&nbsp;LCD
sbit&nbsp;LCD_D6_Direction&nbsp;at&nbsp;TRISB5_bit;&nbsp;//&nbsp;Direção&nbsp;dos&nbsp;pinos&nbsp;do&nbsp;LCD
sbit&nbsp;LCD_D7_Direction&nbsp;at&nbsp;TRISB4_bit;&nbsp;//&nbsp;Direção&nbsp;dos&nbsp;pinos&nbsp;do&nbsp;LCD

//&nbsp;Declara&nbsp;as&nbsp;variáveis&nbsp;&nbsp;*******************************************************
const&nbsp;char&nbsp;character[]&nbsp;=&nbsp;{4,10,14,17,17,17,14,0};
unsigned&nbsp;char&nbsp;txt[10];
unsigned&nbsp;int&nbsp;pulsos&nbsp;=&nbsp;0;
unsigned&nbsp;int&nbsp;total&nbsp;=&nbsp;0;
int&nbsp;timer&nbsp;=&nbsp;0;

//&nbsp;Protótipos&nbsp;de&nbsp;funções&nbsp;*******************************************************
void&nbsp;CustomChar(char&nbsp;pos_row,&nbsp;char&nbsp;pos_char);
void&nbsp;interrupt();
void&nbsp;RPM();

//&nbsp;Inicio&nbsp;&nbsp;*********************************************************************
void&nbsp;main()
{
//&nbsp;Configura&nbsp;as&nbsp;Portas&nbsp;*********************************************************
&nbsp;&nbsp;&nbsp;TRISA&nbsp;=&nbsp;0b00100000;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;define&nbsp;PORTA&nbsp;como&nbsp;ssesssss
&nbsp;&nbsp;&nbsp;TRISB&nbsp;=&nbsp;0b00001000;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;define&nbsp;PORTB&nbsp;como&nbsp;ssssesss
&nbsp;&nbsp;&nbsp;INTCON.GIE&nbsp;=&nbsp;1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Habilita&nbsp;chave&nbsp;geral&nbsp;das&nbsp;interrupções
&nbsp;&nbsp;&nbsp;INTCON.PEIE&nbsp;=&nbsp;1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Habilita&nbsp;Interrupção&nbsp;dos&nbsp;periféricos
&nbsp;&nbsp;&nbsp;PIE1.TMR1IE&nbsp;=&nbsp;1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Habilita&nbsp;interrpções&nbsp;de&nbsp;TMR1
&nbsp;&nbsp;&nbsp;PIE1.CCP1IE&nbsp;=&nbsp;1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Habilita&nbsp;Interrupção&nbsp;do&nbsp;módulo&nbsp;CCP
&nbsp;&nbsp;&nbsp;T1CON&nbsp;=&nbsp;0b00110001;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Liga&nbsp;TIMER1,&nbsp;prescaler&nbsp;1:8,&nbsp;Clock&nbsp;interno
&nbsp;&nbsp;&nbsp;CCP1CON&nbsp;=&nbsp;0b00000101;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;CCP1&nbsp;em&nbsp;modulo&nbsp;CAPTURA&nbsp;e&nbsp;borda&nbsp;de&nbsp;SUBIDA
&nbsp;&nbsp;&nbsp;//CCP1CON&nbsp;=&nbsp;0b00000100;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;CCP1&nbsp;em&nbsp;modulo&nbsp;CAPTURA&nbsp;e&nbsp;borda&nbsp;de&nbsp;DESCIDA
&nbsp;&nbsp;&nbsp;PIR1.CCP1IF&nbsp;&nbsp;=&nbsp;0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Limpa&nbsp;a&nbsp;flag&nbsp;para&nbsp;nova&nbsp;captura
&nbsp;&nbsp;&nbsp;PIR1.TMR1IF&nbsp;=&nbsp;0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Limpa&nbsp;a&nbsp;flag&nbsp;do&nbsp;TIMER1&nbsp;para&nbsp;uma&nbsp;nova&nbsp;contagem

//&nbsp;Atribuição&nbsp;******************************************************************
&nbsp;&nbsp;&nbsp;TMR1H&nbsp;=&nbsp;0b00001011;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Inicializa&nbsp;os&nbsp;registradores&nbsp;do&nbsp;TMR1
&nbsp;&nbsp;&nbsp;TMR1L&nbsp;=&nbsp;0b11011011;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;(65535&nbsp;-&nbsp;3035)&nbsp;x&nbsp;(1&nbsp;(Fosc&nbsp;/&nbsp;4))&nbsp;x&nbsp;Prescaler
&nbsp;&nbsp;&nbsp;
//&nbsp;Configura&nbsp;LCD&nbsp;***************************************************************
&nbsp;&nbsp;&nbsp;Lcd_Init();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Inicializa&nbsp;o&nbsp;LCD
&nbsp;&nbsp;&nbsp;Lcd_Cmd(_LCD_CLEAR);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Limpa&nbsp;o&nbsp;display
&nbsp;&nbsp;&nbsp;Lcd_Cmd(_LCD_CURSOR_OFF);&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Desliga&nbsp;o&nbsp;Cursor

&nbsp;&nbsp;&nbsp;Lcd_Cmd(_LCD_CLEAR);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Limpa&nbsp;o&nbsp;display
&nbsp;&nbsp;&nbsp;Lcd_Out(1,5,"Jeferson");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Escreve&nbsp;o&nbsp;texto&nbsp;na&nbsp;primeira&nbsp;linha
&nbsp;&nbsp;&nbsp;Lcd_Out(2,5,"Projetos");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Escreve&nbsp;o&nbsp;texto&nbsp;na&nbsp;segunda&nbsp;linha
&nbsp;&nbsp;&nbsp;Delay_ms(2000);

&nbsp;&nbsp;&nbsp;Lcd_Cmd(_LCD_CLEAR);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Limpa&nbsp;o&nbsp;display
&nbsp;&nbsp;&nbsp;Lcd_Out(1,4,"Tacômetro");&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Escreve&nbsp;o&nbsp;texto&nbsp;na&nbsp;primeira&nbsp;linha
&nbsp;&nbsp;&nbsp;CustomChar(1,7);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Escreve&nbsp;o&nbsp;Caractere&nbsp;ô
&nbsp;&nbsp;&nbsp;Lcd_Out(2,3,"Conta-giros");&nbsp;&nbsp;//&nbsp;Escreve&nbsp;o&nbsp;texto&nbsp;na&nbsp;segunda&nbsp;linha
&nbsp;&nbsp;&nbsp;Delay_ms(2000);
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;Lcd_Cmd(_LCD_CLEAR);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Limpa&nbsp;o&nbsp;display
&nbsp;&nbsp;&nbsp;Lcd_Out(1,4,"Tacômetro");&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Escreve&nbsp;o&nbsp;texto&nbsp;na&nbsp;primeira&nbsp;linha
&nbsp;&nbsp;&nbsp;CustomChar(1,7);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Escreve&nbsp;o&nbsp;Caractere&nbsp;ô
&nbsp;&nbsp;&nbsp;Lcd_Out(2,3,"RPM&nbsp;=&nbsp;");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Escreve&nbsp;o&nbsp;texto&nbsp;na&nbsp;segunda&nbsp;linha

//&nbsp;Loop&nbsp;************************************************************************
do&nbsp;{
&nbsp;&nbsp;&nbsp;if&nbsp;(timer&nbsp;==&nbsp;2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timer&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RPM();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(timer&nbsp;&gt;&nbsp;2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timer&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PORTB.F0&nbsp;=&nbsp;1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Em&nbsp;caso&nbsp;de&nbsp;erro&nbsp;de&nbsp;leitura&nbsp;liga&nbsp;o&nbsp;led(pino&nbsp;6)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Delay_ms(20);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PORTB.F0&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;}&nbsp;while(1);
}

//&nbsp;Funções&nbsp;*********************************************************************
void&nbsp;CustomChar(char&nbsp;pos_row,&nbsp;char&nbsp;pos_char){
&nbsp;&nbsp;char&nbsp;i;
&nbsp;&nbsp;&nbsp;&nbsp;Lcd_Cmd(64);
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&lt;=7;&nbsp;i++)&nbsp;Lcd_Chr_CP(character[i]);
&nbsp;&nbsp;&nbsp;&nbsp;Lcd_Cmd(_LCD_RETURN_HOME);
&nbsp;&nbsp;&nbsp;&nbsp;Lcd_Chr(pos_row,&nbsp;pos_char,&nbsp;0);
}

void&nbsp;interrupt()
{
if(PIR1.CCP1IF)
{
&nbsp;&nbsp;PIR1.CCP1IF&nbsp;=&nbsp;0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Limpa&nbsp;a&nbsp;flag&nbsp;para&nbsp;nova&nbsp;captura
&nbsp;&nbsp;pulsos&nbsp;++;
}
else&nbsp;if(PIR1.TMR1IF)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PIE1.TMR1IE&nbsp;=&nbsp;0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Desabilita&nbsp;interrpções&nbsp;de&nbsp;TMR1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PIE1.CCP1IE&nbsp;=&nbsp;0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Desabilita&nbsp;interrupção&nbsp;-&nbsp;periféricos&nbsp;CCP1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TMR1H&nbsp;=&nbsp;0b00001011;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Inicializa&nbsp;os&nbsp;registradores&nbsp;do&nbsp;TMR1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TMR1L&nbsp;=&nbsp;0b11011011;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timer&nbsp;++;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PIR1.TMR1IF&nbsp;=&nbsp;0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Limpa&nbsp;a&nbsp;flag&nbsp;do&nbsp;TIMER1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PIE1.CCP1IE&nbsp;=&nbsp;1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Habilita&nbsp;interrupção&nbsp;-&nbsp;periféricos&nbsp;CCP1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PIE1.TMR1IE&nbsp;=&nbsp;1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Habilita&nbsp;interrpções&nbsp;de&nbsp;TMR1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
}

void&nbsp;RPM()
{
&nbsp;&nbsp;total&nbsp;=&nbsp;pulsos&nbsp;*&nbsp;60;
&nbsp;&nbsp;WordToStr(total,&nbsp;txt);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Converte&nbsp;em&nbsp;texto&nbsp;para&nbsp;impressão
&nbsp;&nbsp;Lcd_Out(2,9,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Limpa&nbsp;a&nbsp;segunda&nbsp;linha
&nbsp;&nbsp;Lcd_Out(2,9,txt);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Imprime&nbsp;valores&nbsp;no&nbsp;display
&nbsp;&nbsp;pulsos&nbsp;=&nbsp;0;
}