Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LM35 with lpc2148 (ARM 7)

Status
Not open for further replies.

shruv

Member level 2
Member level 2
Joined
Jun 13, 2013
Messages
47
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
270
Hello Everyone!

I am trying to interface lm35 with ARM 7.Do I have to connect a resistor with LM35 to get the output.
Some suggest for a 1k ohm and some 4.7k ohm.
 

you don't have to connect a resistor with this condition:
- measuring range +2'C to +150'C
- Vcc +4V to 20V
 
  • Like
Reactions: shruv

    shruv

    Points: 2
    Helpful Answer Positive Rating
Thanks a lot. Will try it out.
 

it's reading 0.00.
The program works with a potentiometer,but not with lm35.Can any one tell y?
Code:
#include"lpc214x.h"
#include<stdio.h>


#define LED (0x00000001<<7)
#define BIT16 (0X00000001<<16)
#define BIT18 (0X00000001<<18)
#define BIT24 (0X00000001<<24)  //po.28 adc0.1

 unsigned char key_press[]="key press";
void PrintonVGA(unsigned char *);
void adc_init(void);
void UART_Init (void);
void adc_read(void);
int main()
{ 
unsigned int i;
UART_Init() ;
PINSEL1=BIT24; //ADC0.1
         
IODIR0=LED;
IODIR0|=~KEY;
adc_init();

PrintonVGA( key_press);
adc_read();
IOSET0=LED;
for(i=0;i<40000;i++);
IOCLR0=LED;




void adc_read(void)
{

	float res=0;
unsigned char buf[20];
AD0CR|=0X01000000;
PrintonVGA(" Start conversion");
while(!(AD0DR1 & 0x80000000)); // checking for done bit
PrintonVGA("converted");

res=((AD0DR1>>6)&(0x000003ff)); // extracting the converted value
	

	sprintf(buf,"%f",res);
PrintonVGA(buf);
AD0CR|=0x00200302; // stop adc
	
}
void adc_init(void)
{
        PCONP |= 0x0100;

	AD0CR=0x00200302;  //channel 1 adc 0 pclk=15mHz/4
}

void UART_Init (void)  
{

  PINSEL0 |= BIT16 + BIT18;


  U1LCR = 0x83;
  U1DLM = 0x00;	
  U1DLL = 0x62;
  U1LCR = 0x03;
  

  U1FCR = 0x07;
}


void SendUARTByte (int ch)  
{ 
  while (!(U1LSR & 0x20)); 
  U1THR = ch;
}

void PrintonVGA(unsigned char *ptrBuf)
{
 
  while(*ptrBuf != '\0')
  {
    SendUARTByte(*ptrBuf);
    ptrBuf++;
  }
}
 
Last edited:

hello,

Are sure about the wiring ?

With a potentiometer your voltage input is 0 to 5V , isn't it ?
with LM35 you only can get 250mV @ 25°C ..
what is the analog input range 0-5V 0-1023 pts
( i don't know your µP.)
Even with a low level input you must get any points of measure ( 50 pts )
 

hello,

Are sure about the wiring ?

With a potentiometer your voltage input is 0 to 5V , isn't it ?
with LM35 you only can get 250mV @ 25°C ..
what is the analog input range 0-5V 0-1023 pts
( i don't know your µP.)
Even with a low level input you must get any points of measure ( 50 pts )

I am using lpc2148 arm 7 microcontroller. The controller works at 3.3Volts. I have configured it to be a 10 bit adc. potentiometer is connected to 3v supply. LM35 is connected to 5v supply.I haven't connected any resistor.
 

hello,

if it's works with a potentiometer 0 to 3,3V
it must work with the LM35

did you get 0 to 1023 pts with the potar 0 to 100% ?

what LM35 packaging do you have?
joined doc for TO92 BOTTOM VIEW !
can you measure LM35 output with a multimeter ?
 

Attachments

  • LM35_pinout.jpg
    LM35_pinout.jpg
    15.3 KB · Views: 96

hello,

if it's works with a potentiometer 0 to 3,3V
it must work with the LM35

did you get 0 to 1023 pts with the potar 0 to 100% ?

what LM35 packaging do you have?
joined doc for TO92 BOTTOM VIEW !
can you measure LM35 output with a multimeter ?

Yeah,potentiometer is giving full range 0 - 1023.The lm35 is sensing 286 mvolts and for that the reading is 0.00.
Yes,lm35 is TO92 plastic package.
 

I am a bit suprised for using a long to get ADC value ( 10 bits ADC , so normal int 16 bits is enough))
Try to printout intermediate result

Code:
res=(float) AD0DR1; // extracting the converted [B]RAW value[/B]
sprintf(buf,"%f",res);
 

I am a bit suprised for using a long to get ADC value ( 10 bits ADC , so normal int 16 bits is enough))
Try to printout intermediate result

Code:
res=(float) AD0DR1; // extracting the converted [B]RAW value[/B]
sprintf(buf,"%f",res);
ok have changed it,using unsigned int to extract the value(raw value) into. it's reading full value 1023.

- - - Updated - - -

For 293 mVolts on lm35 it's qiving 1023 (converted value of adc).
 

Remember i don't know your µP..
but on microchip we decide if the ADC measure is left or right justified (for MSB and LSB byte)
ie: for right justified
we add LSB + MSB <<8 to obtain a word ( unsigned int) with the 10 bits value inside it.

or you divide by 64 ( >>6) i don't know why, but i suppose the probleme is around this.
what do you get with potentiometer and RAW value
and turn slowly potentiometer to see if you get every value between 0 and 1023 ..
i don't think so you could..
 

There is no while(1) loop in your code. Try giving a rewference voltage of 1.7V to the ADC. Does the adc input pin have any other multiplexed functions? See if you have to configure any register to make the adc input pin for analog operation.
 

There is no while(1) loop in your code. Try giving a rewference voltage of 1.7V to the ADC. Does the adc input pin have any other multiplexed functions? See if you have to configure any register to make the adc input pin for analog operation.


I just took out while(1).It displays the result when i press the reset button. The reference voltage for adc is 3.3volts. yes,the adc input pin is multiplexed with other functions,I a selecting using PINSEL1 register to set it as adc input pin. Not sure how i can give 1.7 volts,no pin to Vref to change the input voltage.
 

Remember i don't know your µP..
but on microchip we decide if the ADC measure is left or right justified (for MSB and LSB byte)
ie: for right justified
we add LSB + MSB <<8 to obtain a word ( unsigned int) with the 10 bits value inside it.

or you divide by 64 ( >>6) i don't know why, but i suppose the probleme is around this.
what do you get with potentiometer and RAW value
and turn slowly potentiometer to see if you get every value between 0 and 1023 ..
i don't think so you could..
The values are changing between 0 - 1023 for the potentiometer. it reads 500 something or 800 something etc. I am shifting by 6 because in the addr register the data is available after conversion from 6th bit to 15th bit.
 

hello,



Where is the closing parenthesis in the main function ?

Code:
int main()
{ 
unsigned int i;
UART_Init() ;
PINSEL1=BIT24; //ADC0.1
         
[B][COLOR="#FF0000"]do
{[/COLOR][/B]

IODIR0=LED;
IODIR0|=~KEY;
adc_init();

PrintonVGA( key_press);
adc_read();
IOSET0=LED;
for(i=0;i<40000;i++);
IOCLR0=LED;


[B][COLOR="#FF0000"]} while (1);[/COLOR][/B]
[B]}[/B]
 

hello,



Where is the closing parenthesis in the main function ?

Code:
int main()
{ 
unsigned int i;
UART_Init() ;
PINSEL1=BIT24; //ADC0.1
         
[B][COLOR="#FF0000"]do
{[/COLOR][/B]

IODIR0=LED;
IODIR0|=~KEY;
adc_init();

PrintonVGA( key_press);
adc_read();
IOSET0=LED;
for(i=0;i<40000;i++);
IOCLR0=LED;


[B][COLOR="#FF0000"]} while (1);[/COLOR][/B]
[B]}[/B]

I have made the changes with while of one,but problem was with Vref, board problem. Because of the wrong numbering the vref was given to the wrong pin and not to the 63rd pin the the controller,when we manually gave the vref pin 3.3v. The program is displaying the output(room temperature).
Thank you for your time and support.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top