Analog Filter Essentials

Analog frequency-selective filters are useful for noise reduction, antialiasing before digitizing a signal, frequency response correction, and more. In this article, Circuit Cellar columnist Robert Lacoste explains the differences between filters and how to design them with computer-aided tools.
 

The following article by Robert Lacoste appears in Circuit Cellar 307, 2016.

 
 
Welcome back to the Darker Side. I spoke about operational amplifiers (op-amps) in my last few columns. Op-amps shine in plenty of applications—in particular, to build active filters. This month, I’ll focus on filters—more precisely, analog frequency-selective filters, which are used in audio devices, as well as for noise reduction, antialiasing before digitizing a signal, separation of frequency-multiplexed signals, frequency response correction, and so on.

So analog filters must be in the bag of tricks of any designer. Unfortunately, filter design, or even their use, is often perceived as a difficult task close to black magic. This is, well, unfortunate. Filters are definitively useful, simple, and even fun. I bet a textbook about filters full of math would bore you, right? Well, relax. My goal for this article is more pragmatic. I will try to help you to specify a filter, understand the main filter variants, and efficiently use some great computer-aided design tools. I promise, no Laplace transforms or poles or zeros, just electronics.

FILTER SPECIFICATIONS

Let’s start with some vocabulary. By definition, a filter is a circuit that attenuates some signals more than others, depending on their frequency. Figure 1 depicts the most classic filter types. A low-pass filter lets the low frequencies pass through, but attenuates high-frequency signals. It is perfect for removing high-frequency noise on a signal coming from a sensor.

FIGURE 1: Four classic types of frequency filters. Each one attenuates a specific frequency range.

FIGURE 1: Four classic types of frequency filters. Each one attenuates a specific frequency range. Click image to enlarge.

Conversely, a high-pass filter attenuates the low frequencies, and could in particular remove any DC component of a signal. Band-pass filters are a combination of both, and they attenuate all frequencies below or above a given range. For example, any radio frequency receiver is a band-pass filter, providing attenuation of all signals except for frequencies close to its preset frequency. Lastly, a band stop filter, often called a notch filter, does the opposite, and it attenuates a selected range of frequencies. For example, a 50- or 60-Hz notch filter is included in virtually every weight scale to remove EMC perturbations from the surrounding power lines.

Want to specify a filter? Figure 2 illustrates this on a low-pass filter. The first parameter is the filter cut-off frequency, of course. By definition, this is the frequency at which the filter attenuates the power of the signal by 50%. This means that the losses of the filter will be 3 dB at that frequency. Aren’t you fluent with decibels? A decibel is one tenth of a Bel, and a Bel is the base-10 logarithm of the ratio of two powers. Take your calculator and enter 10 × log(0.5), you will get –3.01, which everybody rounds to –3 dB.

FIGURE 2 A filter (low-pass in this case) is specified by its cutoff frequency f3dB, its ripple in the pass-band, and its rejection in the stopband.

FIGURE 2: A filter (low-pass in this case) is specified by its cutoff frequency f3dB, its ripple in the pass-band, and its rejection in the stopband. Click image to enlarge.

But perhaps an attenuation of 3 dB is already too much for your application. The maximum tolerated variation of signal power in the pass-band (here from DC to fPB) is called the ripple of the filter. Lastly, you will very probably want to specify that the filter must provide a given minimum attenuation, called rejection, above some frequency fSB. Of course, these specifications must be established with care. If you decide that you need a filter with 0.01 dB of ripple up to 10 kHz and 100 dB of rejection from 11 kHz upward, you will probably need plenty of time and cash for the design.

RC FILTERS

I propose to start with the most basic designs: RC filters. The basic low-pass filter is built with one series resistor and one capacitor to ground (see Figure 3). The capacitor impedance gets lower when the frequency increases, and the signal power is attenuated. This filter is called a first-order filter, and it provides an attenuation of 6 dB per octave or 20 dB per decade. (. Simply because 23.33 = 10, and 3.33 × 6 = 20.) That means that, above its cut-off frequency, its attenuation is increased by 6 dB each time the frequency is doubled, or by 20 dB each time it is multiplied by 10. I did the simulation for you with Labcenter Electronics Proteus. Figure 3 shows the result. You can do the same with any Spice-based simulator like the free LT-Spice. The attenuation of this RC filter is –20 dB at 100 kHz, and 20 dB more, meaning –40 dB, at 10 × 100 kHz = 1 MHz as expected.

FIGURE 3 A first-order RC filter (top) provides an attenuation of 20 dB/decade (green curve), whereas a second-order filter provides 40 dB/decade (red).

FIGURE 3: A first-order RC filter (top) provides an attenuation of 20 dB/decade (green curve), whereas a second-order filter provides 40 dB/decade (red). Click image to enlarge.

Such a RC filter can be designed for any cutoff frequency. Just select the proper values for R and C. You might wonder how to calculate the values of the R and C. For a single RC cell, it is really easy. The cutoff frequency is 1/(2pRC).

If you want to increase the steepness of the attenuation, you can chain several RCs. For example, I simulated a second-order RC filter, with two RC cells in series (see Figure 3). As expected, the attenuation is now 12 dB (i.e., 2 × 6) per octave, or 40 dB (i.e., 2 × 20) per decade. Nothing magic. The 3-dB cutoff frequency is pushed downward as compared to a single RC cell, simply because at the 3-dB cutoff of each cell the attenuation is now 6 dB. However, you can see in the graph that even if the falloff in high frequencies is two times better, the drop around the cutoff frequency isn’t improved: it is still “soft.” That’s a limitation of cascaded RC cells. I will present you with a better solution.

Maybe a low-pass filter isn’t what you need. If you prefer a high-pass filter, then just exchange capacitors and resistors. A series capacitor and a resistor to ground would make it. Do you want a band-pass? Just put a low-pass cell in series with a high-pass cell with the appropriate cutoff frequencies. For example, a 10-to-50-kHz band-pass can be built with a 10-kHz high pass and a 50-kHz low pass. And for a notch filter? Do the same with the two filters in parallel. With the same example, a 10-to-50-kHz band stop may be implemented with a 10-kHz low pass and 50-kHz high pass in parallel. Easy.

LC FILTERS

For a given filter performance, is it possible to build a passive analog filter with fewer parts than a multicell RC filter and with improved performance? Yes, you can use LC filters. Here the filter is made with capacitors and inductors, as illustrated in Figure 4. How steep can be their attenuation profile? Very easy. It is the same in the case of RC filters. Count the number of capacitors, add the number of inductors, and you’ll get the order or the filter. Then multiply by 6 dB to get the attenuation per octave, or by 20 dB for an attenuation per decade! For example, the first filter simulated in Figure 4 has one inductor and one capacitor. Two parts, so it is a second-order filter, with the same 40 dB/octave attenuation as the dual RC example in Figure 3. The bottom example has three capacitors and two inductors; therefore, its attenuation is 100 dB (i.e., 5 × 5) per decade or 30 dB (i.e., 5 × 6) per octave. I promise. It’s simple!

FIGURE 4: This simulation shows the frequency response of three LC filters, respectively, of order two, three, and five from top to bottom. Their outputs are open-ended, which imply some overshoot.

FIGURE 4: This simulation shows the frequency response of three LC filters, respectively, of order two, three, and five from top to bottom. Their outputs are open-ended, which imply some overshoot. Click image to enlarge.

Well, nearly. Let’s now see the small details. If you refer back to Figure 4, you’ll see that such LC filters have a weird response around their cutoff frequencies. There is an overshoot, which means they have a positive gain at some frequencies. Of course, such passive filters can’t “create energy.” This positive gain is due to the fact that their output is open-circuited so no energy actually flows anywhere. Don’t be confused. This is not an artifact of the simulation. This would be exactly the same on an actual circuit. The amplitude of the overshoot is directly linked to the so-called quality factor of the L and C parts, and in particular their series resistance. If the capacitor and inductors are ideal, then the overshoot will be infinite at the frequency where the L and C oscillate. That’s why I added a small 47-Ω series resistor on the simulations. If you change the value of this series resistor, then the shape of the gain curve changes. I illustrated it in Figure 5 (top graph) which shows a series resistor ranging from 5 to 100 Ω.

FIGURE 5: The top simulation shows the frequency response of an open-ended LC filter with varying serial resistor value. The bottom simulation shows that the overshoot disappears when the filter is connected to a matched load. X varies from 5 to 100 Ω.

FIGURE 5: The top simulation shows the frequency response of an open-ended LC filter with varying serial resistor value. The bottom simulation shows that the overshoot disappears when the filter is connected to a matched load. X varies from 5 to 100 Ω. Click image to enlarge.

How do you avoid such oscillations? Simply connect the filter’s output to a proper load. If you are a regular reader of my columns, you won’t be surprised: this load must provide an impedance matching with the source impedance. Look at the second example in Figure 5. I added a load resistor R3 of the same value as the source resistor R2 (denoted X). I then asked the simulator to show the resulting gain versus frequency graph with different values for these resistors X, ranging from 5 to 100 Ω again. The shapes are varying, but there are no overshoots. Moreover a precise resistor value provides a very clean and flat response, linked of course with the values of the L and C parts. This value, here 50 ohm, is the characteristic impedance of the LC filter.

