Don’t get me wrong. Like most people, there’s nothing I enjoy more than solving a long, involved math problem by hand. But, sometimes, a few pages of algebraic scratches on paper is just a means to an end. I find this especially true during electronic design sessions, be it circuit design or PCB layout; I just need the answer, and any time spent finding it distracts me from the larger task at hand. For me, at least, this seems to happen at least once a week, and about five years ago I decided to do something about it. I had heard of computer algebra packages, of course, but they weren’t taught as part of the undergraduate engineering curriculum when I went to school. So, I set about learning one: let the computers do the math!

The package I chose is wxMaxima, a document-based front-end to the Maxima computer-algebra system. Descended from code originally written in the late 1960s, it’s a general-purpose package supporting symbolic computation for algebra and calculus. There’s solid, mature code underneath with a modern UI veneer on top. Plus, it’s FOSS.

As I’ve progressed, I’ve found that some additional functions make the Maxima environment especially convenient for circuit design. A few are simple enough that I’d typically just re-create them as needed, so I never really got organized – there were several versions of my “library” floating around on various machines. I finally got my act together, cleaned up the most-frequently used functions, and put them into a GitHub repo.

Let’s have a look at how we can use them to take the tedium out of math for some design problems.

Preliminaries

There are few things we need to know about Maxima syntax, which differs from the usual languages you may be more familiar with:

  1. Lines are terminated either with a semicolon, which shows the resulting output, or a dollar sign, which suppresses it.
  2. Variable assignment uses a colon. To set variable “x” to value “3,” we say “x : 3;”.
  3. The equals sign establishes a symbolic equality relationship: “y = 2*x;” defines an equation that can be manipulated symbolically.
  4. If you mix up #2 and #3, you’ll get very confused.

With these in mind, we’re prepared to have a look at some functions from the GitHub code. Three simple functions end up being very useful. The first function, par(), calculates equivalent values for parallel resistors or inductors, or for series capacitors. For example:

The second function, vdiv(r_top, r_bot), calculates a voltage divider ratio for the given resistors. In the first example, a 5 V supply is divided by 400 and 100 ohm resistors to yield a 1 V output, while the second example creates a symbolic expression for the divider formed by r1 and r2.

Finally, the pref(x, E) function finds the closest value to x from the selected EIA “E-series” of preferred values. You can choose any series from {E3, E6, E12, E24, E48, E96, E192} plus the combined series {E48_E24, E96_E24, E192_E24}. For example, we can …read more

Source:: Hackaday