Creating A Bode Analyzer From A Microcontroller

Electrical engineers will recognize the Bode plot as a plot of the frequency response of a system. It displays the frequency on the x-axis and the phase (in degrees) or magnitude (in dB) on the y-axis, making it helpful for understanding a circuit or transfer function in frequency domain analysis.

[Debraj] was able to use a STM32F407 Discovery board to build a Bode analyzer for electronic circuits. The input to the analyzer is a series of sine wave signals with linearly increasing frequency, or chirps, preferably twenty frequencies/decade to keep the frequency range reasonable.

The signals from a DAC are applied to a target filter and the outputs (frequencies obtained) are read back through an ADC. Some calculations on the result reveal how much of the signal is attenuated and its phase, resulting in a Bode plot. The filtering is done through digital signal processing from a microcontroller.

While the signals initially ran through a physical RC-filter, testing the Bode plotter with different circuits made running the signals through a digital filter easier, since it eliminates the need to solder resistors and capacitors onto protoboards. Plotting is done using Python’s matplotlib, with the magnitude and phase of the output determined analytically.

It’s a cool project that highlights some of the capabilities of microcontrollers as a substitute for a pricier vector network analyzer.

13 thoughts on “Creating A Bode Analyzer From A Microcontroller

  1. The approach used severely limits the maximum frequency, as it does not take into account the delays introduced by the DAC and other things. You can actually see this in the graphs he produced: he measured a simple first-order RC filter to have more than 90 degrees of phase shift at higher frequencies.
    I’d very like to see a simple, cheap vector network analyzer for frequencies up to tens of MHz. The only device I know about which can do it is the Analog Discovery 2.

    1. NanoVNA can be had for around 40eur shipped.
      100kHz-300MHz with better than 70dB dynamic range and reduced performance on the upper bands from 300-600MHz and 600-900MHz.
      It’s a portable standalone instrument that can also be connected to a computer for rich plotting options.
      It is also opensource.

  2. “The input to the analyzer is a series of sine wave signals with linearly increasing frequency” isn’t this the output to a network to be analyzed? Meaning the test signal that comes from the DAC?

    The 12 bit ADCs on the chip can go 2 MHz and work in pairs for quadrature sampling. An impulse response done with an FFT will be very fast and perhaps nearly real-time. It produces phase and magnitude (the vector) and resolution can be zoomed by varying sampling, and scale factors in the FFT. Just sayin – next generation?

    1. I don’t know how the people around you use the term electrical engineer, but I have always seen electrical engineer being used as a blanket term. An electrical engineer could describe a variety of specialties, ranging from energy systems to radio or embedded systems.

Leave a Reply to CodeToadCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.