So LC filters must be calculated to get the required frequency response but also taking into account the impedance of the load. For second order filters, using just one inductor and one capacitor, the calculation are straightforward. The cutoff frequency is f3dB = 1/[2p√(LC)], and the characteristic impedance is Z = √(L/C). If you know the required cutoff frequency and designed impedance, then you can easily calculate L and C from these two formulas.

The calculation is not so straightforward for higher-order filters, especially as the design choices are numerous. More on that below. Our ancestors used the abacus; now we can use web-based design tools. (Refer to the Resources section of this article for some links to free LC filter calculators.) There is even a great design tool from Coilcraft that allows you to directly order the samples of the required inductors with a mouse click. Easy, I promised.

FROM LC TO ACTIVE FILTERS

Using inductors often isn’t pleasant. They can be heavy and large, and they’re always significantly more expensive than capacitors and resistors. Moreover, inductors are often quite far from ideal components. They can have a high series resistance as well as parasitic capacitance, nasty electromagnetic compatibility behavior, and a couple of other issues. How can you keep the performance of an LC filter without using inductors? With an active filter, usually built around our dear friend the op-amp.

There are basically three ways to build an active filter. The first is to simply add an amplifier to the RC filters I’ve already talked about. For example, you can add a voltage follower after an RC cell in order to reduce its output impedance or to provide some gain. You can also wire an op-amp as a differentiator or integrator, which are first-order filters.

The second solution is to build a switched-capacitor filter circuit. (I devoted my Circuit Cellar 277 column to the subject.) So let’s talk about the third option, which is based on so-called gyrators. What is that? A gyrator is a circuit that mimics the behavior of an inductor, using an op-amp and only resistors and capacitors. You will find plenty of literature on the subject. Of course, this is explained in the bible, Paul Horowitz and Winfield Hill’s The Art of Electronics, but Rod Elliott provides a clear presentation on the subject in “Active Filters Using Gyrators – Characteristics, and Examples,” (Elliott Sound Products, 2014).

Look at Figure 6 where I have illustrated the basic concept. The top part of the schematic is a classic second-order LC high-pass filter with matched source and load impedances. I used a 390-nF capacitor and a 1-mH inductor, resulting in a cutoff frequency of 8 kHz and a characteristic impedance of 50 Ω—here roughly matched with source and load 56-Ω resistors.

FIGURE 6 This simulation shows the transformation of an LC high-pass filter (top) into a gyrator-based circuit (middle), which is really close to the common Sallen Key filter (bottom).

FIGURE 6: This simulation shows the transformation of an LC high-pass filter (top) into a gyrator-based circuit (middle), which is really close to the common Sallen Key filter (bottom). Click image to enlarge.

The response curve shows noting surprising with a 40 dB/decade (i.e., 2 × 20) attenuation in the stopband. Its gain is –6 dB in the passband, as the voltage is divided by two due to the source and load resistors. (The power is divided by 22 = 4, giving –6 dB.) Now look at the middle section of the schematic in Figure 6. The circuit is exactly the same, but I replaced the inductor with an op-amp, a capacitor, and two resistors. That’s a gyrator. If you look now at the resulting graph, you will see that its frequency response is exactly the same as the LC version, at least up to 1 MHz where the characteristics of the op-amp start to be limiting.

Now another magic trick. Compare the gyrator-based schematic with the schematic at the bottom of Figure 6. If you move the parts and the wires around, you will see that they are exactly identical, except the output is now directly connected to the op-amp output. Do you recognize the new schematic? It is a Sallen-Key second-order active high-pass filter. I modified the part values to a more reasonable range, but you can see that the output frequency response is still the same. More precisely, it doesn’t suffer from the 6-dB losses as the signal is taken directly at the output of the op-amp. So Sallen-Key filters, gyrator-based filters, and LC filters are more than cousins.

FILTER RESPONSES

If you want to design a single-cell filter, either a first-order RC filter, a second-order LC, or an active filter, then you will not have a lot of design choices. You can select the desired filter type, cutoff frequency, and impedance, but nothing more. However, for higher-order filters, the choices are wider. The filter is made of several cells, and you can tune each cell separately. Therefore, you will have a better attenuation curve thanks to the higher order (remember, 6 dB per octave multiplied by the order of the filter), as well as more control on the shape of the filter.

Nothing prevents you from designing your own filter, tweaking each cell however you want. However, mathematicians have already calculated several “optimal” filters for certain applications. Do you want to have a response curve as flat as possible in the passband? Stephen Butterworth calculated it for you in 1930. It’s now called the Butterworth filter, of course. Do you prefer to attenuate as quickly as possible the stop-band even if it implies a higher level of ripple in the pass-band? Use a Chebyshev filter, derived from the Chebyshev polynomials. More precisely, this is a family of filters based on the acceptable ripple (e.g., 0.5 dB). The so-called elliptic filters are close.

