# RC Precision Drawing

#### Wendy

Joined Mar 24, 2008
23,456
This is not a question as such. I have been illustrating for the AAC book, and use approximations of the RC curves many of these circuits require.

I decided to make a precision drawing, and thought I would share how I did it (which was about as kludgy as anything I've ever done).

Never have I seen a more perfect application for Excel, and I used word.

The graph is accurate to within a pixel. I might do it again with a graph 10X the size.

#### Attachments

• 8 KB Views: 142

Joined Jul 7, 2009
1,583
Doesn't look horribly kludgy, as making a graph in a spreadsheet is a pretty straightforward task.

When I need a graph of something, I turn to a python script. I used to use spreadsheets, gnuplot or Mathematica, but then I found matplotlib, which is a python library. It took about a minute to make the attached graph; here's the code:
Rich (BB code):
from pylab import *

TC = arange(0, 5, 0.01)
plot(TC, 100*(1 - exp(-TC)))
title("RC Time Constant")
xlabel("TC")
ylabel("%")
grid(True)
savefig("tc.png", dpi=70)
The last line lets you choose the resolution; larger numbers yield larger bitmaps. If I wanted e.g. a vector drawing instead, I'd change the extension to svg and get a scaled vector graphics (SVG) plot that I can open in e.g. Inkscape or Firefox. I believe there are other "backends" that give output in other formats, but personally I almost always just use the PNG format.

If you're on Linux, a quick run of the app installer will get you going. On Windows, you can download exe's that install python and matplotlib (get numpy too, as you'll find it to be a good tool for numerical work). I'll assume something similar for Macs exists.

The code just gets put into a file, say "plot.py", then a command line of 'python plot.py' produces the graph in less than a second. It just doesn't get any simpler. I think every scientist/engineer should be aware of these free tools and take a look at them -- they can save you lots of time. They are especially appreciated by us geezers that had to plot our graphs by hand before computers became available...

Before making a nice graph with titles and axis labels, I usually just use something like
Rich (BB code):
from pylab import *
TC = arange(0, 5, 0.01)
plot(TC, 100*(1 - exp(-TC)))
show()
just to get a plot on the screen. I don't know many tools that let you get a working plot with less effort. Of course, there are lots of bells and whistles so you can make the graph look like you want. Take a look at the gallery on the matplotlib web site.

#### Attachments

• 17.2 KB Views: 34

#### SgtWookie

Joined Jul 17, 2007
22,230
Gee, thanks!
You had me install Python quite a while back to compare font libraries; and I hadn't done a thing with it since.

Maybe I'll take another look at it.

#### Wendy

Joined Mar 24, 2008
23,456
I can scale this to whatever application I need, which was my base thought.

#### Attachments

• 9.4 KB Views: 26

Joined Jul 7, 2009
1,583
I can scale this to whatever application I need, which was my base thought.
That's a very useful thing! That's a good reason to use vector drawing formats like PostScript or SVG. If you're using Linux, try Xara, as it's a nice vector drawing package. Inkscape is another excellent tool. If you're into programming, learning to program in PostScript is useful (see Don Lancaster's site), but it's a bit like assembly language in the end until you develop a useful library of stuff.

Bill, if you don't mind, I think I'll (slightly) hijack your thread. I'm planning on writing a quickie document on why I think scientists and engineers should get to know some of the capabilities of python, mainly because SgtWookie and tom66 (two members whose technical abilities I esteem highly) expressed thanks. I suspect others would enjoy knowing some of python's abilities. I "discovered" it about 12 years ago when I didn't have a job assignment for 2 months (but was still employed -- a wonderful situation!) and was disappointed with the capabilities of perl. I'll post it to this thread when I finish it...

#### Wendy

Joined Mar 24, 2008
23,456
Be my guest, I'm done with this thread. Base drawing of fundamental curves are more important than noobs give them credit for, since many circuits use them for the basics.

I want to learn some new languages, I was very into coding 30 years ago, but taking the time to do it now is a major problem. At the moment I have about 4 articles that I have started that need finishing, some of them involve hardware, and about 3 projects I'd like to get done. This mixed with work and other commitments mean I'm not moving very fast on any of them.

This site would like me to use XCIRCUIT for the articles, which is available in windows and (mostly) Linux. It is another vector graphic program, but I can already do what I want in M/S Paint, so there it is.

#### tom66

Joined May 9, 2009
2,595
Python is a great language.

It has a few quirks but it's one of the easiest to pick up.

Try this site, http://diveintopython.org/.

I learnt without it, actually - I just learned by example - but for people who have never programmed before in a similar language it's a great way to learn.