LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog read problem on mega

I have a strange problem when reading the analog inputs on my mega.

I'm using almost all pwm signals and a lot of digital channels. This sytem is running 24/7 and is running fine. But the analog reads are giving me a headache. They can run fine for a few days but then it stops reading, sometimes it reads for a few hours and stops reading. Although i'm not sure if it really stops reading because the arduino continues to work fine (no error) and all the pwm and digital signals continue working. So it looks more that the analog input lost it's connection to the ground (floating) or the arduino generates a random signal. But when i check the input to the arduino with a Voltmeter it's getting a normal input value of a few volts.

Also when i get the random values and stop the program (close arduino) and start again (init arduino) all the analog input signals are fine again (for a few hours/days anyway).

Below is the hardware connection is use. There is a 1K resistor between the inputs and the ground to create a "zero" when there is no sensor connected.

http://foto.krillins.com/arduino/sensor.jpg

Below is a part of the program where i read 6 analog inputs. It is placed into a while loop with a wait time of 100ms (so it's taking 10 samples a second). It then fills an array of 25 samples to get an average (for each input).

http://foto.krillins.com/arduino/error.jpg 

Maybe the solution is easy, but i can't figure it out.

0 Kudos
Message 1 of 2
(2,963 Views)

Added another picture wich gives an idea of the averaging

http://foto.krillins.com/arduino/error2.jpg

0 Kudos
Message 2 of 2
(2,398 Views)