Cheap 50MHz bode plotter - Page 1
Forum section: electronics / projects

author: EggertEnjoyer123
author_rank: Frequent Contributor
timestamp: August 04, 2025, 07:42:55 am
content: I think it's possible to make a DC - 50 MHz bode plotter cheaply.The idea is to use PLLs and mixers instead of a DAC to generate the sine wave. Normally, a DAC is used, but getting one with >100Msps is going to be expensive (as well as enough bits).Three outputs from the MS5351 (or the Si5351) are used. One output will be set to 200 MHz constantly, and it will be filtered to make a 200 MHz sine wave. The sine wave will be mixed down using another output of the MS5351 (150 - 200 MHz) as the LO, and filtered with a 50 MHz low pass filter to get rid of all the image frequencies. The mixer used is a 3157 SPDT analog switch IC, along with a fast op amp to convert the differential signal back to single ended. The signal will then be amplified and sent out one of the ports. The 200 MHz signal can be attenuated easily using a PIN diode, and the MCU will measure the amplitude of the 50 MHz output signal using a diode detector. At low frequencies, the MCU can probably just level the amplitude for 10 kHz, and then run everything open loop, since the mixer probably will have the same insertion loss with a 199.999999 MHz as with a 199.99 MHz LO signal.For the two receiver ports, I will use another switching mixer to downconvert everything back to the audio range, where the signals will be digitized by a STM32 microcontroller, which should be fast enough to calculate everything and then send the results back to a computer. At low frequency, the 5351 can just be disabled and the signal will just go straight to the microcontroller.I attached my schematic of the design to this post. There are probably mistakes, (I'm worried about issues between switching from 3.3V to +/- 2.5V in my schematic). I will get the board made and see if everything works. I think the total BOM cost is probably less than 10 bucks, since fast op amps are about 20 cents each from LCSC, and switching ICs can be bought for 7 cents each. The most expensive parts are probably the MCU and the 5351 (which is <$1 on LCSC).

author: moffy
author_rank: Super Contributor
timestamp: August 04, 2025, 07:55:27 am
content: It sounds interesting, I would have thought that DDS ICs would be a more direct route to generating the variable sine frequency.

author: EggertEnjoyer123
author_rank: Frequent Contributor
timestamp: August 04, 2025, 04:07:58 pm
content: DDS ICs cost too much. (The AD9850 would probably cost as much as the entire board right now)There also isn't an easy way to digitize the input signals cheaply without mixing (since you'd need >100Msps, along with all of the processing needed for such a fast ADC).

author: moffy
author_rank: Super Contributor
timestamp: August 04, 2025, 09:39:41 pm
content: Thanks for that, the only reference I can find to the OPA330 is:https://www.ti.com/product/OPA330?utm_source=google&utm_medium=cpc&utm_campaign=asc-null-null-GPN_EN-cpc-pf-google-soas_en_cons&utm_content=OPA330&ds_k=OPA330&DCM=yes&gclsrc=aw.ds&gad_source=1&gad_campaignid=8754035891&gclid=EAIaIQobChMIqqbJh43yjgMVS4ApAx1xdxikEAAYASAAEgIMh_D_BwEWhich can't be right because of its low speed, could you post a link to the opamp you are using?P.S. How are you detecting phase, is there some form of quadrature demodulation?

author: EggertEnjoyer123
author_rank: Frequent Contributor
timestamp: August 05, 2025, 05:30:38 am
content: I just chose a device with the same package and pinout since I couldn't find an exact match in the Kicad database.https://www.lcsc.com/datasheet/C42414424.pdfHere is the datasheet for the op amp.The phase detection will be done in software. There are two signals going to the 2 ADCs on the MCU. The MCU makes a "reference" signal (sine and cosine of the same frequency) and then correlates each signal with the sine and cosine. Basically the microcontroller will window all of the signals, and then multiply the output by sine and cosine, and then add up all the samples. To get the magnitude and angle, you can just use trig. Then you can subtract the magnitudes in dB to get the total gain, and also subtract the angles to get the phase information. The only annoying thing about my design is that calibration probably needs to be done, since differences in the chips could lead to a phase shift even when all of the inputs are connected.It might be a good idea to add a variable gain stage to the input. Scopes can increase the gain to take full advantage of the ADC input range (to get a higher dynamic range for the measurement). I can probably implement something similar cheaply using op amps and switches. Right now I have a preamp on the input, but I can probably amplify the downconverted signal using more op amps (because the frequency is lower I can just use a LM358 or similar jellybean part).

