Author Topic: Please help solve ramp for op amps!  (Read 9663 times)

0 Members and 1 Guest are viewing this topic.

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Please help solve ramp for op amps!
« on: October 02, 2013, 11:25:20 pm »
Hello,

I have been trying to get an op amp to do the following ramp:

(V1) Input: must be 5Vdc!
(V2) Input: 9 to 12Vdc
(Vout) Output: 3.5 to 6.3Vdc
ra = 10K ohms

With all desperation, I have been trying to calculate resistors r1, r2 and rf for a few days now and it seems that I am not able to do it.   |O
To the point that I think this is not doable!  :o

If someone knows the maths on how to calculate this, please get back. I am not looking for a quick answer (or circuit) calculated by some op amp calculator!
I am looking for the mathematical breakdown to this solution please.   :)

And since typical op amp equations such as the "differential equation" or super position equations don't solve for this... I have adventured myself with in experimental in house maths without success.

I have attempted taking the vout/vin ratio which is:

A=(6.3-3.5)/(12-9) = 0.933

Using this ratio, I tried the math around op amps to get the correct ramp without success!  I have given up!   :palm: :palm:

Can someone please provide some insight on this thanks!



« Last Edit: October 02, 2013, 11:27:53 pm by ilbs »
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #1 on: October 02, 2013, 11:27:52 pm »
Ohm's Law!!!!!!!!!!!!!!!!!!!

The whole thing can be solved with Ohm's Law and a relatively simple system of equations... write out an Ohm's Law equation for each resistor, then solve them together as a system.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #2 on: October 02, 2013, 11:29:01 pm »
Hi, Can you show me how please!
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #3 on: October 02, 2013, 11:30:28 pm »
I'm not going to do it for you, but I can steer you in the right direction. What do you know? Do you know enough algebra to work out a system of equations? Do you know what Ohm's Law is?

The other hint, if you haven't gotten this: an op amp, when not saturated, will "attempt" to keep its inputs equal. So write an equation for each input, then set them equal to each other, then solve for values.

You're not going to get individual values for all three resistors. You'll want to pick two of them and solve for the other two. Alternately, if you find the ratio of the resistors, there are a few calculators online which can select a pair of standard values which meet that ratio.
« Last Edit: October 02, 2013, 11:32:42 pm by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #4 on: October 02, 2013, 11:39:37 pm »
Hi,

I am not that much mathematically inclined. Sorry! But if I see an example I will then know how to do the rest of my ramps!

Yes I know ohms law... but its coming up with the equations that I have trouble!

Quote
The other hint, if you haven't gotten this: an op amp, when not saturated, will "attempt" to keep its inputs equal
yes


Quote
So write an equation for each input, then set them equal to each other, then solve for values.

I always have trouble doing that....  :(

thank you for replying!
« Last Edit: October 02, 2013, 11:42:38 pm by ilbs »
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #5 on: October 02, 2013, 11:44:24 pm »
OK, see if this gets you started.

Ohm's Law, as you know, states that V, the voltage across a resistor, is equal to I, the current through it, multiplied by R, its resistance. So for each resistor, figure out the voltage you want to appear across it at a hypothetical point of operation. Then rearrange, and you have an equation for the current through the resistor.

Assuming the op amp's inputs don't take any current themselves, the current through two resistors in series will be equal, so you can set those two currents equal to each other and thus combine two equations.

You'll need two hypothetical operating points to get a solvable set of equations.

If nobody beats me to it, I'll work through a similar problem (but not the same!!) so you can follow along. But I want to eat dinner first :-+

Also, to beat the peanut gallery to the point, yep, there are other ways to do this. Some require fewer equations. But I'd rather have a simple set of equations that you can be handy with than memorize one for every imaginable situation.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #6 on: October 02, 2013, 11:53:25 pm »
c4757p,

Are you sure its that simple, because don't forget, there's a ramp that needs to be taken into consideration  ???

Anyways, I will wait for your solution as I am very curious  :phew: :phew:

thanks
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #7 on: October 02, 2013, 11:54:52 pm »
Positive. (Pun maybe intended.)
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #8 on: October 03, 2013, 12:39:22 am »
OK. I actually did it differently. I figure this way is more intuitive, and works for pretty much any op amp scaling application.

Note that no matter what funny business you have going on with voltage shifts and such, the op amp can't see "ground". So you pick a point to call "ground" that makes the problem look conveniently like a simple amplifier with gain, and there is always one.

Here, I'm inversely scaling voltages, 1 to 5V scaled onto 10 to 7V, using the inverting topology. First, I compute the gain of the amplifier, then I pick the ground point, then I pick resistors to give those.

WARNING!!! I got R1 and R2 backwards, at the very end. It should be R1 = 100k, R2 = 75k, R2 = 3/4 R1. Everything else is correct and has been verified as such.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #9 on: October 03, 2013, 12:45:46 am »
And LTspice likes it! (Can't be bothered to dig out the breadboard...)
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #10 on: October 03, 2013, 03:20:16 am »
Hi c4757p,

You are talking to a veeeeeery slow guy here.... more than you can imagine!!!    :D

Okay, so, I fully understand your calculations when we have the input signal ramp at the inverting input. Your calculations make sense and there is other ways to get the same result.... such as shown at "rampAlt" attachment below.

But that's not my problem.... The problem I have is when we put the ramping signal at the non-inverting input and provide the constant voltage at the inverting input...
See second attachment below "oddRamp2" where I tried to do your example by following your directives but this time 1 to 5 volts is at the non-inverting input and the constant voltage of 15Vdc is at the inverting input. Somehow, I get lost just about here! 

This is why I asked about that *specific* example !!!!

Anyways, I don't have LTSpice... perhaps I should get it..... wonder if its expensive  :-\
If you can do me a favor... and see if your calculations actually work with my specific example... it would clarify my confusion!

Thank you very much for your help!
« Last Edit: October 03, 2013, 03:47:58 am by ilbs »
 

Offline Andy Watson

  • Super Contributor
  • ***
  • Posts: 2082
Re: Please help solve ramp for op amps!
« Reply #11 on: October 03, 2013, 09:31:48 am »
I think c4757p's  intuitive approach is the right one, attempting to solve one huge equation can hide the action of the circuit. Try this: Calculate what V2 should be to give 5V at the output.  5V was not an arbitrary choice, it will enable you to specify (assuming an ideal op-amp) the voltages at all the nodes in the circuit. Now you can find the ratio of R1:R2.
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #12 on: October 03, 2013, 01:29:10 pm »
Dammit, I forgot about this thread... I'll be back in about two hours and I'll look over that.

Quick glance: you are using the wrong equation for gain. It is different for a noninverting amplifier.
« Last Edit: October 03, 2013, 01:45:21 pm by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #13 on: October 03, 2013, 02:29:18 pm »
This one is a bit harder. I'll get you started - if you're "not that much mathematically inclined" you might not see where to begin with this one. Here's what I did.

Vin is being multiplied by Gain1 (this is the "gain" - less than one - from the R1/R2 voltage divider), then by Gain2 (the op amp gain) around a virtual ground.

You already know Vgnd (it's 5V), so we can work backwards:

(Vin Gain1 - Vgnd) Gain2 = (Vout - Vgnd)
(9 Gain1 - 5) Gain2 = (3.5 - 5)
9 Gain1 Gain2 - 5 Gain2 = -1.5

There are multiple solutions to this problem! We know: Gain1 is between one and zero noninclusive (because it's a voltage divider!) and Gain2 is greater than one (because it's a noninverting op amp!). So pick one of them to be a number you like and solve for the other. (Hint: Not all combinations work! Remember those constraints - if you get an answer outside them, try again.)

Best to find all the gains and shifts, then write an equation for them, then start banging on it!

LTspice yet again approves of my solution! But I'm not showing you my values >:D
« Last Edit: October 03, 2013, 02:38:35 pm by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #14 on: October 03, 2013, 02:34:53 pm »
Anyways, I don't have LTSpice... perhaps I should get it..... wonder if its expensive  :-\

Less than a cup of bad coffee, food poisoning from Taco Bell, or a free puppy. And better than at least two of them.
« Last Edit: October 03, 2013, 02:40:02 pm by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #15 on: October 03, 2013, 03:33:51 pm »
 :(
Don't understand!

Thanks anyways
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #16 on: October 03, 2013, 03:40:45 pm »
(Vin Gain1 - Vgnd) Gain2 = (Vout - Vgnd)
(9 Gain1 - 5) Gain2 = (3.5 - 5)
9 Gain1 Gain2 - 5 Gain2 = -1.5

There are multiple solutions to this problem! We know: Gain1 is between one and zero noninclusive (because it's a voltage divider!) and Gain2 is greater than one (because it's a noninverting op amp!). So pick one of them to be a number you like and solve for the other. (Hint: Not all combinations work! Remember those constraints - if you get an answer outside them, try again.)

The first thing I said to do after this point was to choose a number for one of the gains, within the specified limits. Pick a few! What are your choices?

As far as the equation I started with, I just wrote a description of the relationship between input and output:

First Vin is multiplied by the gain of the voltage divider:
Vin Gain1

Then, the op amp sees it as being relative to the virtual ground:
Vin Gain1 - Vgnd

This is then multiplied by the gain of the op amp:
(Vin Gain1 - Vgnd) Gain2

To give the output voltage, again relative to the virtual ground:
(Vin Gain1 - Vgnd) Gain2 = Vout - Vgnd
« Last Edit: October 03, 2013, 03:53:56 pm by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #17 on: October 03, 2013, 04:09:19 pm »
Quote
As far as the equation I started with, I just wrote a description of the relationship between input and output:

First Vin is multiplied by the gain of the voltage divider:
Vin Gain1

Then, the op amp sees it as being relative to the virtual ground:
Vin Gain1 - Vgnd

This is then multiplied by the gain of the op amp:
(Vin Gain1 - Vgnd) Gain2

To give the output voltage, again relative to the virtual ground:
(Vin Gain1 - Vgnd) Gain2 = Vout - Vgnd

Good explanation ^-^....  I at least now I know where you are coming from.... Thanks you for this  ;D


Quote
There are multiple solutions to this problem! We know: Gain1 is between one and zero noninclusive (because it's a voltage divider!) and Gain2 is greater than one (because it's a noninverting op amp!). So pick one of them to be a number you like and solve for the other.

In reference to attachment.... so I picked 0.5 as Gain1, this solves for Gain2 as the gain of the amplifier which is -0.375... I assigned it to the rf/ra resistor gain and this didn't work!!!

So, now what...  I have to pick another value other than 0.5 and re-try again ?   :-//
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #18 on: October 03, 2013, 04:11:40 pm »
This was exactly my first step. Instead of different numbers, try changing your method a bit - pick a Gain2.

Be careful with your math there - somehow you picked a value for RF even though Gain2 was negative! That should not be possible. This is a non-inverting amplifier, the gain is positive by definition.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline Sigmoid

  • Frequent Contributor
  • **
  • Posts: 488
  • Country: us
Re: Please help solve ramp for op amps!
« Reply #19 on: October 03, 2013, 04:18:51 pm »
If you have trouble with algebra, you'll suffer a lot with electronics.
Really, try to bring yourself up to speed. It's not avoidable.

As for op-amps, the model that finally really made me understand them is the following:



G is the open loop gain, expect it to be something gigantic.
As you see, Vout of the amp is (Vin+ - Vin-) * G.

Now, if you feed that back into Vin-, you have a control loop! And everything you learned about control theory comes to life.
Of course if you haven't learned control theory, it's prime time - after you've mastered basic algebra. ;)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #20 on: October 03, 2013, 04:38:36 pm »
Boff !!!  :palm: :palm:

Picked a Gain2 as 2.... still doesn't work for me!  :-[

see attachment!
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #21 on: October 03, 2013, 04:44:29 pm »
You calculated RF wrong! Remember - noninverting amplifier. Different equations.

Your gains are right, though.
« Last Edit: October 03, 2013, 04:48:22 pm by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #22 on: October 03, 2013, 06:00:31 pm »
gain for non inverting is:

(r2/(r1+r2))(1+rf/ra)
(0.472222)(1+2)
1.41666

if I make rf 1.4166 of ra, this still doesn't work  ...

and if I take the difference of the gains:
(2-0.4722) = 1.527777 and use this in the gain for non-inverting input like this:
(4722/10K)(1+1.52777)
1.1936

an rf/ra gain of 1.1936 is close but not precise at all... which means it still doesn't work!

Not sure if this is the way to do it  !

confused
« Last Edit: October 03, 2013, 06:26:53 pm by ilbs »
 

Offline Galaxyrise

  • Frequent Contributor
  • **
  • Posts: 531
  • Country: us
Re: Please help solve ramp for op amps!
« Reply #23 on: October 03, 2013, 06:13:58 pm »
Try not to think of opamps in terms of set equations for gain and what-not.  opamps raise their output voltage when the voltage at the inverting input is lower than the voltage at the non-inverting input, and they lower their output voltage when the voltage at the inverting input is higher than the voltage at the non-inverting input.  That's it, really, and everything else follows from that.
I am but an egg
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #24 on: October 03, 2013, 06:35:08 pm »
It's only that simple if you find algebra intuitive. Sometimes it can be approximated as a fixed-gain system just fine.

I'll look more later.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #25 on: October 03, 2013, 07:17:35 pm »
I think it has more to do with:

vout=V2(gainNon-inv) + V1(gainInv)

I will also look more .... but tomorrow  ;)
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #26 on: October 03, 2013, 08:21:30 pm »
gain for non inverting is:

(r2/(r1+r2))(1+rf/ra)

...the hell'd you get that from? Fix that equation and your problem is solved...
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #27 on: October 03, 2013, 09:28:41 pm »
don't know how... that's why I'm here....
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #28 on: October 03, 2013, 09:31:11 pm »
Just Google "noninverting amplifier"! Then click through to the almighty Wikipedia, where you see this:




Try your math again with that. Your R1 and R2 have nothing to do with Gain2, the amplifier gain - they only affect Gain1, the attenuator gain.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #29 on: October 03, 2013, 09:56:24 pm »
try my math again with what???

you said my gains are right!
and you said rf is badly calculated!

so if it has nothing to do with gain 2, so then
it has to do with gain1 which is
0.4722222 so is it:

V2(1+0.472222)
9(1.47222)
13.24

so what does 13.24 have to do with this....
look.... I'm am obviously trying here...
I am not being lazy!!! I just don't get
this stuff the way you are trying to
explain this.

Does anyone have any detailed
help on this please....

thank you


« Last Edit: October 03, 2013, 09:58:40 pm by ilbs »
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #30 on: October 04, 2013, 03:03:53 am »
Gain2 = 1 + RF/Ra

Your R1/R2 are correct. Though you might want to try picking values closer to standard ones.
« Last Edit: October 04, 2013, 03:12:52 am by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #31 on: October 04, 2013, 03:49:16 am »
if gain2 = 2

and if you are saying that gain2 is:

(1+rf/ra)

then
ra should = 10k

and

rf should also = 10K

therefore:

if r2 = 4722, then va should = 4.24999998
and therefore vb should also = 4.24999998
which works out to:

Vra and vrf = 0.75000V and therefore:
5-0.75000-0.75000 = 3.5vdc

Is this correct.... I am not at the lab
so I can only test this tomorrow
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #32 on: October 04, 2013, 03:52:13 am »
If I remember correctly, yes. I didn't save my data, but it looks good.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #33 on: October 04, 2013, 03:54:40 pm »
One last question,

concerning:

Quote
You already know Vgnd (it's 5V), so we can work backwards:

(Vin Gain1 - Vgnd) Gain2 = (Vout - Vgnd)
(9 Gain1 - 5) Gain2 = (3.5 - 5)
9 Gain1 Gain2 - 5 Gain2 = -1.5

Why are we presuming that Vgnd is 5Vdc, is it because we know the inverting input is 5V??

Because I tried setting Vgnd to 6 Vdc and that didn't work anymore   :(
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #34 on: October 04, 2013, 04:03:30 pm »
The inverting input is the virtual ground. Note that in the usual noninverting arrangement, that point would go to real ground, not a voltage input.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #35 on: October 04, 2013, 04:37:56 pm »
c4757p,

While we are in a lengthy thread, I may as well ask. I have no trouble with algebra, I have done up to college math including calculus. But my usual problem
is defining the equations. Like many (I'm sure) coming up with the equations can be real tough.

How do you guys come up with these equations.... I mean there must be some sort of a rationalization for one to come up with:

(Vin x G1 - Vgnd)(G1) = Vo-Vgnd

In the grand scheme of things (and correct me if I am wrong) the above formula is an intention to make a point in the circuit equal to another point in
the circuit while knowing that these two points MUST be equal,   right?

In other words, I am sure there are other solutions ... but I don't see any other... I think this one would be wrong:

(Vin x G1 - Vgnd)(G1) = V1-Vgnd

are there any other equations we could of written for this?




 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Please help solve ramp for op amps!
« Reply #36 on: October 04, 2013, 05:00:11 pm »
I have no trouble with algebra, I have done up to college math including calculus. But my usual problem
is defining the equations.

That's a common position to end up in. It often takes some experience and intuition to know.

Quote
How do you guys come up with these equations.... I mean there must be some sort of a rationalization for one to come up with:

(Vin x G1 - Vgnd)(G1) = Vo-Vgnd

In the grand scheme of things (and correct me if I am wrong) the above formula is an intention to make a point in the circuit equal to another point in
the circuit while knowing that these two points MUST be equal,   right?

Yep, you got it! :-+ It's just a description, in "algebra language", of what I expect to see at a bunch of points in the circuit. The piece-by-piece explanation that I gave a couple posts ago was pretty much exactly my thought process when I wrote it.

Quote
are there any other equations we could of written for this?

Plenty! You could have gone the pure Ohm's Law route which I originally (foolishly) suggested - I forgot, with that many resistors it often ends up a bit complicated. You'd end up with a system of multiple equations, which I'd probably just toss into MATLAB for a solution :P
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ilbsTopic starter

  • Contributor
  • Posts: 39
Re: Please help solve ramp for op amps!
« Reply #37 on: October 04, 2013, 05:04:04 pm »
c4757p,

I learned a lot in this thread  ;D


Thanks for your help  :-+ :-+ :-+
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf