# Using analog computer to solve 2nd-order diff eq

Tags:
1. Mar 15, 2015

### dilloncyh

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

#### Attached Files:

• ###### 2nd order diff eq.jpg
File size:
29.5 KB
Views:
569
2. Mar 15, 2015

### analogdesign

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. Mar 15, 2015

### jim hardy

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

4. Mar 15, 2015

### dilloncyh

What is common-mode voltage?

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.

#### Attached Files:

File size:
25.6 KB
Views:
299
• ###### plot.png
File size:
10 KB
Views:
207
5. Mar 15, 2015

### jim hardy

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.

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: Mar 15, 2015
6. Mar 15, 2015

### analogdesign

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.

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.

http://en.wikipedia.org/wiki/Op_amp_integrator#Practical_circuit

Last edited: Mar 15, 2015
7. Mar 15, 2015

### jim hardy

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. Mar 16, 2015

### Staff: Mentor

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.

9. Mar 16, 2015

### LvW

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. Mar 16, 2015

### jim hardy

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. Mar 16, 2015

### Staff: Mentor

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.

12. Mar 16, 2015

### LvW

.... provided that the circuit really solves the equation.
Positive feedback at dc never works! This rule applies to all control systems.

13. Mar 16, 2015

### LvW

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. Mar 16, 2015

### jim hardy

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 dont 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. Mar 16, 2015

### LvW

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.

16. Mar 16, 2015

### analogdesign

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. Mar 17, 2015

### LvW

Yes - of course, if the loop gain is below unity. But this does not apply for the Miller integrators.

18. Mar 17, 2015

### LvW

Dilloncyh - why not realizing the classical form
dx/dt + 2x = 0.2*sin(wt) ?

19. Mar 17, 2015

### Staff: Mentor

20. Mar 18, 2015

### dilloncyh

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 wanna 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.

#### Attached Files:

• ###### 2nd order diff eq 2.jpg
File size:
25.8 KB
Views:
257
21. Mar 18, 2015

### LvW

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. Mar 18, 2015

### dilloncyh

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?

#### Attached Files:

• ###### rewrite diff eq.jpg
File size:
10.7 KB
Views:
130
23. Mar 18, 2015

### jim hardy

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.

[

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: Mar 18, 2015
24. Mar 18, 2015

### jim hardy

oops i see more appeared whilst i was typing....

25. Mar 19, 2015

### LvW

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: Mar 19, 2015