Problems about pic thermometer

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.

Reply to
Novel
Loading thread data ...

When it comes to micros, we're happy to help people who can show they've tried coding it on their own first.

If you have code that you've written, post some, and we'll be glad to help debug it. For free.

If you want us to write it for you, we charge by the hour...

=== First off, Google doesn't show much data on a 4504N ADC. Can you provide a link to a datasheet?

Secondly, we'd need to know a bit about the LCD. Different brands use different input signals and command sets.

Thirdly, do you need the 4504N? The '45K20 has an internal 10-bit ADC on board. If you don't need more than

10-bit accuracy, the code would probably be simpler if you used the internal ADC.

Fourthly, what do you mean you 'connect the temp sensor to pin 9'? Depending on the package (pdip, qfn, tqfp), that could be any of three different analog inputs.

Reply to
Randy Day

You have to use the CVI software

Reply to
NASH

Thank you for answering me. Firstly, the address of datasheet of ADC converter is

formatting link
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 }

Reply to
Novel

That's not an ADC, that's a TTL/CMOS level shifter. Why do you need one of those?

Does your LCD already display 'PIC Thermometer'? Then you're 75% of the way there.

Are the +V and Gnd pins of the LM19 connected to the +V and ground of the '45K20? You'll get screwy results if they're not...

Three points: You have ADC_Init and ADC_Convert, but you do not call them in your main() routine.

Your ADC_Init should set the TRIS bit for RE1; that will make it an input pin rather than a TTL output. You need to ensure that the ADFM bit is set to your preference. You also must clear some bits in the ADCON1 register.

Your ADC_Convert returns the ADRESH value, but ignores the ADRESL value. You'll need both to get a meaningful reading. === Once you have the 10-bit value for your reading (ADRESH:ADRESL), you'll have to convert it to an ASCII string for display on the LCD.

Reply to
Randy Day

Sounds like someonei n need of a simpler solution.

The PICAXE microcontrollers (PIC with a BASIC interpreter) can read the DS18B20 temperature chip and report directly in degrees C.

Home Page:

formatting link

Support Forum:

formatting link
Go there and search for DS18B20

The PICAXE chips start at $3US, the DS18B20 is priced similarly.

The compiler for the PICAXE is a free download.

John

Reply to
news

y

Thank you very much.

Reply to
Novel

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.