The last common variant, the Bessel filter, is a little more complex. A Bessel filter is not a great option both in terms of flatness and attenuation; however, it has a key advantage in the time domain. Its so-called group delay is nearly flat. That brings us a little too far here, but these characteristics preserve the shape of the filtered signals in the time domain. I will tackle that subject in another article.

Of course, each variant has drawbacks. For the same filter complexity, a higher ripple in the passband must be accepted to get a higher attenuation in the stop-band. Similarly, a better phase flatness implies a worse frequency response. Life is difficult, but you are the designer, so you have the control. Figure 7 shows the characteristic responses of each filter variant.[1] For more information, I strongly encourage you to have a look at the “Analog Filters” chapter in Hank Zumbahlen’s Linear Circuit Design Handbook (Analog Devices, 2008).

FIGURE 7: These plots show the typical frequency and time (step and impluse) response of the three most common filter variants. (Source: Linear Circuit Design Handbook, Analog Devices)

FIGURE 7: These plots show the typical frequency and time (step and impluse) response of the three most common filter variants. Click image to enlarge. (Source: Linear Circuit Design Handbook, Analog Devices)

DESIGNER TOOLS

So you have plenty of options when designing a filter. Fortunately, there are great computer-based design tools made for the design engineer. Some are expensive, but plenty are free. In particular, several op-amp suppliers offer filter design tools for their products. I like Analog Devices’s Analog Filter Wizard (www.analog.com/designtools/en/filterwizard/). It’s powerful and doesn’t require a PC installation. Other solutions include Texas Instruments’s Webench Filter Designer, Microchip Technology’s FilterLab, Linear Technology’s FilterCAD, and some others.

FIGURE 8 With a tool like the Analog Filter Wizard (Analog Devices), life is easy

FIGURE 8: With a tool like the Analog Filter Wizard (Analog Devices), life is easy. Click image to enlarge.

As an example, Figure 8 shows a typical session with Analog Devices’s Analog Filter Design. Basically, you start by selecting the filter type (here a low-pass), the required gain in the pass-band, the cutoff frequency, and the attenuation you want at a given stop-band frequency. A slider enables you to browse through several designs—namely, Chebyshev, Butterworth, and others. The next window enables you select the desired tolerance for the capacitors and resistors and actually draw the filter’s full schematic (of course using an op-amp from the supplier who offered the tool). Lastly, the resulting frequency, phase, and time plots are generated, taking into account the tolerance of the parts. Other options enable you to calculate the power consumption of the design or its noise figure. Of course, the beauty of such a tool is that you can try tens of designs in minutes and select the most adequate for your specifications and budget.

WRAPPING UP

Here we are. As always, I have only scratched the subject’s surface. Anyway, I hope you grasped the key concepts. Go through the content listed in the Resources section of this article, and don’t forget to practice on your own. Maybe you should stop reading this magazine now (don’t forget to come back to the issue later), download one of the filter design tools, and play with the settings. It would be the best way to really understand the difference between a fourth-order Butterworth filter and a third-order Chebyshev filter. Have fun and don’t be afraid of filters.

Robert Lacoste lives in France, near Paris. He has 25 years of experience in embedded systems, analog designs, and wireless telecommunications. A prize winner in more than 15 international design contests, in 2003 he started his consulting company, ALCIOM, to share his passion for innovative mixed-signal designs. His book (Robert Lacoste’s The Darker Side) was published by Elsevier/Newnes in 2009.

A Coding Interface for an Evaluation Tool

John Peck, a test engineer at Knowles Electronics in Itasca, IL, has used ASCII interfaces to test equipment since he was a graduate student.

“I love test equipment with open, well-documented, ASCII command sets,” he says. “The plain text commands give a complicated instrument a familiar interface and an easy way to automate measurements.”

So when Peck needed to automate the process of reading his ultrasonic range finder’s voltage output, he wanted an ASCII interface to a voltmeter. He also wanted the meter to convert volts into distance, so he added an Atmel AVR Butterfly microcontroller into the mix (see Photo 1). “I thought it would be easy to give it a plain text interface to a PC,” he says.

Atmel AVR Butterfly

Atmel AVR Butterfly

The project became a bit more complex than he expected. But ultimately, Peck says, he came up came up with “a simple command interface that’s easy to customize and extend. It’s not at the level of a commercial instrument, but it works well for sending a few commands and getting some data back.”

If you would like to learn more about how to send commands from a PC to the AVR Butterfly and the basics of using the credit card-sized, single-board microcontroller to recognize, parse, and execute remote commands, read Peck’s article about his project in Circuit Cellar’s May issue.

In the italicized excerpts below, he describes his hardware connections to the board and the process of receiving remote characters (the first step in receiving remote commands). Other topics you’ll find in the full article include setting up a logging system to understand how commands are being processed, configuring the logger (which is the gatekeeper for messages from other subsystems), recognizing and adding commands to extend the system, and sending calibration values.

