About Circuit Cellar Staff

Circuit Cellar's editorial team comprises professional engineers, technical editors, and digital media specialists. You can reach the Editorial Department at editorial@circuitcellar.com, @circuitcellar, and facebook.com/circuitcellar

Execute Open-Source Arduino Code in a PIC Microcontroller Using the MPLAB IDE

The Arduino single-board computer is a de facto standard tool for developing microcomputer applications within the hobbyist and educational communities. It provides an open-source hardware (OSH) environment based on a simple microcontroller board, as well as an open-source (OS) development environment for writing software for the board.

Here’s an approach that enables Arduino code to be configured for execution with the Microchip Technology PIC32MX250F128B small-outline 32-bit microcontroller. It uses the Microchip Technology MPLAB X IDE and MPLAB XC32 C Compiler and the Microchip Technology Microstick II programmer/debugger.

Subscribe to Circuit Cellar magazine! Get 12 months of electrical engineering project articles, embedded design tutorials, embedded programming tips, and much more. We cover micrcontrollers, robotics, embedded Linux, IoT projects, and more!

Your own reasons for using this approach will depend on your personal needs and background. Perhaps as a long-term Arduino user, you want to explore a new processor performance option with your existing Arduino code base. Or, you want to take advantage of or gain experience with the Microchip advanced IDE development tools and debug with your existing Arduino code. All of these goals are easily achieved using the approach and the beta library covered in this article.

Several fundamental open-source Arduino code examples are described using the beta core library of Arduino functions I developed. The beta version is available, for evaluation purposes only, as a free download from the “Arduino Library Code for PIC32” link on my KibaCorp company website, kibacorp.com. From there, you can also download a short description of the Microstick II hardware configuration used for the library.

To illustrate the capabilities in their simplest form, here is a simple Blink LED example from my book Beginner’s Guide to Programming the PIC32. The example shows how this custom library makes it easy to convert Arduino code to a PIC32 binary file.

The Arduino code example is as follows: Wire an LED through a 1-K resistor to pin 13 (D7) of the Arduino. An output pin is configured to drive an LED using pinMode () function under setup (). Then under loop () this output is set high and then low using digitalWrite () and delay () functions to blink the LED. The community open-source Arduino code is:

The open-source example uses D13 or physical pin 13 on the Arduino. In relation to the PIC32MX, the D13 is physical pin 25. Pin 25 will be used in prototyping wiring.

Now, let’s review and understand the PIC32 project template and its associated “wrapping functions.”  The Arduino uses two principal functions: setup () to initialize the system and loop () to run a continuous execution loop. There is no Main function. Using the Microchip Technololgy XC32 C compiler, we are constrained to having a Main function. The Arduino setup () and loop () functions can be accommodated, but only as part of an overall template Main “wrapping” function. So within our PIC32 template, we accommodate this as follows:

Listing 2

This piece of code is a small but essential part of the template. Note that in this critical wrapping function, setup () is called once as in Arduino and loop () is configured to be called continuously (simulating the loop () function in Arduino) through the use of a while loop in Main.

The second critical wrapping function for our template is the use of C header files at the beginning of the code. The XC32 C compiler uses the C compiler directive #include reference files within the Main code. Arduino uses import, which is a similar construct that is used in higher-level languages such as Java and Python, which cannot be used by the MPLAB XC32 C.

The two include files necessary for our first example are as follows:

Listing 3

System.h references all the critical Microchip library functions supporting the PIC32MX250F128B. The Ardunio.h provides the Arduino specific library function set. Given these two key “wrapper” aspects, where does the Arduino code go? This is best illustrated with a side-by-side comparison between Arduino code and its Microchip equivalent. The Arduino code is essentially positioned between the wrapper codes as part of the Main function.

Blink side-by-side comparison

Blink side-by-side comparison

This approach enables Arduino code to execute on a Microchip PIC32 within an MPLAB X environment. Note that the Arduino code void setup () now appears as void setup (void), and void loop () appears as void loop (void). This is a minor inconvenience but again necessary for our C environment syntax for C prototype function definitions. Once the code is successfully compiled, the environment enables you to have access to the entire built-in tool suite of the MPLAB X and its debugger tool suite.

