Now Reading
concept – Can an electrical circuit do recursion?

concept – Can an electrical circuit do recursion?

2023-01-28 20:30:05

First we have to resolve what recursion actually is. Whenever you take a recursive perform, there could exist a change that eliminates the recursion, however introduces state. In different instances, the transformation must introduce each state and iteration. So, writing a perform out recursively is a means of creating state and presumably iteration implicit, versus specific. In different phrases, recursion is only a means of writing out the factor.

The state is there anyway, you are simply not explicitly placing it down on paper. In languages reminiscent of C, recursive perform calls often retailer their state on the stack.

Now, any circuit that has state (saved cost, power, and many others.) – and that can be all of them, actually – is, by definition, recursive. No iteration vital 🙂

Concretely, let’s work on a first-order IIR filter. Its output will be given by a recursive perform. Given an enter sign x(t), the output y(x(t), t) = a1*y(x(t-1), t-1) + b0*x(t), the place a1 and b0 are constants that parametrize the response. That is in discrete time – t is an integer with the unit of numerous clock cycles.

The C implementation, assuming t>=0 and x(-1) == 0, can be:

float a1, b0;

// Recursive, Implicit State
float y(float (*x)(int), int t) {
  return t != 0 ? a1 * y(x(t-1), t-1) + b0 * x(t) : b0 * x(t);

// Non-Recursive, Specific State
float y(float (*x)(int), int t) {
  static float y_prev = 0.0;
  if (1) 
  return y_prev = a1 * y_prev + b0 * x(t);

The code will be even be applied as a primary order switched-capacitor infinite impulse response filter. You may actually construct such a system:


simulate this circuit – Schematic created utilizing CircuitLab

SW1 flips twice in every clock cycle. With values proven, for 12 bit accuracy the clock is proscribed to 10kHz resulting from R4-C1 time fixed. U1, U2, U3 are voltage followers – say op-amps configured for acquire=1.

If we set a1=(1-b0), and rework this to a steady time differential equation, we are able to get the “identical” (steady) response with an RC circuit:


See Also

simulate this circuit

Right here, T is the clock interval of the clock feeding the switched capacitor circuit above, and U1 is a voltage follower.

When the frequencies of curiosity are restricted to ~1/tenth of the clock frequency, each the continuous-time and the discrete-time (switched capacitor) circuits reply the identical.

Each circuits, and the code, will be modeled by a recursive perform, often known as a recurrence relation.

Source Link

What's Your Reaction?
In Love
Not Sure
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top