# For Loop Circuit - calculate the nth derivative of the signal

## Main Question or Discussion Point

For Loop Circuit -- calculate the nth derivative of the signal

I'm trying to design a circuit that differentiate a signal using a differentiating amplifier. What I want to do is to calculate the nth derivative of the signal based on a count I specify. How can I apply the same amplifier to the signal several times?

Thanks.

Related Electrical Engineering News on Phys.org
rbj

i think you need n stages of differentiator to get the nth derivative.

But this is not dynamic at all. I need to control the n parameter at run-time using one differentiator.

Any engineer from Sony? :D

uart

I'm trying to design a circuit that differentiate a signal using a differentiating amplifier. What I want to do is to calculate the nth derivative of the signal based on a count I specify. How can I apply the same amplifier to the signal several times?

Thanks.
There's no easy way to do that with a continuous time signal. I know that in your other thread a sample and hold was mentioned, but that wont work.

You've really got two choices.

1. Sample and use a DPS to do it. OR

2. Use multiple differentiating amplifier's and analog switches to select "n" (and then after you build it, and find that all you are getting out is noise, then use the DSP).

Is this a real time application or not? If not, perhaps you could store the output from the first differentiation in memory and after the first differentiation is complete, apply the stored output to the input and repeat this procedure n times. A warning, repeated differentiation of a signal tends to make the signal noisy.

It seems to me this approach is overkill because it could be done a lot easier in software. Even having a number of sequential differentiators and selecting the output of the nth differentiator using an analog switch would be preferable.

It's supposed to be real-time system. And pure analog no software or any DSP.

I'm trying to think of an analog memory circuit that stores an analog signal in a fixed period from t0 to t1. This way I can buffer part of the signal while one part is being processed.

rbj

But this is not dynamic at all. I need to control the n parameter at run-time using one differentiator.
It's supposed to be real-time system. And pure analog no software or any DSP.
you realize the contradiction in spec's you're making here.

I'm trying to think of an analog memory circuit that stores an analog signal in a fixed period from t0 to t1. This way I can buffer part of the signal while one part is being processed.
what is an "analog memory circuit"? CCD? if so, then you're sampling. if you're sampling what's the problem with DSP?

uart

It's supposed to be real-time system. And pure analog no software or any DSP.

I'm trying to think of an analog memory circuit that stores an analog signal in a fixed period from t0 to t1. This way I can buffer part of the signal while one part is being processed.
Ok. So what is the output of this "continuous time" system doing while you're looping your "analog memory" though it "n" times?

You need to start with the basics and get a better understanding of how real time systems work before starting on what ever this project is.

I see where the problem is...I'm not sure though whether it's a physical limitation or the way analog electronics is developed. The latter is more possible.

You need to start with the basics and get a better understanding of how real time systems work before starting on what ever this project is.
No project yet. I'm studying the basics, so now I'm trying to find equivalent circuit/components to algorithmic constructs, such as loops, conditional statements, variables, ...etc. It may sound a stupid idea but are not ICs the object-oriented counterpart in circuits?
An IC is actually a class/object and the pins are the interfaces.

Integral
Staff Emeritus
Gold Member

In circuitry there are no loops, no function calls no regression. It is more like raw machine code. Straight through every time. Of course with circuitry every component runs continuously, unlike code where it only functions when its turn comes around.

I have been somewhat amused by your efforts to treat circuitry like code, been waiting for your Ah-Ah moment. Circuits are different from code, most anybody can learn to write simple code that will do something. It takes a bit more knowledge to design a meaningful circuit. I personally think you would be better off to totally forget everything you know about coding and learn electronics from the ground up. Then you may be able to do something along the lines of what your are thinking, or more likely come to understand why it will not work.

As every hardware guy knows a soldering iron in the hands of a software guy is scary.

