Go Down

Topic: Y is this happening? (Read 861 times) previous topic - next topic

sanblade

I would be glad if anyone can help me with this..
I have connected a temperature sensor(LM35) to analog pin 1 and a potetiometer to analog pin 0. When the potentiometer reads zero on my serial monitor I have no problem with the LM35. But when i start varying the pot the LM35 values changes even when my room temperature is constant. when i bring back the pot to 0, it reads the correct values. What could be the problem??

Thanks,
SANJAY 

jackrae

How many terminations does your LM35 and your potentiometer have  (3 each?)  so how about a wiring diagram showing where all 6 terminals are actually connected.  You might then get some sensible responses to your rather vague question.

dxw00d

Also, post the sketch that illustrates the problem.

sanblade

I have attached a picture of how i've connected the pot and the lm35. i have connected the positive terminal of the lm35 to pin no 3 and also made it high in the program. I have done this because there is only one +5v on the board. Other connections are as usual.
this is my coding:


void setup()
{
  Serial.begin(9600);
  pinMode(3,OUTPUT);
  digitalWrite(3, HIGH);
  pinMode(0,INPUT);
  pinMode(3,INPUT);
}


void loop()
{
  delay(500);
  int i=analogRead(0);
  int j=analogRead(3);
  float k=(j*5.0*100.0)/1024.0;
  Serial.println(i);
  Serial.println(k);

dxw00d

Code: [Select]
  int i=analogRead(0);
  int j=analogRead(3);


I thought it would look like that. There are side effects from successive analogRead()s on different pins, where some charge remaining from the first read gets mingled with the incoming voltage, after the multiplexor has switched to the second pin. A recommendation is to read the second pin twice, and ignore the first reading.

tuxduino

Maybe a short (i.e. some ms) delay could be put between the two reads ?

MarkT

Delay won't help, the sample/hold capacitor is isolated at that point, it gets connected to the input multiplexer for 12us before each conversion.

Normally there should not be any problem if the input impedance is 10k or less as the sample and hold cap will charge fully in that 12us.
The LM35 has low output impedance though...  Try putting a 10nF or 100nF to ground from A3, that ought to eliminate noise and stiffen up the voltage there.  The long unshielded cable to the sensor is going to be picking a lot of noise from the computer.
[ I won't respond to messages, use the forum please ]

o_lampe

Quote
pinMode(3,OUTPUT);
  digitalWrite(3, HIGH);
  ...
  pinMode(3,INPUT);


The Vs pin of the sensor should be high all the time.
You read the value of the sensor on the same pin as Vs?
The output of the sensor is the middle pin.
It's not my fault when my Posts are full of Errors. This stupid autocorrection from my browser is set up for german grammar.

Do not use USB supply for LM 35 and potentiometer use external supply and make conman ground of both

#9
Sep 21, 2012, 04:47 pm Last Edit: Sep 21, 2012, 04:51 pm by teckel Reason: 1

I would be glad if anyone can help me with this..
I have connected a temperature sensor(LM35) to analog pin 1 and a potetiometer to analog pin 0. When the potentiometer reads zero on my serial monitor I have no problem with the LM35. But when i start varying the pot the LM35 values changes even when my room temperature is constant. when i bring back the pot to 0, it reads the correct values. What could be the problem??

Thanks,
SANJAY  


Nice descriptive tread subject, could you be anymore general?  Seriously people, make your subject descriptive!

How about this for a subject: "Temperature sensor (LM35) reads wrong when pot changes".  Wouldn't that make more sense and allow people with some kind of knowledge into your problem better help?  It's not too late!  Change it!

Sorry, it's Friday and this is huge pet peeve of mine, and WAY to common.

Tim
Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

Go Up