Connect with us

Need a little design help on my latest project

Discussion in 'Electronic Design' started by Charlie E., Mar 1, 2010.

Scroll to continue with content
  1. Charlie E.

    Charlie E. Guest

    Hi Guys,
    Ok, going to put myself in harms way, and ask for a little design
    advice. I have been working on this project for a while now, and it
    has gone through several iterations, and I keep having the same
    problem!

    First, the project: I am designing a small color reader for the
    visually impaired. Really simple operation - put it against the
    object you want to tell the color of, and it will say "RED" or
    whatever the color is. Sensor is simply an RGB LED and a
    phototransistor, buffered by some amps, and then digitized by a PIC24.
    So, what's the problem? I can't get a stable reading. In normal
    operation, this thing will run for about two seconds, and then be
    turned off. To test, however, I run it in debug mode for hours. When
    I first turn it on, and calibrate it to a white sample, I will get one
    set of calibrations. Let it sit for about two minutes, and it starts
    to drift. In about half an hour, I will have readings totally off the
    scale.

    So, why am I baring my soul to ya'll? I need your help identifying
    where the gain drift is coming from, and some ideas on how to control
    them. I have the schematic here:

    http://edmondsonengineering.com/Documents/Rainbow color Reader Schematic.pdf

    Basic description - MCU turns on an LED. The phototransistor is first
    buffered by a non-inverting opamp with a gain of 2, and the signal is
    split. Part goes directly to a PGA where it is first attenuated, and
    then the PGA boosts it up. This gives me a calibration control to
    deal with difference in output of the LEDs. The original and PGA
    signal are added, and this is then applied to another non-inverting
    opamp with a gain of 2. I also have one feed before this opamp to an
    ADC input on the PIC.

    Problems I have already solved:
    First, each LED has a different output level. Red needs a gain of
    around 2, BLUE a gain of around 5, and GREEN a gain of about 7. The
    PGA was added to give me an adjustable gain from around 2 to 14, with
    the two different taps into the separate input channels of the PGA.
    This gives me 16 different gain levels to play with. Using the tap to
    the second ADC channel, it actually gives me 32 different levels.

    Right now, RED uses this lower gain channel, and is steady as a rock.
    Part of this may be that my VCC is 3.3 volts, and only RED has a
    forward voltage below this. Both GREEN and BLUE have forward voltages
    of 3.4 volts.

    So, potential problems? could it be that repeated use warms up the
    GREEN and BLUE LEDs so that they become more efficient? Could the
    power supply drift higher as it warms up? Could the opamps drift with
    slight changes in temperature? Any advice ya'll can give will be most
    appreciated.

    Thanks,
    Charlie
     
  2. Charlie E.

    Charlie E. Guest

    Hi Jim,
    Basically, it is whatever the PIC outputs will put out. They are
    rated at 18mA, but I suspect that they are putting out a whole lot
    less...

    Charlie
     
  3. Joerg

    Joerg Guest


    As Jim hinted, the first order of business would be to regulate the
    current that goes through each LED. A resistor that drops only very
    little voltage isn't going to cut it.
     
  4. Charlie E.

    Charlie E. Guest

    So, my first stupid mistake was using a VCC of 3.3 volts with LEDs
    that required 3.4! Not an easy problem to fix.

    Makes me really wish that the PSOC1s had built in debug capability.
    They could run at 5 VDC...

    Charlie
     
  5. Joerg

    Joerg Guest

    It can be fixed. You'd need three step-up (boost) converters and a small
    resistor in front to each and then regulate. If it has to be cheap you
    could try to regulate with the uC. Alternatively one step-up and three
    linear ones but LDOs are often rather buggy and if you boost to 6V or
    more for a proper linear regulation you'll waste a lot of power.

    Yet another option: Supply the PIC with 3.3V or whetever it needs and
    the LED with more. But even with several volts of headroom a resistor is
    not a constant current source. However, you can make a uC-controllable
    current source with two transistors and two resistors per LED, no big
    deal. AoE figure 2.25, just flipped around using NPNs and R1 goes to a
    PIC port pin.

    This will improve things massively. If that's still not low-drift enough
    you can use an opamp current source.
     
  6. Joerg

    Joerg Guest

    P.S.: If the cathodes are tied together the last idea only works if you
    leave the current source up against positive, like in the AoE example.
    Then drive either with a 5V uC or a logic level FET and add a resistor
    from base to positive supply.
     
  7. Charlie E.

    Charlie E. Guest

    Ah, there's the rub. I need a PIC24 for the speech output routines,
    and those are 3.3VDC only. A PIC18 might work, if I could get the
    speech routines to function, but would require a whole different set
    of development kits... :-(

    Charlie
     
  8. Charlie E.

    Charlie E. Guest

    Joerg,
    Thanks for the advice. Yes, I had been concentrating so hard on the
    amplifiers I never really considered the LEDs. In my mind, they would
    just 'work' and I could then adjust accordingly. Didn't realize that
    they would vary that much. Will have to look at maybe adding a higher
    voltage, and go with the constant current drives for them. This does
    need to be pretty accurate!

    Charlie
     
  9. Joerg

    Joerg Guest

    Where is your VCC coming from? Regulator? If so, what's the minimum
    voltage going into that regulator? If it is a battery that won't drop
    below about 4.5V and has low load ripple (low source resistance, added
    capacitors) fixing this part of the circuit would become fairly simple.
     
  10. Charlie E.

    Charlie E. Guest

    Hi Joerge,
    I only have two AA batteries, so voltage is only about 2.5-3.1 volts.
    That was why I added in the power supply, to try and stabilize that
    voltage. Most of the parts were pretty power tolerant, but I figured
    (somewhat correctly) that the LEDs would be pretty voltage sensitive.

    What do you think of this idea? Take an LED driver chip, like an
    LM3519 to do the voltage step up and current control, and then three
    fets to switch that current to each of the LEDs. Means a chip, a
    small inductor and schottkey, a couple of caps, and three fets.
    Shouldn't take up too much board space or budget...

    Charlie
     
  11. Charlie E.

    Charlie E. Guest

    Yeah, I realize this now... ;-)

    this is my first foray into photometry. Wanted something cheap and
    easily reproducible. I just 'assumed' that an LED would give the same
    output with the same drive...

    Oh well, I guess the boss will just fire me!

    Charlie
     
  12. Joerg

    Joerg Guest

    That will require switch mode conversion, no other choice.

    Nope, it ain't quite that easy. It doesn't have an external sense
    resistor and, consequently, the "accuracy" to which it holds the current
    is really horrid. Look at the Iout versus Vin, that's just not good
    enough. If you want to use a chip (or three) you need to find one with
    at least and external Rsense.

    It is usually easier and less expensive to boost that voltage from the
    two AA cells to 5V and add the analog current source circuits I
    mentioned in my other post (one per LED section). The PIC could be
    supplied directly from the AA cell if it's happy with 2.5V.
     
  13. Charlie E.

    Charlie E. Guest

    You are probably right. One problem is that the opamps for the
    phototransistor (ambient light sensor) should also probably stay on
    the battery, to prevent overdriving the ADC inputs for the PIC. There
    are the other LED drivers with an external current sense resistor, so
    will look into the tradeoffs involved...

    Thanks!
    Charlie
     
  14. Charlie E.

    Charlie E. Guest

    Object is to have this as light and small as possible. Using AAs
    instead of AAAs only because Serpak has their little M-6 enclosure
    that fits right. Would weight too much with 3 or 4 AAs...

    Charlie
     
  15. Charlie E.

    Charlie E. Guest

    Yes, that is pretty much what Joerge is suggesting. It looks like I
    will pretty much have a two voltage system - 3.3 for the PIC and the
    detector, probably also the speaker amp, and then 5.0 for the LEDs.

    Charlie
     
  16. Joerg

    Joerg Guest

    The opamps can be handled with series resistors and, if necessary, BAV99
    double-diodes. But if you have suitable opamps you might as well run
    them off the PIC rail.

    I'd really consider just one li'l boost converter that makes 5V. Tons of
    those available. Then current sources for a clean control.
     
  17. Jon Kirwan

    Jon Kirwan Guest

    This is a very important point. I've used LEDs where
    precision was important in several different uses, where we
    hoped for better but have learned a little in the process.

    In one, we had them thermally stable (heated, by design) and
    very precisely current controlled (better than 0.1%) and
    still needed a long, 2-day bake-in testing process to cull
    the "bad ones" which drifted like hell. We'd select only
    those which showed a very gradual change near the end, but
    that was perhaps 2% or so? The rest were tossed out. The
    results were excellent, after that, and they definitely
    served their purposes well. But ...

    In another, which I'm currently doing something to correct
    right now, the exact same part number from the same
    manufacturer "worked great" with about 50% or better passing
    manufacturing testing and then, a few months back, suddenly
    that rate dropped to about 1% or so... and shipping nearly
    came to an abrupt halt. Fixable, but parts change and if you
    don't buy everything you need "today" you might find yourself
    in deep trouble "tomorrow" if you depend upon specs that
    aren't front and center on the data sheet. We didn't have a
    choice here, as the whole thing is basically a bleading edge
    FAB device. But still ...

    LEDs, driven as well as you may wish, current wise, aren't
    what you call "stable." Even adding thermal control doesn't
    eliminate drift. Not even close, for some needs.

    I think Charlie's method needs to be functional in the face
    of, at best, modest current control, led variability, and
    drift over time and ambient temps if it is going to be
    practical. I think that can be done. But I think some
    mathematics will be required here. I'd start with the idea
    of a linear calibration matrix, 3x3 in size, created by a
    quick calibration step and inverted and then applied to the
    data he gathers from then one. Each measurement on his
    system is a 1x3 vector. I've used such methods with
    completely uncalibrated RGB LED products from OSRAM, to make
    excellent use of them that is repeatable and cheaply
    calibrated in less than a few seconds.

    Jon
     
  18. Jon Kirwan

    Jon Kirwan Guest

    then on.
     
  19. Charlie E.

    Charlie E. Guest

    Actually, just found the MCP1252 series - switchable 3.3 or 5.0 boost
    converters (charge pump) that don't need inductors! Two of these will
    be cheaper than the inductor based solution I have now, and give me
    both rails regulated...

    Charlie
     
  20. Joerg

    Joerg Guest

    Careful, the 5.0V version doesn't have any oomph below 3V input and
    AFAIK it quits once Vbat drops below 2.7V. I'd use a real boost
    converter that can comfortably cover your battery voltage range all the
    way to the end of discharge. That one little inductor isn't going to
    kill ya :)
     
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

-