Yeah I think the way I'm approaching it is unrealistic and wrong, trying to unify the concepts...however I thinking there's a problem with the way analog is developed. It's based on limited-functionality components that have been around for decades and they stuck to the old school not willing to change. There are a very quite few pioneers in analog. I'm really surprised that there's no well established way to apply the same circuit multiple times on a signal and it has to use either DSP or hard-wire a fixed number of probably expensive cascaded circuits. Another shock is there's no analog buffer. Cannot we store the signal temporarily for a specific short period and restore it? I believe nothing impossible but
old-schoolers need to think out of the box a little bit.

Integral
Staff Emeritus
Gold Member

So why do you think processors and software were developed? Because of the limitations imposed by the hardware. So yes ICs can be used as building blocks, one of those blocks can now be a microprocessor, which gives all of those things you are looking for. To attempt to do it in circuitry what can easily be done in a processor and a bit of software just does not make much sense.

I suppose you could wire up a discrete component processor if you wanted, remember that is how computers first got started.

You cannot design a complex analog circuit from a software perspective. Either do it in software with some kind of digital hardware, or think outside your software box and get new perspectives for the analog continuous world. This "I know better than the old-schoolers analog guys" chip on your shoulder mentality has got to be modified. Most of the old-schooler analog guys also know a lot of digital hardware and software as well. Its not enough to know how to do something in analog or digital; its also about knowing when to use which technique for a given application that is more important. If you are working for someone or want to be taken seriously, you should choose the best technique for the application.

Derivatives in analog circuitry are continuous and that seems like a fundamental misunderstanding with your post because, again, you only see it in the way it is done in software. There is no reason to iteratively "loop" as you would in software, the differentiation is instantaneous. Your signal will have history in it because it is continuous and the system is causal, and so simply feeding the same signal back into the differentiator is not that simple since your past output and new input will be indistinguishable.

You need to think more about what a continuous signal means, the signal timing, and the response of your circuit. There are not indispensable generic "buffers", but there are time delays, phase shifts, switching, modulations, and other continuous time signal manipulation tricks that people use. Also, I agree with UART that repeated derivations will amplify your noise and ruin your SNR without really careful and well thought out design. I doubt an undergrad computer science curriculum even teaches many tools of DSP (although some courses may have overlap with EE counterparts), and so I think you need a better survey of the landscape before you try to evaluate the merit of techniques (but that doesn't mean you shouldn't try them for learning/fun).

Last edited:

This "I know better than the old-schoolers analog guys" chip on your shoulder mentality has got to be modified.
I've never said I know better than the masters. I'm just saying I'm thinking of it differently.

I doubt an undergrad computer science curriculum even teaches many tools of DSP (although some courses may have overlap with EE counterparts), and so I think you need a better survey of the landscape before you try to evaluate the merit of techniques.

There is so much misinformation in this thread it is hard to read. Gee whiz.

I'm trying to design a circuit that differentiate a signal using a differentiating amplifier. What I want to do is to calculate the nth derivative of the signal based on a count I specify. How can I apply the same amplifier to the signal several times?

Thanks.
Like I said in the previous thread where you asked, you need to do it in a discrete-time way. Sampling theory says you can convert back and forth from continuous to discrete without loss of information. Discrete-time circuits are an advanced topic not generally covered until graduate school. Stick with single-stage transistor amplifiers and opamp circuits right now for goodness sake!

There's no easy way to do that with a continuous time signal. I know that in your other thread a sample and hold was mentioned, but that wont work.

You've really got two choices.

1. Sample and use a DPS to do it. OR

2. Use multiple differentiating amplifier's and analog switches to select "n" (and then after you build it, and find that all you are getting out is noise, then use the DSP).
I said use a sample-and-hold and of course it will work. The vast majority of commercial and industrial analog signal processing is done using discrete-time circuits. So a third option would be to design a discrete-time signal processor. And the low SNR thing doesn't matter in discrete time since the noise is filtered out using the continuous-time reconstruction filter on the back end of the circuit.

What dijkarte is asking for is a high-order differentiator circuit. This is one of the key functions of delta-sigma modulation which is used in EVERY cell phone. The vast majority of modulators use discrete-time signal processing. The whole point of delta-sigma (besides the oversampling) is to exploit the noise enhancement out-of-band by using differentiators and filtering.

