AD236 Gain problem

Discussion in 'The Projects Forum' started by CoHPhasor, May 15, 2013.

  1. CoHPhasor

    Thread Starter New Member

    May 13, 2013
    13
    0
    Hi everyone.
    This is my 1st post here and let me preface, I've searched my brains out. :)

    It's been a while since I was knee-deep in electronics, and I have had to use Op or In amps previously, but I'm shaking off the rust.

    I have an Arduino project where I want to log current in a circuit and am using an AD236AN.
    If I should use something other than an AD236, I'm open to suggestion.
    The circuit is one following this tutorial:
    http://www.vwlowen.co.uk/arduino/current/current.htm
    I tried contacting the author and banged my head on the desk the last few days.

    Goal:
    Make a kit I can insert between a device's PS and the device that will measure the device's current consumption via Arduino and send the data to a logging server.
    I'd prefer to not have to worry about the tested circuit's supply voltage and instead worry about voltage drop across the shunt to calculate current.

    Parts:
    - Arduino Uno
    - AD236AN
    - .01Ω current sense resistor
    - 100 nF ceramic cap
    - 28 turn Variable resistor
    - Testing load source

    I tried this out on 2 different circuits because even 2 LEDs don't have much current draw which means the drop across the shunt is very low. (<2mV)
    With the .01Ω shunt I (attempt to) use a 100x gain meaning the voltage across the shunt with gain100 should be the current of the circuit it's plugged into.
    (The writeup uses gain of 10 and then multiplies that by 10 in the Arduino code)

    The 2 circuits differ in that 1 uses a flashlight bulb(2.4V) and 2 D cells for its power source
    and the other uses 2 parallel LEDs powered by the Arduino 5V with a 110Ω resistor.

    Problem:
    I cannot get the gain to follow the datasheet.
    for gain 100, I should use 1.02KΩ for R1 but instead it comes out to ~gain 200.
    If I instead double up and use 2020Ω it comes out right?
    (I got that from this example sheet of basic InAmps: pg19 http://www.analog.com/static/imported-files/application_notes/AN-244.pdf)

    I know what you're thinking:
    "Who cares? Use the working resistance."
    I'd rather know what is wrong in this circuit, and I want it to be accurate.
    (It bounces back and forth ~5mA right now and it should really be steady)

    Testing:
    I'm using a DMM to verify the current draw in-line between the circuit and ground.
    I only run the LED *or* lamp circuits, never both.

    Thanks in advance:
    I'm sorry to have to post, I really don't like to and prefer to rely on searching/Google, but it's been days and I need help.
    Thanks for looking and/or helping. (And sorry for TL;DR)

    [​IMG]


    [​IMG]
     
  2. CoHPhasor

    Thread Starter New Member

    May 13, 2013
    13
    0
    Ps, I dislike not being able to edit the title or contents of this post, it's an AD623AN.
    The original author got back to me a little bit ago, he says my circuit looks fine and his works properly, god only knows what is going on here. :-\

    Also, I notice that if I measure the lamp circuit, which has a separate power supply I have to give it common ground or it's completely off.
     
  3. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    I think you slipped a decimal point on your LED calculations. The voltage across the sense resistor will only be a few hundred microvolts. Inamp offset voltage may on the same order of magnitude, so you could get a huge error.
    Two D cells in the other circuit puts your inamp supply voltage at the minimum mentioned in the datasheet, and I don't see offset voltage specs at that voltage.

    The app note you referenced doesn't seem to have a page 19.

    Also - with such a small sense resistor, make sure that the amplifier's inputs are connected as closely as possible to the body of the resistor. Otherwise, you wind up measuring voltage drop across the wiring, in addition to the drop across the resistor.The wires to the amplifier don't necessarily have to be extremely short, because insignificant current flows through them.
     
    Last edited: May 16, 2013
  4. CoHPhasor

    Thread Starter New Member

    May 13, 2013
    13
    0
    Thanks for your reply Ron.

    I measured the voltage drop with my DMM across the 10 mΩ shunt and with the lamp it's 6.2mV drop definitely not microvolts.
    The LED circuit on the other hand is @ 230-300uV (my DMM 's lowest setting is 200mV so it pops between .2 and .3, only shows one decimal place on this setting)


    The page reference is indeed incorrect, that was figure 19, not page haha!
    Page 10-6 continued to the top of page 10-7.

    That's excellent advice, I'll try to get it as close as possible.
     
    Last edited: May 16, 2013
  5. CoHPhasor

    Thread Starter New Member

    May 13, 2013
    13
    0
    Now that I've again measured the voltage drop across the shunt I'm somewhat puzzled.
    My DMM claims 6.3mV, but when I connect it in series and measure the current I get ~530+mA.
    If my shunt is indeed .01Ω then I'm somehow off by ~100mA.
    ( 0.0063 / 0.01 = .630)
    Let's say 620-640mV but for me to get 100x gain I had to adjust the pot to 1.863KΩ which should be around 55x gain.

    This has been the case every time I try a different gain as a test, to get the claimed gain I have to go about 2x as high in resistance.
     
  6. crutschow

    Expert

    Mar 14, 2008
    13,052
    3,244
    The shunt impedance of you multimeter in the current mode may be enough to cause the error you are seeing.
     
  7. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    I didn't say the lamp drop would be microvolts. I said LED. Read it again.


    There is also no Fig. 19, but I think you meant Equation 19. Third time's the charm!:D

     
  8. CoHPhasor

    Thread Starter New Member

    May 13, 2013
    13
    0
    Yea, I made an edit that removed some things and left others, lol!
     
  9. CoHPhasor

    Thread Starter New Member

    May 13, 2013
    13
    0
    If that's true then I should be able to set the pot by matching the DMM in voltmeter mode across the shunt, remove it, and the test circuit should show a value 100x what the voltmeter claimed.
    I'll try that out and see where it goes.
     
  10. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    Have you seen this graph from the datasheet?
    With the lamp circuit, you can only get about one volt out of your amplifier, maybe less (with your low Vcc).

    BTW, do you have the ref pin on the AD623 connected to GND?
     
    Last edited: May 16, 2013
  11. CoHPhasor

    Thread Starter New Member

    May 13, 2013
    13
    0
    Unfortunately I don't have a grasp on common mode.
    The REF pin is grounded.
    I imagine the output ceiling could become a problem and it should get accounted for but so far getting enough gain hasn't been the problem, it's getting too much.
    (If I set G to '100' I get more than 100, closer to 200)

    I'll move the sense resistor to between the LEDs and the current limiting resistor.
    The LED circuit is just something to test sensitivity (As the draw should be ~26mA and I'd like to be within +/-5mA).
    I also didn't want to be having problems specifically because I was using a separate power source so the LEDs use the Arduino Vcc.

    The Pandaboards that I'll run through this later have a 5V 5A power supply.
     
  12. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    I screwed up. You already have the sense resistor between the LEDs and the current limiting resistor. I got your two circuits confused.:(
    I'll go back and edit my previous post.
    Common mode is not mysterious. I'm sure you are aware that In+ and In- are at basically the same DC level. This is the common mode voltage. In the lamp circuit, this voltage is zero. In the LED circuit, it is ≈3V.
     
    Last edited: May 16, 2013
  13. CoHPhasor

    Thread Starter New Member

    May 13, 2013
    13
    0
    I've been thinking it the whole time Ron, but forgot to compliment you, your Avatar is insanely awesome.

    I moved the sense resistor to be between the LEDs and ground. (So the jumper for -Vin hits ground)
    I notice I get pretty close to the right value that way and I tried something else that pretty much hit the mark:

    I moved the +Vin jumper from the breadboard (The BB segment held the 2 LED cathodes and the one end of the sense resistor) and I pinned it to the sense's lead closer to the resistor with an alligator clip which pretty much put me spot on.

    I guess I'm going to have to be wicked precise with those lead placements.
    I'll test the lamp circuit this way too and see if it's close to range as well.

    I have to ask, you mention the common mode on the LED circuit is ~3V, how'd you get that?
    (Not that it's inaccurate, I just want to know how to find that out. :) )
     
  14. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    See the first attachment.
    My point was, the way you had it is better. Putting the sense resistor at ground will limit your output to ≈1V, per my attachment in post #10.

    The 2nd attachment is a graphic of the right and wrong ways to connect to the sense resistor.
    Here is a table which contains resistance for various wire gauges. For example, 30 AWG is .103Ω/ft, which is .0086Ω/in.

    Remember that negligible current flows to the inputs of the inamp, so the length of the wires to these inputs is not a problem, except for the fact that they can pick up noise (EMI).

    Glad you like my avatar. It is cropped from a picture of me and my granddaughter, trying on hats in a hat store in Carmel, CA, after a dinner which included a copious quantity of wine.:D
     
  15. CoHPhasor

    Thread Starter New Member

    May 13, 2013
    13
    0
    It finally hit me last night how much I have to worry about the influence of the connecting wires.
    (Just using standard breadboard jumpers)
    First time working with such a low resistance. :\

    my leads have been a couple inches, but I had even gone <1", and trimmed the sense's leads(It's axial and they were ~1"/side) and it was still inaccurate.
    The effect is so great that if I just pull the wires out of the breadboard and pin them high on the sense resistor's leads it changes more still.

    I think I have to suck it up and realize that a trim pot has to be part of the final circuit and the gain shouldn't be calculated but rather calibrated once the circuit is complete.
    (The Arduino does no calculations, it simply displays the reading from Vout)

    Hats in Carmel with your granddaughter?
    That sounds like a blast nothing like having fun with the kids.
    I'm up near San Jose, maybe we'll catch up some time.
     
  16. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    If I wereyou, I would solder the inamp's input leads to the sense resistor, as close to the body of the resistor as possible.
    See my PM re: Carmel/SJ
     
  17. CoHPhasor

    Thread Starter New Member

    May 13, 2013
    13
    0
    That sounds like exactly what I'll have to do.
    I'll have the resistor as close as I can to the IC and solder some maybe 16Gauge leads right up next to the body.

    I appreciate the help Ron, nothin like a helpin hand to stop you from beating your head on a desk.
     
  18. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    As I said before, the sense resistor doesn't have to be particularly close to the amplifier. You just have to solder the wires that go to the inputs as close as you can to the body of the resistor.
    The wires could probably be at least 6" long, maybe longer, if you twist them together.
     
Loading...