Connect with us

Resolve sub-millivolts with a PIC?

Discussion in 'Electronic Design' started by mike, Dec 11, 2010.

Scroll to continue with content
  1. mike

    mike Guest

    Resolve sub-millivolts with a PIC?

    This is a one-off project.

    I want to measure the output voltage of a peltier device.
    I have access to both wires. Voltage is under 10mV.
    I'd like 7 bits or so of precision.
    I said "precision". I don't care nearly as much about
    the accuracy, I can calibrate that out.
    Needs to have short term stability at fixed temperature
    long enough to get from calibration cycle to measurement
    I want to cobble this onto an existing project that uses
    a PIC16F627 to send data out the serial port.
    It has no A/D converter. I really don't want to add
    instrumentation amps to boost the signal anyway.

    I've been looking into ways to generate a voltage
    with the PWM, stack the peltier device onto that,
    stuff it into the comparator...and "fix it in software".
    I fear that I'll never get the system noise down to the
    point where this is practical, but never hurts to ask.

    Yes, I know that a couple of thermistors would be easier
    to manage electrically, but much more difficult mechanically.
    The Peltier device is just the right mechanical configruation
    for what I want. And I have it in my hand, as do I the
    pic16F627 system.

    I'm not much interested in advice on using different devices
    or technologies. I can think of lots of 'em. I can get what I want
    with an IR thermometer and a calculator, but I'm bored with that.
    I'm interested
    in using what I already have to get me where I want to go.

    A technique to measure small voltages would have general
    applicability to other situations.

    So, any clever ways to resolve sub-millivolt signals with a PIC
    (without internal A/D) and not
    much else?

    Thanks, mike
  2. Joerg

    Joerg Guest

    You meant "resolution"? Precision is usually something absolute :)

    Have you looked into dual slope AD conversion? Essentially your PIC
    (hoping it has at least a comparator ...), plus a couple resistors and a
    cap. I think Microchip even has an app note about that. The resistors
    set the scale factor.
  3. Jon Kirwan

    Jon Kirwan Guest

    I think I was fine with his usage. He used the term to
    assure the rest of us that he, himself, wasn't confused about
    the idea of accuracy vs precision. Which was wise.

    I don't like your phrasing, but I won't bicker. Others can
    come to their own conclusions. But since you took issue,
    I'll use that as a foil to just put out a few words and let
    folks comment on their own understanding of each of them:


    Three of those can be considered independent concepts that
    can stand alone (the other two are dependent entirely upon
    developed relationships between particular pairs of those

  4. nospam

    nospam Guest

    Sounds like you have been trying to invent a delta sigma converter.
    If your input is stable you can average out noise. The comparator input
    offset stability is probably the limiting factor.
  5. Not particularly clever, but that part has some rather crappy
    comparators built in (10mV Vos maximum).

    You could make a slope converter using a resistor as an almost
    constant current source, a capacitor, and time transitions.
    Probably a few resistors, a cap, a 4053 or even a 2N7002 and that's
    about it.

    I can't be bothered to think too much more about this, since it's such
    an artificial constraint-- almost like a classroom exercise.

    Best regards,
    Spehro Pefhany
  6. Frank Buss

    Frank Buss Guest

    There is an application note about delta sigma AD conversion:

    I wonder if dual slope woul be possible with passive components (besides
    the PIC and the internal comperator), only. You do need at least one switch
    for switching the input voltage you want to measure?
  7. mike

    mike Guest

    I mentioned temperature only in the context of the voltage measurement
    system stability.

    Heat flow is exactly what I want to measure.

    Both ends would have to be prettyI believe the surfaces represent the proper measurement conditions.
    and you'd have to know one temperature, for the
    Again, it's heat flow. I don't care about either temperature.
    I've been considering using the peltier device
    to drive its own voltage to zero. The heat flow through the device should
    be a function of the energy input required to achieve zero
    open-circuit voltage...if I can successfully factor out
    the efficiency/self heating of the device. Thermal time constants are
    long enough that I should be able to multiplex the stimulus and measurement.
  8. mike

    mike Guest

    Thanks for the link, but I was hoping for something more clever.
    For example, I should be able to return the peltier device to
    the reference instead of ground. That way, the whole counter resolution
    can be spread over the maximum input voltage plus the comparator offset
    plus the loading effects on the reference.
    Maybe parallel two more outputs across the peltier device so I can PWM
    some energy into it to drive its voltage to zero.
    I haven't figured it out yet, but my gut tells me something interesting
    can be done with the 10-bits of the pwm/ccp module.
  9. mike

    mike Guest

    I knew that would be an issue. I agonized over it before changing the
    subject to "resolve...". I think "precision" works in this context
    as one could include the noise issues that degrade the precision
    from the number you'd expect to get from the resolution alone.
  10. Joerg

    Joerg Guest

    That is a very good one.

    Can't find the Microchip example back, I think it was call PIC
    multimeter or something like that. Very simple, just the uC and some
  11. Joerg

    Joerg Guest

    PWM is the way to go, but your VCC for the uC must be super precise if
    you want to do that without any external parts. If it ain't then I'd
    consider a TLV431 or LMV431.
  12. Frank Buss

    Frank Buss Guest

    Maybe this one?

    They don't mention "dual slope", but of course it is the dual slope
    concept. But you can't measure an input voltage with it, only resistance,
    so something for converting small voltages to a resistance is required,
    maybe a FET?
  13. Jamie

    Jamie Guest

    It almost looks like you're looking for a kelvin bridge input?
  14. Joerg

    Joerg Guest

    You can also do it for voltage measurements, without needing an external
    mux. I can't find the Microchip note back but here is the one from NXP:
  15. Frank Buss

    Frank Buss Guest

    Ok, but you'll need an internal mux :) But this is possible with the
    PIC16C62X, too.
  16. Joerg

    Joerg Guest

    Ok, but so far the uCs I had to deal with had a mux in front of the
    comparator. A uC without one wouldn't be all that useful to an analog
    guy like me :)

    Essentially that's just about the only way to zero out the comparator
    input offset which is usually quite horrid in uC. Well, back to my new
    toy now, this one just arrived:

    So far (except for a rather serious amplitude setting glitch) it's been
    quite impressive.
  17. mike

    mike Guest

    Thanks, but I've been woefully inadequate at getting my point across.

    The methods suggested are charge balance measurements.

    A sigma-delta converter is a big bucket. There's a hole in the bottom
    and the size of the hole represents the quantity being measured.
    You sit at the top and teaspoon more water in to keep the water level
    constant. The number of teaspoons per unit time has to equal the
    volume of water running out the bottom.

    Similarly, a single slope converter lets the water level fall to
    a threshold and you dump a whole lot of water in the top to bring the
    level instantly back to the top threshold. Same concept, bigger
    spoon and you only do it once/cycle. Time measurement vs count...

    These are both current controlled devices. You're measuring the current
    produced thru the resistor from the input to the reference voltage for
    and the current charging the cap in the slope converter.

    Neither of these are very helpful when you want your input voltage
    dynamic range to be half the offset spec of the comparator.

    In the sigma-delta case, it's like trying to keep the level in a
    5-gallon bucket constant by pouring from a peanut butter
    jar into a straw sealed into the top of the bucket without a funnel.
    Some of the water gets in, some doesn't. The "slop" in the system
    exceeds the quantities being measured.

    What I'm looking for is a CLEVER topology that gets rid of the slop.
    It's the funnel in the above analogy. You're more likely to find
    such an item in a patent disclosure than in "A/D for dummies".

    The obvious "funnel" is a voltage to current converter that gets
    the signal into the proper paradigm for these types of converters.
    Might even be able to do it with a modified current mirror.
    The nice thing about current is that the voltage on the cap keeps
    changing until it reaches the threshold...even if the threshold ain't
    exactly where you expect it. You can calibrate out systematic
    errors. You can't do nothin' if the voltage never gets to the threshold.

    Somebody asked for numbers. The numbers I gave in the first post
    are what I want. 10mV full scale and 1% resolution.
    But I did dig out a real voltmeter. I wrapped the peltier device
    in cellulose...aka a paper towel, stuck it into the plastic lid
    of a spray can and set it on the desk. After a LONG time,
    the voltage did settle to about 100nanovolts. That's the best this
    old meter can do. I was surprised it did anywhere that well as I
    took zero precautions to balance the thermals in the interconnect.
    I can see significant voltage transient if I flex the coax that connects it.

    If I take it out of its cocoon, the voltage is all over the place.
    Stick it on a window with 14F inside/outside temperature differential,
    voltage goes to 100mV or so and dribbles down to about 2mV. It's the
    2mV I want to measure. my 1% resolution is worth 5% at 20% of FS.

    All seems consistent with my initial estimates.

    The back story is this...
    I got a new gas furnace and a bunch of insulation added to the house.
    I've been graphing heat input.
    Consistent with my minimalist approach, I used a flapper on
    a microswitch sitting on a vent and plugged into the serial port
    of a Palm IIIc...and fixed it in software.

    I've been seeing significant anomalies that I can't explain by outside
    air temperature fluctuations.
    Consistent with my lazy approach, the measurement system was a bottom-up
    design...who am I kidding, it wasn't designed, it was evolved...
    I had no idea what I was measuring. After I did the math,
    I discovered that the system has a RESOLUTION of 17 BTU. I don't claim
    that it's anywhere near that accurate, but it does resolve well.
    Turns out that I can see when the computer goes into standby or when
    I'm watching TV mirrored in gas consumption.

    By this time, I'm into measuring losses. My windows are specified
    as R3.125. But I didn't measure anywhere near that high. And when
    I added R5 foam on the outside the improvement was more than I expected
    from R8.125/R3.125. That's where all the peltier device stuff started.

    So, I have no idea how they measure the insulating capabilities of
    windows, but the numbers seem optimistic.
    This is an interesting reference:

    It's the operator/application manual for their IR thermometer
    tweaked to measure building heat loss.

    If you sandwich the window between two metal plates and measure R, you get
    a small number. If you measure ambient air temperature in still air
    on both sides, you get a much bigger number. If you use the method
    outlined in the link, you get a third number.

    There are all kinds of issues with boundary layers, convection, wind
    etc. on both sides
    of a window. I started looking into those effects. And I need some
    repeatable method to measure it.

    Why do I want to do this? Because I can...and I'm bored.

    Still looking for that clever way to resolve small voltages with
    no hardware.
  18. Frank Buss

    Frank Buss Guest

  19. Frank Buss

    Frank Buss Guest

    I don't know much about analog electronics, but IIRC the idea of the dual
    slope converter is to cancel out any inaccuracies of the comparator,
    because it is a ratiometric measurement.

    I've done a quick amateurish test: A 12 V Battery powered LM393: At
    inverting input a voltage devider with two 10 k resistors and at the
    non-inverting input two 33 k resistors and a 2 k potentiometer for setting
    the raw offset, and a 100 ohm potentiometer in series for fine tuning. Some
    100 nF and 1 uF at the inputs to ground, to avoid oscillating and noise. At
    the output a LED and a 1 k resistor to +12 V.

    Then I was able to switch on the LED with very small movements of the 100
    ohm potentiometer. Sometimes the LEDs blinks, faster if I move the hand
    some cm near or away the circuit, so maybe more shielding and better setup
    is required. But I measured the difference of the potentiometer when it
    switched the LED on and the calculated voltage change was below 0.2 mV
    (hystereses was much larger with my setup).

    I think the resolution depends on the voltage gain and the short-term
    stability. The LM393 has a minimum voltage gain of 50 V/mV, so you could
    measure with a resolution of 0.1 mV, if you need 5 V output. Is it possible
    to cascade two comparators without problems?

    The PIC16F627 datasheet and the comparator has +/-10 mV maximum input
    offset voltage, but I didn't found anything about the gain. But maybe for
    high precision dual slope measurement you'll need an external comparator
  20. TheJoker

    TheJoker Guest

    The brand says it all.

    Sounds like "Qwacko". Bwuahahahahahahaha!
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day