It's supposed to be real-time system. And pure analog no software or any DSP.

I'm trying to think of an analog memory circuit that stores an analog signal in a fixed period from t0 to t1. This way I can buffer part of the signal while one part is being processed.
Like I said before, use a sample-and-hold and do your processing in the discrete-time domain.

you realize the contradiction in spec's you're making here.

what is an "analog memory circuit"? CCD? if so, then you're sampling. if you're sampling what's the problem with DSP?
What contradiction? I think dijkarte is going about things the wrong way but you're not helping. Of course dijkarte has to sample (otherwise his/her request makes no sense) but sampling does not imply DSP. People were sampling long before DSP was available.

People haven't used CCDs as filters since the mid-70s. I don't think they were ever popular for that application. Switched-cap circuits killed them, just like DRAM killed them for memory applications and active pixels have mostly killed them for imaging.

Ok. So what is the output of this "continuous time" system doing while you're looping your "analog memory" though it "n" times?

You need to start with the basics and get a better understanding of how real time systems work before starting on what ever this project is.
You might do with a bit of a refresher yourself. Wow, such hostility in this thread. Before the world was digitized in the 90s there were a lot of discrete-time circuits doing "continuous-time" processing without DSP. As long as they satisfy the Nyquist Criterion they're golden. Even today they are all over the place.

Yeah I think the way I'm approaching it is unrealistic and wrong, trying to unify the concepts...however I thinking there's a problem with the way analog is developed. It's based on limited-functionality components that have been around for decades and they stuck to the old school not willing to change. There are a very quite few pioneers in analog. I'm really surprised that there's no well established way to apply the same circuit multiple times on a signal and it has to use either DSP or hard-wire a fixed number of probably expensive cascaded circuits. Another shock is there's no analog buffer. Cannot we store the signal temporarily for a specific short period and restore it? I believe nothing impossible but
old-schoolers need to think out of the box a little bit.
There is an extremeley well-established way to do this. Discrete-time signal processing based on switched-capacitor circuits. These were invented in the 1970s and are EVERYWHERE in modern electronics.

I told you how to store a signal in a previous thread... use a sample-and-hold. You are sooooo far in over your head, my friend. This is advanced stuff... you're not going to understand until you learn some basics.

You cannot design a complex analog circuit from a software perspective. Either do it in software with some kind of digital hardware, or think outside your software box and get new perspectives for the analog continuous world. This "I know better than the old-schoolers analog guys" chip on your shoulder mentality has got to be modified. Most of the old-schooler analog guys also know a lot of digital hardware and software as well. Its not enough to know how to do something in analog or digital; its also about knowing when to use which technique for a given application that is more important. If you are working for someone or want to be taken seriously, you should choose the best technique for the application.

Derivatives in analog circuitry are continuous and that seems like a fundamental misunderstanding with your post because, again, you only see it in the way it is done in software. There is no reason to iteratively "loop" as you would in software, the differentiation is instantaneous. Your signal will have history in it because it is continuous and the system is causal, and so simply feeding the same signal back into the differentiator is not that simple since your past output and new input will be indistinguishable.

You need to think more about what a continuous signal means, the signal timing, and the response of your circuit. There are not indispensable generic "buffers", but there are time delays, phase shifts, switching, modulations, and other continuous time signal manipulation tricks that people use. Also, I agree with UART that repeated derivations will amplify your noise and ruin your SNR without really careful and well thought out design. I doubt an undergrad computer science curriculum even teaches many tools of DSP (although some courses may have overlap with EE counterparts), and so I think you need a better survey of the landscape before you try to evaluate the merit of techniques (but that doesn't mean you shouldn't try them for learning/fun).
I don't think many people on this board know much about discrete-time processing of continuous-time signals. But certainly a CS undergrad will lack the tools to understand it without a lot of remedial reading.

