Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: chungungon on April 03, 2010, 11:31:25 PM

Title: Analog readings affecting adjacent readings in an Axon
Post by: chungungon on April 03, 2010, 11:31:25 PM
Hi Fellows,

I'm having a weird problem with my Axon. I built a tactile bump sensor as explained in http://www.societyofrobots.com/sensors_tactbumpswitch.shtml (http://www.societyofrobots.com/sensors_tactbumpswitch.shtml) . I made the sensor with the resistance between the GND and Vout.

I connected the sensor pin 0 of the analog I/O of the Axon and uploaded to the Axon a simple program that reads every pin from 0 to 15 utilizing the a2dConvert8bit function from a2d.h

Here is the output of the program. Note that the readings are proportional to the distance to pin 0.   :o

0  0  18  35  48  57  59  59  60  62  64  65  65  65  64  62
0  0  16  35  48  57  59  59  60  62  64  64  64  64  63  61
0  0  17  35  48  57  60  59  60  62  64  64  64  64  63  61

When I turn on the switch of the sensor, the readings change to these
255  200  165  141  124  112  99  87  75  73  72  71  69  68  67  69
255  226  203  185  168  151  133  113  92  87  83  80  76  74  72  78
255  231  211  196  184  170  154  131  105  99  94  89  84  80  78  86

At first, I supposed that there could be some kind of short circuit, so I looked with a magnifier glass to the analog pins, both at the place where they connect to the sensor and at the side of the chip, and they all seem OK.

What could be happening?  ???

Thanks in advance.
Title: Re: Analog readings affecting adjacent readings in an Axon
Post by: cyberfish on April 04, 2010, 12:56:46 AM
I'm guessing the other inputs aren't connected to anything.

The inputs are "floating", meaning they can take just about any value. Most likely that of adjacent pins.

If you touch it with your finger, or look at it weird, the readings will change, too.

Note that unconnected (high impedance) does NOT mean 0 (ground).
Title: Re: Analog readings affecting adjacent readings in an Axon
Post by: chungungon on April 04, 2010, 07:47:13 AM
It's great to know that the situation of my Axon is normal behavior. For a moment, I thought that my Axon was acting weird  ;D

Thanks for the advice!
Title: Re: Analog readings affecting adjacent readings in an Axon
Post by: Admin on April 04, 2010, 09:15:53 PM
Yea, you'll see this happen with all microcontrollers.

I once lost a robot competition because I was accidentally reading the pin right next to the pin with the analog sensor. It seemed to work most of the time, but sometimes it wouldn't, or would be very flaky. The debugging drove me crazy. I didn't realize the dumb mistake until a month or so later . . . all from floating voltage.

There was a moral to that story, somewhere, I think . . .
Title: Re: Analog readings affecting adjacent readings in an Axon
Post by: Ro-Bot-X on April 05, 2010, 07:22:45 AM
Yea, you'll see this happen with all microcontrollers.

I once lost a robot competition because I was accidentally reading the pin right next to the pin with the analog sensor. It seemed to work most of the time, but sometimes it wouldn't, or would be very flaky. The debugging drove me crazy. I didn't realize the dumb mistake until a month or so later . . . all from floating voltage.

There was a moral to that story, somewhere, I think . . .

Yeah, try to declare all unused analog pins as outputs, then you won't have any floating voltage problem.
Title: Re: Analog readings affecting adjacent readings in an Axon
Post by: Admin on April 05, 2010, 09:14:33 AM
Yeah, try to declare all unused analog pins as outputs, then you won't have any floating voltage problem.
Nah, that would have caused a short - pin says 5V and sensor says 2.5V . . . something will give . . .

I always look for this mistake when debugging a sensor that doesn't work.
Title: Re: Analog readings affecting adjacent readings in an Axon
Post by: Soeren on April 05, 2010, 09:56:37 AM
Hi,

Yeah, try to declare all unused analog pins as outputs, then you won't have any floating voltage problem.
Nah, that would have caused a short - pin says 5V and sensor says 2.5V . . . something will give . . .
Nothing will give, as the sensor reading from an unused pin is merely a Hi_Z reception of a neighbour pin.
Title: Re: Analog readings affecting adjacent readings in an Axon
Post by: Admin on April 05, 2010, 10:21:38 AM
Hi,

Yeah, try to declare all unused analog pins as outputs, then you won't have any floating voltage problem.
Nah, that would have caused a short - pin says 5V and sensor says 2.5V . . . something will give . . .
Nothing will give, as the sensor reading from an unused pin is merely a Hi_Z reception of a neighbour pin.
But a pin set to output isn't floating, its either 0V to 5V . . .
Title: Re: Analog readings affecting adjacent readings in an Axon
Post by: Soeren on April 05, 2010, 04:19:22 PM
Hi,

Hi,

Yeah, try to declare all unused analog pins as outputs, then you won't have any floating voltage problem.
Nah, that would have caused a short - pin says 5V and sensor says 2.5V . . . something will give . . .
Nothing will give, as the sensor reading from an unused pin is merely a Hi_Z reception of a neighbour pin.
But a pin set to output isn't floating, its either 0V to 5V . . .
Oh well, who puts sensors on outputs?   :P  ;)