Strange Voltage on Analog Input A13

Hi,

I've got a Mega2560 on a custom PCB. I've used Mr Nic Gammons Boot Loader and programmed the board, A-OK. I've made several versions of these over the last couple of years and now have a strange problem with some of my latest ones....

Analog input A13 on some of the boards has circa 2v on it, even when nothing is connected.

I have two schottky diodes going to zero and 5v, just in case the signal is ever on when the board is off, so initially I thought these must be faulty. But even with these depopulated, I still get 2v on the analog pin - with nothing else connected.

I thought maybe it's an induced voltage, but when I connect a voltage source to the pin and vary it, at zero or 5v, it acts as expected, but in the middle region, it sort of clings to the 2 - 3 v mark, as if the strange voltage is in fact there.

Any ideas what to check next please?

This seems pretty normal to me and I wouldn’t worry about

Btw if you are measuring voltage in a non ratiometric way , use the internal voltage reference and scale input to suit .

Hi. Thanks for replying. Can you expand a bit please? I don't understand what's going on with it.

I measure the voltage with DMM from 0v to the signal (A13 pin).

  • If you remove the diodes does the voltage go away ?

  • The input impedance is > 100meg so there might be a floating voltage.

  • Try a 10k pull down resistor.

Unconnected inputs (both analog and digital) "float" to an undefined voltage/value. I've also noticed that an open analog input tends to float around the middle (between 0 and 5V) but technically it's just undefined and can be anything.

Floating digital inputs can read 0 or 1, and since high impedance inputs are sensitive to noise pick-up the readings may switch "randomly" between 0 and 1.

The meter 'pulls down" the input through it's input impedance (probably around 1M) so when the meter is connected it really is 0V, and the Arduino should read the same. (With high impedance, there can be some noise/instability which the meter will filter-out, and the Arduino may show some random readings around zero.)

If you want it to behave like meter and read zero with nothing connected, you can put a "pull-down resistor" between the analog input and ground.

No. I thought maybe it would, but no, it's still there.

Analog inputs 0 - 12 are local to the board and are 0 - 10v, reduced to 0 - 5v by using simple resistor voltage dividers. The one I am looking (A13) at is basically a piggy-backed signal from an identical board, but after the voltage divider so already at 0-5v. I'm worried that if I add a resistor to ground it would shift the signal. It's positional feedback so I need it to be "the same" across the two boards. Is this worry legit, or could I add it in? The 0v are linked between the two boards.

My problem is that the meter reads the 2 volts, and the analog input reads a corresponding value. If I apply an external voltage to the input, only the extremes of 0-5v make a difference to either. 0 pulls it low, 5v pulls it high, but the bulk of the range in between seems pulled towards 2.x volts. It doesn't act like a floating voltage (I think). I still don't understand!

Thanks.

I trust you have a common 0v line between the Arduinos ?

Do they have any loads on any pins ?

Check voltages on the two 5v lines .

Voltage dividers should be in the tens of k ohms .

Can we see a schematic ? And code ? ( try a simple sketch from the examples for analog read ).

What’s different from the earlier boards /code /different processor model ?

The ADC is referenced , by default , to its Vcc voltage , so you can see variations even if driven from the same supply .
When you read an analog sinput , it is worth taking 2 readings and throw the first away .

Does sound like wiring error, short , dry joint issue .( does it read ok when not connected to the other board ?)

Which is effectively grounding the pin with a 10Megohm resistor.
You should measure 0volt that way.
If not, then there is something wrong with the board or the chip..
Pictures/schematic please.
leo..

Hi,
Can you please post images of your PCB?
Can you please post exported images from the CAD that you designed the PCB on?
Can you please post a schematic of the PCB?
If you remove the 2560 from the PCB, what do you measure on the input pin with power ON and with power OFF?

Remove the two Schottky's gnd with the 2560 also removed, measure the resistance from the analog pin to gnd and Vcc, in both directions?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

