15 November 2010

Design Note: Op-Amps

This quick note is less for design in an MSP430 circuit, but a quick tutorial on Op-Amps that will help those less familiar with electronic components to understand the next tutorial.

The Operational Amplifier, or Op-Amp is an extremely useful piece of hardware. (Some MSP430 devices come with Op-Amp peripherals built in!) The name reflects two very important functions of the device; it can be used to effect the equivalent of a mathematical operation to one or more electrical signals, or it can be used to amplify a signal.

While the details of how an op-amp works physically are a little complicated, visualizing what happens from a practical viewpoint is not so difficult. There are two inputs, labeled V+ and V- in the above schematic. The + and - labels next to the V+ and V- pins help you remember which pin is which. While both are inputs, they don't necessarily behave the same way, which gives the op-amp some of its flexibility. There is one output (Vout). Vs+ and Vs- are the positive and negative sides of a power supply. (Note that Vs- does not necessarily have to be a negative value--some circuit designs use ground on this pin.)

When you analyze an op-amp design, the simplest way to view the chip is to recognize that the output will be an amplification of the potential difference between the V+ and V- pins. Usually the gain on an op-amp is very high (1-10s of thousands) and so a very small difference can be enough to drive the output all the way up to Vs+ (if V+ > V-) or down to Vs- (if V+ < V-). (This is the behavior of what's called a differential amplifier.)

Since the gain is so high, we can use the op-amp in this configuration to compare two voltages. If voltage 1 on V+ is greater than voltage 2 on V-, we get a high output from the op-amp. If we have the reverse situation, we get a low output from the op-amp. In reality, general purpose op-amps are not the best choices to make this comparison, so a special chip called a comparator was designed to do this job. We'll examine it more closely in the coming tutorial.

The true power of the op-amp comes in the ability to tie the output to one of the inputs, providing a feedback that drives the output one direction or another. With feedback in place, the output will change until one of three conditions is reached: the output has increased to Vs+ and cannot increase further, the output has decreased to Vs- and cannot decrease further, or the output has found a state where the two inputs are the same potential. Whenever feedback is used, the output will drive up or down seeking to make the potential difference on the inputs zero.

Op-amps are a very important component for electronic designs. If you're not familiar with them, I'd highly recommend doing some reading to understand them better. (See for example the page on Wikipedia.) My purpose in this note was to mention the comparison operation so that readers have at least been introduced to the comparator before I write up the next tutorial.


This post was prepared while in Andenes, Norway.

01 November 2010

Design Note: Power

A number of comments in the community lately have suggested a note on powering the MSP430 outside of the launchpad would be helpful; to that end I'm writing up this design note to help explain the options and requirements for powering the MSP device.

Chip Configuration

The MSP430 has two pins for power that correspond to the high and low states for the digital logic: Vcc and Vss respectively. For the MSP430, Vss is typically ground and Vcc is usually in the 1.5-3.6 V range, depending on the application. (On the value line devices, these are labeled as DVCC and DVSS, with the D referring to the digital circuitry. Some devices also have a separate AVCC and AVSS for analog signals and peripherals. On these devices, you can tie the A and D supply pins to each other, but the ability to use separate supplies is there.)

Regardless of your chosen power source, there is one thing that must absolutely be done in all designs. Every MSP430 device has a RST/NMI pin. This pin allows you to reset the chip externally by grounding that pin. (The non-maskable interrupt feature is something we'll look at in a more advanced tutorial sometime in the future; for now, only the default operation of the pin is considered.) The LaunchPad is designed with a button that does just that.

In the button tutorial that for a button to behave as an input, the pin needs a definite default state (either grounded for active-high buttons or Vcc for active-low buttons). In order for a chip to be powered, the RST pin must be tied to Vcc. Note that a direct wire is not a safe method of doing this; if a reset is triggered and the pin is grounded, it would short out your power supply. A pull-up resistor is required, and a careful look at the LaunchPad schematic (it's on page 15) shows that TI uses a 47 kΩ resistor, and that seems a reasonable choice for the typical supply voltages one would use for any MSP430 design.

Note in the schematic one other aspect: on the Vcc pin, there are two capacitors. One of these is a 0.1 μF capacitor (100 nF if you're unfamiliar with SI prefixes) and the other a 10 μF capacitor. These capacitors are used to filter the power input, by which we mean keep any fluctuations in the power supply from affecting the value of Vcc. You will see below that many suggested designs for regulated power supplies use a 10 μF capacitor or similar on their output, and you may be able to get away with not using another on the MSP430 if you use one of these power sources. (You might have also noticed a small 1 nF capacitor connecting RST to ground. While not absolutely necessary, if you find your design has sporadic resets that you can't explain, add this capacitor. A TI support technician tells me that for SBW programming to work properly, it should be a capacitor of about 1 nF in size.)

Unlike the larger filtering capacitor, the 0.1 μF should always be included unless you have good reason not to. Digital circuits, especially when run at higher frequencies, can be susceptible to noise from pins switching between high and low. This capacitor is used specifically to filter out that noise, and works best if it can be physically located close to the Vcc pin on the MSP430. If you plan on making your own board designs rather than relying solely on the LaunchPad, get a number of this size of capacitor, as it will be used a lot!

Power Options

There are a huge number of possibilities for powering your circuit: solar panels, large super-capacitors, even various fruits will supply enough electrical power to run your MSP430 designs! For most hobbiest work, however, there are three major places from which to draw power: batteries (consumer type, like you'd buy at the grocery store), the wall AC, and the USB port of a computer.

Batteries are sometimes the easiest choice, but there are some caveats to consider. For the most part, a typical battery holder with a couple of wires can be connected to Vcc and Vss. On the LaunchPad, there are pins for this purpose; soldering female header pins to the wires or using jumpers make battery use simple. Before just connecting up, however, remember that the MSP430 can't handle voltages higher than about 4 V. A 9V battery might sound like a good idea, but alone is not safe to use on the microcontroller.

Good combinations of batteries: 1 or 2 alkaline AAA, AA, C, or D cells would give 1.5 V or 3 V, both good supply voltage values. If you switch to a rechargeable battery, double check the type. Many rechargeable cells are nominally 1.2 V rather than 1.5 V. If you use the 1.2 V cell types, you can use up to three of these in series (a total of 3.6 V) without trouble. Coin cell batteries also work well if you have a holder for them. In general, batteries need no other external parts, though it may be a good idea to have both filtering capacitors on the MSP430 in this case.

If you use a higher voltage battery or battery combination, or if you want to use the USB power (5 V), you will need to step down the voltage to an acceptable level. While there are a number of ways to do this, perhaps the simplest and most effective is to use a voltage regulator. (The LaunchPad is powered from USB; the portion of the board dedicated to the SBW programmer includes a voltage regulator to drop the USB line voltage to 3.6 V.) These components are cheap, robust, and work very well when used properly. Some can even handle such a wide range of inputs that you could connect most any common power source to it and have the output you need. If you've never used a voltage regulator before, read up about it and learn how to use them. An excellent tutorial can be found at SparkFun, and is a good place to start. For my designs, I like to use Linear Technologies regulators, such as the LT1763. (Note that the suggested design on the LT1763 page includes a 10 μF capacitor on its output.) This particular regulator is only available in surface mount packages, but Linear makes a number of other varieties that are comparable in through-hole packages (as an example, the LT1965). There are plenty of options out there that fall into the voltage ranges useful for the MSP430.

If you want to use a wall outlet, you will also need a transformer with a rectifier. Plenty of stores carry such power supplies in a variety of voltages. Anything in the 1.5-3.6 V range will work directly, but I've found most wall-wart supplies are 5 V or higher, and will require a regulator to operate the MSP430.

There are many, many more ways to power your circuit, but these will give you a few reliable sources to start from. Remember to tie the RST pin to Vcc with a resistor, add a 0.1 μF capacitor near the Vcc pin, and keep your voltage within the usable range for the MSP430. Don't forget to connect ground (or the negative side of the battery as the case may be) to the Vss pin, and have fun exploring your power options!