2
\$\begingroup\$

I am trying to wrap my head around wether and with which circuit it would be possible to emulate the behaviour of a digital easing function like output += delta_to_target_value * easing_factor as it is illustrated in a 2D-version here.

I know basic rise-/fall slew circuits, but I expect this is different.

My thoughts: Let's assume the target's value is a steady stream of random DC voltages, straight out of a Sample-and-Hold. I'd need to find the difference (delta) between target and final output. I then need to attenuate this delta with a easing-factor (< 1). In the digital loop I would then set the output value to equal the current output value plus the attenuated delta value. Somehow I am afraid It would not work that way in a time-continous system. Do I oversee anything here?

Edit:
Nevermind, I had some trouble wrapping my head aropund this. I ran a Circuit simulation with random stepped values and a RC-filter which yielded this result:

Simulation of RC Filter RC-Filtered random DC-Steps

And then used the same step values and programmed a the easing function I mentioned, which yielded a very very similar result as you can see:

Simulation of Easing Function
Simulation of the mentioned easing function

What I hoped for: I hoped for a read curve which does not appruptly change it's direction, maybe as if it had some sort of inertia. The delta in the mentioned easing function is way bigger with growing differences which results in a speedup at value changes. I would definitly know how to fix this in the digital domain, but I am not sure about the analog domain.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ It seems to me that an RC filter with an adequately long time constant would perform the required function. \$\endgroup\$
    – Transistor
    Commented Sep 29, 2017 at 18:17
  • 2
    \$\begingroup\$ Looks like a simple RC function to me... but your question is a tad confusing. \$\endgroup\$
    – Trevor_G
    Commented Sep 29, 2017 at 18:17
  • \$\begingroup\$ I will have a look at the simulations, and clarify once I got some fancy graphics : ) \$\endgroup\$
    – ato
    Commented Sep 29, 2017 at 18:18
  • \$\begingroup\$ If you need to change your requirements like that you should start a new question or it nullifies the existing answers..... and yes it is doable... fairly trivial analog computer stuff. \$\endgroup\$
    – Trevor_G
    Commented Sep 29, 2017 at 20:30

2 Answers 2

3
\$\begingroup\$

I know basic rise-/fall slew circuits, but I expect this is different.

For a one dimensional signal it's very basic - it's an RC low-pass filter. Here is the transient response to a step change: -

enter image description here

Trace A is the step input and trace B is the output as indicated in the circuit below: -

enter image description here

And, just in case you have any doubt, you can take an analogue RC filter and digitize it as follows: -

enter image description here

So, if your digital algorithm matches the IIR one immediately above then you have the equivalent of an RC filter.

\$\endgroup\$
2
  • \$\begingroup\$ Completely right. I actually build a simulation and found out that onedimensional easing looks just the same as a RC filter \$\endgroup\$
    – ato
    Commented Sep 29, 2017 at 18:58
  • \$\begingroup\$ @ato - you mentioned in the dit in your comment "maybe as if it had some sort of inertia" - if you need a more sophisticated function then simulate adding an inductor in series with the resistor. Make the resistor value small but not too small or the "inertia" will cause overshoot - i.e. make it critically damped for a slightly more realistic response. \$\endgroup\$
    – Andy aka
    Commented Sep 30, 2017 at 8:20
2
\$\begingroup\$

In your discrete system:

$$\begin{align*} \Delta x &= k_{easing} \left(TARGET-x\right)\:\Delta t \end{align*}$$

Note that in the software case you referenced, it is implicit that \$\Delta t=1\$.

In a continuous system:

$$\begin{align*} \textrm{d} x &= k_{easing} \left(TARGET-x\right)\:\textrm{d}t\\\\ \end{align*}$$

The only difference between these is that \$\Delta t\$ is a finite variable and \$\textrm{d} t\$ is an infinitesimal variable. They are otherwise the same concept. The infinitesimal form being more of an "always true" kind of thing where the discrete form assumes you know average values.

Regardless, it all boils down to a first-order linear ordinary differential equation, whose solution is:

$$x=TARGET\cdot\left(1-e^{-k_{easing}\cdot t}\right)$$

This is exactly the same thing as you'd get in an RC circuit:

$$V_C=V_{IN}\cdot\left(1-e^{-\frac{t}{R C}}\right)$$

with \$k_{easing}=\frac{1}{R C}\$ and your target being \$V_{IN}\$.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.