author: moffy
author_rank: Super Contributor
timestamp: August 05, 2025, 06:31:52 am
content: Quote from: EggertEnjoyer123 on August 05, 2025, 05:30:38 amThat makes sense, I often do the same in Altium but change the label on the schematic, it lets one do that not so sure about Kicad though.I'm beginning to get a better understanding of your circuit, distortion from the switch mixers will be interesting, but if your sine/cosine correlation works well it might discriminate against that.

author: radiolistener
author_rank: Super Contributor
timestamp: August 05, 2025, 07:28:46 am
content: may I ask - what’s the specific reason for generating a sine wave in a Bode plot application? A square wave is typically sufficient, especially since selective frequency scanning (at frequency offset from harmonics) allows accurate measurements even with rich harmonic content. See NanoVNA for details.In fact, using a square wave has distinct advantages: it enables frequency-domain analysis at higher harmonics, allowing you to probe response at frequencies beyond the fundamental output range of the synthesizer. This is particularly useful when working with low-cost sources like the si5351, which have limited upper frequency range but generate rich harmonic content that can be exploited selectively with appropriate signal processing.

author: rf-fil
author_rank: Regular Contributor
timestamp: August 05, 2025, 07:44:00 am
content: Mixers will still have harmonics in their output. But you'd only need pure sinewave if the device under test is nonlinear.. at which point a frequency response plot is not that useful..

author: radiolistener
author_rank: Super Contributor
timestamp: August 05, 2025, 07:44:20 am
content: On the other hand, if your goal is not to perform vector analysis but rather implement a simplified scalar approach - similar to the NWT-type analyzers that use a broadband logarithmic detector and a frequency sweep from a DDS (replacing the DDS here with an si5351) - then using a square wave source may introduce significant problems.Specifically, without coherent detection or harmonic rejection, the rich harmonic content of the si5351 output becomes problematic. For example, at a fundamental frequency of 1 kHz, strong 3 kHz, 5 kHz, 7 kHz, etc., harmonics will also be present. These cannot be filtered out by a 50 MHz low pass filter, and they will distort the measured response. The result is a Bode plot contaminated by the response at multiple frequencies simultaneously, leading to misleading or completely incorrect amplitude curves.In such scalar systems, the harmonic purity of the stimulus signal becomes critical, and generating a clean sine wave or at least suppressing higher-order harmonics is essential to obtain accurate measurements.Therefore, if you're using a square wave as the stimulus, it's important to employ vector analysis with scanning at an offset frequency that is neither directly generated by the synthesizer nor a harmonic of it. This approach effectively avoids harmonic contamination in the Bode plot and eliminates the need for sine wave generation or additional filtering.

