Interfacing Temperature sensor with lcd

Discussion in 'The Projects Forum' started by johnjameson2011, Feb 17, 2011.

  1. johnjameson2011

    Thread Starter New Member

    Feb 17, 2011
    12
    0
    Heys guys,I currently building a lm35 temperture sensor and want to display my results on a lcd,I programming a mcd9000 board(with an onboard a/d converter) using keil uvision and just have a few questions
    I think I have my analog to digital code set up right but the signal that saves into the AD0DAT1 register,can I manipulate that with a formula and then display on my lcd?

    Below is my code(ignore he lcd parts)
    # include <REG935.H>

    //LCD commands
    #define FunctionSet 0x3B
    #define DisplayOn 0x0E
    #define EntryModeSet 0x06
    #define ClearScreen 0x01
    #define SecondLine 0xC0

    //function prototypes
    void lcd_write(unsigned char display_data);
    void delay(unsigned char x);
    void delay_5msec();

    //pin definitions
    sbit EN = P2^2;
    sbit RS = P2^1;
    sbit RW = P2^0;

    void main()
    {

    P2M1=0x00; //output
    P2M2=0x00;

    P1M1=0x00; //lcd
    P1M2=0x00;

    P0M1=0xFF; //set as input for sensors
    P0M2=0x00;

    RW = 0;
    RS = 0;
    lcd_write(FunctionSet);
    lcd_write(DisplayOn);
    lcd_write(EntryModeSet);
    lcd_write(ClearScreen);


    ADINS=0x02; //set ad01(P0.0) for sampling
    ADCON0=0X04; //ADC channel 0 enabled
    ADMODB=0x40; //sets to divide by 3,for accuracy
    ADMODA=0x02; //fixed channel,continous conversion,until terminated by user

    while(1)
    {
    int t;
    ADCON0 |= 0x01; //start conversion,immediate start mode
    while((ADCON0 & 0x08) == 0); //wait for end of conversion
    ADCON0 &= 0xF7; //clear EOC flag
    t = AD0DAT1; //display result on port 2 LEDs
    lcd_write(ClearScreen);
    lcd_write(t);
    }
    }
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    What is the level of output from the LM35? What is the LSB sensitivity of the A to D converter?
     
Loading...