0
\$\begingroup\$

BLUF: What causes the ADC2 to work perfectly while ADC3 charges towards a value of 328 (1.6V) on ATMEGA328P?

I use an ATMega328P for one of my current projects and had an issue with the ADC.

\$A_{VCC}\$ is connected as in the datasheet with a 100nF capacitor and a 10uH inductor. enter image description here

My project reads frequently ADC2 and ADC3 to calculate some outputs. When I tested it, ADC2 was reading the same voltage as I could measure with a multimeter. But ADC3 showed semi-random values (at least it appeared to me at the time). After some measurements and flashing some code which just outputs the ADC2 values to Serial I figured out that ADC2 was working perfectly. Then I did the same with ADC3 and what appeared to be semi-random values was actually the charging curve of a capacitor (which btw. was completely independent to the actual voltage on the ADC3 pin).


Update

After I changed the inductor it was working. After a couple of tests, it went bad again. Meanwhile, I checked everything again, including the points mentioned in the comments.

All negative:

  • The connection of the pin is Ok
  • there is 0V on ADC3 Pin
  • The inductor is OK
  • 100nF cap is OK

I even changed the ATMEGA and the same happened again, it was working for some time, and then went bad...

Below the shematics: enter image description here enter image description here

As for the code:

void setup() {
    analogReference(DEFAULT);
    Serial.begin(9600);
}

void loop() {
    Serial.println(analogRead(A3));
    delay(100);
}

This results in the following data beeing plotted: enter image description here

void setup() {
    analogReference(DEFAULT);
    Serial.begin(9600);
}

void loop() {
    for (uint8_t i = 0; i < 50; i++) {
        Serial.println(analogRead(A2));
        delay(100);
    }
    for (uint8_t i = 0; i < 50; i++) {
        Serial.println(analogRead(A3));
        delay(100);
    }
}

This results in the following data beeing plotted: enter image description here

Either way the ADC2 result runs towards a value of 328 (equals 1.6V), which I cannot measure anywhere in my circuit...


Update I changed now all parts twice. The inductor, both capacitor and the ATMEGA. From time to time it's working, from time to time not.

\$\endgroup\$
  • \$\begingroup\$ Actually sounds more like a bad solder connection on your ADC3 pin, and by pushing on the inductor/board you make contact. \$\endgroup\$ – JvO Mar 19 '17 at 18:24
  • \$\begingroup\$ No, I checked this at first, I could measure the correct voltage on both pins via multimeter. \$\endgroup\$ – KarlKarlsom Mar 19 '17 at 18:27
  • 2
    \$\begingroup\$ Pushing with your multimeter probe could temporarily "fix" a cold solder joint... \$\endgroup\$ – peufeu Mar 19 '17 at 18:50
  • \$\begingroup\$ @peufeu Sorry for the late reply, I checked twice, no cold solder joint :) \$\endgroup\$ – KarlKarlsom Mar 23 '17 at 7:12
  • \$\begingroup\$ Do the same test with a Arduino Uno and you will see that it will work just fine. It can be the soldering or the 100nF at reset or something else. Do you have an Arduino bootloader and a usb-serial with DTR to reset ? Perhaps the 100nF at the reset pin drops the voltage of the usb-serial module. The Arduino Uno does not have that 100nF at the reset pin, because the reset is used to start the bootloader. Other possibilities are: oscillating 5V or wrong voltage of the 5V (for example 3.0 or 7.0) or ground currents, or bad crystal (I think you use the internal oscillator ?). \$\endgroup\$ – Jot Mar 23 '17 at 14:53
1
\$\begingroup\$

First of all make sure that your code is as posted and there is no funny business other than what's posted.

A dc results can change from a variety of reasons. I would put a probe on a3 , vcc / avcc, and aref to make sure that they are not going up and down.

After that, tie a2 and a3 together and plot them out on the same chart and see if there is a pattern.

The key is to make sure that those implicit assumptions you made are indeed true.

\$\endgroup\$
0
\$\begingroup\$

I would focus on the A/D reference circuitry in the block diagram:

enter image description here

There are three sources of reference: AVCC, INTERNAL 1.1V REFERENCE and AREF, with two switching options in the ADMUX register - a multiplexer and a switch to AREF.

So I would first look closely at your code to see if the multiplexer and switch were set up absolutely identically (configuration-wise AND timing-wise) for ADC2 and ADC3.

If you find that there are absolutely no differences in the code for the mux and switch setup, one could easily speculate that the IC design does not ensure identical behavior (especially timing-wise) for all A/D inputs. The design software typically optimizes for size, speed, crosstalk and other parameters, but not necessarily perfectly identical sequencing. Under normal operation, a small difference in sequencing may not matter, but with AVCC unconnected the timing differences could lead to different behavior.

A third possibility is that your specific ATMega was damaged by whatever caused the inductor damage (e.g. maybe the board was bent, dropped or badly soldered). This could be verified by getting a second board, temporarily removing the 10uH inductor and checking for similar behavior, or, if you have the right soldering equipment, simply replacing the existing ATMega with a new one.

\$\endgroup\$
  • \$\begingroup\$ As written in my update above, I changed the inductor and checked both 100nF caps to no effect. It worked for some time and went bad again... \$\endgroup\$ – KarlKarlsom Mar 23 '17 at 7:03
0
\$\begingroup\$

The inductor current has only two possible paths - through C3 or into the AVCC pin. Since C3 checks OK (recheck) the only path left is into AVCC.

One possible reason for high current into AVCC is that AREF is shorted to ground, which could happen if C4 is bad, but you've checked C4 also. (recheck)

So, what's left?

From the ATmega32P data sheet: AVCC is the supply voltage pin for ... PC3:0 and ADC7:6.

Therefore, carefully check if any of PC3:0 and ADC7:6 becomes a digital output and consequently draws a lot of current. Carefully check for shorts (or layout errors) to ground/supply of those 6 pins under a microscope or magnifier. For example, you measure 0V on A2 - is it possibly tied to ground?

Edit: Also completely agree with DannyF to tie A2 and A3 together and replot your two graphs.

The fact that you have damaged two inductors is a clue that a really large current flowed through your inductor. You have to find the reason for a current large enough to damage an inductor.

\$\endgroup\$
  • \$\begingroup\$ @KarlKarlsom did you ever solve this problem? \$\endgroup\$ – neonzeon Sep 6 '17 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.