Configure the Microstick II prototype as in the following schematic. Both the schematic and prototype are shown below:

Exercise 1 schematic

Exercise 1 schematic

Exercise 1 prototype

Exercise 1 prototype

Table 1 compares Arduino core functionality to what is contained in the Microchip PIC32 expanded beta library. In the beta version, I added additional C header files to accomplish the necessary library functionality. Table 2 compares variable types between Arduino and PIC32 variable types. Both Table 1 and Table 2 show the current beta version has a high degree of Arduino core library functionality. Current limitations are the use of only one serial port, interrupt with INT0 only, and no stream capability. In addition, with C the “!” operator is used for conditional test only and not as a complement function, as in Arduino. To use the complement function in C, the “~” operator is used. The library is easily adapted to other PIC32 devices or board types.

Table 1

Table 1: Arduino vs Microchip Technology PIC32 core library function comparison

Talble 2

Table 2: Arduino vs Microchip Technology PIC32 core library variable types

If you use interrupts, you must identify to C the name of your interrupt service routine as used in your Arduino script. See below:

Interrupt support

Interrupt support

For more information on the beta release or to send comments and constructive criticism, or to report any detected problems, please contact me here.

Four test case examples demonstrating additional core library functions are shown below as illustrations.

Serial communications

Serial communications

Serial find string test case

Serial find string test case

Serial parse INT

Serial parse INT



Editor’s Note: Portions of this post first appeared in Tom Kibalo’s book Beginner’s Guide to Programming the PIC32 (Electronics Products, 2013). They are reprinted with permission from Chuck Hellebuyck, Electronic Products. If you are interested in reading more articles by Kibalo, check out his two-part Circuit Cellar “robot boot camp” series posted in 2012 : “Autonomous Mobile Robot (Part 1): Overview & Hardware” and “Autonomous Mobile Robot (Part 2): Software & Operation.”


Tom Kibalo

Tom Kibalo

Tom Kibalo is principal engineer at a large defense firm and president of KibaCorp, a company dedicated to DIY hobbyist, student, and engineering education. Tom, who is also an Engineering Department adjunct faculty member at Anne Arundel Community College in Arnold, MD, is keenly interested in microcontroller applications and embedded designs. To find out more about Tom, read his 2013 Circuit Cellar member profile.

Industry 4.0: The Industrial IoT and the Future

The Internet of Things (IoT) is everywhere. Industry 4.0 is becoming serious and many companies develop hardware and software solutions. Relayr is a company with an interesting focus on the IoT and bringing industry to the cloud. Wissa Hettinga interviewed Jaime Gonzalez-Arintero Berciano, a Relayr developer and product evangelist, about the company, its technology, and future of innovation in the IoT space.

4G LTE Maker Modem for M2M Apps

The TOBY-L2 a u-blox LTE module has been embedded in the first 4G LTE Maker Modem by M2M Circuits. Designed for the MakerSpace, the 4G Maker Modem enables direct cellular connection to microcontrollers and SBCs for M2M applications. In addition to offering high-speed TCP/IP over the LTE network for higher data-rate M2M applications and broader coverage, the Maker Modem is also set up for SMS and communication via text messages. Due to its open-source API, you can use your favorite SBCs and microcontrollers. The modem also includes a built-in antenna system and two data-port connections (USB connection and two-wire serial interface for low-power microcontrollers).UB035 MakerModem

The Maker Modem is looking to be certified in the US. For more information, check out the Kickstarter video.

Source: u-blox

Simplified, Cost-Effective EtherCAT Implemenation with XMC4300 Microcontrollers

The Infineon Technologies XMC4300 microcontroller series simplifies EtherCAT implementation complexity and cost. Developed for cost-sensitive industrial applications, the XMC4300 is well suited for a variety of applications, such as factory automation, industrial motor control, and robotics.Infineon EtherCAT

Like Intineon’s XMC4800 series, the XMC4300 features an integrated EtherCAT node on an ARM Cortex-M processor with on-chip flash and analog/mixed signal capabilities. Neither the XMC4300 nor XMC4800 require oadditional components such as dedicated EtherCAT ASIC, external memory, or a quartz clock generator to start the EtherCAT slave controller. An integrated PLL supplies the EtherCAT IP with the necessary 25-MHz clock. Code executes from the Cortex-M4 processor at 144 MHz from the integrated RAM or flash memory.

You can use the XMC4300 and XMC4800 in mixed networks with CAN and EtherCAT because they allow a gateway from CAN to EtherCAT via through DMA transfers. In addition to 256 KB of flash memory and 128 KB of RAM memory, the XMC4300 features two CAN nodes with up to 64 message objects to be organized into send/receive FIFO. In addition, the XMC4300 series is certified for an ambient temperature of up to 125°C.

The two devices in the XMC4300 series vary in temperature range, with up to 85°C and up to 125°C, respectively. Offered in an LQFP-100 package, they are pin- and code-compatible with devices in the XMC4800 series.

Infineon offers a development board, the XMC4300 Relax EtherCAT Kit, and software development tools for immediate EtherCAT node setup. The XMC4300 Relax EtherCAT Kit is equipped with an XMC4300 and an on-board debugger, EtherCAT, CAN node, and USB. For software development, you can use the DAVE development environment with libraries for low-level drives and apps free of charge. For EtherCAT, DAVE uses Slave Stack Code (SSC) from Beckhoff. In addition to the free development environment, third-party manufacturers offer commercial EtherCAT slave stacks.

Source: Infineon Technologies

STMicroclectronics Offers Free Dev Tools to Linux Users

STMicroelectronics now offers free high-productivity tools to Linux users interested in working with STM32 microcontrollers. The STM32CubeMX configurator and initialization tool and the System Workbench for STM32—which is an IDE created by Ac6 Tools and supported by the openSTM32.org community—are now both available to run on Linux OS. Thus, Linux users can work on embedded projects with STM32 devices without leaving their favorite desktop environment.

System Workbench for STM32 supports the ST-LINK/V2 debugging tool under Linux through an adapted version of the OpenOCD community project. You can use the tools STMicro hardware such as STM32 Nucleo boards, Discovery kits, and Evaluation boards, as well as microcontroller firmware within the STM32Cube embedded-software packages or Standard Peripheral Library.

Source: STMicroelectronics

Photocoupler for RS-232C 100-kbps Communications

Toshiba Electronics Europe recently announced a new photocoupler that can support signal transfer speeds of up to 100 kbps. Intended for communication applications in industrial systems and home appliance devices, the TLP2703 can be driven by a low input current of 1 mA. It features a high current transfer ratio (IC/IF) of 900% (min) at an input current of 0.5 mA. With propagation delay at 25 µs (max) at an input current of IF = 1.6 mA and 7 µs (max) at IF = 12 mA, the IC is well suited for insulated communication interfaces (e.g., RS-232C).Toshiba TLP2703

Housed in an SO6L package (maximum height of 2.3 mm) and featuring a creepage distance of 8 mm and an isolation voltage of 5 kVRMS, you can use the TLP2703 in applications requiring high insulation performance. Futhermore, its temperature range is up to +125°C.

Source: Toshiba

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.


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.


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.


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.


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.


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)


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.


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.

Brain Control: An Interview with Dr. Max Ortiz Catalan

Dr. Max Ortiz Catalan is Research Director at Integrum AB, a medical device company based in Molndal, Sweden. Wisse Hettinga recently interviewed him about his work in the field of prosthetic design and biomedical systems.MOC_Lab3

As an electrical engineer, your first focus is to create new technology or to bring a new schematic design come to life. Dr. Max Ortiz Catalan is taking this concept much further. His research and work is enabling people to really start a new life!

