Fork me on GitHub

Microcontrolandos

O Blog está passando por uma fase de mudanças. Todos os posts estão sendo atualizados, códigos, links e imagens estão sendo arrumados. Conteúdos novos ainda estão por vir.

PIC: TC1047A

Compartilhe:

TC1047A é um sensor de temperatura.

Características

  • Tensão de operação: 2.5V até 5.5V;
  • Acurácia de ±2°C;
  • Faixa mensurável de temperatura: -40°C até 125°C;
  • Baixo consumo de energia: 35uA.

Funcionamento

O TC1047 converte o valor de temperatura em um valor de tensão linearmente proporcional. Cada 10mV corresponde a 1°C.

Através do canal analógico do microcontrolador, iremos ler o valor digital da temperatura. Numa temperatura de -40°C o TC1047A tem uma tensão de saída de 0,1V. A 0°C o TC1047A tem uma tensão de saída de 0,5V e a 125°C tem uma tensão de saída de 1,75V. Precisamos converter o valor lido do canal analógico em um valor de temperatura. Para isso vamos converter o valor lido em um valor de tensão. No caso de um microcontrolador com um ADC de 10 bits, o valor de tensão (em mV) será: ADC * 5000 / 1024. Ainda temos que subtrair 500mV (pois a 0°C a tensão de saída é 0,5V). Como a resolução da tensão de saída é de 10mV/°C, temos que dividir tudo por 10. Então nossa fórmula fica assim: ADC * 500 / 1024 - 50.

Download

TC1047A.zip

Código

/*
TC1047A - Sensor de temperatura.
Autor: Tiago Melo
Blog: Microcontrolandos
Compilador: MikroC PRO PIC
Bibliotecas: ADC, Lcd, Lcd_Constants, Conversions, C_String
*/
// Pinos do LCD.
sbit LCD_RS at RC0_bit;
sbit LCD_EN at RC1_bit;
sbit LCD_D4 at RC2_bit;
sbit LCD_D5 at RC3_bit;
sbit LCD_D6 at RC4_bit;
sbit LCD_D7 at RC5_bit;
sbit LCD_RS_Direction at TRISC0_bit;
sbit LCD_EN_Direction at TRISC1_bit;
sbit LCD_D4_Direction at TRISC2_bit;
sbit LCD_D5_Direction at TRISC3_bit;
sbit LCD_D6_Direction at TRISC4_bit;
sbit LCD_D7_Direction at TRISC5_bit;
// O PIC16F876A tem um ADC de 10 bits.
#define RESOLUCAO_ADC 10
signed TC1047A_Read(char channel) {
long adc = ADC_Get_Sample(channel);
return ((adc * 500) >> RESOLUCAO_ADC) - 50;
}
void main() {
char texto[5];
// Define somente o pino RA0 como analógico.
ADCON1 = 0x0E;
// Desabilita o comparador analógico.
CMCON = 7;
// Inicializa o módulo ADC.
ADC_Init();
// Inicializa o LCD.
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
while(1) {
// Lê a temperatura. Canal analógico 0.
signed valor = TC1047A_Read(0);
// Converte em texto.
IntToStr(valor, texto);
// Escreve no LCD.
Lcd_Out(2, 1, texto);
Lcd_Chr_CP(223); // O símbolo de °.
Lcd_Chr_CP('C');
// Faz nada durante 1s.
Delay_ms(1000);
}
}
view raw TC1047A.c hosted with ❤ by GitHub

Escreva um comentário

5 comentários:

  1. amazing tutorials i must say...keep em rolling...may god bless you

    ResponderExcluir
  2. If you're looking to lose weight then you certainly need to try this brand new custom keto plan.

    To create this keto diet, certified nutritionists, fitness trainers, and chefs have united to develop keto meal plans that are powerful, decent, price-efficient, and delightful.

    From their grand opening in January 2019, 1000's of people have already completely transformed their body and health with the benefits a great keto plan can provide.

    Speaking of benefits: in this link, you'll discover eight scientifically-proven ones given by the keto plan.

    ResponderExcluir