Peck programmed his system so that it has room to grow and can accommodate his future plans:

“I built the code with AVR-GCC, using the -Os optimization level. The output of avr-gcc –version is avr-gcc (Gentoo 4.6.3 p1.3, pie-0.5.1) 4.6.3.

“The resulting memory map file shows a 306-byte .data size, a 49-byte .bss size, and a 7.8-KB .text size. I used roughly half of the AVR Butterfly’s flash memory and about a third of its RAM. So there’s at least some space left to do more than just recognizing commands and calibrating voltages.”

“I’d like to work on extending the system to handle more types of arguments (e.g., signed integers and floats). And I’d like to port the system to a different part, one with more than one USART. Then I could have a dedicated logging port and log messages wouldn’t get in the way of other communication. Making well-documented interfaces to my designs would help me with my long-term goal of making them more modular.”

These are the connections needed for Atmel’s AVR Butterfly. Atmel’s AVRISP mkII user’s guide stresses that the programmer must be connected to the PC before the target (AVR Butterfly board).

Figure 1: These are the connections needed for Atmel’s AVR Butterfly. Atmel’s AVRISP mkII user’s guide stresses that the programmer must be connected to the PC before the target (AVR Butterfly board).

WORKING WITH THE AVR BUTTERFLY
The AVR Butterfly board includes an Atmel ATmega169 microcontroller and some peripherals. Figure 1 shows the connections I made to it. I only used three wires from the DB9 connector for serial communication with the PC. There isn’t any hardware handshaking. While I could also use this serial channel for programming, I find that using a dedicated programmer makes iterating my code much faster.

A six-pin header soldered to the J403 position enabled me to use Atmel’s AVRISP mkII programmer. Finally, powering the board with an external supply at J401 meant I wouldn’t have to think about the AVR Butterfly’s button cell battery. However, I did need to worry about the minimum power-on reset slope rate. The microcontroller won’t reset at power-on unless the power supply can ramp from about 1 to 3 V at more than 0.1 V/ms. I had to reduce a filter capacitor in my power supply circuit to increase its power-on ramp rate. With that settled, the microcontroller started executing code when I turned on the power supply.

After the hardware was connected, I used the AVR downloader uploader (AVRDUDE) and GNU Make to automate building the code and programming the AVR Butterfly’s flash memory. I modified a makefile template from the WinAVR project to specify my part, programmer, and source files. The template file’s comments helped me understand how to customize the template and comprehend the general build process. Finally, I used Gentoo, Linux’s cross-development package, to install the AVR GNU Compiler Collection (AVR-GCC) and other cross-compilation tools. I could have added these last pieces “by hand,” but Gentoo conveniently updates the toolchain as new versions are released.

Figure2

Figure 2: This is the program flow for processing characters received over the Atmel AVR Butterfly’s USART. Sending a command terminator (carriage return) will always result in an empty Receive buffer. This is a good way to ensure there’s no garbage in the buffer before writing to it.

HANDLING INCOMING CHARACTERS
To receive remote commands, you begin by receiving characters, which are sent to the AVR Butterfly via the USART connector shown in Figure 1. Reception of these characters triggers an interrupt service routine (ISR), which handles them according to the flow shown in Figure 2. The first step in this flow is loading the characters into the Receive buffer.

Figure 3: The received character buffer and pointers used to fill it are shown. There is no limit to the size of commands and their arguments, as long as the entire combined string and terminator fit inside the RECEIVE_BUFFER_SIZE.

Figure 3: The received character buffer and pointers used to fill it are shown. There is no limit to the size of commands and their arguments, as long as the entire combined string and terminator fit inside the RECEIVE_BUFFER_SIZE.

Figure 3 illustrates the Receive buffer loaded with a combined string. The buffer is accessed with a pointer to its beginning and another pointer to the next index to be written. These pointers are members of the recv_cmd_state_t-type variable recv_cmd_state.

This is just style. I like to try to organize a flow’s variables by making them members of their own structure. Naming conventions aside, it’s important to notice that no limitations are imposed on the command or argument size in this first step, provided the total character count stays below the RECEIVE_BUFFER_SIZE limit.

When a combined string in the Receive buffer is finished with a carriage return, the string is copied over to a second buffer. I call this the “Parse buffer,” since this is where the string will be searched for recognized commands and arguments. This buffer is locked until its contents can be processed to keep it from being overwhelmed by new combined strings.

Sending commands faster than they can be processed will generate an error and combined strings sent to a locked parse buffer will be dropped. The maximum command processing frequency will depend on the system clock and other system tasks. Not having larger parse or receive buffers is a limitation that places this project at the hobby level. Extending these buffers to hold more than just one command would make the system more robust.