People without an upper limb often find it difficult to manage tasks due to the limitations of prostheses. Dr. Catalan’s research at Chalmers University of Technology and Sahlgrenska University Hospital in Gothenburg, Sweden, focuses on the use of osseointegrated implants and a direct electronic connection between the nervous system and a prosthetic hand. People can control the prosthesis just like you control your hand, and they are able to sense forces as well. The results are impressive. The first patient received his implant three years ago and is successfully using it today. And more patients will be treated this year. I recently interviewed Dr. Catalan about his work. I trust this interview will inspire seasoned and novice engineers alike.—Wisse Hettinga

HETTINGA: What led you to this field of research?

CATALAN: I was always interested in working on robotics and the medical field. After my bachelor’s in electronics, my first job was in the manufacturing industry, but I soon realized that I was more interested in research and the development of technology. So I left that job to go back to school and do a master’s in Complex Adaptive System. I also took some additional courses in biomedical engineering and then continued working in this field where I did my doctoral work.

HETTINGA: I was surprised you did not mention the word “robot” once in your TEDx presentation (“Bionic Limbs Integrated to Bone, Nerves, and Muscles”)? Was that coincidence or on purpose?

CATALAN: That was coincidence, you can call a prosthesis a “robotic device” or “robotic prosthesis.” When you talk about a “robot,” you often see it as an independent entity. In this case, the robotic arm is fully controlled by the human so it makes more sense to talk about bionics or biomechatronics.

HETTINGA: What will be the next field of research for you?

CATALAN: The next step for us is the restoration of the sense of touch and proprioception via direct nerve stimulation, or “neurostimulation.” We have developed an embedded control system for running all the signal processing and machine learning algorithms, but it also contains a neurostimulation unit that we use to elicit sensations in the patient that are perceived as arising from the missing limb. The patients will start using this system in their daily life this year.

HETTINGA: You are connecting the controls of the prosthesis with nerves. How do you connect a wire to a nerve?

CATALAN: There are a variety of neural interfaces (or electrodes) which can be used to connect with the nerves. The most invasive and selective neural interfaces suffer from long-term instability. In our case we decided to go for a cuff electrode, which is considered as a extra-neural interface since it does not penetrate the blood-nerve barrier and is well tolerated by the body for long periods of time, while also remaining functional.

HETTINGA: Can you explain how the nerve signals are transferred into processable electric signals?

CATALAN: Electricity travels within the body in the form of ions and the variations in electric potentials, or motor action potentials for control purposes. They are transduced into electrons by the electrodes so the signals can be finally amplified by analog electronics and then decoded on the digital side to reproduce motor volition by the prosthesis.

HETTINGA: What is the signal strength?

CATALAN: Nerve signals (ENG) are in the order of microvolts and muscle signals (EMG) in the order of millivolts.

HETTINGA: What technologies are you using to cancel out signal noise?

CATALAN: We use low-noise precision amplifiers and active filtering for the initial signal conditioning, then we can use adaptive filters implemented in software if necessary.

HETTINGA: How do you protect the signals being disturbed by external sources or EM signals?

CATALAN: Since we are using implanted electrodes, we use the body as a shielding, as well as the titanium implant and the electronics housing. This shielding becomes part of the amplifier’s reference so it is rejected as common noise.

HETTINGA: How are the signals transferred from the nerves to the prosthesis?

CATALAN: The signals from nerves and muscles are transferred via the osseointegrated implant to reach the prosthesis where they are amplified and processed. In a similar ways, signals coming from sensors in the prosthesis are sent into the body to stimulate the neural pathways that used to be connected to the biological sensors in the missing hand. Osseointegration is the key difference between our work and previous approaches.

HETTINGA: What sensors technologies are you using in the prosthetic hand?

CATALAN: At this point it is rather straightforward with strain gauges and FSRs (Force Sensitive Resistor), but on research prostheses, motors are normally instrumented as well so we can infer joint angles.

This interview appears in Circuit Cellar 307 February.

New PSoC 4 L-Series

Cypress Semiconductor Corp. recently introduced the PSoC 4 L-Series, which is an integrated single-chip solution with a 32-bit ARM-Cortex-M0 core. It features 256-KB flash memory, 98 general-purpose I/Os, 33 programmable analog and digital blocks, a USB device controller, and a control area network (CAN) interface. The PSoC 4 L-Series is well-suited for industrial and consumer applications requiring reliable user interfaces.Cypress PSOC 4 L

The PSoC 4 L-Series delivers up to 13 programmable analog blocks including 4 high-performance opamps, four current-output digital-to-analog converters (IDACs), two low-power comparators, a 12-bit SAR ADC and dual CapSense blocks with up to 94 capacitive-sensing channels. The programmable analog blocks enable you to create on-chip, custom analog front ends.

The PSoC 4 L-Series delivers up to 20 programmable digital blocks including eight timer/counter/PWM blocks, four serial communication blocks, and eight Universal Digital Blocks (UDBs)—programmable digital blocks that each contain two programmable logic devices, a programmable data path, and status and control registers. UDBs can be configured as coprocessors to offload compute-intensive tasks from the ARM Cortex-M0 core. The blocks also enable you to implement custom digital peripherals, state machines, or glue logic. Traditional microcontrollers typically require additional ICs to implement this functionality. The scalable PSoC 4 architecture is complemented by the easy-to-use PSoC Creator IDE and PSoC Components—free embedded ICs represented by an icon in the IDE.

The PSoC 4 L-Series is currently sampling with production expected in the first quarter of 2016. Parts will be available in 48-pin TQFP, 64-pin TQFP, 68-pin QFN and 124-pin VFBGA packages.

Source: Cypress Semiconductor

New IC for Real-Time Power Monitoring of Multiple Loads

Microchip Technology recently expanded its power-monitoring IC portfolio with the addition of the MCP39F511N, which provides standard power calculations and event monitoring of two electrical loads. It includes three ADCs for voltage and two current load measurements, a 16-bit calculation engine, EEPROM, and a flexible two-wire interface.Microchip MCP39F511N

An integrated low-drift voltage reference in addition to the 94.5 dB of SINAD performance on each current measurement channel enables the MCP39F511N to monitor two current loads with only 0.5% error across a wide 4000:1 dynamic range.  The ability to measure active, reactive and apparent power, active and reactive energy accumulation, RMS current and RMS voltage, line frequency, and power factor combined with advanced, integrated features enables you to reduce bill of materials and time to market.

The MCP39F511N is supported by Microchip Technology’s $200 MCP39F511N Power Monitor Demonstration Board (ADM00706). The MCP39F511N is available for sampling and volume production in a 28-lead, 5 × 5 mm QFN package. It costs $1.82 in 5,000-unit quantities.

Source: Microchip Technology

High-Side N-Channel FET Driver

Texas Instruments recently introduced the a single-chip, 100-V, high-side FET driver for high-power lithium-ion battery applications. Offering advanced power protection and control, the bq76200 high-voltage solution drives high-side N-channel charge and discharge FETs in batteries commonly used in energy storage systems and motor-driven applications (e.g., drones, power tools, e-bikes, and more). TexInst bq76200

Compared to 50-V low-side FET driver solutions, the 100-V high-side FET driver provides increased protection against possible inductive transient events in motor-driven applications. It also helps maintain constant battery monitoring and enhanced system diagnostics.

Key features and benefits:

  • Versatile supply voltage range: Compatible with a variety of battery architectures, capacities and voltage ranges from 8 to 75 V, with an absolute maximum of 100 V.
  • Advanced-protection FET control: The fast-switching feature minimizes fault response time and disables the discharge FET if a battery has been severely discharged.
  • Quick development time and reduced overhead: The adaptable driver works with small to large power FET arrays by simply scaling the charge-pump capacitor, reducing engineering overhead and speeding development time.
  • High integration and small package size: The bq76200 integrates a high-voltage charge pump and dual FET drivers into one 5 mm × 4.4 mm × 1 mm thin shrink small outline package (TSSOP).

The bq76200 can be used in conjunction with the bq76940 battery-monitoring family, allowing for the application to move to a high-side FET drive and ensure that communication is always possible. The bq76200 can also drive Texas Instrument’s CSD19531Q5A 100-V NexFET power MOSFET as in the bq76200 evaluation module.

