Page 1 of 1

RC Circuit Tutorial

PostPosted: Sun Oct 02, 2011 8:13 am
by Leslie Sanford
Here's a good tutorial on the ubiquitous RC Circuit:

RC Circuit Tutorial

I like the graphs showing charging curves on a timeline.

PostPosted: Mon Oct 03, 2011 3:26 am
by Leslie Sanford
Learned something new from this

f = 1 - exp(-1 / d) gives you the coefficient to use to get to 63.2% of the target amplitude in d number of samples. After another d number of samples have passed, the amplitude is 63.2% of the remaining amplitude. This continues forever.

So if our target is 1, i.e. y += f * (1 - y), we get the following results:

Code: Select all
1d    0.632
2d    0.865: (1 - 0.632) * 0.632 + 0.632
3d    0.951: (1 - 0.865) * 0.632 + 0.865
4d    0.982: (1 - 0.951) * 0.632 + 0.951
5d    0.993: (1 - 0.982) * 0.632 + 0.982


We can calculate the amplitude of the curve arbitrarily by using this formula:

a = 1 - exp(-x / fs)

Where x is the position in samples and fs is the sample rate.

Say the sample rate is 44100 and we wish to calculate the curve at 22050:

a = 1 - exp(-22050 / 44100)

Which gives us:

0.3934693403

PostPosted: Tue Oct 04, 2011 10:01 am
by duncanparsons
I oft scale my targets so that they reach the desired level exactly within the samples wanted :-)

PostPosted: Tue Oct 04, 2011 10:45 am
by mystran
The 1 - exp(-1 / (time*samplerate)) formula is certainly useful for a lot of things from envelope coefficients to constant-time decay of delay feedback etc.

PostPosted: Tue Oct 04, 2011 12:51 pm
by Borogove
duncanparsons wrote:I oft scale my targets so that they reach the desired level exactly within the samples wanted :-)


Chamberlin describes a trick where you aim an exponential 5% beyond the desired target and stop after 3 time constants: (1-0.632)^3 = ~0.05.

PostPosted: Thu Oct 06, 2011 12:37 am
by CUNKA
You might also enjoy this informative website also Leslie.

http://www.falstad.com/circuit/e-index.html#sawtooth