EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: gotwood on February 09, 2014, 03:00:45 am

Title: Excel w/chart for rc and rl circuits....
Post by: gotwood on February 09, 2014, 03:00:45 am
Looking to make excel spreadsheet to graph V/I for the devices over time frame

New to excel.....How do I vary the timeframe based on the tau/time constant
How many steps are needed for a particular timeframe?

I'm in the dark because I'm not really plotting a true curve...just a bunch of individual points...

Also, is there a way to use one sheet for the charging phase AND discharging phase? Or do I need do separately? 


Formulas I know I need:
tau=R*C
e^-t/T
1-e^-t/T

Any others?


Title: Re: Excel w/chart for rc and rl circuits....
Post by: edy on February 09, 2014, 04:05:32 am
Are you looking for something like this?:

http://www.referencedesigner.com/rfcal/cal_05.php (http://www.referencedesigner.com/rfcal/cal_05.php)

Here is another good explanation:

http://www.electronics-tutorials.ws/rc/rc_1.html (http://www.electronics-tutorials.ws/rc/rc_1.html)

Seems the only equation you need is:

Vc(t) = Vs (1- e^-t/RC)

Vc=voltage across capacitor at any given time
Vs=supply voltage applied
t=time
R=resistor ohms
C=capacitor farads

Notice that at the beginning, -t/RC = 0. Therefore e^0 is 1, and Vs(1 - 1) = 0.
When time is the "time constant" or t=RC, we have e^-1 which is 1/e = 1/2.718 = 0.36.
So then Vc = Vs (1-0.36) = Vs (63.2) which is 63.2% of the supply voltage.

The excel spreadsheet would simply have columns for each of the variables, plotted against time. I will upload something if I have a chance.
Title: Re: Excel w/chart for rc and rl circuits....
Post by: edy on February 09, 2014, 04:36:07 am
I've added an Excel spreadsheet I just put together since the previous post. It simply uses that formula I mentioned. A column for time, just pick arbitrary interval and extend downwards. I have 0 to 5 seconds. I also set my R and C at top of the spreadsheet to the values, and the supply voltage Vs. The formula calculates the values of Vc for different times (I have separated it across several columns so you can see each piece calculated but you can simply combine into 1 column for time, 1 colum for the resulting Vs and that is it.

I have graphed the result as well, you can see a nice natural logarithmic curve. Using this spreadsheet you can play around with all the values and pick it apart to understand it. Same can be applied to your LC and other types of circuits where you want to figure out your values. The decay curve would be the same idea... I'll let you try and come up with it, and post it to this thread. Hope that helps.
Title: Re: Excel w/chart for rc and rl circuits....
Post by: gotwood on February 09, 2014, 06:23:09 am
I was thinking that based on the time constant and t-start/t-end you could have a column that uses the appropriate units according to how many points should be used to deliver a decent graph .

Example...a time constant of 18us would not be using ms or conversely
Title: Re: Excel w/chart for rc and rl circuits....
Post by: Rerouter on February 09, 2014, 07:28:43 am
calculate the time constant, times it by 5, then round up to the nearest decade, then take 5+ samples per time constant
Title: Re: Excel w/chart for rc and rl circuits....
Post by: gotwood on February 09, 2014, 07:59:41 am
You say 5+ samples per T
What would be overkill?
Would 10/T be adequate for an accurate graph?
Title: Re: Excel w/chart for rc and rl circuits....
Post by: edy on February 09, 2014, 05:34:09 pm
In the Excel spreadsheet I uploaded, simply make the TIME column a function of the RC. For example, we know that at time=RC means it will reach 63% of the max curve. Therefore just make the time column rather than fixed numbers, based on a formula where it reaches "RC" at about half the steps, and then continue to 2RC at the end.

For example, you can add another column called "steps". Make steps increment from 0 to 100. Now make time column equal to (step x  2 x RC/100). Does that make sense?

So at step 0, time = step x 2 x R C/100 = 0
At step 50, time = 50 x 2 x RC / 100 = RC
At step 100, time = 100 x 2 x RC / 100 = 2 RC

Now when you set your RC at the top of the spreadsheet I uploaded, the time automatically SCALES to allow the graph to have that characteristic. You can choose 3 RC as the horizontal time range, 4 RC, whatever you want.
Title: Re: Excel w/chart for rc and rl circuits....
Post by: gotwood on February 09, 2014, 07:06:09 pm
I pretty much have the charging phase with Cap V/I and Res V plotted vs. time down pat......
Is it possible to have a spreadsheet go through a time line where you have charging phase, steady state and discharge phase plotted vs. time?   With charge phase not at 100%? And adding or taking out resistance between phases ....thus changing time constant?

Is excel capable?  I'll not bother trying if it cannot handle complex situations like this.
Title: Re: Excel w/chart for rc and rl circuits....
Post by: edy on February 09, 2014, 09:55:03 pm
Excel should be very capable. I've done a ton of stuff with Excel, including 2D maps and very heavy math calculations, GPS geocoding and other stuff. I'll try to modify my previous spreadsheet and upload a new one showing charge, steady state and discharge. Keep in mind the steady state will not be at 100% because it would take an infinite time to reach, but it is a close approximation.
Title: Re: Excel w/chart for rc and rl circuits....
Post by: edy on February 10, 2014, 01:38:41 am
Hi,

I've attached the REVISED Excel spreadsheet showing the RC calculations, along with a screenshot. As you can see, I've created series with different colors plotting the charging, steadystate and discharging phases. I've arbitrarily set 50 steps for charging, 25 steps for steadystate (which is boring) and 50 steps for discharging. The time scale automatically ranges depending on the RC so that we get to 99.3% of the charge. 1xRC gets to 63%, and 5xRC gets to 99.3%.

All you have to do in the spreadsheet is modify the yellow cells... R, C and V. The rest is automatic. Let me know if this helps. Excel will let you do almost anything. There is even a flight simulator embedded in there. :-)

Title: Re: Excel w/chart for rc and rl circuits....
Post by: gotwood on February 10, 2014, 02:15:02 am
Thanks so much.....Ill learn much about the excel formulae from this