RC Precision Drawing

Discussion in 'General Electronics Chat' started by Wendy, Oct 29, 2010.

  1. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    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).

    [​IMG]

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

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

    Senior Member

    Jul 7, 2009
    1,585
    141
    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:
    Code ( (Unknown Language)):
    1.  
    2. from pylab import *
    3.  
    4. TC = arange(0, 5, 0.01)
    5. plot(TC, 100*(1 - exp(-TC)))
    6. title("RC Time Constant")
    7. xlabel("TC")
    8. ylabel("%")
    9. grid(True)
    10. savefig("tc.png", dpi=70)
    11.  
    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
    Code ( (Unknown Language)):
    1.  
    2. from pylab import *
    3. TC = arange(0, 5, 0.01)
    4. plot(TC, 100*(1 - exp(-TC)))
    5. show()
    6.  
    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.
     
    • tc.png
      tc.png
      File size:
      17.2 KB
      Views:
      34
    tom66 and SgtWookie like this.
  3. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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. ;)
     
  4. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
  5. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    I can scale this to whatever application I need, which was my base thought.
     
  6. someonesdad

    Senior Member

    Jul 7, 2009
    1,585
    141
    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...
     
  7. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    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.
     
  8. tom66

    Senior Member

    May 9, 2009
    2,613
    213
    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.
     
  9. someonesdad

    Senior Member

    Jul 7, 2009
    1,585
    141
    I finished the document on python and posted it in another thread.
     
Loading...