# Second order differential equation implementation using OP-Amp

I am trying to implementat the following equation $$\begin{equation} x''+4x'+25=\sin(20t+36) \end{equation}$$

using OP-Amp's. I tried to use state-space technique to implement it in the below circuit x is the voltage of output node of up-right OP-Amp. But the problem is I don't have the x term in the equation. In other words the transfer function is of the form $$\begin{equation} \frac{1}{s(s+4)} \end{equation}$$ The 1/s term is problematic, the above circuit gives us low-pass characteristic of the form $$\begin{equation} \frac{1}{s^2+b_1s+b_0} , b_0\neq 0 \end{equation}$$ What do you guys suggest I do to get the correct setup?

Also I noticed that if we introduce $$\begin{equation} y=x' , y'=x'' \end{equation}$$ we can do something with it, but I can't figure out how? Also if another circuit configuration is better, please suggest it so I switch to that. The above circuit gives me wrong output when I simulate in OrCAD-PSpice , it is a homework for my (circuit-I) class and I thought it would take only 4 hours to solve but it's been a long 24 hours now 😂, I really need help.

Any help would be appreciated.

• where's $x$ in your circuit? Do you even need $x$? Jun 5 '20 at 13:55
• If you introduce $y$, you save yourself a factor of $s$, which might or might not make your problem easier. Jun 5 '20 at 13:57
• @Marcus Müller, thank you for your comment, x is the output of the second OP-Amp. The two OP-Amp's up of the circuit are integrator's, I'll refine the shape Jun 5 '20 at 14:01
• You don't need the second integrator, there is no x in the equation. I suspect the equation should be: $\small \ddot x +4\dot x+25x= sin(20t+36)$
– Chu
Jun 6 '20 at 1:03
• @Chu thanks for your attention but I checked that, the equation is right, I wish it was like the one you wrote, much more easy. Jun 6 '20 at 9:31

The substitution x'=y doesn't seem a big deal and it really is nothing for an experienced analog computerist. But it helps a beginner to keep things in order.

With that substitution you have a pair of equations:

x'=y and y'=-4y+sin(20t+36)-25

These are the inputs for a pair of integrators which output x and y.

Integrator which outputs y gets 3 signals as summed: y itself multiplied by -4, the sinusoidal voltage and constant -25; all scaled to practical volts.

The other integrator gets only y and its output x is observed to see what happens, x is not fed back. Both integrators need some initial value.

Scaling to practical voltages and time scale is essential. Seemingly you have already understood it. But you feed x back for calculating x" and that's an error.

ADD The questioner says in a comment the preceding text is too difficult. Another comment hints some troubles can appear if I do homeworks.

This case shows at least some attempt, it's not like "HEY YOU! SOLVE THIS! IT'S MY HOMEWORK AND I NEED IT NOW!"

Unfortunately only some faint correlation between the numbers in the equation and the component values hints this can be an attempt to solve the problem. I guess it's an attempt. Thus you will get guidance, but nothing that can be copied and pasted as a full solution.

At first we must note that no circuit can obey your equation as is, because circuits obey physical laws. Those laws are equations between quantities which have dimensions. If X in the equation is presented as volts, X" must have dimension volts/(second^2). 4X' has dimension volts/second, it cannot be added with X". The equation needs some modification to make it physically constructable but still retaining the numeric values right.

SI unit system has an advantage. We can multiply in a non-dimensioned pure math equation summed terms with quantities which are 1 multiplied or divided by SI units and get something physically sound with quantities which all have right numeric values and compatible units. Let's take a simple example, much simpler than your equation. Let's have X' = 10 - X

So, let's decide we want X to be red from a voltmeter, the wanted X is the number of volts. In addition let's decide we have the time as seconds. It can appear later that things happen too fast or too slowly and have far too high or low voltages for practical circuits. In that case we could select X or time or both are presented as scaled to different magnitude, but keeping volts and seconds are OK as long as the results show the circuit cannot work accurately or fast enough.

X'=10-X has dimension conflict. X' has dimension volts/second. X is volts. It can be fixed in SI system without changing the numeric values as follows:

X' * (1 second) = 10V - X . If we knew this cannot be built because our opamps are 10 times too slow we could write for ex. X'*(10 seconds)=10V-X. Then one time unit would happen in 10 seconds.

Now let's check what we can get with common opamp circuits. The next is the common integrator: This could be used to solve the equation, only select RC=1 second and feed to the input the inverted sum of -X and constant +10V. The inversion compensates the inversion in the integrator:

The summing circuit can be avoided by making the integrator to have two 1MOhm input resistors to its virtual ground. One gets the X and the other gets -10V.

It's possible that we just haven't exact -10V. Let's assume we have only -1V accurately enough. We can increase the gain of the constant by reducing its summing resistor: If you simulate this circuit with zero initial value for X (=empty capacitor) you'll see

X = 10V * (1 - exp(-t/1s)) as anyone who has calculated some RC charging cases could confirm. The original dimensionless equation has solution X=10(1-exp(-t)). I guess you can see the relation between the circuit function and the solution of the original equation. Here's a screenshot of a simulation: Your homework needs 2 integrators. This case is so simple that we skip the intermediate substitution y=x'. We start with the double integration to get x from x" You can well select RC=1s for simplicity. Write your equation as x"=-4x'+sin(20t+36)-25 and draw the circuits which feed the right half to the input x" (or actually x"*(1 second)^2).

• user287001 Thank you for the answer, but I did not understand your solution. Can you provide me with a schematic, or can you tell me what should I change in my own circuit? Jun 5 '20 at 14:52
• ok, but takes a few hours because I got a job just now. Jun 5 '20 at 15:01
• Thanks a lot, really appreciate it, I just want this torture to be over. Jun 5 '20 at 15:03
• Please remember that this is not a homework solution service. We do not hand out solutions to homework problems. Jun 5 '20 at 18:39
• Thank you, that seems working well, now I should go implement it using breadboard and a bunch of ua741's, wish me luck man xD! Thanks again and I'll remember that, no homework's, only super-duper hard projects Jun 6 '20 at 9:28