We are given two voltages A and B between 0 and 5V. So how do I generate a smooth/continuous analog change in voltage from A to B in a predefined time? The current with that varying voltage is 1 ma or less. The output voltage value is described by a simple quadratic (aX^2)+(bx)+c, at time x seconds.

If that not possible using an Arduino - what is the nearest solution to it? It seems that it would require an RC circuit?

When I mean smooth/continous I mean it doesn't move in "digital steps" or to use an analogy with resistance instead of voltage - it would be like the way resistance changes when a potentiometer is turned between two places, in a given time, by hand.

A potential solution would be to make a circuit that generate arbitrary voltage between 0 and 5v, some how, at a point in time. For each subsequent small change in time, the change in time is constant, generate the desired voltage from a sketch. If the change of time is small and constant, will putting in a high pass RC filter work? Though I'm not sure of a circuit that can create an arbitrary voltage, or arbitrary voltage resolution or how good the RC filter approximates the quadratic smoothness. I don't know the answer.

  • 1
    If your only constraint is that the change be smooth, then an RC circuit would do the trick, with the proviso that the voltage will approach 5v asymptotically but never truly get there. Are there in fact other constraints, such as you want the voltage to increase linearly, so after half the time you have half the voltage?
    – Mark Smith
    Nov 12, 2016 at 19:30
  • What kind of load will be attached to it? An RC filter will not work well with highish loads. You need to buffer it using an opamp. Alternatively add an DAC chip to your circuit.
    – Gerben
    Nov 12, 2016 at 19:46
  • @MarkSmith The asympotitic behaviour is not really a problem (because I think you can use an opamp to rescale from between greater than 0 and less than 5 volts). .But I would prefer a solution without op-amps. Regarding the linear behaviour -I updated the question.
    – Pete
    Nov 12, 2016 at 20:24
  • @Gerben It sounds like the answer may be in your comment (use RC filter and OP amp).
    – Pete
    Nov 12, 2016 at 20:28
  • The quadratic requirement is quite significant - I can't think of any way to get that with an RC circuit, op-amp or no op-amp.
    – Mark Smith
    Nov 12, 2016 at 22:28

1 Answer 1


I'm not sure that there exists a perfect solution for what you want. Generating the correct output voltage for time is easy. Just keep track of time and use the formula you wrote to compute the correct voltage you should be at. Then you can use a PWM output. However, this isn't going to be perfect since it is made with pulses rather than a continuous output. On the Uno the pulses are at 490Hz or 980Hz depending on which pin you use. Use an RC filter and you can then make it continuous - when you tell it output 2.5V you get 2.5V rather than 0 then 5 then 0 then 5 in short bursts. But, you're still going to get discrete steps based on the resolution of the ADC - for an Arduino Uno, it's 255 steps I believe. You could get a separate DAC chip to increase this and can probably get enough steps that their small enough you won't notice. Some versions of the arduino like the due have 12bit analog output and higher frequency, which should help.

  • It all depends on how literally you want to interpret the requirement of "continuous". You could have a million-bit DAC and it'd still be discrete, but the intervals would be tiny. 8-bit might be "continuous enough", depending on the application.
    – Mark Smith
    Nov 13, 2016 at 9:33
  • @MarkSmith It all depends on how literally you want to interpret the requirement of "continuous" I wonder if that is really provably true. Because you could base an answer on the following idea- you could get a servo to turn a potentiometer to turn a cam-that encodes the shape of the quadratic functrion. And using the resistance with ohms law you can answer the question is some circumstances.
    – Pete
    Nov 14, 2016 at 1:35
  • @Pete OK, I could have worded that better. You can make it continuous by putting a capacitor in to low-pass filter out the step - in fact given small-enough steps, even stray capacitances will do that. But the smoothing is just smoothing - it doesn't make the voltage equal the function. If you "zoom in" far enough, you'll see the errors. It's just a case of when it stops mattering.
    – Mark Smith
    Nov 14, 2016 at 11:37

Your Answer

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

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