Pages: [1]   Go Down
Author Topic: Analog Input to Digital Serial occasionally quits (Uno)  (Read 456 times)
0 Members and 1 Guest are viewing this topic.
Tulsa USA
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a project where I feed a voltage supplying sensor to A0. The Uno converts it to a digital value and transmits it via serial cable to my PC and I graph the result on my PC. It works real well most of the time, but occasionally for some reason it just stops converting the input to digital and always delivers 0 to the PC.

The first time it happened, I removed the sensor input and put in a simple potentiometer to supply a variable voltage using the Uno's 5V as the source. This worked fine. I hooked the senor back up again and it was all working fine again, converting the voltage to digital just as it should be.

I thought maybe I was getting >5V from the sensor occasionally. I bought a 5V zener diode to put across the output of the sensor to prevent against possible over voltages. The system seemed to work just fine again in this scenario, until it happened again, and it is reading all zeroes again. I know that there sensor is delivering more than 0V because I can measure it. The ADC should be converting the voltage but it is not. Pressing the Arduino reset, or removing power has no affect. It is still reading zero after reset.

I'm new to Arduino, I was wondering if anyone knows what is going on. Is there something other than reset I can use to make sure the Arduino is properly initialized at start-up?
Logged

Chris H

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A input of +5vdc or greater will return a 1023 count value, if it doesn't destroy the input pin as it has a Vcc +.5vdc limit.

The best course of action to troubleshoot this problem is to run the sketch with the sensor connected and when and if you see it reading zero again, just measure the voltage at the input pin with your Digital Multimeter. That will 'half-split' the problem from being a sensor problem or a arduino problem. If you don't own one, go on-line and order one, they are cheap these days and no one should be wiring up arduino projects without having and learning to utilize a DMM.

Lefty
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12577
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a project where I feed a voltage supplying sensor to A0. The Uno converts it to a digital value and transmits it via serial cable to my PC and I graph the result on my PC. It works real well most of the time, but occasionally for some reason it just stops converting the input to digital and always delivers 0 to the PC.

Can't say whether it's a hardware or software problem at this stage. I suggest you post your code, and hopefully we can then rule out software as the cause.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also post your schematic, and a link to the datasheet for the sensor.

PS - if you suspect that the output from the sensor may be a little out of range sometimes, connect a 10K resistor between the sensor output and the Arduino input pin, and let the internal pin protection diodes do the rest.
« Last Edit: January 06, 2013, 07:55:29 am by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Tulsa USA
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm actually trying to digitize an audio signal. I have a sensor (Geophone) that produces a signal, is goes through a pre-amp, then to an LM386 amplifier. The output produces a mono audio signal. I'm trying to condition that signal such that it is suitable to put to an analog pin on the Arduino. I am thinking that it needs to be rectified, and limited so that it can't produce more than 5V. In the hyperlinked schematic, the lower right corner shows the Arduino interface, which in parallel with the speaker audio output. It uses a 5.1 V zener to limit the voltage seen at A0 on the Uno. I'm not sure that it is doing the job well enough though.

http://www.flickr.com/photos/7697481@N04/8373568939/

Hopefully the link I attached shows the schematic. If someone might be able to suggest a more effective way to condition the signal for the Arduino, I would appreciate it.

Logged

Chris H

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7175
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The circuit is a bit hard for me to understand. If you have access to an oscilloscope, check if the signal is within range and stays positive.
Logged


Australia
Offline Offline
Sr. Member
****
Karma: 11
Posts: 472
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It seems that you are feeding an AC signal into the Arduino, which wont produce any kind of sensible result.
You need some kind of peak rectifier to convert the signal into DC between 0 and 5V, and also possibly some smoothing.
Logged

Tulsa USA
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I modified the interface portion of the circuit by adding a diode (D2) that will rectify the audio signal, so that it is all positive. I think the reason it stopped working in the past was because I was getting some negative voltages.

I also made a dramatically better schematic:

http://www.flickr.com/photos/7697481@N04/8374042587/

Its working very well now. I get a beautiful display on my PC screen:

http://www.flickr.com/photos/7697481@N04/8375130306/
« Last Edit: January 12, 2013, 08:00:23 pm by cmh2001 » Logged

Chris H

Pages: [1]   Go Up
Jump to: