Using analog computer to solve 2nd-order diff eq

In summary: I think the differential equation [1] solves out?Yes, the equation will solve for x(t). However, you will need to use some trigonometric methods to solve for the actual frequency and amplitude of the waveform.
  • #1
dilloncyh
39
0
I'm trying to build a circuit to solve the differential equation x''+2x'+x = f(t), where f(t) is a sine wave with frequency 5Hz and amplitude 0.5V. I am supposed to get a sine/cosine wave (as the diff. eq is just the same as the ove governing spring-mass forced oscillation) as solution, but instead I get a delta function every 0.1s with alternating sign. What's wrong with my circuit? How should I modify it to get the solution I want, and what else do I need to pay attention when solving any 2nd-order diff equation with constant coefficients in general?

PS: I'm actually a 1st-year physics student with very little prior experience in circuit. Sorry if this question sounds stupid. thanks
 

Attachments

  • 2nd order diff eq.jpg
    2nd order diff eq.jpg
    26.1 KB · Views: 1,382
Engineering news on Phys.org
  • #2
One issue is that the common-mode voltage of the input is wrong. You need to dc bias your input source (by putting a dc source in series) so you're in the common-mode range of your first op amp.

The easiest way to debug this kind of circuit is to simulate each independent block separately and verify they work alone before you hook them up. Circuits the size you show almost never work the first time.

I would suggest, especially since you're a beginner, to debug the architecture of your circuit using voltage-controllled voltage sources (VCVS in SPICE) in place of your opamps. You can find out how to model opamps this way in a million spice tutorials.

Cool circuit, I'm sure you can make it work.
 
  • #3
dilloncyh said:
What's wrong with my circuit?

My analog computing course was fifty years ago...
but i notice

firstly you have all 3 inputs to U2 shorted together at left side of R2 R1 and R3

secondly you use all inverting opamps
so your integral and double integral terms arrive back at R1 and R3 with opposite polarity yet i didn't notice a minus sign in original equation.

hope I'm right ( see @davenn 's signature...)

keep us posted ?

old jim
 
  • Like
Likes davenn
  • #4
analogdesign said:
One issue is that the common-mode voltage of the input is wrong. You need to dc bias your input source (by putting a dc source in series) so you're in the common-mode range of your first op amp.


What is common-mode voltage?


analogdesign said:
The easiest way to debug this kind of circuit is to simulate each independent block separately and verify they work alone before you hook them up. Circuits the size you show almost never work the first time.