I've never said I know better than the masters. I'm just saying I'm thinking of it differently.
But you need to be more careful about how you write. You are coming across like an uninformed jerk in some of the things you say. It may not be intentional but that is how you look. So much innovation has been done in analog circuits in the last 100 years. Did you know that the Battle of Britain was won in large part because of radar-directed artillery? Guns controlled by linear predictive ANALOG circuits were able to take the integral of velocity in real time and predict the location of German planes and buzz bombs. Did you know that the original nuclear power plants and jet aircraft were designed using ANALOG computers?

Anyway, here is how you would build a circuit to do an arbitrary number of derivatives.

Here's how it works. On the left is a continuous-time anti-alias filter to make sure there isn't any aliasing when you sample.

In the middle is the switched-capacitor differentiator circuit. It is driven by a two-phase non-overlapping clock. On Phi 2 it either samples the input or the fed-back signal (the drawing should have a AND gate driving the first Phi 2 switch. The output of the anti-aliasing filter should only be sampled on the first loop... sorry!) Then the first difference of the input is taken by the sampling of the signal onto C1 and then transferring it to C2. (when you map the real number line into the unit circle by sampling, the first derivative collapses into the first difference). The counter counts each clock period the recirculates the signal until you are done. You can take the second difference, third difference, whatever. The increased noise is rejected by the reconstruction filter on the right which converts the signal back to continuous-time.

You have to follow Nyquist here and make sure the highest frequency in the input signal is significantly less that twice the sampling rate.

I'm almost positive you have no idea what I'm talking about. I'm begging you to learn basics. If you must jump years ahead, here is a good writeup on switched-capacitor techniques:

http://www.aicdesign.org/scnotes/2001notes/Chapter09(6=4=01)-2UP.pdf

From the other thread I mentioned.

I cant really see how this can work with a simple op-amp RC differentiating amplifier, which is what the OP was inquiring about.

Obviously you can do it with a sampled data DSP type system, I've said that all along. I make no distinction between whether the DSP is cpu (IC) based or whether it's built from discrete transistors, it's still a DSP solution.

So, with reference to a single stage RC-opamp differentiating amplifier and a sample hold, can you provide some details of how your above proposed circuit works?
The circuit I posted *is* the analog circuit whose algorithm I described in the quote you posted. It is not DSP.

Now, to clarify this, here is the OP's original quote:

I'm now thinking about applying a circuit to a signal multiple times. For example, I want to differentiate a signal f(t) using a differentiating amplifier. But I'm interested in finding nth derivative of the signal, and I don't want to hard wire a series of amp's. I just want to use the same amp.
The OP wants an analog circuit that reuses a single differentiating amplifier. That is exactly what I posted. Where in that quote did the OP specify that the differentiating amplifier had to be implemented using an RC-opamp structure?

To reiterate, the circuit I posted implements the algorithm you quoted. The counter is the loop counter. The first switch (I omitted the AND gate on the switch driver) implements the sampling function. You can read the explanation I already put for how the switched-capacitor amplifier works.

This kind of thing *can* probably be done using opamp-RC differentiators but it would be really tricky (continuous-time delta-sigma modulators use a similar type of circuit). In that case I would imagine there would be severe noise problems. But maybe not (depending on filtering).

So, are you misunderstanding the circuit I posted, are you misunderstanding the definition of DSP, or something else?

The OP asked for an analog circuit that provides n derivatives using the same amplifier. That is what I posted.

At any rate, the best solution is almost certainly ADC -> DSP -> DAC.

uart

So, are you misunderstanding the circuit I posted, are you misunderstanding the definition of DSP, or something else?
No Carl. I posted that before I noticed that you had attached the switched capacitor solution. I'm just viewing it now.

Yes, in the other thread I did assume that when the OP mentioned differentiating amplifier that he was considering a simple RC-Opamp circuit.

Last edited:

No Carl. I posted that before I noticed that you had attached the switched capacitor solution. I'm just viewing it now.

