Pages: [1]   Go Down
Author Topic: Analog inputs are averaging?  (Read 748 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So, I have two analog inputs, on separate circuits, one should read 10 and the other 34, but they are both coming up as 22? 

Code:
int loadcell;
int battery;

void setup()
{
Serial.begin(9600);
}

void loop()
{
loadcell = analogRead(0);
battery = analogRead(1);
Serial.print(loadcell);
Serial.print(" ");
Serial.println(battery);
delay(100);
}

????? Help ???

Thanks, Ryan
Logged

Offline Offline
Edison Member
*
Karma: 56
Posts: 2145
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Diagram?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wiring schematic would be helpful. But take a digital multimeter and measure the voltages at analog pins 0 and 1 and see what readings you get at that point independent of your program.

Lefty

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Checked with a multimeter, voltages are what they should be.  I dont know why the Serial monitor is showing them as averaged...  The diagram is real complex, not sure how I'd post it.  It has three batteries, a load cell, amplifier, and LEDs.  But the battery and loadcell are on totally different circuits.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Checked with a multimeter, voltages are what they should be.  I dont know why the Serial monitor is showing them as averaged...  The diagram is real complex, not sure how I'd post it.  It has three batteries, a load cell, amplifier, and LEDs.  But the battery and loadcell are on totally different circuits.

Well the output impedance of the signals (if too high) you are reading could be a factor, and if not that then your sketch is mangling the values before sending them out to the serial monitor.
So without wiring diagram and sketch code help will be just guessing.

Lefty
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 168
Posts: 12428
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
????? Help ???
help!!

Analogports are A0 iso 0 and A1 iso 1

give this a try. Be aware that analog reads fluctuate ...
Code:
int loadcell;
int battery;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  loadcell = analogRead(A0);
  battery = analogRead(A1);
  Serial.print(loadcell);
  Serial.print(" ");
  Serial.println(battery);
  delay(100);
}
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31384
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this:-
Code:
void loop()
{
loadcell = analogRead(0);
loadcell = analogRead(0);
battery = analogRead(1);
battery = analogRead(1);
Serial.print(loadcell);
Serial.print(" ");
Serial.println(battery);
delay(100);
}
It will help if the impedance of each input is too high.
Logged

Pages: [1]   Go Up
Jump to: