ADC values not zero when plugged into ground and turning on LEDs

I've been trying to figure out why, when I turn on a lot of LEDs, that the ADC was getting noise. So I moved the wire from the sensor to ground and saw that the noise was still there. Just leaving the LEDs on (instead of turning them on and off) I get a constant reading above zero.

So I'm assuming that the problem is with the draw of the current on the system is causing the ADC to fail? I am using an external analog reference and that seems to help lower this problem, but it would be a great help if I can get rid of this problem all together.

Any ideas? The LEDs are collectively drawing about 80mA.

Thanks,

Adrian

I presume you mean the ADC, not the DAC. You need to separate your ground wiring. Dedicate one of the ground pins on the Arduino to be analog ground, and use it to connect only the ground side of the sensors and any associated filtering capacitors. Use a different ground pin to connect the ground sides of the LEDs or other output devices, and power (if not powering from USB or the barrel jack).

Try using a pull-down resistor on the ADC input... something like 10k should be able to filter out ambient voltage. But this may introduce a bit of distortion, can someone fact-check me on this?

Try using a pull-down resistor on the ADC input

???
But he said that he already connected the input to ground so a pull down resistor across a dead short is not going to do much is it?
DC42 has the answer.
If you can't sort it then post a photograph of your setup.

dc42:
I presume you mean the ADC, not the DAC. You need to separate your ground wiring. Dedicate one of the ground pins on the Arduino to be analog ground, and use it to connect only the ground side of the sensors and any associated filtering capacitors. Use a different ground pin to connect the ground sides of the LEDs or other output devices, and power (if not powering from USB or the barrel jack).

Yeah, I meant the ADC brain fart. :~ Changed the name of the thread and all DAC refs.

I thought that all grounds were the same. This isn't so?

It is a universal untruth that all grounds are created equal.

If a wire has a return current running through it then it is lifted in voltage. If that same wire is used to ground an input from the far end then instead of seeing ground the input sees the voltage created by the return current on that wire.

Ok, well all good to know, but plugging in the ADC into ground was just a test. Moving it to a different ground solved the problem. Now I have another problem. When I plug it into the detection circuit I was using it for, and switching that circuit to a different ground didn't do anything. I'm assuming that the +5 line is being disrupted the same way as the ground was.

These are my two circuits:

Circuit 1:

                        D00  D01   R0
        +5 -----------+-|>|--|>|--'\/\,--+
                      | D10  D11   R1    |
                      +-|>|--|>|--'\/\,--+
                      | D20  D21   R2    |
                      +-|>|--|>|--'\/\,--+
                                         |
      GND1 ---E\ /C----------------------+
              T0|B
                |    RB
                +---'\/,-- pin 12

 Dxy = IR LEDs where x is which sub-circuit and y is which diode
 R0  = 27 resistor
 R1  = 27 resistor
 R2  = 27 resistor
 T0  = transistor PN2222A
 RB  = 100 resistor

Circuit 2:
               PD           R0
           +---|>|-----+---'\/\,-------+
           |           |               |
           |         T0|B              |
           |         E/ \C             |
           |         |   +-+           |
           |       T1|B    |           |
           |       E/ \C   |    R1     |
           +-------+   +---+---'\/\,---+--- AREF
           |               |           |
           +--- GND2       +--- A1     +--- +5


 PD  = IR PhotoDiode
 T0  = transistor BC183
 T1  = transistor BC183
 R0  = 1M resistor
 R1  = 47k resistor

EDIT: Fixed photo diode's direction.

Circuit 2 is a modified version of Sneak Thief from Grumpy Mike (Sneak Thief) where I switched the PD with the R0. This was done intentionally since it appears to give me better sensitivity. And as I am only looking for differences in voltage when I turn on and off pin 12, a small (what I thought was constant) voltage is not a problem. However the fluctuating voltage is disrupting the signal, causing me problems.

I had thought that plugging into the external analog reference would resolve this, but it only helped, not remove the problem.

So I see only one alternative at the moment, and that is to have a some other load go on when the LEDs are off while I'm measuring. Is there a better way?

In that circuit you have drawn you have the photo diode the wrong way round.

No need to use an external referance especially if all you are going to do is connect it up to 5V. Put a large capacitor about 47uF across the supply to the detector circuit.

Grumpy_Mike:
In that circuit you have drawn you have the photo diode the wrong way round.

Oops, finger slip. Thanks.

Grumpy_Mike:
No need to use an external referance especially if all you are going to do is connect it up to 5V. Put a large capacitor about 47uF across the supply to the detector circuit.

That's it? Cool! Will try that! :smiley:

Grumpy_Mike:
In that circuit you have drawn you have the photo diode the wrong way round.

Are you sure? They are usually reverse biased in circuits that I've seen.

EDIT: Now that I put have my glasses on, I can see that the OP's circuit shows the photo-diodes forward biased as Grumpy Mike pointed out. Photo-diodes are normally reverse biased.

Grumpy_Mike:
No need to use an external referance especially if all you are going to do is connect it up to 5V. Put a large capacitor about 47uF across the supply to the detector circuit.

Ok, that didn't work quite right. It caused lagging in the signal which is not what I wanted, but by putting several in parallel around the IR LED emitter circuit it did reduce the problem. I think it stopped the LEDs from stressing the ADC circuit so much.

I'm going to try with a big ass cap tomorrow. I used 5 47uF in parallel, which is the equivalent to 235uF, so I'll try for something 2 - 4 times as big.

I also ditched the amplifier. I got better results by just using a simple voltage divider with a 2-3M resistor on the GND leg and the IR photo diode on the +5.

Thanks for all the help! :smiley: When I have this just the way I want it, I'll post all schematics and code. Is there a place for that here?

adrian_h:
I'm going to try with a big ass cap tomorrow. I used 5 47uF in parallel, which is the equivalent to 235uF, so I'll try for something 2 - 4 times as big.

I also ditched the amplifier. I got better results by just using a simple voltage divider with a 2-3M resistor on the GND leg and the IR photo diode on the +5.

I doubt size is the problem, but speed might be. Small ceramics are much faster than "big ass". Try some ceramics across the terminals of the "big ass" so you combine speed+capacity.

fungus:

adrian_h:
I'm going to try with a big ass cap tomorrow. I used 5 47uF in parallel, which is the equivalent to 235uF, so I'll try for something 2 - 4 times as big.

I also ditched the amplifier. I got better results by just using a simple voltage divider with a 2-3M resistor on the GND leg and the IR photo diode on the +5.

I doubt size is the problem, but speed might be. Small ceramics are much faster than "big ass". Try some ceramics across the terminals of the "big ass" so you combine speed+capacity.

Thanks for the suggestion. I was using electrolytic can types. They were red with a black strip down the negative terminal. I've never seen a red one before. Wonder if they are different from the black ones I normally see.

It caused lagging in the signal which is not what I wanted,

That suggests you did not put it in the right place. There is no way a capacitor on the supply can delay the signal.

Grumpy_Mike:

It caused lagging in the signal which is not what I wanted,

That suggests you did not put it in the right place. There is no way a capacitor on the supply can delay the signal.

Well, I only have two power buses and one is dedicated to the IR LED circuit and the other is dedicated to the detection circuit. And the only difference between them is that each uses a different ground. I don't know what to say. :? I would have to reqire the circuit and rewrite the code to check the data again. I just remember that it interfered with the detection. IIRC, I actually started to get an off signal higer than an on signal.

fungus:
I doubt size is the problem, but speed might be. Small ceramics are much faster than "big ass". Try some ceramics across the terminals of the "big ass" so you combine speed+capacity.

I was thinking about this and I don't remember reading anything that stated that different types of capacitors had different charge/discharge rates. Could you give me some place where I could find such information?

adrian_h:
I was thinking about this and I don't remember reading anything that stated that different types of capacitors had different charge/discharge rates. Could you give me some place where I could find such information?

Straight from the horse's mouth: http://www.atmel.com/Images/DOC0484.PDF

Well, I only have two power buses and one is dedicated to the IR LED circuit and the other is dedicated to the detection circuit. And the only difference between them is that each uses a different ground.

Are the two grounds electrically the same?
Not sure about the two power buses, are they from a different source?
Either way, as I said, that simply can't happen if it is wired as described. Think about it, all that you are doing is adding a capacitor across the supply, this can't affect the signal. What were you seeing that made you think there was a delay.

different types of capacitors had different charge/discharge rates.

Well I would not say they are different charge/discharge rates but the capacitive reactance and effective series resistance are different with different types of capacitors.

Grumpy_Mike:
Are the two grounds electrically the same?

No, different GND pins.

Grumpy_Mike:
Not sure about the two power buses, are they from a different source?

No, same source. What I mean by power bus is that I've got a breadboard with two buses going down each side. I'm connecting the LEDs to one and the sensor to the other. Each connected to a separate ground pin.

Grumpy_Mike:
Either way, as I said, that simply can't happen if it is wired as described. Think about it, all that you are doing is adding a capacitor across the supply, this can't affect the signal. What were you seeing that made you think there was a delay.

Ok, here's my data. Numbers on right of graph are values I've received from ADC, the graph is a representation of those numbers. ON represents when the LEDs are switched on, OFF when they are off:

With no caps:

With 235uF on LED circuit:

With cap on sensor circuit:

It sure does look like the signal is being delayed. That or its being inverted. Oh, BTW, the values were taken when the sensor was partially blocked from the IR LEDs.

fungus:
Straight from the horse's mouth: http://www.atmel.com/Images/DOC0484.PDF

Thanks for this. I'll have to read it later.

Looks like I don't need more caps. Just 3 or 4 of these 47uF were enough. I actually was getting signals from the ceiling when I had all 6 IR LEDs on. :smiley: I may only need 1 or 2 IR LEDs on for this project.