Skip to content

Instantly share code, notes, and snippets.

@oseiskar
Created June 16, 2018 14:05
Show Gist options
  • Save oseiskar/9965370acf2e9232a80c32d0989a97d6 to your computer and use it in GitHub Desktop.
Save oseiskar/9965370acf2e9232a80c32d0989a97d6 to your computer and use it in GitHub Desktop.
RC discharge simulation
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jvsalo
Copy link

jvsalo commented Jul 16, 2018

I got the below expressions for the intervals.

Note that log of capacitor voltage VC divided by starting voltage V0 is always negative (we can assume even with error bounds that this is true (it is because VC drops so much per 5us)).

I assumed [ta, tb] = [t, t] because the clock is very high precision in this context, at 20ppm, resulting in only 100 picoseconds of error per 5 us interval that I'm using. According to my previous formulas, its effect in the total error is absolutely invisible (I did take into account that this error is cumulative).

Fwiw the formula for error caused by time (using 5us steps) is E_t(t) = (E_t_meas * t/(5e-6)) * (-1)/(C*log(VC(t)/V0)) with E_t_meas 100e-12 being the measurement error (20ppm of 5us)

[Ra, Rb] = -t/([Ca, Cb] * log([VCa, VCb]/[V0a, V0b]))     
                                                            
[VCa, VCb]/[V0a, V0b]                                       
= [VCa, VCb] * [1/V0b, 1/V0a]                               
= [VCa/V0b, VCb/V0a]                                
                                                            
[Ra, Rb]                                                           
= -t/([Ca, Cb] * log([VCa/V0b, VCb/V0a]))           
= -t/([Ca, Cb] * [log(VCa/V0b), log(VCb/V0a)])      
= -t/[Cb * log(VCa/V0b), Ca * log(VCb/V0a)]   # Ca/Cb inverted here because logs are known to be negative
= -t * 1/([Cb * log(VCa/V0b), Ca * log(VCb/V0a)])
= -t * [1/(Ca * log(VCb/V0a)), 1/(Cb * log(VCa/V0b))]
= [-t/(Cb * log(VCa/V0b)), -t/(Ca * log(VCb/V0a))]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment