Monday, May 21, 2012

The Basics: Part I

Welcome back.

In this post we'll start a project and introduce a few tools that should be very helpful along the way. 

First I would like to state the pre-requisites for this project, or the things you should probably know in order to get the most out of this discussion. This is difficult to say.  I'm not a teacher, and also I can't expect that you would know everything that I needed to figure this project out. Roughly, then, you should know:

  • Algebra
  • Ohm's Law
  • Hopefully a little more circuit theory, ala Kirchoff's Laws

To help illustrate what I'm talking about in this post, I'll be taking advantage of some really nice, free tools. For displaying math, like $$\mu = r_p g_m,$$ I'll be using a script called MathJax, which is an easy to use plug-in of sorts to allow high-quality, cross-browser support for rendering mathematics. I'm pretty sure any questions you ask in the comments can take advantage of this.  Just couch your math statements in back-ticks, like this: `y = 2*x^2` . It support several syntaxes for input, including ASCIIMathML, which is pretty close to what you would type with a standard text interface anyway.

For drawing schematics, there a couple of good options that are cross-platform, and both are web-based. There is Upverter and CircuitLab. Both have nice HTML5 (not Flash!) interfaces for drawing schematics, you can share schematics with your friends and hot-link them on forums all you like. I'll probably be using CircuitLab more though, because it has integrated simulation functionality and has easier access to the more common circuit elements.

A beautiful circuit drawn with CircuitLab

For more involved simulations I'll be using a version of Spice. There are many of these around, most derived from Berkeley Spice 3f5, developed at the University of California, Berkeley. For those of us working on Macs, there is MacSpice, as well as ng-spice, which is available through MacPorts or Fink. Linux has several versions of Spice available, and Windows users have access to the GUI-oriented LTSpice and TINA from Texas Instruments. However, MacSpice and other command-line versions of Spice are extremely powerful and useful, and have a surprisingly shallow learning curve, especially if you've ever done any programming. 

I feel it's important to lay out the programs I'll be using for these posts clearly, because if you like my diagrams or schematics or whatever, you'll be able to use them too.  I have been frustrated before trying to figure out how some guy made his graphs or where he got his cool charts.

Okay, now let's talk about a circuit and what we want it to do. Imagine we have a signal source, like an electric guitar.  Guitars produce a signal composed of a series of sine-waves. If you play an A, you'll get a sine-wave output with a frequency near 440 Hz, or an integer multiple of 440 Hz, like 880 Hz, for an A one octave up in pitch. The signal would look like this:

A 440 Hz sine wave

What if we wanted to change that signal? We could do lots of things, like increasing the amplitude of the signal, or inverting the signal. Both of those operations could be done pretty easily with a basic amplifying circuit.  But let's do something more interesting; let's change the frequency of the signal. How can we do that? Well, if we look at a rectifier circuit, like one might find after the transformer in an AC power supply, we'll get a clue:


A center-tapped rectifier circuit

Simulation showing input signal and output signal

Take a look at the blue squiggle. The first peak looks a lot like the `In` signal, but with a smaller amplitude. Then there's a little null area, a flat spot, followed by another peak. But notice, the second peak comes when the `In` signal is having a valley.  We've doubled the frequency! But not quite. The out `Out` waveform is not exactly a sine wave.  Mathematical analysis would show that the new signal is composed of not just one sine wave, but of in fact a whole slew of sine waves of vary frequency, starting with the primary, or fundamental frequency, of `2*440 Hz = 880 Hz`. So we have succeeded in some respects: we have created a filter that transforms the frequency that is fed into it.  Mathematically, we have $$f_{out} = 2f_{in}.$$ For those who haven't dealt with diodes before or need a refresher: the way this circuit works is during the input signal's positive half-cycle, diode `D1` conducts the input signal into the load resistor, while diode `D2` blocks the input signal from passing through it. Therefore the only path for current from the input signal is through `D1`, through the resistor, and then to ground. On the next half-cycle, when the input signal is negative, the diodes reverse roles and allow the input signal to pass through `D2` and into the load resistor. The result is that the `Out` signal is never negative; the diodes "rectify" the flow of current such that it always flows in the same direction.

Also, notice that it takes a while before the `Out` signal leaves the horizontal axis and takes on some positive value. If you draw a vertical line, from the point where the `Out` signal starts to rise, to the curve of the `In` signal, you will see that the input voltage is around `600 mV = 0.6 V`. This is a feature of silicon diodes. They require a minimum voltage between their terminals of around `0.6 V` before they begin to conduct appreciable current.  This is called a diode's forward voltage drop. As long as the circuit driving the diode has a potential higher than the diode's forward voltage, or `v_f`, the voltage across the diode will remain fairly constant, close to `0.6 V`.

So, to recap, we have a circuit that doubles the input signal's frequency, but due to the realities of silicon diodes, it produces a distorted output. In the next post, we'll introduce a useful circuit element that will help us overcome some of these limitations.

Sunday, May 20, 2012

Inaugural Post!

This is the first post of a new blog dedicated to the practical design of electronic circuits.

Hopefully this blog will help both you, the audience, and myself better understand the design and analysis of electronic circuits for a variety of purposes.

A little about me: I'm currently studying electrical engineering at a university in the middle of the U.S and I've been tinkering with electronic since a pretty young age.

A lot of people out there are interested in electronics projects as a hobby.  Specifically, there is, or was, a community devoted to building homebrew guitar effects and amplifiers.  Unfortunately, many of the websites one finds containing information about those topics are extremely old and haven't been updated in a long time.  Many of the links point to non-existent Tripod pages, and the ones that work point to a hand-drawn schematic or a GIF that's been saved as a JPEG again and again to the point of illegibility.  How frustrating!  Moreover, practical explanation of the theory is hard to come-by and often outdated.

The most important thing I've learned about engineering in my years is the importance of simplification.  Sometimes the amount of effort expended by engineers to make something easy dwarfs the effort needed for the original task.  That's why we have developed simple models for circuit elements.  Linear is easier to think about than non-linear.  Pretend an op-amp is linear and you'll be okay most of the time.  Don't worry about the temperature coefficient of a resistor most of the time.  Round off those last few decimal places!

Breaking apart the problem into smaller problems is the best way to manage the complexity.  Sometimes you will have to worry about the interaction between those problems though; that's where experience can help inform a solution. 

The niche I hope to serve is that group of people who haven't been completely turned off on the whole proposition of creating unique projects with their own knowledge.  Electronics isn't about buying a kit and soldering it together; that's soldering.  It's not about replicating a schematic without understanding it.

Electronics is a little weird and mathematical.  It's frustrating and confusing at times.  The dichotomy between theory and practicality can seem insurmountable.  However, with some knowledge and effort, electronics can be interesting and gratifying.

In my next post I will introduce you to what I believe to be a unique circuit for a guitar effect, as well as some basic knowledge you will need to follow along.  We'll refine it as we go and try to realize it.  I'll also hopefully introduce some tools to help, and I promise they won't be Windows-only programs that need a trip to The Wayback Machine to grab a demo that only works in 256-colors mode.