Editor’s Note: If you are interested in other projects utilizing the AVR Butterfly, check out the Talk Zombie, which won “Distinctive Excellence” in the AVR Design Contest 2006 sponsored by ATMEL and administered by Circuit Cellar. The ATmega169-based multilingual talking device relates ambient temperature and current time in the form of speech (English, Dutch, or French). 

Stand-Alone, 8-Channel Event, State, and Count Data Logger

DATAQThe DI-160 is a stand-alone event, state, and count data logger that features four programmable measurement modes. The data logger enables you to determine when events occur, the total number of events, and the period of time in between events. It can count parts by monitoring a proximity sensor’s pulse output, or determine a machine’s downtime by monitoring AC power.

The DI-160 includes eight channels. Four ±300-VDC/peak AC isolated channels can accommodate high-level DC voltage signals, pulse inputs up 2 kHz, or AC line voltage. Four ±30-VDC/peak AC non-isolated channels (pulled high) enable you to monitor lower-level DC voltages, TTL-level, signals, or switch closures.

You can use DATAQ’s Event Recorder set-up software, which is included with the data logger, to enable/disable channels, select measurement modes on a channel-by-channel basis, and choose one of 21 sample intervals, ranging from 1 s to 24 h. Data is stored to a removable SD memory card in CSV format, enabling up to 500 days of continuous recording and easy viewing in Microsoft Excel.

The DI-160’s AC channels provide channel-to-channel and input-to-output isolation up to 500 VDC (±250-V peak AC) and have a 4-V trigger threshold. The low-voltage channels are protected up to ±30 VDC/peak AC and trigger at 2.5 V.

A built-in rechargeable battery acts as a “bridge” when disconnecting the data logger from a PC and connecting it to the USB power supply. Three LEDs indicate when the DI-160 is actively acquiring data, when the unit is connected via USB to a PC (or the included AC power supply), and the battery’s charge state. A push button enables you to start and stop recording to the SD memory card.

The DI-160’s four selectable measurement modes. State mode determines an event’s duration. Event mode detects a single change of state (within a sample interval). High-Speed (HS) Counter mode yields the total number of state changes within a sample interval. AC Counter mode counts the number of times AC power turns on/off within a sample interval.

The DI-160 costs $299 and includes a mini screwdriver a 2-GB SD memory card, an AC power supply, and a mini-USB cable. The DATAQ Event Recorder software is available for free download.

DATAQ Instruments, Inc.
www.dataq.com

Pulse-Shaping Basics

Pulse shaping (i.e., base-band filtering) can vastly improve the behavior of wired or wireless communication links in an electrical system. With that in mind, Circuit Cellar columnist Robert Lacoste explains the advantages of filtering and examines Fourier transforms; random non-return-to-zero NRZ signaling; and low-pass, Gaussian, Nyquist, and raised-cosine filters.

Lacoste’s article, which appears in Circuit Cellar’s April 2014 issue, includes an abundance of graphic simulations created with Scilab Enterprises’s open-source software. The simulations will help readers grasp the details of pulse shaping, even if they aren’t math experts. (Note: You can download the Scilab source files Lacoste developed for his article from Circuit Cellar’s FTP site.)

Excerpts from Lacoste’s article below explain the importance of filtering and provide a closer look at low-pass filters:

WHY FILTERING?
I’ll begin with an example. Imagine you have a 1-Mbps continuous digital signal you need to transmit between two points. You don’t want to specifically encode these bits; you just want to transfer them one by one as they are.

Before transmission, you will need to transform the 1 and 0s into an actual analog signal any way you like. You can use a straightforward method. Simply define a pair of voltages (e.g., 0 and 5 V) and put 0 V on the line for a 0-level bit and put 5 V on the line for a 1-level bit.


This method is pedantically called non-return-to-zero (NRZ). This is exactly what a TTL UART is doing; there is nothing new here. This analog signal (i.e., the base-band signal) can then be sent through the transmission channel and received at the other end (see top image in Figure 1).


Note: In this article I am not considering any specific transmission channel. It could range from a simple pair of copper wires to elaborate wireless links using amplitude, frequency and/or phase modulation, power line modems, or even optical links. Everything I will discuss will basically be applicable to any kind of transmission as it is linked to the base-band signal encoding prior to any modulation.

Directly transmitting a raw digital signal, such as this 1-Mbps non-return-to-zero (NRZ) stream (at top), is a waste of bandwidth. b—Using a pulse-shaping filter (bottom) reduces the required bandwidth for the same bit rate, but with a risk of increased transmission errors.

Figure 1: Directly transmitting a raw digital signal, such as this 1-Mbps non-return-to-zero (NRZ) stream (top), is a waste of bandwidth. Using a pulse-shaping filter (bottom) reduces the required bandwidth for the same bit rate, but with a risk of increased transmission errors.


