Help with custom pcb MCU Analog input reading 1.1v when expecting 0v

Thread Starter

USAWME

Joined Mar 29, 2023
18
Hi all, I have recently built my own board for a project which uses a atmega 2560. Have had the pcb's made and have uploaded my code and got it all working but have noticed a few issues with the analog readings.

I have 10k pulldown resistors on some sensors to be able to show when the sensor wire is broken or been disconnected. They are pressure sensors and hall effect sensors so read 0.5v - 4.5v in normal operation so when disconnected i'd expect to see 0v.

Some of the sensors do indeed read 0v when disconnected but some read 1.1v and this has been confirmed with my multimeter the pin does indeed read 1.1v or thereabouts ( 1.05-1.09) on the multimeter).

Given this, I am assuming it has to be pcb related but nothing stands out to me.
Given that i use 10k resistors for pulldowns or pullups on the whole board im assuming its something somewhere feeding a low voltage from 5v through a pull down to gnd pin through this 10k pulldown resistor but im not sure ive spent hours looking at my pcb and testing with a multimeter and cant work it out.


PCB Overview.png

The reset pin is also pulled high to 5v with a 10k resistor so am wondering if this has something to do with it as they are the same resistor values not sure how they are linked internally on the atmega2560 though

Testing resistance between say Analog sensor 1 and sensor 2 inputs on the MCU gives a 20kohm resistance as expected ( connected to ground through 2 10k resistors ) so not sure if this is the issue either but i'm not sure where to go from here.

I can eliminate the pulldown resistors or even make them pull up resistors if I have to but id like to utilize it as will be easy to code when they are disconnected ( if the value is 0 or less than 0.5v when using pulldown or above 4.5 when using pull up) versus trying to work out when they are disconnected guess what will happen to the sensor values which could be hard based on vehicle environments which could float realistic values


Thanks,
Darcy
 

KeithWalker

Joined Jul 10, 2017
3,143
I find your diagram very difficult to read with pale colours and grey lettering. It would be much better to understand in plain black and white.
If the section in the top left of the diagram is the signal input circuit, I would suspect reverse leakage current in the protection diode which is connected from +5V to the input. You can check this by disconnecting the diode in one of the faulty inputs.
 
Last edited:

Thread Starter

USAWME

Joined Mar 29, 2023
18
I find your diagram very difficult to read with pale colours and grey lettering. It would be much better to understand in plain black and white.
If the section in the top left of the diagram is the signal input circuit, I would suspect reverse leakage current in the protection diode which is connected from +5V to the input. You can check this by disconnecting the diode in one of the faulty inputs.
Thanks for the reply i'll upload each schematic individually as theres no output that i am aware of in fusion so had to screenshot the zoomed out image so loses quality.

