EmbeddedRelated.com
Forums

Problems about pic thermometer

Started by Novel March 3, 2009
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.
On Mar 3, 3:35 pm, Novel <ntacao...@gmail.com> 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?
On 4 Mar, 05:06, linnix <m...@linnix.info-for.us> wrote:
> On Mar 3, 3:35 pm, Novel <ntacao...@gmail.com> 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? =A0Double checking the PIC A2D?
Thank you for answering me. Firstly, the address of datasheet 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 =3D 0x50; // IRCFx =3D 101 OSCTUNEbits.PLLEN =3D 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 =3D 0; // clear roll-over interrupt flag T0CON =3D 0b00000001; // prescale 1:4 - about 1 second maximum delay. TMR0H =3D 0; // clear timer - always write upper byte first TMR0L =3D 0; T0CONbits.TMR0ON =3D 1; // start timer } void ADC_Init(void) { ANSEL =3D 0; //turn off all other analog inputs ANSELH =3D 0; ANSELbits.ANS6 =3D 1; // turn on RE1 analog ADCON0 =3D 0b00011001; } unsigned char ADC_Convert(void) { // start an ADC conversion and return the 8 most-significant bits of the result ADCON0bits.GO_DONE =3D 1; // start conversion while (ADCON0bits.GO_DONE =3D=3D 1); // wait for it to complete return ADRESH; // return high byte of result
On Mar 4, 4:04 am, Novel <ntacao...@gmail.com> wrote:
> On 4 Mar, 05:06, linnix <m...@linnix.info-for.us> wrote: > > > On Mar 3, 3:35 pm, Novel <ntacao...@gmail.com> 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 datasheet of ADC converter ishttp://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.
So, how do you hook up the 14504BCP?