author: radiolistener
author_rank: Super Contributor
timestamp: August 05, 2025, 07:58:16 am
content: The core idea is to perform frequency downconversion using a mixer, but deliberately avoid analyzing the zero-IF component. Instead, a band pass filter is applied in DSP at an offset frequency - typically around 5-10 kHz with a corresponding frequency shift in the synthesizer configuration. As a result, the DSP effectively removes the zero-frequency component, which contains info about signals at the LO frequency and its harmonics. Analysis is then performed at the offset frequency, where no carrier or harmonics are present to interfere, ensuring a clean and accurate measurement.At low frequencies, the offset must be selected dynamically, as a fixed 5-10 kHz offset can easily coincide with a harmonic that is a multiple of the offset frequency. This creates the risk of interference, so adaptive offset selection is necessary to avoid overlap with spurious components.The complete DSP for vector analysis can be implemented in real time on an STM32 MCU. All that’s required is a standard audio codec with good input dynamic range, operating at 48 or 96 kHz sampling rate.You can implement this even on an STM32F103, however I recommend using a more modern MCU like the STM32G431. This device offers hardware FPU support and additional DSP-optimized features like math accelerators for CORDIC and FMAC, which significantly improve processing efficiency while maintaining a similar cost level to the STM32F103. Additionally, the STM32G431 also has a 12-bit ADC and DAC, which can serve as a cost-effective alternative to an external audio codec when ultra-high dynamic range is not a critical requirement.

author: tszaboo
author_rank: Super Contributor
timestamp: August 05, 2025, 08:20:19 am
content: Quote from: radiolistener on August 05, 2025, 07:28:46 amThis is only applicable if you measure linear devices, typically passives. If you want to measure active parts, you will quickly realize why having large harmonic content is not suitable.Quote from: EggertEnjoyer123 on August 04, 2025, 07:42:55 amThe downconverter might be unnsessary. Your ADC with undersampling might do the downconversion itself, depends on the analog input range. You also don't place an anti-aliasing filter before your ADC with this.I've been toying with the idea to build something like a RLC meter with RF design practices and 50 Ohm impedance. Too many projects, not enough time.

author: radiolistener
author_rank: Super Contributor
timestamp: August 05, 2025, 03:35:55 pm
content: Quote from: tszaboo on August 05, 2025, 08:20:19 amI’m highly skeptical that a typical audio codec with 48/96 kHz sample rate can reliably digitize signals in the 50 MHz range using undersampling. These codecs are not designed to handle RF inputs, and their analog front-end bandwidth is usually far too limited with antialiasing filter.More importantly, undersampling fundamentally limits your ability to implement coherent scanning, which is a key principle of this approach. The whole idea is to intentionally shift the signal down in frequency via mixing and then isolate the desired component using narrowband low pass filter. Without this step, you'll end up with multiple overlapping spectral components from different Nyquist zones, and no straightforward way to distinguish them - leading to unusable measurement data.In other words, by using a mixer followed by a fixed low-pass filter, you effectively create a tunable band-pass system whose passband can be shifted to any desired frequency by adjusting the LO. This allows you to isolate a narrow portion of the spectrum while suppressing all out-of-band signals and harmonics and give you frequency selectivity.When the LO is phase synchronized with the tracking generator (stimulus signal), this architecture enables coherent detection, so you will have also phase selectivity. Coherent detection is inherently robust against relatively strong external interference, even if the interference frequency coincides with the tracking generator frequency, provided that it do not saturate the ADC input and don't synchronized with tracking generator.

author: tszaboo
author_rank: Super Contributor
timestamp: August 05, 2025, 03:58:57 pm
content: Quote from: radiolistener on August 05, 2025, 03:35:55 pmWe agree on that. But this design seem to use the STM32F411's built in ADC. The datasheet doesn't specify it's analog input bandwidth, but it's a 6MSPS SAR. SAR typically can do this, I think the input bandwidth is probably a few dozen MHz.Quote from: radiolistener on August 05, 2025, 03:35:55 pmYou were very eager to push square waves as the output signal, and when I suggest doing the equivalent of that on the receiving end, it's suddenly not good enough?