Yes, if the other thread I did assume that when the OP mentioned differentiating amplifier that he was considering a simple RC-Opamp circuit.
OK, no worries. I thought that the switched-cap solution would automatically show up in the post. I guess you had to click it or something? My mistake.

I think we're all in agreement that the OP is totally putting the cart before the horse though.

I think we're all in agreement that the OP is totally putting the cart before the horse though.
I just wish we could shed this software/computer science perspective in these discussions. This thread is a thinly veiled reintroduction of the software perspective motivation (For Loop Circuit..). I think hubris and impatience are getting in the way of understanding the basics. In a way, it is understandable: if someone already knows the math and general concepts from somewhere else, why would he want to relearn it and apply it to things that might seem trivial on the surface, like boring resistor networks just to learn the basic circuit theory or an opamp circuit that seems to have been dreamed up by the authors. The problem is that we can only talk about these things in a general and superficial way from that outside perspective, and it almost paralyzes us from learning or making anything real/new. Instead of trying to find an example of a "for loop circuit" to validate his computer science intuition, he should work his way up (try building a 1st derivative design before you worry about nth derivative) and see how such an nth derivative circuit could occur naturally.

Computer science and software design is irrelevant to almost everything that has been in these last 2 threads, but it keeps popping up as if it has some relation to circuit design so that the OP thinks he can replace the basic circuit/signal theory horse (the one he doesn't have yet) and pull the analog design cart with the computer science horse instead. I have met EE educated software engineers who don't pretend to know anything about analog design, even though they have had a good exposure to both the software and electronics fields, because they know the details are where it counts in any technical field (which is why so many people read The Elegant Universe and then post their revolutionary ideas in the general physics forum without understanding why physicists here might get annoyed at them). What is being done with this computer science approach (for loop = feedback?) is like a mechanical engineer coming here and asking us to talk about resistors in terms of friction, capacitance in terms of mass/inertia, and inductors in terms of springs and then asking us to build/explain a circuit design with the same approach they use to build a car, or like a thermodynamics engineer coming here and wishing us to revolutionize analog designs by applying the concepts of heat transfer with enthalpy, pressure, temperature, and volume analogs to circuit design.

If the OP thinks there is a better way of analog design that can draw from principles or techniques of the computer science field, he may have some valid ideas, but he can't get those ideas without understanding circuit design first or without closely collaborating with someone who does know circuit design inside and out. So it makes more sense to learn circuit design for what it is without a biased slant, and then when it is at a solid understanding, then go back and see what can be applied between the 2 fields. So, OP, if you want to do the computer science approach, stop asking us questions about it and start showing us examples/proof of how this approach actually works, because no one else uses that approach as far as I know. Until then, it is best just to forget this speculative link between the 2 fields and learn electronics with unbiased questions (NO FOR LOOPS). I hope we aren't discouraging you from learning analog design, because I think you will be good at it once you learn it D I still think the best advice is to start building/designing circuits at a bench and explore that way with your textbook references. My apologies again for sounding like a pompous jerk, but my intentions are good :P

Last edited:
uart

Here's how it works. On the left is a continuous-time anti-alias filter to make sure there isn't any aliasing when you sample.

In the middle is the switched-capacitor differentiator circuit. It is driven by a two-phase non-overlapping clock. On Phi 2 it either samples the input or the fed-back signal (the drawing should have a AND gate driving the first Phi 2 switch. The output of the anti-aliasing filter should only be sampled on the first loop... sorry!) Then the first difference of the input is taken by the sampling of the signal onto C1 and then transferring it to C2. (when you map the real number line into the unit circle by sampling, the first derivative collapses into the first difference). The counter counts each clock period the recirculates the signal until you are done. You can take the second difference, third difference, whatever. The increased noise is rejected by the reconstruction filter on the right which converts the signal back to continuous-time.
Ok I've only just found time to have a good look at this circuit and I can tell you that is extremely flawed on many levels. Obviously I know it's only a "overview sketch" so I'm not expecting all the fine details to be covered, but even so it looks pretty flawed to me.

- Firstly the differentiator is inverting, making the feedback inconsistent for taking differences with the previous input voltage. Ok that's no biggie, easily fixed with an inverting amplifier.

- Secondly there's no charging path for C1 under the feedback conditions. That is, C1 is disconnected (at one end or the other by either phi1 or phi2) at all times after the first input voltage sample (n=1). The output voltage of the differentiator will always be zero after n=1. You cant fix this by overlapping phi1 and phi2, because then you'll have a positive feedback loop on the opamp (assuming you fixed the previous flaw) and it would slew to rail. You could probably fix this with a sample hold after the phi1 switch (to c1 input) in the feedback loop.

- Thirdly however I just don't think this finite difference approach can even work properly on these recycled samples rather than consecutive samples of the input. I'm assuming you're thinking in terms of a finite difference approx to the derivative like $1-z^{-1}$ for the first derivative and $1 - 2 z^{-1} + z^{-2}$

For example, even if I assume that your circuit is "fixed" so that it correctly compares the voltage of the previous input/feedback (stored on c1) with that of the most recent output stored on the sample/hold (forgive me if this is not how you envisage it, this is just my best guess at what I think you are trying to achieve), then when I analyze the output for a 2nd derivative then I don't get what I would expect.

Take a series of input samples 1 2 3 4 ..., with an initial capacitor voltage of zero. I get the following sequence of output sample for n=2. Output = 0, -1, -1, -2, -2, -3 ..., doesn't look right. The finite difference $1 - 2 z^{-1} + z^{-2}$ would yield a sequence of zeros. This confirms my initial suspicion for this type of implementation.

Last edited:

Ok I've only just found time to have a good look at this circuit and I can tell you that is extremely flawed on many levels. Obviously I know it's only a "overview sketch" so I'm not expecting all the fine details to be covered, but even so it looks pretty flawed to me.

- Firstly the differentiator is inverting, making the feedback inconsistent for taking differences with the previous input voltage. Ok that's no biggie, easily fixed with an inverting amplifier.

- Secondly there's no charging path for C1 under the feedback conditions. That is, C1 is disconnected (at one end or the other by either phi1 or phi2) at all times after the first input voltage sample (n=1). The output voltage of the differentiator will always be zero after n=1. You cant fix this by overlapping phi1 and phi2, because then you'll have a positive feedback loop on the opamp (assuming you fixed the previous flaw) and it would slew to rail. You could probably fix this with a sample hold after the phi1 switch (to c1 input) in the feedback loop.

- Thirdly however I just don't think this finite difference approach can even work properly on these recycled samples rather than consecutive samples of the input. I'm assuming you're thinking in terms of a finite difference approx to the derivative like $1-z^{-1}$ for the first derivative and $1 - 2 z^{-1} + z^{-2}$

For example, even if I assume that your circuit is "fixed" so that it correctly compares the voltage of the previous input/feedback (stored on c1) with that of the most recent output stored on the sample/hold (forgive me if this is not how you envisage it, this is just my best guess at what I think you are trying to achieve), then when I analyze the output for a 2nd derivative then I don't get what I would expect.

Take a series of input samples 1 2 3 4 ..., with an initial capacitor voltage of zero. I get the following sequence of output sample for n=2. Output = 0, -1, -1, -2, -2, -3 ..., doesn't look right. The finite difference $1 - 2 z^{-1} + z^{-2}$ would yield a sequence of zeros. This confirms my initial suspicion for this type of implementation.
You're quite right, both about the small errors and the fact that it doesn't seem to take the second difference correctly. Obviously this was a sketch I made to try to prove a point (not sure I proved it haha!). To do a real second difference I think you need a more complex structure (as in a high-order delta sigma modulator (without the modulation).

My gut tells me it is possible, but I'm not going to look into it.

The bottom line is doing it this way is crazy. You should use a computer. I was responding to the comments that it was "impossible" to do it in an analog way, and I dispute that.

Thanks for taking the time to go over the circuit!

Carl