← All posts

Building a Portable Electrochemical Analyzer Around an STM32F303

The engineering decisions, measurement challenges and lessons behind an STM32-based potentiostat developed for EIS, CV and LSV.

Block diagram of the STM32F303-based electrochemical analyzer

Related project: Portable Electrochemical Analyzer →

An electrochemical analyzer is an interesting embedded-systems problem because almost every engineering layer can affect the final measurement.

A perfectly timed ADC conversion cannot recover information already buried in analog noise. A well-designed transimpedance amplifier is of little use if waveform generation introduces timing errors. And both can appear to work on an oscilloscope while still producing inaccurate electrochemical results.

That interaction between analog electronics, embedded timing, signal processing and physical measurement was what made this project particularly valuable.

The Objective

The project was developed during my M.Sc. in Embedded Systems at Technische Universität Chemnitz.

The objective was to investigate how much electrochemical measurement capability could be implemented around a single STM32F303 ARM Cortex-M4, using its integrated DACs and ADCs rather than relying on a dedicated impedance-analyzer IC.

The target system combined a potentiostat, current-to-voltage conversion, waveform generation, synchronized acquisition, embedded processing and a PC interface.

System Architecture

System architecture of the electrochemical analyzer showing the PC interface, STM32F303 digital stage, DAC excitation paths, potentiostat, transimpedance current measurement and differential ADC feedback

The architecture is useful context for everything that follows. The STM32F303 sits at the center of the system, generating excitation through its DACs, synchronizing acquisition through its ADCs, processing the measurements and communicating with the PC. Around it, the analog front end controls the electrochemical cell and converts its response into signals that the MCU can acquire.

This separation between the digital generation/acquisition layer and the analog control/measurement layer is the key to understanding the design decisions discussed below.

Why the Analog Front End Matters

A potentiostat controls the potential of an electrochemical cell while measuring the current produced by the reaction.

For a three-electrode cell, the reference electrode provides feedback, the counter electrode is driven by the control loop and the working electrode provides the current measurement.

Potentiostat schematic

The STM32 DACs are unipolar, while the electrochemical excitation needed to move above and below zero. A buffered 1.65 V reference and op-amp subtractor stages therefore translate the DAC signals into bipolar signals. A summing stage combines the waveform and DC/ramp components before they enter the potentiostat.

Current from the working electrode is converted into voltage using a transimpedance amplifier.

The TIA brings several competing requirements together. Increasing feedback resistance improves sensitivity to small currents but changes bandwidth and makes parasitic effects increasingly important. Feedback capacitance improves stability and limits high-frequency noise but also affects usable bandwidth.

The design therefore involved a practical trade-off between sensitivity, frequency response, stability and noise.

Using the STM32 as an Acquisition Engine

Generating a waveform in a software loop is straightforward. Generating it while sampling the response with repeatable phase relationships over a large frequency range is a different problem.

The timing-critical work was therefore moved into STM32 peripherals.

A hardware timer controls the sampling interval. DMA transfers waveform values to the DAC and acquired ADC values into memory with minimal CPU intervention.

Conceptually:

waveform table → timer → DMA → DAC → analog system → ADC → DMA → memory

The processor can then coordinate the measurement, process acquired data and communicate with the PC instead of servicing every sample.

This was particularly important for EIS, where phase is part of the measurement itself.

Implementing EIS

Electrochemical Impedance Spectroscopy applies an AC excitation and measures the voltage/current relationship over frequency.

The system generated excitation from approximately 0.1 Hz to 100 kHz, with approximately ±165 mV AC amplitude and a programmable DC offset of approximately ±1.65 V.

For each frequency point, voltage and current were acquired and processed to obtain impedance magnitude, phase, real component and imaginary component.

Rather than continuously transferring raw ADC samples to the PC, measurement calculations were performed on the embedded side and the resulting values were sent over USART.

Reusing the Platform for Voltammetry

The design was intentionally not limited to EIS.

For Cyclic Voltammetry, the firmware generates a triangular potential ramp, measures current throughout the sweep and reverses direction at the configured switching potential.

Linear Sweep Voltammetry reuses the same underlying acquisition chain but scans in one direction.

SWV exposed an architectural limitation. The pulsed waveform could be generated and observed experimentally, but separating forward- and reverse-bias current samples within the DMA-based implementation proved more difficult. The complete SWV processing path was therefore not finalized within the available project time.

This was a useful demonstration that an architecture well suited to one measurement method does not necessarily map perfectly onto another.

From Circuit to PCB

Potentiostat PCB

Once the analog stages had been investigated through simulation and prototyping, the design was transferred to PCB.

Layout matters around the high-impedance current-measurement path. Trace length, grounding, nearby digital activity and parasitic capacitance can all become part of the effective measurement circuit.

A dedicated supply board provided the bipolar and separate analog/digital rails needed by the system.

Power-supply schematic

Top and bottom PCB layouts of the dedicated power-supply board

The PC Side

C# measurement application

A C# application completed the system. It allowed the operator to configure communication and measurement parameters, start tests, receive results, visualize measurements and save data.

This forced the embedded protocol and measurement state machine to operate as part of a usable instrument rather than as isolated firmware.

Testing Against Reference Instruments

Testing began with passive dummy cells. Known resistor/capacitor networks made it possible to investigate the measurement chain without the additional variability of a real electrochemical reaction.

The device was then tested with electrochemical cells and solutions including Ferri-Ferro and Naphthoquinone.

Reference measurements were performed using commercial equipment including PalmSens potentiostats and laboratory impedance-analysis equipment.

Experimental setup showing the prototype electrochemical analyzer and reference measurement setup

For EIS, results were evaluated using Bode magnitude, Bode phase and Nyquist plots.

EIS comparison against reference instrumentation using Bode and Nyquist representations Naphthoquinone measurements showed close agreement with the commercial reference through much of the tested 10 Hz–100 kHz range, with greater deviation toward low frequencies.

CV comparison with PalmSens

LSV comparison between the prototype and PalmSens reference measurements

CV and LSV provided further comparisons with the commercial potentiostat.

Where the Prototype Reached Its Limits

Validation was useful not only for demonstrating functionality but also for identifying limitations.

The work exposed issues involving low-level noise, DAC behavior, TIA bandwidth and compensation, parasitic capacitance, EMI, ADC resolution and manual current-range selection.

Potential future improvements therefore included better shielding and grounding, refined TIA compensation, lower-noise excitation, higher-resolution acquisition where needed and automatic range selection.

The Main Engineering Lesson

The biggest lesson was that measurement systems cannot be divided cleanly into “hardware problems” and “software problems.”

A strange curve on the PC can originate in the electrochemical cell, an op-amp, PCB parasitics, ADC configuration, DMA timing, numerical processing or communication software.

Debugging requires following the signal through the entire chain.

The project ultimately covered the complete path from measurement concept and analog design to embedded implementation, PCB hardware, PC software and comparison against commercial instruments.

View the project showcase →