Go Down

Topic: How to program an analogue voltage ramp as part of an arbitrary waveform? (Read 436 times) previous topic - next topic


Hi all,

I'm trying to build an arbitrary waveform to output on the DAC of an Arduino DUE
It is a 12-Bit DAC.

I have plotted a lot of the waveform but there are parts of the waveform that are a linear lines from one value to another. Instead of calculating the values of the points on the linear line and writing them in with delays. Is there a better way I could go about doing it?

Something like increase 1V to 2V over 100ms.

Could any of you point me in the right direction. The kind of ramps I will need to build are below.

Any tips of would be much appreciated. Thanks!

Some of the ramps are:
•2.77V to 1.385 over 1ms.
•Ramp 1.385V to 2V over 100ms
•2V to 2.2V over 500ms
•2.5V-2.77V over 1ms.


1. You can't get 2.77V out of the standard Due analog output. 2.75 is the maximum I calculated the last time I went through the datasheet.

2. Just set up two arrays, one with the times in milliseconds and the other with the voltages (preferably pre-calculated as an analog out integer.) Then look at the millis() clock, work out which two time entries you are between and interpolate between the corresponding voltages.
"The problem is in the code you didn't post."

Go Up