1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Problems about pic thermometer

Discussion in 'Embedded' started by Novel, Mar 3, 2009.

  1. Novel

    Novel Guest

    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
    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.
    Novel, Mar 3, 2009
    1. Advertisements

  2. Novel

    linnix Guest

    If you are using the internal A2D already, what are you using the
    external A2D for? Double checking the PIC A2D?
    linnix, Mar 4, 2009
    1. Advertisements

  3. Novel

    Novel Guest

    Thank you for answering me.
    Firstly, the address of datasheet of ADC converter is
    Secondly, the part number of LCD is PMC1602C-SYR.
    Thirdly, I really need ADC converter. What I need to do is to test
    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.
    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
    do not know whether they are right or wrong.


    #include "p18f45k20.h"
    #include "delays.h"
    #include "lcd.h"

    #pragma udata // declare statically allocated uinitialized

    #pragma code // declare
    executable instructions

    void main (void)
    // set internal oscillator to 4MHz
    OSCCON = 0x50; // IRCFx =
    OSCTUNEbits.PLLEN = 0; // x4 PLL

    lcd_init(); //
    initialise display
    write first screen
    lcd_goto(0x00); //
    goto 1st line position 3

    lcd_puts ("PIC
    Thermometer"); // write string to
    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:");
    ("lalalala.."); //
    I just use lalalala to inst. temperature what I want.

    Delay10KTCYx(255); //
    delay approx 2.5 Seconds


    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
    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
    Novel, Mar 4, 2009
  4. Novel

    linnix Guest

    So, how do you hook up the 14504BCP?
    linnix, Mar 4, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.