The bq76200 is available now. The driver (six-pin TSSOP) costs $1.69 in 1,000-unit quantities.

Source: Texas Instruments

Hands-On Test Instrument Workshop Tour

Keysight recently announced it is running hands-on, test instrument workshop for design and test engineers.The workshop series (February 2–June 24) will be held in the United States and Canada.

The workshop is intended to focus on top test challenges with seminars and instructors leading demonstrations and lectures. Attendees can use high-performance and general-purpose oscilloscopes, RF signal analyzers and sources, RF network analyzers, AC/DC power analyzers, and bench instrumentation.

Workshop highlights include:

  • Power Integrity and Analysis Using Oscilloscopes and Power Analyzers
  • RF Transmitter/Receiver Measurements
  • Faster and Simpler Design Validation/Characterization

In addition, attendees will receive a course completion certificate and will be entered into a drawing for a free U1273A 4.5 digit, OLED display hand-held digital multimeter with a U117A Bluetooth adapter.


More information about the free workshop and registration, visit www.keysight.com/find/testdrive.

Source: Keysight Technologies

Collider (College Park, MD, USA)

Collider is a College Park, MD-based hackerspace founded in 2014. According to Cofounder Ibrahim Hashme, most member projects are focused on electronics (e.g., MCUs, PCBs, robotics, and radio).

What are the most typical projects undertaken at your space? 

  • Mostly electronics projects (e.g., MCUs, PCBs, robotics, radio)

What sort of tools/equipment do you have at your space? 

  • Soldering station, multimeter, voltmeter, and electronics hand tools

Are there any tools your group really wants or needs?

  • Oscilloscope, 3-D printer, dremel, higher quality soldering iron

Tell us about your space!

  • Store all projects and hardware in cubbies. Two rooms, one hardware oriented and the other software. Each room is about 500 square feet. They are connected by an open wall.

What’s the craziest, most exciting, and/or most innovating project your group or group members have completed? 

  • Everything was exciting but small scale so far, such as a virtual reality chair, a speed sensing tunnel, etc.

Do you have any events or initiatives you’d like to tell us about? Where can we learn more about it? 

  • We hold hacktorials everyThursday, where someone familiar with a certain field shares his expertise in a hands on workshop. We also are starting a mentor program. No weekly “hack nights” also occur.

Can you tell us about some of your group’s recent tech projects?

  • Recently we were forced to move by the University, and are still setting up in the new room. I created a secret knock door lock, and others did things too for the new space.

The Future of Wireless: IoT “Connect Anywhere” Solutions

Wireless communications have revolutionized virtually every industry, from healthcare to defense to consumer electronics. We recently asked 10 engineers to prognosticate on the future of wireless technology. France-based engineer Robert Lacoste writes:3 Lacoste purple

I don’t know if the forecasts about the Internet of Things (IoT) are realistic (some analysts predict from 20 to 100 billion devices in the next five years), but I’m sure it will be a huge market. And 99% of IoT products are and will be wireless. Currently, the vast majority of “things” connect to the Internet through a user’s smartphone, used as a gateway typically through a Bluetooth Smart link. Other devices (e.g., home control or smart metering) require the installation of a dedicated fixed RF-to-Internet gateway, using ZigBee, 6lowPan, or something similar. But the next big thing will be the availability of “connect anywhere” solutions, through low-power wide area networks, nicknamed LPWA. Even if the underlying technology is not actually new (i.e., using very low bit rates to achieve long range at low powers), the contenders are numerous: LORA Alliance, INGENU, SIGFOX, WEIGHTLESS, and a couple of others. At the same time, the traditional telcos are developing very similar solutions using cellular bands and variants of the 3GPP protocols. EC-GSM, LTE-MTC, and NB-IOT are the most discussed alternatives. So, the first big question is this: Which one (or ones, as a one-size-fits-all solution is unlikely) will be the winner? The second big question has to do with whether or not IoT products will be useful for society. But that’s another story! — Robert Lacoste, France (Founder, Alciom; Columnist, Circuit Cellar)