Now, what is the issue when using simple 0/5-V NRZ encoding? Bandwidth efficiency. You will use more megahertz than needed for your 1-Mbps signal transmission. This may not be an issue if the channel has plenty of extra capacity (e.g., if you are using a Category 6 1-Gbps-compliant shielded twisted pair cable to transmit these 1 Mbps over a couple of meters).


Unfortunately, in real life you will often need to optimize the bandwidth. This could be for cost reasons, for environmental concerns (e.g., EMC perturbations), for regulatory issues (e.g., RF channelization), or simply to increase the effective bit rate as much as possible for a given channel.


Therefore, a good engineering practice is to use just the required bandwidth through a pulse-shaping filter. This filter is fitted between your data source and the transmitter (see bottom of Figure 1).


The filter’s goal is to reduce as much as possible the occupied bandwidth of your base-band signal without affecting the system performance in terms of bit error rate. These may seem like contradictory requirements. How can you design such a filter? That’s what I will try to explain in this article….


LOW-PASS FILTERS

A base-band filter is needed between the binary signal source and the transmission media or modulator. But what characteristics should this filter include? It must attenuate as quickly as possible the unnecessary high frequencies. But it must also enable the receiver to decode the signal without errors, or more exactly without more errors than specified. You will need a low-pass filter to limit the high frequencies. As a first example, I used a classic Butterworth second-order filter with varying cut-off frequencies to make the simulation. Figure 2 shows the results. Let me explain the graphs.

Figure 2: This random non-return-to-zero (NRZ) signal (top row) was passed through a second-order Butterworth low-pass filter. When the cut-off frequency is low (310 kHz), the filtered signal (middle row) is distorted and the eye diagram is closed. With a higher cutoff (410 kHz, bottom row), the intersymbol interference (ISI) is lower but the frequency content is visible up to 2 MHz.

Figure 2: This random non-return-to-zero (NRZ) signal (top row) was passed through a second-order Butterworth low-pass filter. When the cut-off frequency is low (310 kHz), the filtered signal (middle row) is distorted and the eye diagram is closed. With a higher cutoff (410 kHz, bottom row), the intersymbol interference (ISI) is lower but the frequency content is visible up to 2 MHz.

The leftmost column shows the signal frequency spectrum after filtering with the filter frequency response in red as a reference. The middle column shows a couple of bits of the filtered signal (i.e., in the time domain), as if you were using an oscilloscope. Last, the rightmost column shows the received signal’s so-called “eye pattern.” This may seem impressive, but the concept is very simple.

Imagine you have an oscilloscope. Trigger it on any rising or falling front of the signal, scale the display to show one bit time in the middle of the screen, and accumulate plenty of random bits on the screen. You’ve got the eye diagram. It provides a visual representation of the difficulty the receiver will have to recover the bits. The more “open” the eye, the easier it is. Moreover, if the successive bits’ trajectories don’t superpose to each other, there is a kind of memory effect. The voltage for a given bit varies depending on the previously transmitted bits. This phenomenon is called intersymbol interference (ISI) and it makes life significantly more difficult for decoding.


Take another look at the Butterworth filter simulations. The first line is the unfiltered signal as a reference (see Figure 2, top row). The second line with a 3-dB, 310-kHz cut-off frequency shows a frequency spectrum significantly reduced after 1 MHz but with a high level of ISI. The eye diagram is nearly closed (see Figure 2, middle row). The third line shows the result with a 410-kHz Butterworth low-pass filter (see Figure 2, bottom row). Its ISI is significantly lower, even if it is still visible. (The successive spot trajectories don’t pass through the same single point.) Anyway, the frequency spectrum is far cleaner than the raw signal, at least from 2 MHz.

Lacoste’s article serves as solid introduction to the broad subject of pulse-shaping. And it concludes by re-emphasizing a few important points and additional resources for readers:

Transmitting a raw digital signal on any medium is a waste of bandwidth. A filter can drastically improve the performance. However, this filter must be well designed to minimize intersymbol interference.

The ideal solution, namely the Nyquist filter, enables you to restrict the used spectrum to half the transmitted bit rate. However, this filter is just a mathematician’s dream. Raised cosine filters and Gaussian filters are two classes of real-life filters that can provide an adequate complexity vs performance ratio.

At least you will no longer be surprised if you see references to such filters in electronic parts’ datasheets. As an example, see Figure 3, which is a block diagram of Analog Devices’s ADF7021 high-performance RF transceiver.

This is a block diagram of Analog Devices’s ADF7021 high-performance transceiver. On the bottom right there is a “Gaussian/raised cosine filter” block, which is a key factor in efficient RF bandwidth usage.