That can not be right - so something else MUST be connected. Either external to the chip, or internally.

HAve you measured the current that is flowing from +5 to A13? and from -5 to A13? That would give you a value for the resistance that is pulling it to 2.5

I wondered about a soldering issue on the 2560
image

are you using A14 or A12? Are they set as inputs?
Is A13 set as an input?

I'm sure you will have already done this but have you inspected the whole length of the A13 trace for solder whiskers or flux?

When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.

Yes.

Yes. A0 to A12 are used, plus a bunch of digitals.

All fine

150K each

I rearranged the layout a bit for the PCB. The diodes are from a different manufacturer because of component shortages, but the spec seems fine to me - The reverse voltage is rated at 30v.

However, I did suspect these diodes first, so I swapped them for old diodes and on 6 out 7 of the boards, this worked. I don't know why the 7th didn't. The suspect diodes all test OK with the diode test on the DMM. I thought they must be passing when under voltage (in reverse, at only 5v), but I couldn't find any examples of this happening on Google.

The code hasn't changed, I don't think. However, I decided to port the Arduino project to PlatformIO for this version, so it's possible one of the library versions may be different or the compilation itself. Ironically, I did this partly because I wanted more control over the libraries. I can't rule the code out, but it doesn't explain why the fault seemed fixed on the 6 boards with old diodes. I can't spot anything in the code other than my analog read referencing that pin.

The chip is the same as far as I know.

The 2v is there when nothing else is connected. The trace looks fine. It's from PCBWay, who I've used for all the boards.

In a header file:
extern const int inPosActExt;

In the cpp file:
const int inPosActExt = A13;
This decodes as 67 when I hover the mouse over it.

In the main setup cpp:
pinMode(inPosActExt, INPUT);

In use in another cpp file (it's mapped to the variable, so the name is different):
posFollowingRaw = analogRead(pinPosFollowing);

Signal coming in from a terminal:

Connected to pin 84 / 67 / A13:

The two diodes near the terminal:

Trace connected to processor:

Hi,

Can you read the part numbers printed on the diodes, it sounds like you may have a few low voltage Zener diodes.

Test the suspect diodes under a load.
Put one in series with a 1k resistor across the 5V supply and measure the volt drop when forward and then reverse biased.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

The diodes are

https://datasheet.lcsc.com/lcsc/Diodes-Incorporated-B130LAW-7-F_C129191.pdf

Hi,
Have you setup a bit of strip board to test the troublesome diodes, experiment!!!!!!!!!!!!!!

Tom... :smiley: :+1: :coffee: :australia:

Why are you using Schottky clamping diodes if you have a 150k:150k voltage divider.

  1. 150k limits fault current to what the internal clamping can deal with.
  2. Schottky diodes have a high leak current, so you avoid using them in high impedance situations.
    Leo..

Shall do. I'll report back.

The setup is 12 local analog signals, each with the 150k:150k voltage divider in - These don't use the diodes. The 13th analog signal, A13, is from another identical board - a piggy-backed signal from A1, so it does have the current limiting resistor local to it's board. I've used the clamping diodes as I was worried that the external board could be powered up before this one, so I didn't want the signal on the analog input without the processor being powered up. I read somewhere that would damage the input. If this shouldn't be a worry, I can just remove the diodes and live a happy life. Can anyone confirm if the diodes are needed please?

Can you explain this please? I don't follow.

I've taken the diodes off the board and cobbled some others together on breadboard. With no diodes, there is no voltage present at the analog in. As soon as I put the diodes in I get 2.5v (GND to Analog pin) if I use a scope, or 1.4v if I use my DMM. Am I measuring it wrong? What am I doing??? Help!

Hi,
Simply do these two tests;

Tell us what the DMM reads in each case.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Reverse Bias: 4.83v

Forward Bias: 0.163v

Since I've got the 150K voltage divider, Can I do away with the external clamp diodes and rely on the internal ones of Mega2560? Current would be tiny, no?