
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 500
mV (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
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); | |
} | |
} |
amazing tutorials i must say...keep em rolling...may god bless you
ResponderExcluirI likable the posts and offbeat format you've got here! I’d wish many thanks for sharing your expertise and also the time it took to post!!
ResponderExcluirangularjs-Training in annanagar
angularjs Training in chennai
angularjs Training in chennai
angularjs Training in online
angularjs Training in bangalore
If you're looking to lose weight then you certainly need to try this brand new custom keto plan.
ResponderExcluirTo 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.
This is very informing and helpful. Thanks
ResponderExcluirweb designing course in chennai | online internships for civil engineering students | online internship for mechanical engineering | online internship for mba students | online internship for computer science students | online internship for biotech students | internships for ece students | internship for electrical engineering student | internship for ece students
ığdır
ResponderExcluirmaraş
afyon
bandırma
hakkari
1AF4