Picking The Right Output

The other day I ran across a publication from Allegro MicroSystems which was filled with an extensive list of terms and definitions for IC outputs. For instance, do you know the difference between a bipolar and a unipolar output? Well, a bipolar design allows the output to both sink and source current via controlled connections to power and ground. A unipolar output, however, can either sink or source current, but it cannot do both.

Now I don’t know about you, but I frequently confuse NPN and PNP outputs. I guess I just don’t work with these terms that often. Well, here’s one way to keep track of the difference: NPN outputs connect to the Negative supply while PNP outputs connect to the Positive supply. So just remember “N” for negative and “P” for positive! Take for example the following NPN sensor connected to a microcontroller (MCU):

NPN Sensor Wiring

The actual sensor circuitry is not shown here, only the output transistor. Now in this case, we have a unipolar output (the “Signal” line) which can only sink current to ground. In other words, this NPN sensor either connects the output to the negative supply (ground) or lets it float. In this configuration, however, the output does not float but gets pulled up to the positive supply line (V+) by a pull-up resistance. In this way, the input to the MCU is always either high (V+) or low (Gnd), but never in between (an undefined state).

For completeness, here’s one example of an actual PNP output used on a light curtain:

PNP Output ExampleThis may be a little tougher to interpret at first. However, there is one transistor directly connected between the positive supply rail (the topmost line) and the output (labeled OSSD). This means that the output may be connected directly to the positive supply as expected with a PNP configuration. This particular device also includes a pull-down resistor of 2.2kΩ. The difference here is that the pull-down may not always be connected to ground. That extra lower transistor can be disabled, allowing the output to float.

Anyway, check out that document and save it someplace – it might come in handy!

The $868.73 Op-Amp

Yes, you read that right; this here is an $868.73 operational amplifier, the Apex PA50A:

Apex PA50 Power Op-Amp

It doesn’t look like much, does it? Well at only ~1.5″ square, it’s not much larger than most power transistors. However, I can guarantee you it’s impressive. Most impressive. This is a power op-amp, which means it’s designed to deal with high currents and voltages. How high, you ask? Try 40 amps continuous (100A peak) at up to 130V. But you’re going to want a heat sink – this little guy may dissipate up to 400W internally.

JEDEC MO-127 HeatsinkNow sadly, these pictures aren’t mine, as I do not have a PA50 of my own. I also doubt I’d ever buy one (I just like to look at crazy-expensive parts on Digi-Key). However, this would be a fairly useful device. Normally op-amps are used at small-signal levels (from a few millivolts up to a few volts), and as such are only useful for amplifying sensors, performing filtering, etc. But with 40A and 130V to play with, you could drive multi-kilowatt speaker systems, go-kart motors, high-voltage transformers, etc (assuming stability with inductive loads). This baby would also make one serious output stage for a function generator, although its gain-bandwidth product is only 3Mhz. Interestingly, the datasheet lists “semiconductor testing” as the only potential application. Come on guys, I think a little more creativity is in order for such a product!

Now of course, you’re going to need one or two fairly beefy DC voltage sources to power the PA50, but I imagine they’ll cost you less than $800. And just what’s so special about this op-amp that drives up the cost so dramatically anyways? Frankly, I don’t know. Take a look at the following “equivalent schematic” provided in the PA50 datasheet:

PA50 Equivalent Schematic
Although this schematic doesn’t give values for individual components, we know that the final output MOSFETs (Q5,Q7,Q20,Q22) need to be rated for at least 100A (peak) and 130V. Well I’ve spec’d transistors like this in the past, and they’re not terribly expensive – perhaps $6-8 per device (double that if you want something really special). Even if all of the transistors in this package cost $10, that’s still just $220. Maybe there’s something costly about laying out all of this hardware in a single package? I’m certainly no expert in semiconductor design… Or perhaps the actual device is encased in 24k gold and diamond-studded? No, I guess they’re just trying to recoup development costs.

By the way, if you’re looking for high voltage instead of high current, try the Apex PA89, rated for ±600V output. It’s only $885.94 plus tax & shipping from Digi-Key. And don’t worry, I’m sure no one will question such a purchase. 🙂

The AVR AM Radio Transmitter (and Plantenna)

Fair warning: the following details on what led me to experiment with AVR-based AM radio transmission are rather long and convoluted. Feel free to skip to the good stuff.

Well just a couple of months ago I was in Toronto presenting a paper at this year’s IEEE CASE conference. While there I happened to speak with one gentlemen about his work in agricultural automation. He was looking for ways to autonomously and uniquely identify plants growing in the rows of a field. Now although each plant could be easily identified by the base of its stalk, the leaves of several plants often grew together. So if you wanted to take samples of a certain plant’s leaves, you might have trouble tracing base to leaf (particularly if you were a robot). Well this got me to thinking: what if we measured the electrical resistance between stalk base and leaf while sampling? Then perhaps we could determine which leaves belong to which stalk, thereby uniquely identifying our samples.

To test this idea, I popped outside with my multimeter and started sampling. Sadly, my initial resistance measurements, made by poking sewing needles into leaves and stems, proved unfruitful. Each pair of points I tested showed an impedance in the megaohm range, regardless of whether or not the points were located on the same plant. In other words, I couldn’t find a way to distinguish measurements taken on the same plant from measurements taken between plants. Well eventually I got to thinking that perhaps this was due to capacitance within the plant, and that I should instead try an AC impedance measurement. This technique has actually proven much more interesting. I’m still in the process of performing frequency response tests, but I’ll likely post my results next week.

The Plantenna?

So how does the electrical impedance of plants relate to AM radio transmission? Well, as I was injecting different high-frequency (10-100kHz) signals into my philodendron, I noticed that even with my second electrode disconnected, I still picked up a small but measurable radiated signal. This got me to thinking – can plants act as decent antennae? Or rather, plantennae? To find out, I decided to build a simple radio transmitter. And the simplest technique for radio transmission, as far as I know, is amplitude modulation.

The Technique

Faced with the task of constructing an AM transmitter, most people would probably build themselves a purely analog circuit based on one of the thousands of schematics available online. However, I don’t have much of a selection of analog parts and oscillators. Plus, I wanted to build something I’ve yet to see online: a microcontroller-based AM transmitter.

First, a little background is in order. According to the US Office of Spectrum Management, the AM broadcast band runs from 535 to 1605kHz; it’s the largest blue strip shown in the frequency allocation chart below (an equivalent chart for the UK can be found here):

US Frequency Allocation ChartSo the first thing I needed was a carrier wave oscillating somewhere within this frequency range. I then needed a way of modulating the amplitude of said carrier wave at any given audio frequency. This is the basic principle of amplitude modulation: your low-frequency audio signal essentially “rides” on top of a high-frequency carrier wave.

To accomplish this task, I used one of the timer/counter modules provided on my ATMega324, an 8-bit AVR microcontroller. With the chip internally clocked at 8Mhz, I configured counter TC1 to generate a PWM signal at approximately 540kHz. This output was then modulated via changes to its duty cycle (scroll to the end for source code):

AVR Amplitude Modulation Technique (not to scale)
At the top of the above image, in blue, is the PWM output generated by the ATMega324. You can see that its duty cycle is being modulated between about 5% and 50%. The rate of this modulation is controlled by a second MCU counter (TC0). Now this square-wave output isn’t quite ready for transmission. While it could be fed straight into an antenna, it should first be filtered to eliminate the harmonics inherent in any square-wave. This filtering actually converts the square-wave into a sine wave, producing the modulated output shown in yellow above. This signal can now be picked up by any AM radio, which will then convert this modulated transmission into an audio signal (the red line above).

In order to filter the AVR’s square-wave output into a sinusoidal AM signal, I designed a simple resonant RLC circuit. Not only does this clip off most of the square-wave’s harmonics, it actually provides a slight voltage amplification through resonance between C1 and L1. The resistance R3 in this circuit was needed to prevent excessive current draw from the AVR, and R2 is included to model the series resistance of the inductor L1:

PSpice RLC Circuit Schematic - The antenna is connected at the voltage probe.

PSpice Bode Plot - Cursors are located at ~540kHz

Now unfortunately, the components I had available yielded a resonant frequency of about 563kHz – slightly higher than my 540kHz target. However, the PSpice bode plot above still predicts a significant gain from the RLC circuit at 540kHz. Computing the resonant frequency of any RLC circuit can also be accomplished by using this simple formula:

RLC Resonant FrequencyIn addition, I ran simulations of this circuit’s transient response using a pulse input:

PSpice RLC Circuit Transient Response Schematic - The antenna is connected at the voltage probe.

PSpice Transient Plot
The ringing you see in the transient response above is not intentional, but has to do with the input frequency being slightly different from the resonant frequency. This is a phenomenon called beating. Fortunately, the beat frequency above is about 20kHz, which is well outside of the audio range, so this won’t impact the transmission of any signals.

So with the components selected, I proceeded to build and program my transmitter. An antenna was connected between the inductor and capacitor shown in the schematics above. Initially I used a piece of wire about 40.6″ in length (an even fraction of the transmitted wavelength). As planned, I also tested the system using a shorter length of wire (about 36″) connected to a houseplant via a small sewing pin. Interestingly, the plant actually did function slightly better than the wire whip antenna:

AVR AM Radio Circuitry

The receiver I used was a simple Timex clock radio, positioned on the other side of the plant, approximately three feet from my electronics and wire antenna:

Timex Clock Radio ReceiverAs I mentioned, the “plantenna” did slightly improve reception. However, the effect was admittedly quite small. My fingers actually had a greater impact on the signal’s strength than did the plantenna. Whenever I touched the leads of the resistor in my RLC filter, the volume and clarity of the received signal were noticably improved. Perhaps I need to try a few other varieties of plants?

Of course, what this circuit really needs is an active amplifier. However, increasing my transmission radius much beyond three feet would probably fracture a law or two. As it stands, I imagine my radiated power is somewhere in the microwatt range, so I doubt the FCC will be banging down my door any time soon. But you never know…

One final thing I found interesting: high-power AM signals actually transmit significantly farther at night than during the day. I’d read about this, but had never experienced the effect until the other night. During the daytime, AM540 had been almost completely clear of broadcasts. But at night, I was pulling in one station very clearly. In fact, it was almost overpowering my teeny transmitter. According to this website, “distant AM radio stations are better received at night because the ionosphere that reflects AM stations is protected from ionizing radiation and ionized particles from the Sun.” Pretty nifty, eh?

The Video

So having successfully tested this AM transmitter, my next logical step was to program it to play music. And the first thing that came to mind? The Tetris theme! I’ve played so much of that game it’s practically burned into my memory. So creating the following video wasn’t too tough, it just took a bit of trial and error getting the timing right. (And sadly, something weird seems to have happened to the audio during upload compression…)


  • The complete AVR Studio project can be found here
  • Or, if you just want a peek at the source code, try: am_test.c

ThinkPad T43p, T61p Power Consumption Tests

One of my biggest hobby electronics projects thus far has been the development of a solar power system, used primarily for home automation (for details see Part I and Part II). In the past, I’ve used it to partially power my five-year-old ThinkPad T43p laptop, which also acts as the brains of the system. Unfortunately, given the limited number of photovoltaic (PV) panels I possess (not to mention the lack of a good mounting location for these panels), I could only run the laptop off-grid for about six hours on a sunny day.

My ThinkPad T43p - This is one of my stock images.  If you look closely, you'll see that the lappy is actually in standby, despite what you see on the screen.Now that my PV system is (mostly) inactive, and I’ve got my Kill-A-Watt meter back, I’ve taken some time to quantify just how far I can reduce the power consumption of my T43p by disabling components. While I was at it, I ran the same tests on my more modern ThinkPad T61p. And if you’re like me, I think you’ll find the results rather interesting. 🙂

However, before I begin, I must tell you that this morning I’m mourning the loss of my ThinkPad T60. What, another laptop? Yes, admittedly, I have something of an obsession with ThinkPads. I bought the T60 as a replacement/upgrade for my T43p. I got a great deal on it from a guy on EBay, too – just $230 for a mint condition, perfectly functional PC. Even the battery still held about 80% of its design capacity. Unfortunately, after owning and operating my T60 for about six straight months, it shut down and now won’t start.

Dead, Partially-Disassembled, ThinkPad T60
I’m not really sure what’s happened; I wasn’t around when it failed. I had it running as a server in a remote location for several weeks. Then one day I just couldn’t connect. It appears the motherboard has been damaged somehow, but certainly not from any physical impact. Perhaps an electrical storm? I’ve tried everything – pressing the power button 10+ times as some forums have suggested, removing components, etc. It just won’t turn on. When plugged into AC, the battery and plug lights come on, but nothing more.

Well, at least I can still use it for parts. I’ve already swapped one of its 2GB RAM sticks into my mom’s virtually identical T60. And the battery fits my T61p, so now I can carry that along as a spare. I may look into buying a new motherboard, but it’d probably cost me another $80-100. Oh well… so far this is the only blemish on my ThinkPad experience.

Testing Power Consumption

P3 Kill-A-Watt MeterIn order to perform these tests, I’ve used a P3 Kill-A-Watt power meter. This is a super handy gadget for anyone interested in determining how quickly their devices are using electrical energy. It’ll measure up to 15A at 125VAC. In addition to current, voltage, and real power, this device also measures frequency, VA, and power factor.

I should quickly mention that while I trust the Kill-A-Watt’s real power measurements, I’m not sure it accurately computes power factor and VA for devices with non-sinusoidal current draws. And most laptop power supplies draw a very distorted current waveform due to the nature of their input rectifiers and capacitance. Here’s one example I recorded a few months back using the supply for my T61p and a nice hall-effect current probe:

ThinkPad T61p Current and Voltage Waveforms

The Kill-A-Watt claims this signal represents a power factor of 0.59. Although I haven’t crunched the numbers, my guess is that this is a little on the low side. Of course, I’m no expert in power-factor correction, particularly with such odd waveforms…

Well let’s get on to the good stuff. During this testing, I always allowed my laptops to reach a steady-state condition before recording anything. Thus, I took no data during boot-up, program launches, etc. I also ran all tests using a fully-charged battery. The following numbers would of course be somewhat higher if the battery were charging. However, just how much higher they’d be may vary depending on the battery’s state of charge. So in an effort to eliminate some variability, the battery in each laptop was first fully charged. The data I collected was then condensed into one simple graph (click to enlarge):

T43p Power Consumption Graph (Watts)Now you can look at this however you like, but I prefer to read it from left to right. So beginning on the left, in blue, you’ll see that the T43p draws a minimum or “base” power of 16W. As we move right, the numbers you see represent how much additional power is required by each specific component. For example, next in the sequence you’ll see that 1W is consumed to trickle charge the laptop’s battery. I determined this by first running the laptop without any battery connected. I then installing a charged battery pack and recorded the difference in measured power.

Moving right along the above graph, you’ll see that the T43p’s LCD backlight consumes seven watts. Next, I used the laptop’s power management software to set the CPU to its maximum clock speed, which required an additional four watts (and at this point, no additional software was calling for CPU time). Inserting the optical drive drew another watt. Surprisingly, enabling bluetooth consumed six more watts, while 802.11 wireless only called for 2W. Loading the CPU by enabling World Community Grid called for 10W. Next, running the hard drive with HD Tune required three more watts. Finally, I stressed the graphics card using the OpenGL benchmark within CineBench R10. This drew an additional six watts, bringing the T43p’s maximum power consumption to 56W. Not bad.