Figure 3: This is a block diagram of Analog Devices’s ADF7021 high-performance transceiver. On the bottom right there is a “Gaussian/raised cosine filter” block, which is a key factor in efficient RF bandwidth usage.

The subject is not easy and can be easily misunderstood. I hope this article will encourage you to learn more about the subject. Bernard Sklar’s book Digital Communications: Fundamentals and Applications is a good reference. Playing with simulations is also a good way to understand, so don’t hesitate to read and modify the Scilab examples I provided for you on Circuit Cellar’s FTP site.  

Lacoste’s full article is in the April issue, now available for membership download or single issue purchase. And for more information about improving the efficiency of wireless communication links, check out Lacoste’s 2011 article “Line-Coding Techniques,” Circuit Cellar 255, which tells you how you can encode your bits before transmission.

A Fundamental Rule of Grounding (EE Tip #124)

Quantum mechanics notwithstanding, our world is analog. And so despite our fascination with everything digital, we need interfaces to provide bridges for our analog reality to cross over to the digital paradigm and then back again. One may ask: Is there a common denominator that binds these two worlds together regardless of their many conceptual differences? In my mind, it is grounding.

The fundamental rule for grounding is depicted in Figure 1. By “ground” I mean the common 0 V potential to which signals are referenced. The “chassis ground”, if grounding conductors had 0 Ω impedance, would also be 0 V—but, unfortunately, it never is. Yet there are still systems that are sufficiently insensitive to ground potential differences. They use the chassis for the signal and power returns. At one time, this was the way cars had been wired.

Figure 1: Botth sections, A and B, may be on the same PCB with separate ground planes (e.g., analog and digital). The diodes and the capacitor between the planes limit potential differences due to ground bounce, etc. Broken lines inside boxes 1 and 3 indicate ground referenced, non-symmetrical inputs and outputs.

Figure 1: Botth sections, A and B, may be on the same PCB with separate ground planes (e.g., analog and digital). The diodes and the capacitor between the planes
limit potential differences due to ground bounce, etc. Broken lines inside boxes 1 and 3 indicate ground referenced, non-symmetrical inputs and outputs.

Figure 1a shows circuits sharing a common ground run. Notice that the output or the highest current drawing stage (1) must be the closest to the common point to minimize the voltage developed by that stage current over the grounding conductor. Also notice that the input signal and its return must be tied to the input block (3). Internal signal returns (grounds) are shown by broken lines. Returning inputs or outputs anywhere else would superimpose the noise from stages 1, 2, and 3 on the input signal. Figure 1b shows the approach often used in RF equipment. There is no sharing of grounds; they are all individually tied to a single point. Each circuit A and B can occupy its own PCB or they can be on a single PCB, their ground planes separate, such as analog and digital circuits. The grounds come together at the point G, where the chassis is also connected. Where there are a few inches of wire tying the individual grounds together, it is a good idea to insert fast signal diodes and a capacitor as shown between the separate ground runs. Any potential difference developed between the separate grounds due to finite impedance of wiring, as shown in Figure 1, will be attenuated and clamped by the three components. Note that the “capacitor” should in fact be a parallel combination of a number of capacitors, depending on the application, to guarantee performance across the spectrum. The following are typically used: 100 pF, 1 nF, 10 nF, 0.1 μF, and 1 μF.

In safety-critical systems such as aircraft comprising two or more subsystems enclosed in metal cabinets, such as shown in Figure 2, only currents from lightning or other interference suppressed by the EMC blocks is allowed to be returned to the chassis.

Figure 2: Connecting subsystems to avoid ground loops

Figure 2: Connecting subsystems to avoid ground loops

Power needs to be delivered by twisted pairs and all the returns connected to the chassis at a single point. If the signal grounds of the electronics are not allowed to be connected to the chassis, which depends on the system architecture, a combination of diodes, a capacitor, and a resistor as shown needs to be used to prevent ground loops as well as parasitic feedbacks between the electronics and the metal cabinet.

The subsystem enclosures shown with dotted lines connect to the chassis by mounting screws or straps. Most of today’s avionic equipment uses isolated power supplies. There is no galvanic connection between the power return and the internal signal ground to eliminate ground loops, yet the enclosures need to be connected to the internal grounds to eliminate parasitic feedbacks through capacitive coupling; but then they would create ground loops. Some system architectures require signals working with their own ground, isolated from the chassis, to prevent ground loops. To compensate for the parasitic capacitances existing due to the proximity of the metal enclosure to the components and the EMI/lightning protection, the resistor, capacitor, diode combination (as mentioned above) is used, with typical values of resistor about 10 kΩ and capacitance less than 10 μF. The capacitance is again a parallel combination of smaller capacitors to suppress the desired frequency spectrum.—George Novacek, “My Analog World: The Significance of Grounding,” Circuit Cellar 244, 2010.