author: radiolistener
author_rank: Super Contributor
timestamp: August 05, 2025, 04:33:06 pm
content: Quote from: tszaboo on August 05, 2025, 03:58:57 pmEssentially, what you're proposing with undersampling is functionally equivalent to a scalar analyzer with no selectivity, but one with a poorly defined frequency response, since an ADC amplitude response outside the first Nyquist zone is far from flat, even within its specified analog bandwidth.In contrast, my approach is based on a true vector analyzer architecture, which, unlike the method you suggested, offers a nearly flat amplitude response over a wide bandwidth (limited with mixer specification), while also providing both frequency and phase selectivity. This allows it to reject not only all harmonics, but also significantly suppress interference that is not phase-synchronized with the LO and stimulus signal. That is the fundamental difference.Your point about testing nonlinear systems with a square wave is technically valid - it will be problematic. However, I would argue that Bode plots are fundamentally a linear analysis tool, intended to characterize the frequency response of linear systems. In that context, analyzing a nonlinear system using a Bode plot is of limited practical value.

author: tszaboo
author_rank: Super Contributor
timestamp: August 05, 2025, 09:04:21 pm
content: Quote from: radiolistener on August 05, 2025, 04:33:06 pmThe frequency response of ADCs is usually well defined in their characteristics, either explicitly, when they are RF focused. Or implicitly when the input characteristics are written.Besides, it's going to get calibrated out anyway.Why on earth would you use bode plot on a passive system? It's a tool for opamps gain, stability, power supplies, PSRR, CMRR and other measurements.

author: uer166
author_rank: Super Contributor
timestamp: August 06, 2025, 12:05:24 am
content: Quote from: radiolistener on August 05, 2025, 04:33:06 pmYour RF background is leaking through. Reading between the lines the OP wants to match something like a Bode 100, which is used to characterize all kinds of systems, not necessarily fully linear, where the harmonics would often cause a problem with DUT. In the extreme, even passives are nonlinear; a Bode plotter is useful for systems that can be locally approximated as an LTI, even though a large signal response would be anything but.I would love a Bode 100 alternative that doesn't cost many thousands of $$, has just as good phase detection, and very high sensitivity. Why would you dump square waves with such a device is beyond me..

author: mawyatt
author_rank: Super Contributor
timestamp: August 06, 2025, 01:13:15 am
content: Quote from: uer166 on August 06, 2025, 12:05:24 amTake a look at the Siglent SDS800X HD DSO and SDG2042X AWG. Don't discount this because it's an entry level DSO with a half-baked built-in Bode Function. With this AWG the Bode Function covers from 10Hz to 120MHz and dynamically ranges the DSO inputs, and can also have the AWG range scaled dynamically.Anyway, they're loads of discussions on DSO based Bode Functions and Plots around here!!Here's couple we've posted on EDN and here, there are many more here if you search.https://www.edn.com/author/mike-wyatt/Best

author: EggertEnjoyer123
author_rank: Frequent Contributor
timestamp: August 06, 2025, 05:03:35 am
content: Quote from: mawyatt on August 06, 2025, 01:13:15 amJust wondering, what is the dynamic range of the Siglent Bode plotter?

author: EggertEnjoyer123
author_rank: Frequent Contributor
timestamp: August 06, 2025, 07:32:10 am
content: Quote from: tszaboo on August 05, 2025, 03:58:57 pmI'm using the bluepill board (which uses the STM32F103C8T6).Should be fast enough even though this chip is worse than the F411

author: ftg
author_rank: Frequent Contributor
timestamp: August 06, 2025, 10:08:57 am
content: Unlike the STM32F411, STM32F103C8T6 has 3x ADC's, so sampling multiple signals at the same time is possible.While with the F411 one has to deal with a single ADC and switching between channels.So it does have that going for it, even if it has a slower core without floating point.

author: tszaboo
author_rank: Super Contributor
timestamp: August 06, 2025, 10:15:30 am
content: Quote from: EggertEnjoyer123 on August 06, 2025, 05:03:35 amI've this setup. It works up to 10-15MHz well enough, above that it fell apart in my setup.Not sure exactly why, I suspect ground loops, external termination, probe loading, maybe the cables and BNC junctions.By falling apart, I mean I get more than ~0.5-1 dB of error.You get 60-80dB dynamic range with it, no problem, the scope will change it's range to increase it's dynamic range.https://siglentna.com/application-note/bode-plot-filter-oscilloscope-generator

