Shop OBEX P1 Docs P2 Docs Learn Events
Op amp/Regulator math — Parallax Forums

Op amp/Regulator math

Erik FriesenErik Friesen Posts: 1,071
edited 2010-12-19 09:12 in General Discussion
tps79901.jpg


I need a dual voltage regulator. What I want to do is set R1 & R2 so I get an output of 4.5V, lets say, then add another resistor to FB, which I can drive using an output from my micro, to give me an output of either 4 or 5 volts. I could do the math easier if I just let the pulled the pin low, or let it float, but I want to drive the pin high and low. This is regular op amp math, I know, but I have a tough time getting the three ways in my head.
374 x 238 - 32K

Comments

  • kwinnkwinn Posts: 8,697
    edited 2010-12-17 12:07
    First thing needed to know is the output voltage on your micro's output pin when it is high and low ( is Vdd is 3.3V or 5V ). Then you can calculate values of R1 and R2 when the input resistor (Rp) has a high or low coming from the micro's pin. R1 and Rp would be in parallel when the pin is high, R2 and Rp would be in parallel when the pin is low.

    Problem is a single resistor value will not allow you to go from 4.5V with the pin in hiZ state to 5V when it is high and 4.0V when low.
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2010-12-17 13:11
    I didn't think of it that way. Thanks. I don't want to tristate the pin. All I am after is two voltages. Thats works out by my figures to a 200k, 68k, and 17k resistor. I don't suppose that will cause any odd oscillation, will it?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-17 13:29
    Erik,

    I hope this isn't the voltage regulator that supplies the micro. If it is, the level of the high output will change, and you will get oscillation. If that's the case, use the output pin to drive a MOSFET to pull the bias resistor low or to let it float.

    -Phil
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2010-12-17 13:34
    Its a regulator for driving a small lamp. My math is wrong above, will get it right soon. That does complicate the math a little more, because there will be 5v into r3, and 4v into R1, if I have this right.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-17 15:26
    If it's just for a lamp (either incandescent or LED -- doesn't matter), why not simply PWM it at the higher voltage, and call it good?

    -Phil
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2010-12-17 16:19
    Erik,

    This may be what you are after. You are right, this is op-amp-type DC feedback math.

    circuit.png


    This is from basic principles. The current i3 is the sum of currents i1 and i2. (Kirchoff's current law) Note that the currents have associated reference directions, and a current is positive if it flows in the direction of the arrow and negative if it flows against the arrow. (Pleeeeease, no one break in to argue about which way the electrons are hustling along!) Each branch obeys Ohm's law, that is, the current through the resistor is I=V/R, and the equations show that the V's are differences. V2 is the input from the Prop (it is a Prop, right?) at either 3.3 or 0 volts. Plugging the branch equations into the node equation gives the 5th equation in the picture.

    Now turn that into two equations by plugging in the desired voltages: 1) Vo=5V when V2=0V, and 2) Vo=4V when V2=3.3V. The reference for the regulator is always V1=1.193V, and feedback will act to make that true. Now you have two equations in three unknowns, R1, R2 and R3, but as is always the case, you can find two resistor ratios, and the absolute values are open to selection based on other criteria such as current drain or secondary effects. When I solve it, I get
    R3 = 3.3 * R1 and R2 = 0.346 * R1

    (the details and veracity check are left to the reader :cool:!
    382 x 334 - 10K
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2010-12-18 04:39
    Thanks. Figuring it by current flow is a good way to get the concept. My math now aligns with yours. For 5 volt operation that will be R1 = 100K, R2 = 33.43K, R3 = 500K.

    Its not a prop. I feel a little guilty about using parallax forums. These forums have a level of patience, and knowledge that does not exists on others, therefore I like using it.

    @Phil. You can read the app notes I am using here - http://www.alphasense.com/pdf/NDIR/AAN_202-03.pdf

    I considered pwm, but my gut says this is a cleaner method. Why set it up to use pwm when I only need the full 5v 2min a day? It has to do with keeping a halogen lamp from plating out. ref http://www.alphasense.com/pdf/NDIR/AAN_205-02.pdf
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2010-12-18 12:48
    Hi Erik,

    IMO. There is never a reason to feel guilty about using this forum to discuss fundamental notions in electronics. As you phrased it, it is regular op-amp math.

    I agree with your solution, given that your control voltage is 5V instead of 3.3V:
    Vo = 5V or 4V, V1 = 1.193 and V2 = 0V or 5V.
    R3 = 5 * R1 and R2 = 0.334 * R1, so,
    R1 = 100k, R2 = 499k, R3 = 33.2k using standard 1% values.
    The two defining equations solved for those ratios are:
    (5 - 1.193)/R1 + (5 - 1.193)/R2 = 1.193/R3 for 5V output
    (4 - 1.193)/R1 + (0.0 - 1.193)/R2 = 1.193/R3 for 4V output
    Note that with resistor values that high, the bias current of the regulator feedback pin may have to thrown into the equations for best accuracy. I see that the bias current of the TPS79901 is bounded by +/- 0.5 µA, so the error due to the bias current will be about +/- 0.05 V at the output (100kΩ * 0.5E-6µA).
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-18 13:33
    Hi Erik,

    Reasons to use PWM:

    1. It uses fewer parts: just a MOSFET, assuming your micro can produce the requisite PWM waveform.

    2. It uses less power: no (Vi - Vo)*I losses from the regulator.

    3. You can soft-start the filament, thus prolonging the life of the lamp.

    -Phil
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2010-12-18 13:50
    I want to use a regulator anyway though, because the voltage I am regulating from is 6 volts coming from a switching supply that is somewhat noisy. Running it through a 5 volt reg cleans it up a bunch. The idea is to keep as much noise as I can away from the sensor. The min - max levels are 20-50mv pp riding on a dc about 1 volt. I should try it, I guess, I just don't feel like I understand the effects of pwm on the system as a whole, including overall bulb output levels. Have you ever done the ndir thing? or similar? It would be a fun project to try on your own, if you could find the appropriate filter and receiver.

    I still like the challenge of getting this stuff figured out, whether or not pwm.
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2010-12-18 14:43
    I don't know, Phil, this is an NDIR sensor that asks to be driven by a stable, low noise voltage source. The lamp is to be turned on and off at a frequency of 2Hz. PWM directly to the lamp at a high frequency could certainly regulate the lamp intensity and turn it on and off, but I'd wonder about noise, and getting the power just so. Straying from the data sheet examples might be dangerous! It would still need to PWM a regulated voltage source, so the number of parts wouldn't really improve. Good point on the soft start. There is still the fact that it has to be turned on and off at 2Hz, and the reason for running it at 4 V instead of 5 V is to increase the life of the lamp.

    Another approach to the voltage control would be a digital pot controlled by the µC.
  • kwinnkwinn Posts: 8,697
    edited 2010-12-19 09:12
    I think the simplest way to do this is to use the prop pin as either a low output (gnd) or hiZ (no connection). Now you can calculate the value of R2 for a 4V and a 5V output. The actual R2 would be the higher value resistor, and R3 would be the resistor placed in parallel with R2 to produce the lower value resistor.
Sign In or Register to comment.