Go Down

Topic: ADC values not zero when plugged into ground and turning on LEDs (Read 2921 times) previous topic - next topic

adrian_h

Apr 02, 2013, 10:21 pm Last Edit: Apr 02, 2013, 10:51 pm by adrian_h Reason: 1
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

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).
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

normanc

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?

Grumpy_Mike

Quote
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.

adrian_h


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?

Grumpy_Mike

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.

adrian_h

#6
Apr 03, 2013, 12:47 am Last Edit: Apr 03, 2013, 01:08 am by adrian_h Reason: 1
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:
Code: [Select]
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 (http://www.thebox.myzen.co.uk/Hardware/Sneak_Thief.html) 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?

Grumpy_Mike

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.

adrian_h


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

Oops, finger slip.  Thanks.


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! :D

afremont

#9
Apr 03, 2013, 01:22 am Last Edit: Apr 04, 2013, 09:20 pm by afremont Reason: 1

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.
Experience, it's what you get when you were expecting something else.

adrian_h


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! :D  When I have this just the way I want it, I'll post all schematics and code.  Is there a place for that here?

fungus


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.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

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.

Grumpy_Mike

Quote
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.

adrian_h

#14
Apr 04, 2013, 07:20 pm Last Edit: Apr 04, 2013, 07:25 pm by adrian_h Reason: 1

Quote
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.


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?

Go Up