Next up, I performed the same tests with my main workhorse, the ThinkPad T61p:

T61p Power Consumption Graph (Watts)Interestingly, the T61p consumed slightly less base power than the older T43p – just 15W! Its backlight did draw a bit more power at 9W, but this isn’t terribly surprising since its screen is bigger. What I found particularly impressive was the ability of the CPU to throttle back, even when set to its highest clock rate. The difference between an unloaded and loaded CPU at full clock was 22W. The more modern graphics card of the T61p consumed about twice as much power as that of the T43p – fully 13W, bringing the total to 67W. Still not too bad. I should also note that with the T61p there was no noticeable difference in power consumption (e.g. from trickle charging) with the battery removed.

So there you have it! There’s quite a bit of power to be saved by cutting back your CPU speed (if your laptop allows it) as well as disabling your wireless radios and optical drive. Since I’ll be using my T43p as a server, I’ll also be able to disable itsLCD screen, which will get me very close to a base power of 16W. Not quite as good as an some netbooks, or the SheevaPlug, but still not bad given the processing power it affords me.

Oh and if you’re curious, here are my CineBench R10 results for both machines:

  • T43p Rendering (Single CPU – Pentium M 760 at 2.0GHz): 1694 CB-CPU
  • T43p Shading (OpenGL – 128MB ATI Mobility Fire V3200): 1015 CB-GFX
  • T61p Rendering (Single CPU – Intel T9300 at 2.5 GHz): 3061 CB-CPU
  • T61p Rendering (Multiple CPU – Intel T9300 at 2.5 GHz): 5757 CB-CPU
  • T61p Shading (OpenGL – 256MB NVIDIA Quadro FX 570M): 4212 CB-GFX

Computing for a Cause

World Community GridIf you’re reading this, it’s too late for me. you’re probably using a personal computer of some type. And as you read, your computer is most likely doing, well, approximately nothing. Sure, it’s keeping time, maybe playing a bit of light jazz and running a few background tasks. But in the grand scheme of things, it’s doing nothing. Your processor is likely just idly burning power.

So why not put that power to good use? For nearly five years now, my computers have been crunching data for the World Community Grid (WCG), a distributed-computing project which focuses on humanitarian projects. Although there are a number of similar grid-computing projects out there, I chose WCG because I believe what they do makes a real and positive impact on our world. Here are a few of their projects (source):

  • Clean Energy Project — tries to find the best organic compounds for solar cells and energy storage devices.
  • FightAIDS@Home — identifies candidate drugs that have the right shape and chemical characteristics to block HIV protease.
  • Help Conquer Cancer — improves the results of protein X-ray crystallography in order to increase understanding of cancer and its treatment.
  • Help Cure Muscular Dystrophy — investigates protein-protein interactions for more than 2,200 proteins whose structures are known, with a particular focus on those proteins that play a role in neuromuscular diseases. Currently on Phase 2.
  • Help Fight Childhood Cancer — finds drugs that can disable three particular proteins associated with neuroblastoma.
  • Human Proteome Folding Project — studies proteome folding in conjunction with Rosetta@home.
  • Influenza Antiviral Drug Search — finds drugs that can stop the spread of influenza strains that have become drug resistant, as well as new strains.
  • Nutritious Rice for the World — tries to predict the protein structure of rice in order to help rice breeders create more abundant, resilient and nutritious harvests. The project was finished in April 2010.

I can tell you from personal experience that using the BOINC software with WCG is totally painless. I run it as a background service, as opposed to a screensaver, and only occasionally look at the interface to see what’s happening. Whenever another program requires additional processing power, BOINC immediately yields its resources. I’ve never had a problem with this. However, you can also tell BOINC when it should run, and how much disk space, processing power, and RAM it may use. Currently two of my computers are on the grid – my personal laptop as well as this server. Check out my stats:

So if you’re looking for an easy way to save the world, join the World Community Grid.