Last Posts

  • Art for the Maker Movement

    This is an idea I’ve been kicking around for awhile — I’ve wanted to do a photograph which captured what I think of when I think of makers, and which makers themselves would enjoy as a work.

    All of us started the same way — as curious kids (maybe big kids). At first, most of us were following in the path of someone else — along what feels like a straight, well-defined line. But there’s a point where things start to diverge, and we go off and do our own thing. That’s what making is all about, and that’s what I tried to capture here.

    Symbolism aside, I just dig this image. I’d like to sell it as a print, with a portion of the proceeds going to charity. What I’d like to know from you is if you’d be interested in buying such a thing. It’s always hard to judge whether or not a print will sell, especially for the artist, who is often too close to the work to be objective — that’s what galleries and curators are for. But I don’t want this to be a gallery piece. I’d like it to be an affordable work that people can hang in their homes, hackerspaces, shops, or offices and enjoy, so I’m asking you directly.

    This would be an 8×12 digital c-print, matted to 6×10, without a frame. The image above is a mockup of the final print in a frame. You can see a larger version of the image here. The price would be no more than $30/print and would include a custom matte.

    Please respond in the comments if you’re interested.

    UPDATE: Wow! Thank you all so much for your enthusiastic response! I’m currently working out distribution (shipping cost, setting up a shop, etc.) but it looks like this could really happen. Prepping the image for print takes some time too, because I set very high standards for myself when it comes to prints. Thanks again for your amazing comments and encouragement — they mean a lot to me!

    continue reading
  • Arduino Leonardo Pinout Reference

    I made this Arduino Leonardo pinout reference for anyone considering building shields for the Leonardo. Please note that shields designed for the UNO, Duemilanove, Diecimila and others will most likely NOT WORK on the Leonardo, because a lot of the pin functions have been moved around. This image helps you see some of the differences.

    For example, the lower 8 digital pins are no longer all a single port, and many of the pins, with the exception of the RX and TX lines, are moved around. Some of the PWM lines are in the same place, but are now connected to different ports and OC registers than they were before.

    On the other hand, you now have access to twice as many ADC pins as you did before, and you don’t have to give up 2 ADCs for I2C. You also get two more low-level interrupt lines and, of course, USB native functionality, which (I personally feel) is exciting!

    You can see the full-size image (about 2200×1600) in my Flickr photostream. This pinout was derived from the info found here. The Leonardo image is from the official Arduino Leonardo page.

    Happy hacking!

    continue reading
  • New Arduino Library: INA219 i2c Current/Power Monitor

    I’m happy to announce a new Arduino library —  my first ever — for the TI INA219 current/power monitor chip. This is a neat little chip that has an isolated shunt voltage amplifier tied to a 12-bit delta-sigma converter. It has on-board oversampling (up to 128 samples) and is addressable over I²C. The I²C is handled by the Arduino Wire library.

    The INA219 can provide the four main figures of interest for a DC bus: shunt voltage, bus voltage, load current and power. Note that it will not work with AC — it cannot calculate RMS values, or account for lead/lag phasing due to reactive loads — but it’s still super handy for monitoring the power consumption of circuits with DC rails.

    You can download the library and an example sketch over on GitHub.

    Happy current sensing!

     

    continue reading
  • Eico 377 Audio Generator, Part I

    This weekend I picked up a very nice Eico 377 Audio Generator. When I first took it home on Saturday, I fired it up and checked it on the scope. The output looked good — the only thing amiss was a burned out power indicator lamp. I figured that could be easily replaced, so I set it aside and left it until Monday. On Monday, I took the unit apart to replace the lamp:

    (Yes, it’s supposed to look like that.) In case you’re wondering about the light bulb, it’s part of the Wien bridge oscillator circuit. The negative resistance of the lamp acts as a variable parasitic path to ground — it keeps the gain around the feedback loop steady at 1 (unity), so that the ringing never saturates or dies out. The light bulb resistance is a clever hack originally invented by Bill Hewlett of Hewlett-Packard — since its introduction in the 1940’s, it became the standard topology for many Audio/IF oscillator circuits.

    After replacing the power indicator bulb, I turned the unit back on to play around with it some more. On start up it worked fine, as it had on Saturday. I left the room for a few minutes to let it stabilize, and when I came back, the output was different. It looked like the top trace in this image:

    Bear in mind that the scale in the bottom trace is off by a factor of 10. It reads as 5V/div, but it’s actually 50V/div. The Tek scope is not detecting that the HP probe used here is a 10x type, so it’s not correcting the scale.

    I suspect that at some point while I was out of the room, something went amiss inside the output buffer tube (V-4 in the schematic).

    (schematic from NostalgicKitsCentral.com) this schematic is actually from an earlier version of this unit — my unit has a dual-ganged vari-cap (not quad-ganged as shown here) and different range selector resistor values, but other than that the circuit is the same.

    The bottom trace in the scope image above is from the wiper of pot R22, which is just to the left of V-4, beyond the coupling cap C-14. Pot R22 is the amplitude pot on the front panel. As you can see, the bottom trace is a nice, clean sine wave, so V-4 is getting a decent input, but it’s putting out garbage. This garbage has a characteristic though — you can see how the ‘spike’ in the output is aligned perfectly with the crown of the sine wave of the bottom trace. Obviously, there’s some rectifier action going on. Only at the peak of the waveform is there enough potential to push beyond the threshold and cause some current to flow at the v-4 cathode (the output). I

    This leads me to believe that V-4 is either very weak, or completely bad. I tested the tube down at the local electronics shop, and it tested right on border of ‘good’ and ‘weak’, so it’s probably not entirely dead, but it still has some problems. I have no idea when that tester was last calibrated, though, so it could be totally shot. I’ll hopefully be getting a replacement tube next week, so then I’ll know for sure if it’s the tube or something else. It may also be one (or more) of the passive elements around the tube, but I doubt it. I checked them (with the tube removed) and they seem to align with the values printed on the sides, but you never know.

    In the meantime, we can look at the schematic to get a basic idea of how it works. This is what I’ve figured out so far:

    V-1 (6SJ7) is the active element in the Wien bridge oscillator.

    V-2 is a buffer for the oscillator, which makes sense because you wouldn’t want to load the Wien bridge directly.

    S-3 is the waveform switch, which selects between sine and square wave output. When ‘sine’ is selected, the V-2 output is routed directly to V-4 input via the R22 amplitude pot. When ‘square’ is selected, the V-2 output goes to V-3, which acts as a schmitt trigger to produce a square wave from the sinusoidal input. The output of V-3 is then routed to V-4, the output buffer (again via R22), which is where I suspect the problem is. Here’s the square wave version of the scope capture above:

    Again, the input to V-4 is shown on the bottom (but the V/div scale is off, it’s actually 50V/div), and the output is shown on top. The jitter is caused by variations coupled in from the power rail.

    One final interesting note is that the suppressor (topmost) grid of V-4 is not connected to anything, so this pentode is basically acting as a beam tetrode. In fact, both 6K6 tubes (V-2 and V-4) leave the suppressor unconnected, so I’m guessing the designers simply used this tube because it was cheaper (for them, at least — perhaps they had a lot of them in stock) than a dedicated beam tetrode.

    So, that’s it for now. Hopefully I’ll get this output issue fixed by next week and I can share some more pictures.

    The entire photo set is here.

    UPDATE: what I thought was a bad capacitor turned out to be a cold solder joint, something not terribly uncommon in user-assembled devices with this sort of rats-nest wiring. So there’s a lesson there: always reflow the solder joints before removing anything, since your problem might just be a loose or bad connection.

    continue reading
  • BB313 Parts List Update — 2.1mm DC Barrel Jack

    The BB313 parts list has been updated with a new DC barrel jack, after Mouser suddenly declared the old one obsolete. Mouser’s suggested replacement is (naturally) out of stock and isn’t expected until June, so you can use this one in the meantime, though it’s a bit more expensive.

    Thanks to Steve Wall for alerting me about the change of status. This was unexpected, as I had ordered 25 of the old barrel jacks only a week earlier, and there was no indication of end-of-life. Goes to show you need to keep a close eye on your supply chain, even for generic parts.

    continue reading
  • Opampomancy: Feedback Networks and the Non-Inverting Amplifier

    The purpose of this post is to lay out some of the stuff I wish someone had explained to me when I was first learning about electronics. This is a pretty entry-level introduction, intended by me to ‘fill in the gaps’ with regard to basic operating principles. Opamps are not all that complicated, but for many people they appear as a black box. With so many schematics available online, it can be very tempting to simply ‘cut-and-paste’ subcircuits into your own designs without understanding them. This is okay to a point, and useful for learning, but it may come back to bite you later if your design doesn’t work the way you expect it to.

     

    First, let’s look at the schematic symbol for an op-amp and identify the pins and their functions.

    V+ is the positive supply and V- is the negative supply. Often these will be omitted in diagrams, especially if the opamp is part of a dual or quad package. For most schematics, it is implied that the opamp is connected to such supply rails.

    Vin+ is the non-inverting input. Because of the plus sign, you may be tempted to call this the positive input, but that would be something of a misnomer because the signal voltage applied to it can positive or negative with respect to ground.

    Vin- is the inverting input. Again, the signal voltage applied here can be positive or negative with respect to ground.

    Vout is the voltage output.

     

    There are two concepts which are typically used to describe how opamps function. The first is: the voltage output of the opamp is the voltage difference between the two inputs multiplied by the gain of the device. The gain of the device is often denoted as A, and refers to the open-loop gain of the amp. Further, the voltage difference refers to the difference between the voltage at the non-inverting input (Vin+) and the voltage at the inverting input (Vin-). In other words:

    (1)   \begin{equation*}V_o = A \cdot (V_{in+} - V_{in-})\end{equation*}

    This voltage difference can be considered the input to the opamp. The order of terms in the above subtraction is where the inputs get their names. To explain, let’s assume that the voltage at Vin+ is X, and the voltage at Vin- is 0 (ground). Thus, Vin would be X – 0, which is just X. However, if Vin+ = 0 and Vin- = X, the input voltage would be -X (negative X), thus its sign would be inverted, hence the term inverting input. This sign inversion would hold true regardless of whether X itself was a positive or negative value (with respect to ground).

    So now that we’ve dealt with the Vin terms, let’s talk about A. A, as mentioned above, is the open-loop gain of the opampit is typically very large, on the order or 10,000 or more. This huge gain factor makes an open-loop opamp pretty useless for most applications. There are very few occasions where you would need to multiply a signal 10,000+ times, and even then it would be unwise to do so using an open-loop opamp. The reason is that even though A can be regarded as quite large, it’s very difficult to control exactly how large it will be. This is due to a number of factors, but mostly it’s due to manufacturing variances. The gain of the opamp is directly related to the gains of the individual transistors which make it up. Transistor gain can be difficult to control, particularly in large numbers. While it is possible to create very precise transistors, and thus pretty precise opamps, it’s not at all cheap. Further, it’s completely unnecessary, as we will soon see.

    It’s much better to approach opamp design from a different angle. Rather than create a device which has a large but precise gain factor, it’s better to create one with a theoretically infinite gain and provide some other constraint which can be used to control it. This brings us to the second big concept for opamp functionality:

     

    “An opamp tries to keep the voltage across its two inputs at zero.”

     

    In fact this is the fundamental operating principle of all opamps, but when I was first learning about active devices, I always found this statement to be very confusing. The problem is that very few sources go on to explain why this is so. It seems a little counter-intuitive. Amplifiers aren’t supposed to make things smaller (or zero), they’re supposed to make them bigger, so why is the opamp trying to mitigate it’s own inputs, and how the heck does it do that?

    I’ll answer the second question first. The how is with a feedback network. The original statement would be more complete if it read:

     

    “An opamp tries to keep the voltage across its two inputs zero by using a feedback network to control one of the inputs with the output.

     

    The construction of the feedback network will determine the extent to which the opamp has to swing the output one direction or another, so that one of the inputs is equal to the other input. The easiest way to explain this is by looking at a simple circuit — the non-inverting amplifier:

    In the non-inverting amplifier, the input voltage is applied to the non-inverting (+) input of the amp. The output of the amp is connected, via a feedback resistor, to the inverting (-) input. There are two resistors here which make up the feedback network. The first is the aforementioned feedback resistor (R_feedback or R_f), and the second is a resistor from the inverting input to ground, called R_ground or simply R_g. Let’s ignore the non-inverting input for now and just look at the feedback network — it forms what is known as a voltage divider. Below is an example of a simple voltage divider circuit.

    A voltage divider is so named because it provides a fraction of the input voltage as its output. The simplest voltage divider is made with two resistors, R1 and R2. In the figure above, the output voltage (Vout) is equal to the input voltage (Vin) times the ratio of the lower resistance, R2, to the total resistance, R1+R2. The lower point of R2 is tied to ground.

    (2)    \begin{equation*} V_o = V_{in} \cdot \frac{R_2}{R_1+R_2} \end{equation*}

    The nice thing about the voltage divider is that it has lots of applications, one of which is in our non-inverting amplifier feedback network. In that case, the input to the voltage divider would be the output of the opamp, and the inverting input of the opamp is the output of the voltage divider. Seems very confusing, I know. Perhaps a diagram will help.

    The formula for the voltage divider still applies, and we can substitute the terms from the non-inverting amplifier from above:

    (3)    \begin{equation*} V_{in-} = V_o \cdot \frac{R_g}{R_f+R_g} \end{equation*}

    To make things a little clearer, let’s replace the resistor fraction with something less cluttered — the greek letter Beta:

    (4)    \begin{equation*} \beta = \frac{R_g}{R_f+R_g} \end{equation*}

    –thus–

    (5)    \begin{equation*} V_{in-} = V_o \cdot \beta \end{equation*}

    Ok, now we need to relate this equation to the whole circuit, so that we can come up with the transfer function for the non-inverting amplifier. A transfer function is an equation that describes the output in terms of the input. It’s usually written as follows:

    (6)    \begin{equation*} \frac{output}{input} = transfer function \end{equation*}

    In other words, it’s a function that describes the ratio of the output to the input. This is an easy form to understand and use, because to find the value of the output, all we need to do is multiply the transfer function by the input value. Remember that the input to the whole circuit is at the non-inverting input, so we are going to need to include that in our function as well.

    NOTE: From this point on, it’s mostly just a lot of algebra — moving terms around between both sides of the equation until we get a nice Vout/Vin transfer function. If you’re thinking of studying electrical engineering, you should know that this stuff is critical. Being able to do algebra like this quickly is something you should make an effort to get really good at, because you will use it all the time. There aren’t really any shortcuts here — you just have to do it.

    One of the problems when you’re studying this stuff is that textbook authors tend to ‘skip steps’ when reducing or reconfiguring equations, because they assume some intermediate steps are self-evident. Sometimes they are, particularly if you have a lot of experience working equations, but for n00bs (or sleepy college students), they are not. As such, I’m going to try to show each and every step, and explain what I’m doing, so you can understand it.

    Getting back to the problem at hand, we need to create a transfer function for our opamp+feedback network. In order to do that, we will take equation (3) and substitute it into equation (1), replacing Vin- with the voltage divider equation. Doing that, we get:

    (7)    \begin{equation*} V_o = A \cdot \left(V_{in+} - V_o \cdot \beta\right) \end{equation*}

    –or–

    (8)    \begin{equation*} V_o = A \cdot V_{in+} - A \cdot V_o \cdot \beta \end{equation*}

    The next step is to get both Vo terms over on the same side of the equation, so let’s do it:

    (9)    \begin{equation*} V_o + A \cdot V_o \cdot \beta = A \cdot V_{in+} \end{equation*}

    Now we extract the Vo term as a common coefficient of both terms on the left.

    (10)    \begin{equation*} V_o \cdot \left(1 + A \cdot \beta\right) = A \cdot V_{in+} \end{equation*}

    Our original mission, of course, was to find the transfer function of Vo/Vin. Vin, in this case, is Vin+, so we want to find Vo/Vin+, so we divide both sides by Vo.

    (11)    \begin{equation*} 1 + A \cdot \beta = \frac {(A \cdot V_{in+})}{V_o} \end{equation*}

    Now we’ll divide both sides by A:

    (12)    \begin{equation*} \frac{\left(1 + A \cdot \beta\right)}{A} = \frac {V_{in+}}{V_o} \end{equation*}

    which becomes:

    (13)    \begin{equation*} \frac{1}{A} + \frac{A \cdot \beta}{A} = \frac {V_{in+}}{V_o} \end{equation*}

    Now we can use a little trick to simplify things. Recall that A is very large — theoretically infinite. As such, 1/A is very small, theoretically zero. We can use this to our advantage, because it means we can get rid of the 1/A term by equating it to zero. Further, looking at the second term on the left, the A in the numerator and the denominator cancel out, so we can get rid of them too.

    (14)    \begin{equation*} 0 + \frac{A \cdot \beta}{A} = \beta = \frac {V_{in+}}{V_o} \end{equation*}

    Oh snap! Look how much simpler that is! Now we can substitute back the resistor fraction for Beta:

    (15)    \begin{equation*} \frac{R_g}{R_f+R_g} = \frac {V_{in+}}{V_o} \end{equation*}

    and we invert both sides to get the Vout/Vin form we’re aiming for:

    (16)    \begin{equation*} \frac {V_o}{V_{in+}} = \frac{R_f+R_g}{R_g} \end{equation*}

    Rg/Rg = 1, so:

    (17)    \begin{equation*} \frac {V_o}{V_{in+}} = \frac{R_f}{R_g} + 1 \end{equation*}

    To figure out Vo in terms of Vin, we simply multiply:

    (18)    \begin{equation*} {V_o} = V_{in+} \cdot (\frac{R_f}{R_g} + 1) \end{equation*}

    And that’s the equation of a non-inverting amplifier. Now that we know where that formula comes from and how it’s derived, it’s a little easier to understand the concept of a feedback network. In order to create a voltage at Vin- which is equal to the voltage at Vin+, the opamp has to produce an output voltage  which, when attenuated by the Rf/Rg divider, is equal to Vin+. So, if the voltage divider is set up to output 50% of its input, the opamp has to produce a voltage twice as large as the voltage at Vin+ in order to mitigate it. As such, it is indeed acting as an amplifier with a gain of 2. Likewise, other voltage divider values would produce different gains, as expressed in equation 18.

    So now that you know how it works, you should build a couple circuits to try it out. Happy amplifying!

    About the equations: the equations here are rendered as alpha-channel PNGs with the WP QuickLaTeX plugin. This is a great plugin which renders LaTeX beautifully and even provides equation numbers. If you want something that will allow you to write nice-looking equations on a blog, you should check it out.

    continue reading
  • BB313 Pinout Reference Sheet

    I created this reference sheet for my BB313 board outlining all the alternate pin functions and descriptions. While I’ve pretty much got the pins memorized at this point (from constantly cross-checking with the ’313 datasheet), I wish I’d thought of this earlier. The sheet is a single-page 8.5×11 PDF, so you can just print it out and keep it for reference at the workbench (or desktop). You can get the PDF, as well as all the project source files, at the GitHub project page.

    continue reading
  • ‘Constant Brightness’ HSB to RGB Algorithm

    For an embedded project I’m working on, I had to implement an algorithm to convert from HSB (hue/saturation/brightness) to RGB color values. This is what I came up with. It creates a ‘constant brightness’ RGB value: at full saturation (no ‘whitewash’), only two of the 3 RGB colors are on at a time, and their ‘on’ times are mathematically complimentary (though not phase-complimentary) with respect to the max 255 value.

    Increasing saturation will increase the overall brightness of the LEDs, but that is to be expected — for a given maximum magnitude, there is more overall energy in white light than there is in light of a particular color. The saturation calculation works by adding a constant ‘floor’ value to all channels. Individual color values are then placed between this floor and the 255 maximum. A saturation value of 0 results in all channels at 100% duty cycle.

    The ‘brightness’ is the last calculation performed. It takes a saturation modified hue value, and simply proportions it to the maximum value. So, a brightness of 197 will output light which is ~197/255 of the maximum output value. Naturally, there are losses inherent to integer arithmetic, but it’s close enough for most uses. Further, the linear nature of the brightness control means it is not ‘gamma corrected’ — that would require logarithmic brightness control which, for what I’m doing, is completely unnecessary.

    This algorithm uses no sine tables or floating point math, so it’s pretty fast, though it could probably be optimized to use shifts and adds instead of mults and divides. It’s also relatively small. The code itself is in C, so it can be used on most platforms.

    /******************************************************************************
     * accepts hue, saturation and brightness values and outputs three 8-bit color
     * values in an array (color[])
     *
     * saturation (sat) and brightness (bright) are 8-bit values.
     *
     * hue (index) is a value between 0 and 767. hue values out of range are
     * rendered as 0.
     *
     *****************************************************************************/
    void hsb2rgb(uint16_t index, uint8_t sat, uint8_t bright, uint8_t color[3])
    {
    	uint16_t r_temp, g_temp, b_temp;
    	uint8_t index_mod;
    	uint8_t inverse_sat = (sat ^ 255);
    
    	index = index % 768;
    	index_mod = index % 256;
    
    	if (index < 256)
    	{
    		r_temp = index_mod ^ 255;
    		g_temp = index_mod;
    		b_temp = 0;
    	}
    
    	else if (index < 512)
    	{
    		r_temp = 0;
    		g_temp = index_mod ^ 255;
    		b_temp = index_mod;
    	}
    
    	else if ( index < 768)
    	{
    		r_temp = index_mod;
    		g_temp = 0;
    		b_temp = index_mod ^ 255;
    	}
    
    	else
    	{
    		r_temp = 0;
    		g_temp = 0;
    		b_temp = 0;
    	}
    
    	r_temp = ((r_temp * sat) / 255) + inverse_sat;
    	g_temp = ((g_temp * sat) / 255) + inverse_sat;
    	b_temp = ((b_temp * sat) / 255) + inverse_sat;
    
    	r_temp = (r_temp * bright) / 255;
    	g_temp = (g_temp * bright) / 255;
    	b_temp = (b_temp * bright) / 255;
    
    	color[RED] 	= (uint8_t)r_temp;
    	color[GREEN]	= (uint8_t)g_temp;
    	color[BLUE]	= (uint8_t)b_temp;
    }
    continue reading
  • Amazing Steamed Greenbeans with Mirepoix

    So tonight I made some awesome panko chicken. To go along with it, I made this delicious steamed green bean recipe. I was surprised at just how good it was, so I’m posting it here. You can thank me later.

    • 1 package frozen green beans, defrosted.
    • 1 cup baby carrots, chopped into 1/2-inch discs.
    • 1/2 cup chopped celery
    • 1/2 cup chopped yellow onion.
    • 1 tsp each garlic powder, coriander seed, black pepper.
    • 1/2 tsp. thyme.
    • 1 tsp. unsalted butter.
    • 1-1/2 tbsp olive oil (not extra virgin)

    Fill a medium saucepan with about 3-4 cups of cold water.

    Place all the vegetables into a steamer and cover with the spices. Drizzle the olive oil over the veggies and then toss the mixture a few times until the vegetables are evenly coated. Place the pat of butter on top of the vegetables, and put the steamer on top of the saucepan.

    Set the burner to medium-high and let the water come to a boil. Open up the steamer and toss the vegetables around a bit. Depending on the steamer and what kind of heat ‘medium-high’ corresponds to on your stove, it should take about 8 minutes. Basically, you want to stop the process when the onions are translucent and the carrots are just tender (but not mushy).

    Turn the heat off, strain the excess water from the vegetables and serve.

    continue reading
  • BB313: A Breadboarding Platform for the ATTiny2313/4313

    A little over a year ago, I started playing around with the newly available AVR ATTiny4313. It’s a neat little chip, and you can have a lot of fun with it. However, I soon got tired of wiring up programming headers, power supplies and all the other stuff you need to get up and running. I also grew wary of all this support circuitry taking up significant breadboard real estate.

    To eliminate all that hassle, I created the BB313. It’s got all the stuff you need (programming header, regulated 5V power, etc.) wrapped up in a nice little package, and it plugs in on the edge of the breadboard so you have lots of space for other stuff. I also added an 6-pin connector for an FTDI cable or adapter.

    I originally designed it for myself, but I figured other people might like it too, so I’m releasing it open-source CC-BY-SA 3.0) so you can make your own.

    All the details and source files are at the project page. If you find it useful, please let me know!

    You might also find the following items useful:

    USBtinyISP programmer, FTDI friend, and 9V switching power supply, all available from Adafruit Industries in NYC.

     

    continue reading