Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
Hi guys , I managed to display the voltage of my board using C18 compiler. any ideas how i can use these current code to build a thermal sensor out of it ?
Use a sensor chip that outputs a voltage that represents the temperature, so that the output voltage to the PIC changes with temperature. Adjust the voltmeter code to read the sensor. Eg. If you use LM35, the output is 10mV per degree Celsius. So, if you have 74'C, the output is 0.74V. Adjust your code so that when the input is 0.74V, the voltmeter display 74 ('C) instead of displaying 0.74 (V).
TC74 uses the I2C protocol. So you'll need to utilize that. The Voltmeter program you have can not be completely used. You can make use of the display part, but not the ADC sense part.
unsigned char data[20]="ADC OUTPUT=";
unsigned int digital_out[10],avg_output=0,temp;
unsigned int i=0;
void main()
{
TRISCbits.TRISC0=0;
TRISA=0; // Configure RA0 as input pin
PORTA=0;
TRISB=0;
PORTB=0; // Configure Port B as output port
lcdcmd(0x38); // Configure the LCD in 8-bit mode, 2 line and 5x7 font
lcdcmd(0x0E); // Display On and Cursor Off
lcdcmd(0x01); // Clear display screen
lcdcmd(0x06); // Increment cursor
lcdcmd(0x86); // Set cursor position to 1st line, 1st column
lcddata('w');
while(data!='\0')
{
lcdport=*data; // Call lcddata function to send character one by from 'data' array
i++;
}
ADCON1=0xCE; // Make RA0/AN0 pin as analog pin (Other pins remain to be digital I/O)
ADCON0=0x81; // Select Channel0 & ADC off
ADCON2=0x8A; // Left justified, 2TAD acquiciation time, Fosc/32 clock option
ADCON0bits.GO=1; // Enable ADC
while(1)
{
temp=0;
for(i=0;i<10;i++)
{
ADCON0bits.GO=1; // Start A/D conversion
while(ADCON0bits.DONE=1); // Wait until conversion gets over
digital_out=((ADRESL)|(ADRESH<<8)); // Store 10-bit output into a 16-bit variable
DELAY (20);
temp=temp+digital_out;
}
avg_output=temp/10; // Take average of ten digital values for stablity
adc_con(avg_output); // Function to convert the decimal vaule to its corresponding ASCII
}
}
void adc_con(unsigned int adc_out)
{
unsigned int adc_out1;
int i=0;
char position=0xC3;
for(i=0;i<=3;i++)
{
adc_out1=adc_out%10; // To exract the unit position digit
adc_out=adc_out/10;
lcdcmd(position);
lcddata(48+adc_out1); // Convert into its corresponding ASCII
position--;
}
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.