Re: Problems about pic thermometer
- From: Novel <ntacao998@xxxxxxxxx>
- Date: Wed, 4 Mar 2009 04:04:51 -0800 (PST)
On 4 Mar, 05:06, linnix <m...@xxxxxxxxxxxxxxxxxx> wrote:
On Mar 3, 3:35 pm, Novel <ntacao...@xxxxxxxxx> wrote:
Now I am doing a pic thermometer which use the LM19 temperature sensor
to measure the temperature and display on the 2*16 LCD without
backlight.
And I have a pic18f45k20 microcontroller chip and 4504N adc converter.
I have connect the temp sensor to pin 9 of the pic18f45k20.
Now I just want to ask who can give me help with the codes to let this
system works.
Thanks.
If you are using the internal A2D already, what are you using the
external A2D for? Double checking the PIC A2D?
Thank you for answering me.
Firstly, the address of data*** of ADC converter is
http://www.datasheetcatalog.com/datasheets_pdf/M/C/1/4/MC14504BCP.shtml.
Secondly, the part number of LCD is PMC1602C-SYR.
Thirdly, I really need ADC converter. What I need to do is to test
the
connection on the board and finally to finish on the PCB.
Fourthly, I connect the Vout of the temp sesor to the AN6/WR#/RE1 pin
9 of the microchip_18F4XK20.
I never learned c language before, I feel difcult to work it out.
What
I want to know now is how to display the voltage value of the temp
sensor on the LCD. After that, I know how to use the eqn. for
temperature and voltage to show the temperature on the LCD.
The following was the code I have figure out. I could not going on
and
do not know whether they are right or wrong.
[Main.c]
#include "p18f45k20.h"
#include "delays.h"
#include "lcd.h"
#pragma udata // declare statically allocated uinitialized
variables
#pragma code // declare
executable instructions
void main (void)
{
// set internal oscillator to 4MHz
OSCCON = 0x50; // IRCFx =
101
OSCTUNEbits.PLLEN = 0; // x4 PLL
disabled
lcd_init(); //
initialise display
//
write first screen
lcd_goto(0x00); //
goto 1st line position 3
lcd_puts ("PIC
Thermometer"); // write string to
display
lcd_goto(0x44); //
second line position 4
lcd_puts ("Runnin..."); // write
second line
Delay10KTCYx(255); //
delay approx 2.5 Seconds
lcd_clear(); //
clear lcd
lcd_goto(0); // 1st
line position 1
lcd_puts("Temperature is:");
lcd_goto(0x40);
lcd_puts
("lalalala.."); //
I just use lalalala to inst. temperature what I want.
Delay10KTCYx(255); //
delay approx 2.5 Seconds
while(1);
}
void Timer0_Init(void)
{
INTCONbits.TMR0IF = 0; // clear roll-over interrupt flag
T0CON = 0b00000001; // prescale 1:4 - about 1 second
maximum delay.
TMR0H = 0; // clear timer - always write
upper byte first
TMR0L = 0;
T0CONbits.TMR0ON = 1; // start timer
}
void ADC_Init(void)
{
ANSEL = 0; //turn off all other analog inputs
ANSELH = 0;
ANSELbits.ANS6 = 1; // turn on RE1 analog
ADCON0 = 0b00011001;
}
unsigned char ADC_Convert(void)
{ // start an ADC conversion and return the 8 most-significant bits
of
the result
ADCON0bits.GO_DONE = 1; // start conversion
while (ADCON0bits.GO_DONE == 1); // wait for it to complete
return ADRESH; // return high byte of result
.
- Follow-Ups:
- Re: Problems about pic thermometer
- From: linnix
- Re: Problems about pic thermometer
- References:
- Problems about pic thermometer
- From: Novel
- Re: Problems about pic thermometer
- From: linnix
- Problems about pic thermometer
- Prev by Date: about video card driver
- Next by Date: Re: FAT file system problem ... Microsoft is suing TomTom ...
- Previous by thread: Re: Problems about pic thermometer
- Next by thread: Re: Problems about pic thermometer
- Index(es):
Loading