author: mawyatt
author_rank: Super Contributor
timestamp: August 06, 2025, 02:19:03 pm
content: Quote from: EggertEnjoyer123 on August 06, 2025, 05:03:35 amRecall rf-loop did a demonstration with a stepped attenuator that showed ~100dB with an older Siglent DSO (8 bit DSO I believe), but can't locate the post.Edit: Here we just grabbed a two cheap 40dB SMA attenuators in series (80dB attenuation), a cheap BNC 50Ω Thru and some SMA to BNC adapters and cables laying around. The Signal Source is an SDG2042X and the DSO is a SDS814X, both connected by LAN. With more care, time, quality components and cables results should improve. Added a single 40dB attenuator and a 20dB (note scale zoomed in to 1/2dB per division).Anyway, hope this helps.Best

author: tszaboo
author_rank: Super Contributor
timestamp: August 06, 2025, 08:42:18 pm
content: Quote from: mawyatt on August 06, 2025, 02:19:03 pmThanks, these show the deviation above 10MHz as well, similar to what I saw.

author: EggertEnjoyer123
author_rank: Frequent Contributor
timestamp: August 07, 2025, 05:42:15 am
content: Quote from: mawyatt on August 06, 2025, 02:19:03 pmCan you calibrate out the phase error at higher frequencies (I'm assuming it's not supposed to be there).

author: gf
author_rank: Super Contributor
timestamp: August 07, 2025, 08:55:25 am
content: Quote from: EggertEnjoyer123 on August 07, 2025, 05:42:15 amI wonder what this phase trace would look like if it were displayed using a linear frequency scale. Is it approximately a straight line through the origin then? IOW, is it in the end just a delay due to the length of the DUT and/or possibly different cable lengths for the two channels?

author: mawyatt
author_rank: Super Contributor
timestamp: August 09, 2025, 02:39:58 am
content: Quote from: EggertEnjoyer123 on August 07, 2025, 05:42:15 amAt the moment no. Altho we've hinted that allowing the Bode function to have a calibration feature as well as utilizing math functions would be a welcome enhancement. Having the calibration feature would allow removing the measurement setup/fixture/cable/probe effects like this phase response.Anyway, we'll see if Siglent was listeningBest

author: mawyatt
author_rank: Super Contributor
timestamp: August 09, 2025, 02:47:49 am
content: Quote from: gf on August 07, 2025, 08:55:25 amLikely due to cable lengths and channel mismatch.Best

author: Terry Bites
author_rank: Super Contributor
timestamp: August 10, 2025, 02:38:03 pm
content: How does your proposed circuit implementation cost look compared to a nano VNA? Seefor remote control.Low cost DDS with PLL upconversion?How fast does your sweep need to be? Not that fast I'd guess. And likely no need for very high resolution.The stimulus is a predictable time continuous signal which makes undersampling very attractive.Undersampling removes any need for a down mixer and so relaxes the spec burden on the ADCPLL loop filter settling time will limit agility and the settling of amplitude leveling loop.This way lies missery I think.Still HP have made a very good go of it for years.

author: EggertEnjoyer123
author_rank: Frequent Contributor
timestamp: August 12, 2025, 04:17:28 am
content: Quote from: Terry Bites on August 10, 2025, 02:38:03 pmThe NanoVNA doesn't work at low frequency, which is annoying for certain tasks. For example, last time I was trying to measure the response of an adjustable filter which works at audio range. It would be impossible to do this measurement with the NanoVNA because it wouldn't get anywhere close to 100 Hz. Also, settling time is probably not that important, given that it would take a lot of time to collect the data at low frequencies like 10 Hz anyways (you need a few cycles worth of data). A device which costs less than a scope and goes through all of the common frequencies for things like audio would be useful.Undersampling could work. However, I don't think the STM32 ADC would work at 50 MHz, and also the noise floor would go up too. A switching mixer is cheap enough anyways and costs less than a dime, so there's not really any point in trying to do undersampling.