As for the top left its not actually connected to 12v in this board i changed it as i accidentally forgot to connect it to 12v ( that is meant to be a voltage divider to read battery voltage up to around 19v which will give 5v on the input used 110k oh resistor and 39.2k resistor values for the divider instead of what is shown here.

So currently that net labelled 12v there is only connected to the illumination wire which is connected in the vehicle. ( I copied the illumination group and forgot to change the net input to 12v so it would only read battery voltage when headlights are on now so that will be on board rev 2 haha.

There is more outputs missing from the schematics shown but they are all the same as the output shown individually.

Will upload them here individually in next post hopefully it works
 

Thread Starter

USAWME

Joined Mar 29, 2023
18
So all outputs (Valve trig 1 - 4 Down and Up, Compressor Trig 1, Output 2 ) are the same design as Compressor Mosfet image.

Then the Voltage sens line was meant to go to 12v but i found after looking at schematic i had the input for the voltage divider going to illumination as well instead of the 12v constant feed from vehicle so can disregard that one or essentially is the same as the illumination circuit only with the output going to pin A11(voltage_sense Pin) instead of the headlight trigger input
 

Attachments

Thread Starter

USAWME

Joined Mar 29, 2023
18
These are the main sensors that i am refferring to so both Press sens and Height Sens are the pressure and height sensor inputs this is where they connect directly to the harness for the pressure and height sensors.

From there they go to the MCU inputs but with the pulldown resistors attached as well.
Sensors and ICSP.png
So the wire net would be for example pressure sensor input 1:
Pressure sensor harness connected to 5v Gnd and P_Sens_1
P_Sens_1 - MCU Analog input P_Sens_1
P_Sens_1 - 10k resistor -GND

MCU.pngAdd Ons 1.pngHeadlight Input.pngMosfet Output.png
 

Thread Starter

USAWME

Joined Mar 29, 2023
18
And as for which pins were showing 1.1v and which were ground here is the results which have been confirmed with a multimeter.

I find it interesting that corner 1 is the "outlier" in the data Yellow is pressure sensor and Red is Height Sensor.

in this image the tanksensor was connected so initially though perhaps if tank sensor is connected and its also connected to gnd through the 10k resistor which is linked to the other sensors through their 10k resistors that it may be that issue but i disconnected it last night and same result.

Voltage HMI.jpg
 

nsaspook

Joined Aug 27, 2009
13,426
I don't know if this is the case here but it's something to consider.

The ADC on most controllers uses a single sample and hold with a MUX for all pin measurements. If a pin is open or at a high impedance, previous ADC measurements on other pins can leave a charge on the SH circuit to shows up as a phantom voltage. One solution is to selected a shorted ADC pin for a measurement first to drain residual charge for a good 'zero' and then to select the wanted pin for a measurement.
 

Thread Starter

USAWME

Joined Mar 29, 2023
18
I don't know if this is the case here but it's something to consider.

The ADC on most controllers uses a single sample and hold with a MUX for all pin measurements. If a pin is open or at a high impedance, previous ADC measurements on other pins can leave a charge on the SH circuit to shows up as a phantom voltage. One solution is to selected a shorted ADC pin for a measurement first to drain residual charge for a good 'zero' and then to select the wanted pin for a measurement.
Thanks for the reply, yeah i knew this was the case which is why i was doing the pulldown resistors and i woud have thought 10k would have been plenty enough to give a solid reading.

If i have the sensors connected first giving a reading voltage and disconnect it, it always pulls straight down to 0v 1.1, 1.1, 1.1 ( Height sensor 1,2,3,4) and so on and given that with the multimeter it is also reading this 1.1v then i must have something with less resistance than 10kohm connected to the analog inputs so not sure where it is or how but to me that's the only logical explanation.

Im wondering if the placement of the copper traces on the board itself would give electrical noise greater than 10k ohm to interfere with these values?

I wouldn't have thought so or if so i would expect fluctuation rather than a set voltage or even sometimes corner 1 to show the 1.1v but corner 1 height sensor is always 0v when disconnected and the other 3 corner pressure sensors are always 0v when disconnected while the rest are the 1.1v so its very weird.
 

nsaspook

Joined Aug 27, 2009
13,426
Thanks for the reply, yeah i knew this was the case which is why i was doing the pulldown resistors and i woud have thought 10k would have been plenty enough to give a solid reading.

If i have the sensors connected first giving a reading voltage and disconnect it, it always pulls straight down to 0v 1.1, 1.1, 1.1 ( Height sensor 1,2,3,4) and so on and given that with the multimeter it is also reading this 1.1v then i must have something with less resistance than 10kohm connected to the analog inputs so not sure where it is or how but to me that's the only logical explanation.

Im wondering if the placement of the copper traces on the board itself would give electrical noise greater than 10k ohm to interfere with these values?

I wouldn't have thought so or if so i would expect fluctuation rather than a set voltage or even sometimes corner 1 to show the 1.1v but corner 1 height sensor is always 0v when disconnected and the other 3 corner pressure sensors are always 0v when disconnected while the rest are the 1.1v so its very weird.
I don't have your PCB so it's only a guess. Usually when I have strangeness like this in a new board I check to be sure that VCC/GND everywhere on the board is actually connected to VCC/GND on the controller and power supply bus.
For ADC processing checks:
It should be easy to check if you scan in the same sequence. Short a pin(s) before the one measured in the sequence to see if leakage from S&H or any other source is a factor. Use the low-Z meter setting if you have one for measuring voltages.
 

Thread Starter

USAWME

Joined Mar 29, 2023
18
I don't have your PCB so it's only a guess. Usually when I have strangeness like this in a new board I check to be sure that VCC/GND everywhere on the board is actually connected to VCC/GND on the controller and power supply bus.
For ADC processing checks:
It should be easy to check if you scan in the same sequence. Short a pin(s) before the one measured in the sequence to see if leakage from S&H or any other source is a factor. Use the low-Z meter setting if you have one for measuring voltages.
Quick update:

Just did a test and have uploaded new code just to change the onboard 8 addressable rgb LEDs based on the input voltage on the 4 pressure and 4 height sensors.

So if i short out the pressure sensor input straight to ground it goes red ( 0v) but disconnecting goes back to 1.1v ( which i set to blue Anything between 1 and 2v is blue)

This happens across all the same sensor pins

So something is supplying it with voltage and i'm assuming its creating its own voltage divider between that source and the 10k pulldown resistor causing it to always have the 1.1v
 

nsaspook

Joined Aug 27, 2009
13,426
Quick update:

Just did a test and have uploaded new code just to change the onboard 8 addressable rgb LEDs based on the input voltage on the 4 pressure and 4 height sensors.

So if i short out the pressure sensor input straight to ground it goes red ( 0v) but disconnecting goes back to 1.1v ( which i set to blue Anything between 1 and 2v is blue)

This happens across all the same sensor pins

So something is supplying it with voltage and i'm assuming its creating its own voltage divider between that source and the 10k pulldown resistor causing it to always have the 1.1v
I don't know that chips analog and gpio setup settings but are the pin internal pull-ups off in the config? They normally are about 45 to 50K tied to VCC, so with a 10K pulldown that's in the range of 1V on a voltage divider.
 

Thread Starter

USAWME

Joined Mar 29, 2023
18
I don't know that chips analog and gpio setup settings but are the pin internal pull-ups off in the config? They normally are about 45 to 50K tied to VCC, so with a 10K pulldown that's in the range of 1V on a voltage divider.
I haven't set them as internal pullups in the code but potentially by default they could very well be internally pulled high.

I'll have an investigate and see what i can find out
 

Thread Starter

USAWME

Joined Mar 29, 2023
18
I don't know that chips analog and gpio setup settings but are the pin internal pull-ups off in the config? They normally are about 45 to 50K tied to VCC, so with a 10K pulldown that's in the range of 1V on a voltage divider.
Have just tested, rewrote the code listing them all as inputs and then digital writing them all LOW and still has the same issue so i don't think its that.

The only thing i'm wondering is the gnd connection on these output wires is all linked and then goes to the closest ground point which is shared ground with other components i'm wondering if this somehow could affect it?

For example there is a GND wire that goes from gnd to pulldown resistor 1 to pulldown resistor 2 to 3 and to 4 then to flyback diode gnd then to another gnd on the board.

Wondering if this could have something to do with it
 

Thread Starter

USAWME

Joined Mar 29, 2023
18
Iv probed Miso, Mosi, SCK and am getting around 1.2v on all lines between these and gnd is this normal do you think?
 
Top