I think the circuit is probably a bit too complicated, so I try to study a first-order diff eq first. The attached circuit is for the simulation of 'dx/dt -2*x = 0.2*sin(wt)', where w=2*pi*f and f is 5Hz (I am not sure if the circuit is indeed representing the equation, please correct me if I'm wrong, especially the sign). I've tested the integrator and the summer separately and they work fine. However, when I combine them, I get an oscillatory signal with increasing amplitude. The increase is also dependent on C1*R4 (which shouldn't be the case for ideal op-amp right?). What's wrong? Basically, I'm having trouble when I need to divert the output signal back to the input signal of an integrator.
 

Attachments

  • x'-2x=0.2sin(wt).jpg
    x'-2x=0.2sin(wt).jpg
    23 KB · Views: 825
  • plot.png
    plot.png
    6.4 KB · Views: 613
  • #5
As i said it's been fifty years and I'm rusty.

See if this paper is any help, particularly around page 14.
https://courses.engr.illinois.edu/ece486/labs/lab1/analog_computer_manual.pdf

Darn - you got my curiosity up... i hate not being able to do what once seemed natural

Around page 16&17 is the key , i think

but at my age things come back slowly.

i'll be thinking about this for next several days I'm sure.

At this point it looks to me like your first order circuit gives Vout = x(t)
for
dx/dt] = 2x + 0.2(sin*wt) [1]

have you solved that expression for various t ?

Looking at it as an electronic circuit not an analog computer, it seems to have positive DC feedback so should integrate exponentially to a power supply rail with time constant C1R4.

I like math but math loves to torment me.

How does that differential equation [1] solve out?

old jim
 
Last edited:
  • #6
dilloncyh said:

What is common-mode voltage?

Common-mode voltage is the dc level upon which an ac signal rides. I don't know the syntax for your input voltage source. Is the ac input signal riding on a dc level that is consistent with the bias point of the rest of your circuit?

Also, it looks like the input to your integrator is not perfectly balanced. You will need to put a large-valued resistor in parallel with the integrating capacitor to keep it from approaching the rail as it is.
jim hardy said:
As i said it's been fifty years and I'm rusty.

See if this paper is any help, particularly around page 14.
https://courses.engr.illinois.edu/ece486/labs/lab1/analog_computer_manual.pdf

That's an awesome set of notes! True analog computers are before my time but I regularly design circuits that do simple math (additions, subtractions, integrations, etc) in the analog domain in the context of analog-to-digital converters and frequency synthesizers.

It's funny, the author makes what he calls a "pun" when we says analog circuits solve differential circuits in an analogous way, but it's not really a pun. The is *why* analog circuits are called analog circuits, because their behavior is analogous with physical systems. This is why it is natural (although impractical these days) to use them to solve differential equations.

I agree with Jim that it appears to have positive dc feedback as you invert the input signal twice before you return it to the input amplifier. An ideal integrator has infinite dc gain so you could have trouble. As Jim suggested, check your signs.

In my experience, something like 90% or 95% of all functionality problems with analog circuits end up being a biasing issue. I recommend you do a dc bias point and look at the voltage of every node of the circuit. Make sure you understand why the voltage is what it is.

This link to Wikipedia will help you understand analog integrators.

http://en.wikipedia.org/wiki/Op_amp_integrator#Practical_circuit
 
Last edited:
  • Like
Likes jim hardy
  • #7
it's coming back slowly.
For me the light came on(and i remember that day vividly) when i realized rightmost integrator's output is x(t)
its input is xdot(t),
which is output of second integrator ,, whose input is xdoubledot(t)
and so on.

as explained in that document.
So the trick is in writing the equation as in eq 1.19 which transcribes easily into fig 1.21.

old jim
 
  • #8
dilloncyh said:
The increase is also dependent on C1*R4 (which shouldn't be the case for ideal op-amp right?). What's wrong?
There's probably nothing wrong. That may be the solution of the D.E.

The time constant of the integrator does influence the amplitude of the output. To set up the integrator requires both time scaling and amplitude scaling, though I forget the detail.
 
  • Like
Likes jim hardy
  • #9
dilloncyh said:
However, when I combine them, I get an oscillatory signal with increasing amplitude. The increase is also dependent on C1*R4 (which shouldn't be the case for ideal op-amp right?). What's wrong?

There is a fundamental error: You have connected two inverting circuits in a closed loop. This is identical to positive feedback which always results in oscillations or amplifier saturation (at one of the supply rails). For stability, each feedback loop must NOT contain an equal number of sign inversions.
 
  • #10
LvW said:
There is a fundamental error: You have connected two inverting circuits in a closed loop. This is identical to positive feedback which always results in oscillations or amplifier saturation (at one of the supply rails). For stability, each feedback loop must NOT contain an equal number of sign inversions.

i'm not convinced there's an error.
He built a circuit to solve this equation:

dx/dt = 2x + 0.2(sin*wt)

and if that equation has positive feedback, well, that's that.We should evaluate it for first few cycles of the AC term and see where it's headed.
 
  • #11
jim hardy said:
i'm not convinced there's an error.
He built a circuit to solve this equation:

dx/dt = 2x + 0.2(sin*wt)

and if that equation has positive feedback, well, that's that.We should evaluate it for first few cycles of the AC term and see where it's headed.

That's true Jim, but the time domain solution of an equation with a positive root will always go to infinity. Simulations with finite results are only useful for negative feedback systems.
 
  • Like
Likes jim hardy
  • #12
jim hardy said:
i'm not convinced there's an error.
He built a circuit to solve this equation:
dx/dt = 2x + 0.2(sin*wt)
and if that equation has positive feedback, well, that's that.

... provided that the circuit really solves the equation.
Positive feedback at dc never works! This rule applies to all control systems.
 
  • #13
Dilloncyh - I don`t understand your circuit diagram; can you post the corresponding integral equations?
For my opinion, it is not correct to have two integrators in a feedback loop.
The input signal f(t) must be integrated twice - but the output x(t) is to be integrated only once (hence one single feedback loop)!.
 
  • #14
anorlunda said:
the time domain solution of an equation with a positive root will always go to infinity.

Thanks ! (Sheepish grin icon - you can see how rusty I've got at DE)

If the analog circuit does the same thing as the equation it's supposed to be solving
then the verdict is "not guilty".
That's what analog computers do. It's their job.

It's the job of a control system to keep a process from going to infinity.

I'm trying to entice OP to put some numbers to it.

dx/dt = 2x + 0.2(sinwt)

dx = 2xdt + 0.2(sinwt)

∫dx = ∫2xdt + ∫0.2(sinwt)dt

i understand why OP gets increasing signal
but i don't see right off why it's oscillatory, just should contain a cosine term.

As i said I've become shamefully rusty. It is with trepidation i ventured even this far.

Improvements welcome, after all that's why we are here to share our strengths and buttress our weaknesses, no?

old jim
 
  • #15
jim hardy said:
i'm not convinced there's an error.
He built a circuit to solve this equation:
dx/dt = 2x + 0.2(sin*wt)
and if that equation has positive feedback, well, that's that.
We should evaluate it for first few cycles of the AC term and see where it's headed.

Hi Jim - perhaps a misunderstanding between us? All my comments were related to the 2nd order system as given in post#1.
Only now I have recognized that you were speaking about another (simpler) system of 1st order. Sorry.
 
  • Like
Likes jim hardy
  • #16
LvW said:
Positive feedback at dc never works! This rule applies to all control systems.

It can be useful if the gain around the loop at dc is less than unity. Have you ever seen the bias loop of the 741?
 
  • #17
analogdesign said:
It can be useful if the gain around the loop at dc is less than unity. Have you ever seen the bias loop of the 741?
Yes - of course, if the loop gain is below unity. But this does not apply for the Miller integrators.
 
  • #18
dilloncyh said:
I think the circuit is probably a bit too complicated, so I try to study a first-order diff eq first. The attached circuit is for the simulation of 'dx/dt -2*x = 0.2*sin(wt)', where w=2*pi*f and f is 5Hz (I am not sure if the circuit is indeed representing the equation, please correct me if I'm wrong, especially the sign).

Dilloncyh - why not realizing the classical form
dx/dt + 2x = 0.2*sin(wt) ?
 
  • #20
Basically my ultimate aim is to build a circuit similar to the last circuit in this file: http://aries.ucsd.edu/najmabadi/CLASS/MAE140/NOTES/dynamic-2.pdf, and I've built the circuit here, but it doesn't seem to produce the expected result (the amplitude of the steady-state solution is just not right when I compare it to my MATLAB simulation, and the transient solution is also not the same).

1. Suppose I want to solve the diff eq of the form x''+bx'+cx=f(t), where b and c are positive. Is the circuit on the link and my own circuit actually correct? The integrator itself inverts the sign, so we need an inverted summer, right?

2. What frequency range should I use? I heard that since the op-amp is not ideal, there may be a small offset current, so even when the input signal is zero, the output signal is not, and so the output signal may drift to the rail of the op-amp, especially when the frequency is small. To be honest, I don't actually know what this means. The oscilloscope I use during lab seems not to be working properly for frequency of the range 1-10Hz when I am testing a single inverting op-amp circuit, but it works fine when I switch to about 1k Hz. Does 1k works for the whole analog integrator circuit?

3. Again, what values of R and C should I use? Are there any more systematic ways to study the circuit and know this? To my understanding, the product of CR should be 1 for each integrator, is it true? And the ratios of the resistors in the summer only depends on the coefficient b and c of the differential equation, right? I've added a resistor with high resistance in parallel with the capacitor as people say that it helps, why?

thanks for reading. I know it's a lots of questions.
 

Attachments

  • 2nd order diff eq 2.jpg
    2nd order diff eq 2.jpg
    22.9 KB · Views: 731
  • #21
Dilloncyh, if you want to design an integrator-based circuit which is able to simulate a 2nd-order diff. equation it is the first step to transfer the diff. equation into an integrating equation. Then, the next step is to create a corresponding circuit.
Therefore, I have asked you already in my post#13 to show us your approach for such an equation.
 
  • #22
LvW said:
Dilloncyh, if you want to design an integrator-based circuit which is able to simulate a 2nd-order diff. equation it is the first step to transfer the diff. equation into an integrating equation. Then, the next step is to create a corresponding circuit.
Therefore, I have asked you already in my post#13 to show us your approach for such an equation.

Maybe I have overlooked something important, but I think all we need to do is to move the terms to the right and simply integrate it?
 

Attachments

  • rewrite diff eq.jpg
    rewrite diff eq.jpg
    10.7 KB · Views: 438
  • #23
dilloncyh said:
1. Suppose I want to solve the diff eq of the form x''+bx'+cx=f(t), where b and c are positive.

Here's the approach i was taught.. It' same as in that U of Illinois link.
It is cookbook and straightforward and it works. I well remember the day it "clicked" for me. I was stumped , just couldn't make sense of the process and was in danger of failing the course.
Upon solving the equation longhand then building the circuit and seeing the amplifiers replicate it, well it was an AHA moment. I caught up on all six labs in one weekend, got an "A" and made a professor very happy.

This process is so mechanical it's almost foolproof.
diffyQ2.jpg


please excuse my awkward graphics...
[
DifyQ3.jpg
I couldn't make sense out of that UCSD link it looks to me like they start from wrong end.

Now, there remain the matters of R&C values and initial conditions.
Initial conditions require initial charge on the capacitors. It's easiest to start at zero by shorting all the caps with a multipole relay and releasing it, surely your simulation can do that for you. My old analog computer used relays...
If you want real time solution make RC product = 1, less than 1 to speed up and more than 1 to slow down.

Your resistors across C change the equation, they're no longer integrators (1/RCs) but lag elements(1/(RCs +1))

I recommend you solve the equation longhand for first several seconds (maybe 0,1 second intervals with a FOR-NEXT loop?)
and compare that to your circuit's solution .

One cannot ignore the constant of integration, initial conditions .. Maybe that's the trouble with your simulation?

Thanks - I've enjoyed re-visiting this fascinating topic. I really liked analog computers but you see how rusty my math has become.

old jim
 
Last edited:
  • #24
oops i see more appeared whilst i was typing...
 
  • #25
I think, the block diagram as shown by Jim hardy will fulfill the given task.
However, it needs 5 opamps.
It is possible to reduce the total number of opamps to three if the first adder is changed into a differential amplifier (feedback connections to both opamp terminals).
In this case, we arrive at a very popular universal filter circuit named after "Kerwin, Huelsmam, Newcomb": KHN structure.

EDIT: The integrators as shown in your post#20 do NOT need resistors (R7 and R8) in parallel to the feedback capacitors. If you have overall (negative) feedback the dc operating point always is stabilized.
 
Last edited:
  • #26
thanks for all the replies so far. Solving first-order diff eq is not a problem, but the problem is still the 2nd-order diff eq. I just try to have two integrators connected together, hoping that it will integrate the input signals two times. Suppose the input signal has the form sin(wt), then Vout2 should have the form cos(wt) and Vout should be like -sin(wt) (the integrator inverts the sign as well). But in reality Vout2 has a phase shift from the signal that is not pi/2 (meaning that the second integrator does have an effect on the first one?) and Vout is just the same as Vout2 with a slightly different amplitude. What's wrong? It works fine with just one integrator, but everything starts to go wrong after I add a second one.
 

Attachments

  • 2 integrators.png
    2 integrators.png
    5.4 KB · Views: 506
  • #27
dilloncyh said:
But in reality Vout2 has a phase shift from the signal that is not pi/2 (meaning that the second integrator does have an effect on the first one?)

Maybe.

Can you put up a trace of your outputs?

The LT1001 specsheet says its output is guaranteed to produce full swing only for loads of 1kohm or more.
See datasheet at
http://cds.linear.com/docs/en/datasheet/1001fb.pdf
page 5 chart labelled "Output Swing vs Load Resistance"Your U2 is asked to deliver current into both C2 and R1, oops make that R2 and C1...
so above some frequency (more precisely above some dv/dt) he sees what amounts to a 0.5kohm load, half the minimum in specsheet.
See if making R1=10K and C1=100nf makes him better behaved.
Or reduce amplitude of input 10X.

might be something else.

You already did first step of good troubleshooting, dividing problem in half by disconnecting second integrator.
Keep tightening the noose around that trouble's neck.
One step at a time. Test, observe, think.old jim
 
Last edited:
  • #28
dilloncyh said:
thanks for all the replies so far. Solving first-order diff eq is not a problem, but the problem is still the 2nd-order diff eq. I just try to have two integrators connected together, hoping that it will integrate the input signals two times. Suppose the input signal has the form sin(wt), then Vout2 should have the form cos(wt) and Vout should be like -sin(wt) (the integrator inverts the sign as well). But in reality Vout2 has a phase shift from the signal that is not pi/2 (meaning that the second integrator does have an effect on the first one?) and Vout is just the same as Vout2 with a slightly different amplitude. What's wrong? It works fine with just one integrator, but everything starts to go wrong after I add a second one.
Ideally, two integrators in series will give a phase shift of Pi, not Pi/2.

Op-amps always have a phase shift 'error', and this gets worse as the frequency increases. You are noting this when the second integrator is not included in the feedback loop? How many degrees in error is the output?

The original idea with analog computing was that by time scaling you could slow everything down to a leisurely speed where electronics shortcomings vanished into insignificance, and you could use non-specialized consumer-grade plotters to record these slowly-changing waveforms. So we could, in effect, scrutinize the visual blurr of bounce and vibration in a jet's landing gear but do it in slow motion. We could then take the plot and, for example, relabel the horizontal scale from "seconds" to "milliseconds" and thereby have produced an accurate plot of the gear's realtime behaviour.
 
  • #29
pi/2 at Vout2 looks right for his circuit.. pi at Vout (3 inferred)
2-integrators-png.80790.png


i note there's no DC feedback to U2.
Integrators with no DC feedback tend to "wind up" toward one or the other supply rail after a short while. It's because they integrate their own input offsets.
So measure DC at Vout2, when it strays a few volts from zero you need to reset the integrator by briefly shorting C1. If this is a real not a simulated circuit short it through a few hundred ohms.
With LT1001's 4na input bias current your windup on U2 should be only 4 millivolts or less per second. i/c = dv/dt
So without DC feedback to keep integrators centered you have minutes of runtime on U2 but just seconds on U3.

Another troubleshooting experiment. Change your sinewave input to a square wave symmetric about zero.
Circuit troubles will then show up as waveform distortion not just phase shift, which can be hard to pick out by eye.

First integrator's output, Vout2, should then be a triangle shaped wave resembling saw's teeth.
If U2 is running out of drive capability you'll see flattened peaks.
 
  • #30
jim hardy said:
Here's the approach i was taught.. It' same as in that U of Illinois link.
It is cookbook and straightforward and it works. I well remember the day it "clicked" for me. I was stumped , just couldn't make sense of the process and was in danger of failing the course.
Upon solving the equation longhand then building the circuit and seeing the amplifiers replicate it, well it was an AHA moment. I caught up on all six labs in one weekend, got an "A" and made a professor very happy.

This process is so mechanical it's almost foolproof.View attachment 80597

please excuse my awkward graphics...
[View attachment 80601

I couldn't make sense out of that UCSD link it looks to me like they start from wrong end.

Now, there remain the matters of R&C values and initial conditions.
Initial conditions require initial charge on the capacitors. It's easiest to start at zero by shorting all the caps with a multipole relay and releasing it, surely your simulation can do that for you. My old analog computer used relays...
If you want real time solution make RC product = 1, less than 1 to speed up and more than 1 to slow down.

Your resistors across C change the equation, they're no longer integrators (1/RCs) but lag elements(1/(RCs +1))

I recommend you solve the equation longhand for first several seconds (maybe 0,1 second intervals with a FOR-NEXT loop?)
and compare that to your circuit's solution .

One cannot ignore the constant of integration, initial conditions .. Maybe that's the trouble with your simulation?

Thanks - I've enjoyed re-visiting this fascinating topic. I really liked analog computers but you see how rusty my math has become.

old jim
I finally manage to get some output signals that I suspect are correct both in LTSPICE and in my actual circuit. My circuit is the same as yours, except I remove the inverter for f(t) as it merely have a pi phase shift for the forcing function. It shouldn't affect the amplitude of the steady-state solution. One of the problem now is that for practical reason, I use C=0.1uF and R=100k for the integrators, so Vout=100*integrate(Vin), and I don't quite know how to work out the scaling of the circuit. For y''+by'+cy=-f(t) and 1/CR = 1, b=R/Rb and c=R/Rc. But now 1/CR=100, how to work out the values of b and c in terms of the values of resistors in the circuit?

thanks
 
  • #31
dilloncyh said:
One of the problem now is that for practical reason, I use C=0.1uF and R=100k for the integrators, so Vout=100*integrate(Vin),
i'd have made R=10meg to keep it real time...

i remember doing time scaling but not quite exactly how.

have you tried on your simulator placing 100::1 attenuators at inputs of both integrators?
see section 9 at pdf page 35 of 51 here:
https://courses.engr.illinois.edu/ece486/labs/lab1/analog_computer_manual.pdf

 
Last edited:
  • #32
jim hardy said:
i'd have made R=10meg to keep it real time...

i remember doing time scaling but not quite exactly how.

have you tried on your simulator placing 100::1 attenuators at inputs of both integrators?
see section 9 at pdf page 35 of 51 here:
https://courses.engr.illinois.edu/ece486/labs/lab1/analog_computer_manual.pdf

I tried other values of resistance and capacitance for the integrator, but 100k ohm and 0.1uF seems to work best. If I use any other larger resistor (~1M ohm), the output signal is just to small to be seen on the oscilloscope). Since y'=-100*integrate(y''), and y=-100*integrate(y')=10000*integrate(y''), my first thought is that the diff eq becomes y''+100by'+10000cy=-f(t), but it doesn't seem to be true when I check the results.
For the lecture notes u mention, I can't really understand what it means and what it has to do with 'time' scaling, as now it is the output (y-axis of a plot) of each integrator that is changed.

PS: for the circuit diagram, just ignore Ud (Vsignal and Vin are shorted together). It predicts the actual Vout of my circuit in the lab quite well, and based on output of Vout and Vout2 using different values of R2 and R3, I believe that it actually works. Only problem is I don't know what equation is it actually solving and I need to work backward to get the coefficients b and c (which I have no idea how to do).
 

Attachments

  • 2nd order works.png
    2nd order works.png
    45.1 KB · Views: 381
  • #33
Problem solved already. I guess my project's done. thanks for all the replies and help
 
  • #34
dilloncyh said:
Problem solved already.
Just now tuned in. What'd you do ?
 
  • #35
let 1/CR = k
the equation should be y''+k*b*y'+k^2*c*y=-k^2*f(t)
at least the ltspice and the actual circuit give the solution to this equation
 

Similar threads

  • Differential Equations
Replies
7
Views
1K
  • Electrical Engineering
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
8
Views
195
  • Calculus and Beyond Homework Help
Replies
3
Views
1K
Replies
2
Views
2K
  • Electrical Engineering
Replies
5
Views
3K
Replies
2
Views
1K
  • Differential Equations
Replies
2
Views
1K
Replies
1
Views
611
Back
Top