Skip to the content
4 layers87.4 × 175.5 mmTM MUX Board REV B, the printed circuit board in 3D

TM MUX Board REV B

emilefarine/redpitaya-afm1

master project, low cost solution for afm acquisition

Size
87.4 × 175.5 mm
Copper layers
4
Thickness
1.6 mm
Parts
183
Nets
165
Pads
705
Tracks, vias
1,272, 1,032
Pours
6
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
2 Jul 2026
Updated
7 Nov 2026

Overview

TM MUX Board REV B is an open-source printed circuit board by emilefarine, from the emilefarine/redpitaya-afm repository on GitHub, published under the MIT licence. It is a 4-layer board of 87.4 × 175.5 mm with 183 parts on 165 nets, routed with 1,272 tracks and 1,032 vias.

It is built around the LPC1114FBD48/301:1, PGA849RGTR and ADG1409YRUZ, with the TLV76133DCY, TPS7A3301RGW and M50-3600542R among its other parts. Its parts include 66 capacitors, 45 resistors, 19 ICs, 15 connectors and 12 diodes. It belongs with the NXP (LPC, Kinetis, i.MX RT) boards of this library.

Main components

7

README

README.md

Open-Source Zynq-Based AFM Acquisition System

An open, low-cost acquisition instrument for Atomic Force Microscopy (AFM), built around the Red Pitaya STEMlab 125-14 (Xilinx Zynq-7010 SoC) and delivered as a self-contained 19-inch rack unit. It replaces the closed, expensive and proprietary acquisition boards typically used in AFM setups with a fully inspectable and extensible signal chain.

The instrument generates an excitation signal, conditions it through a custom analog board, drives the AFM, acquires the cantilever response, and processes it (FFT, peak detection, lock-in detection) entirely on the device. Results are exposed over the network through an SCPI-inspired protocol and can be driven from Python, LabVIEW, MATLAB or any TCP client.

MUX board

Architecture

The system is organised in four layers:

LayerDescriptionLocation
FPGA datapathCustom programmable-logic design on the Zynq: excitation generation and acquisition around a single shared BRAM, with adaptive decimationfpga/
Analog boardCustom conditioning board: programmable gain (×1/8 to ×16), input multiplexer, ±10 V range, analog sum/difference outputs, LPC1114 control microcontroller, OLED IP displayhardware/, ElectronicBoard/
Embedded C++ serverSingle-client TCP server running on the Red Pitaya's Linux, exposing an SCPI-inspired command language over the networkcpp/
Python clientsClient library, interactive CLI, PyQt6 desktop GUI with routing schematic dialog, and deployment toolingpython/

Two measurement modes are available: a broadband sinc that captures a whole spectrum in a few milliseconds, and a lock-in sweep that resolves narrow resonances.

Repository layout

text
cpp/                 Embedded C++ server + signal processing (build & run on the Red Pitaya)
  Hardware/          Hardware abstraction: FPGA register access, board UART, SSD1306 OLED
  Server/            TCP server, SCPI command handler, protocol
  SignalProcessing/  Signal generation, FFT (FFTW3), sine fit
  Tools/             oled-ip helper + systemd service
  tests/             Host-side unit tests (run on the dev PC, no Red Pitaya needed)
python/              Client library, CLI, GUI (with routing schematic dialog) and deployment
fpga/
  rtl/               SystemVerilog / VHDL sources for the custom datapath
  sim/               Testbenches for the custom modules (Vivado simulator)
  bitfiles/          Prebuilt bitstream (flash without rebuilding in Vivado)
ElectronicBoard/
  src/               LPC1114 firmware for the analog board (MUX + gain control)
hardware/
  TM_MUX_Board_REV_B/  KiCad 10 project: schematics, PCB, 3D model, interactive BOM

Requirements

Hardware

  • Red Pitaya STEMlab 125-14 (Zynq-7010)
  • Custom analog MUX board (optional; design in hardware/). Without it the server runs in Red Pitaya-only mode and the BOARD:* commands are unavailable.

Software

  • Client PC: Python 3.10+ (developed on 3.13)
  • On the Red Pitaya: g++ (C++17), FFTW3 single precision (libfftw3f), Red Pitaya libraries (librp, librp-hw, librp-hw-calib, librp-hw-profiles), all present on the stock Red Pitaya OS 2.0+ image
  • FPGA rebuilds only: Xilinx Vivado/Vitis (a prebuilt bitstream is shipped, so this is optional)
  • Board firmware only: MCUXpresso IDE + a J-Link EDU mini

Installation

bash
git clone https://github.com/emilefarine/redpitaya-afm 
cd redpitaya-afm
python -m venv .venv
# Windows:  .venv\Scripts\activate.bat
# Linux/macOS:  source .venv/bin/activate
pip install -r python/requirements.txt

All scripts that connect to the board accept --host <ip> (or the RP_HOST environment variable). SSH credentials default to the Red Pitaya factory login root / root and can be overridden with --user / --password (or RP_USER / RP_PASSWORD). Prefer RP_PASSWORD: a --password value stays in the shell history. rp_deploy.py accepts any SSH host key, which suits a Red Pitaya on a private bench network.

Usage

1. Flash the FPGA bitstream

A prebuilt bitstream is included, so you do not need Vivado:

bash
python python/rp_deploy.py --host 192.168.1.100 --deploy
python python/rp_deploy.py --host 192.168.1.100 --status   # expect: FPGA state operating

By default the newest fpga/bitfiles/*.bit.bin is used; pass --bitfile <path> to select another. A raw .bit (from a local Vivado build) is converted automatically with bootgen (point to it with --bootgen / the BOOTGEN env var, or let the script scan a local Vitis install).

The server reads the FPGA VERSION register and refuses any other bitstream than the one in fpga/bitfiles/. The previous bitstream (0x15062026) and its server are kept under the git tag and GitHub release fpga-15062026.

2. Build and deploy the C++ server

The C++ code is compiled on the Red Pitaya (not cross-compiled). rp_deploy.py mirrors the sources over SSH, then build with make:

bash
python python/rp_deploy.py --host 192.168.1.100 --cpp      # sync sources to the board

# then over SSH on the Red Pitaya, from the synced cpp/ directory:
make server        # build the AFM SCPI server
./out/afm_server   # run it (listens on TCP 5025)

Other make targets: make all (server + tools), make tools.

Host-side unit tests run on the dev PC without a Red Pitaya. Shell: the MSYS2 UCRT64 shell on Windows (install mingw-w64-ucrt-x86_64-gtest and mingw-w64-ucrt-x86_64-fftw via pacman) or any POSIX shell on Linux (apt install libgtest-dev libgmock-dev libfftw3-dev), plus pip install gcovr for coverage. From cpp/:

bash
make test_host      # build and run the unit tests
make coverage       # unit tests + HTML report at out/host/coverage/index.html

3. Red Pitaya-only operation (no analog board)

The custom analog board is optional. To run measurements with only a Red Pitaya, start the server with --no-board, the electronic board is then never probed and every BOARD:* command is rejected with ERR_HARDWARE: Electronic board disabled (RP-only mode):

bash
./out/afm_server --no-board

Connect the cantilever signal directly to IN1, the only input acquired by the FPGA datapath. MEASURE:SINC and MEASURE:SWEEP work exactly as with the board, mux routing and programmable gain are unavailable. Query the active mode with SYSTEM:MODE? (FULL or RP_ONLY); SYSTEM:STATUS? also reports MODE=. The GUI disables the board panel and the routing schematic automatically in RP-only mode.

4. Connect a client

Interactive CLI:

bash
python python/afm_cli.py 192.168.1.100

Desktop GUI (PyQt6, real-time magnitude/phase plots):

bash
python python/afm_gui.py

GUI commands run in the background, so a server that stops answering never freezes the window. While a measurement runs, the Measure button becomes Cancel: it closes the connection and reconnects (a server from 2.9.0 also stops the sweep). In the CLI, Ctrl+C cancels.

The -3 dB band and the Q-factor are interpolated between points. When the band is narrower than 3 frequency steps, it is the resolution and not the resonance: the GUI then shows a bound (for example < 22.4 Hz and > 6872). Use more samples, a higher decimation or a finer step to resolve it.

Click the "Board Configuration" title to fold that panel and keep the measurement controls in view on a small screen; the GUI remembers the choice. The sidebar scrolls when the screen is too short.

The GUI has an "Open Routing Schematic" button showing the live 4x4 crossbar routing and PGA gains (read from BOARD:STATUS?); the same dialog runs standalone without hardware for preview:

bash
python python/afm_schematic.py

Python library:

python
from afm_client import AFMClient

with AFMClient("192.168.1.100") as client:
    client.init()
    spectrum = client.measure_sinc(center_kHz=1000, bandwidth_kHz=200)
    peak = spectrum.freq_kHz[spectrum.magnitude.argmax()]
    print(f"Peak at {peak:.1f} kHz")

    sweep = client.measure_sweep(center_kHz=1000, range_kHz=100, step_kHz=0.5)

5. ADC input protection

Keep the Red Pitaya input jumpers on LV (+/-1 V). That input is rated 6 V absolute maximum, and only its full scale above 1 kHz, while the board can output about +/-10.5 V.

Before each measurement the server predicts the peak at the ADC: amplitude x excitation gain x sample gain x return gain.

  • Loop: excitation on IN1, return = the input routed to OUT1. Automatic.
  • Refusal: above 1 V the measurement is not run: ERR_PARAM: ADC overdrive: ... with a suggested gain or amplitude.
  • Weak signals: BOARD:ADC:SAMPLEGAIN <factor> (CLI adc_sample_gain, GUI "Sample gain") is the expected return / excitation ratio of the sample, default 1. Set it below 1 to use a high return gain.
  • Override: BOARD:ADC:PROTECT OFF (CLI adc_protect off, GUI "ADC protection" checkbox). *RST and a restart re-enable it and reset the sample gain.
  • State: LOOP=, OVERDRIVE=, SAT=, PROTECT=, SAMPLEGAIN= in SYSTEM:STATUS?, "ADC Input" in the GUI.

The prediction is only as good as the declared sample gain and assumes a +/-1 V output (DAC_FULL_SCALE in cpp/Hardware/InputSafety.h). SAT= reports real clipping in the last acquisition: the FPGA flags any raw ADC sample at a rail, before the averaging. RP-only mode has no monitor.

6. Hardware loopback check

Run after flashing a bitstream or changing cpp/Hardware/. It needs the standard wiring (Red Pitaya OUT1 -> board IN1, board OUT1 -> Red Pitaya IN1), or a cable OUT1 -> IN1 in --no-board mode:

bash
python python/afm_hil_check.py 192.168.1.100

The script routes board OUT1 <- IN1 at gain x1 and leaves it so. It checks the signal level and flatness, linear phase, every decimation, the sinc level, the full 65536-sample depth, amplitude linearity (no stale data) and repeatability. Exit code 0 when every check passes.

7. FPGA simulation

The custom FPGA modules have testbenches for the Vivado simulator (Vivado 2025.1 in its default folder, or the install named by XILINX_VIVADO):

bash
python fpga/sim/run_sim.py                  # every testbench, exit code 1 on a failure
python fpga/sim/run_sim.py tb_measure --gui # open the waveforms

tb_averager checks the stored averages at every decimation from 16 to 1024. tb_measure runs complete measurements through the PS bus, as afm_server does: BRAM fill, registers, START, END, COUNT and read-back, including a full 65536-sample measurement, and the overrange flag (STATUS bit 2) inside and outside the acquisition window.

SCPI protocol

The server speaks an SCPI-inspired ASCII protocol over TCP port 5025. Commands are case-insensitive, colon-separated, ?-suffixed for queries, with comma-separated arguments; every line ends with \n. Responses are a single line, OK [data] or ERR_<CODE>: <message>, except MEASURE:* and BOARD:STATUS? (below). Extra arguments are refused with ERR_SYNTAX.

CommandDescription
*IDN? / *RST / *OPC?IEEE 488.2 common commands
SYSTEM:INIT / SYSTEM:DEINIT / SYSTEM:STATUS?Hardware lifecycle and status
SYSTEM:PING / SYSTEM:VERSION? / SYSTEM:SHUTDOWNConnectivity check, server version, server shutdown
SYSTEM:MODE?Operating mode: FULL or RP_ONLY (board disabled with --no-board)
BOARD:MUX:ROUTE <out>,<in>Route input to output (channels 1-4)
BOARD:MUX:DISCONNECT <out>Disconnect a multiplexer output
BOARD:GAIN <ch>,<idx>Set programmable gain (idx 0-7 → ×1/8 … ×16)
BOARD:STATUS? / BOARD:RESETQuery board routing/gains, reset board to defaults
BOARD:ADC:LOOP AUTO / <excite>,<return> / OFFADC protection loop: from the routing (default), by hand, or off
BOARD:ADC:PROTECT ON / OFFRefuse overdriving measurements (default), or override
BOARD:ADC:SAMPLEGAIN <factor>Expected return / excitation ratio of the sample (default 1)
MEASURE:SINC <center_kHz>,<bw_kHz>[,<samples>,<dec>,<amp>]Broadband sinc + FFT
MEASURE:SWEEP <center_kHz>,<range_kHz>[,<step_kHz>,<dec>,<amp>]Lock-in frequency sweep

MEASURE:* return a multi-line spectrum: a header OK DATA <N> <BYTES> followed by N rows of freq_kHz,magnitude,phase_rad. <BYTES> is the exact size of the payload that follows the header line, so a client can read it in one shot instead of scanning for newlines.

MEASURE:SWEEP skips the points at or below 0 Hz when center - range/2 is negative. phase_rad is the phase of the response relative to the excitation (negative = lag): for MEASURE:SWEEP relative to the sine, for MEASURE:SINC relative to the sinc pulse. Both account for the one-sample delay between generation and acquisition, so a direct cable reads about 0 with a small lag from the cable and converters. The sweep fits a sine with an offset, so a DC offset on the input does not leak into the low-frequency points.

The MEASURE:SWEEP magnitude is the amplitude of the response in volts. The MEASURE:SINC magnitude is a per-bin FFT level that depends on the band and the record: multiply it by 2 * bandwidth * samples / fs (sinc_amplitude_scale in afm_client.py) to get the amplitude a sine of the same setting would give. The GUI plots the sinc that way, so sinc and sweep read in the same volts.

BOARD:STATUS? returns OK LINES <N> followed by the N lines of the board status block.

A measurement that does not complete returns ERR_TIMEOUT. A MEASURE:SWEEP stops between points with ERR_ABORTED when the client closes the connection or the server is stopping. SYSTEM:SHUTDOWN ends the server process.

MUX board firmware

The analog board is controlled by an on-board LPC1114 microcontroller (MUX routing, programmable gain, OLED IP display). Firmware sources are in ElectronicBoard/src/.

To build and flash with MCUXpresso IDE:

  1. Create a new C++ project for the LPC1114/LPC1125 target (the sources include the cr_startup_lpc11xx startup and crp.c code-read-protection files).
  2. Import the contents of ElectronicBoard/src/ into the project's source folder.
  3. Build, then flash to the board over SWD using a J-Link debug probe (Debug / Program).

Hardware design

The analog MUX board (REV B) is designed in KiCad 10, under hardware/TM_MUX_Board_REV_B/:

  • Schematics: open TM_MUX_Board_REV_B.kicad_pro, or read the exported PDFs
  • PCB layout: TM_MUX_Board_REV_B.kicad_pcb
  • 3D model: TM_MUX_Board_REV_B.step
  • Interactive BOM: bom/ibom.html (open in a browser)

License

Released under the MIT License.

Developed as a Master's thesis, "Design and Implementation of an Open-Source Zynq-Based Synchronous Acquisition System for Atomic Force Microscopy", by Emile Farine at the HES-SO Master of Science in Engineering (hepia / MSE), in collaboration with the DQMP, University of Geneva.

Parts

183
QtyValueFootprintReferences
35100nFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC3, C10, C11, C12, C13, C14, C15, C16, C17, C20, C21, C22, C25, C26, C27, C30 +19
19TestPoint_SmallTestPoint:TestPoint_Loop_D1.80mm_Drill1.0mm_BeadedTP1, TP2, TP3, TP4, TP5, TP6, TP10, TP11, TP12, TP13, TP14, TP15, TP17, TP18, TP19, TP20 +3
123kRCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderR5, R7, R9, R10, R11, R12, R13, R14, R27, R28, R29, R30
111uFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC44, C49, C51, C59, C60, C61, C62, C63, C64, C65, C66
10SD12_SOD323Diode_SMD:D_SOD-323D2, D3, D4, D5, D6, D7, D8, D9, D10, D11
8100pFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC1, C2, C18, C19, C23, C24, C28, C29
60RCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderR3, R6, R8, R21, R23, R25
6Conn_CoaxialConnector_Coaxial:BNC_Amphenol_B6252HB-NPP3G-50_HorizontalJ5, J6, J7, J8, J10, J12
6OPA828IDRPackage_SO:SOIC-8_3.9x4.9mm_P1.27mmU2, U3, U4, U5, U6, U7
40RResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR2, R22, R24, R26
4100RResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR31, R32, R33, R34
41MRResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR4, R15, R17, R19
447RResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR1, R16, R18, R20
447pFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC50, C53, C54, C55
4ADG1409YRUZPCB_Library:SOP65P640X120-16NIC1, IC6, IC7, IC8
4Conn_CoaxialConnector_Coaxial:SMA_Amphenol_132289_EdgeMountJ2, J3, J4, J9
4MountingHole_PadMountingHole:MountingHole_3.2mm_M3_Pad_ViaH1, H2, H3, H4
4PGA849RGTRPCB_Library:QFN50P300X300X100-17N-DIC2, IC3, IC4, IC5
310uFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC6, C45, C46
2470RResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR44, R47
247uFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC48, C58
1100kRCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderR35
110kRResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR49
110kRCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderR38
110nFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC47
112kRCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderR42
1150kRCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderR43
11M5RCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderR40
1220RCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderR37
1220uF 16VCapacitor_THT:CP_Radial_D6.3mm_P2.50mmC57
12u2FCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC52
1330kRCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderR36
1660RResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR48
1Conn_01x04_PinConnector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_VerticalJ13
1Conn_02x13_Odd_EvenConnector_IDC:IDC-Header_2x13_P2.54mm_VerticalJ11
1Fuse_SmallFuse:Fuse_1812_4532MetricF1
1Jumper_2_BridgedConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJP1
1LED_ARGBLED_SMD:LED_ASMB-KTF0-0A306D1
1LPC1114FBD48-301Package_QFP:LQFP-48_7x7mm_P0.5mmU1
1M50-3600542RPCB_Library:HUSSP10W40P127_2X5_635X340X420PJ1
1MCP120-300TTPackage_TO_SOT_SMD:SOT-23U8
1PTVS5V0Z1USKPDiode_SMD:Nexperia_DSN1608-2_1.6x0.8mmD13
1SW_Omron_B3FSButton_Switch_SMD:SW_SPST_Omron_B3FS-100xPSW1
1Screw_Terminal_01x02TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2_1x02_P5.00mm_HorizontalJ15
1Screw_Terminal_01x03TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-3-5.08_1x03_P5.08mm_HorizontalJ14
1TLV76133DCYPackage_TO_SOT_SMD:SOT-223-3_TabPin2U9
1TPS7A3301RGWPackage_DFN_QFN:Texas_RGW0020A_VQFN-20-1EP_5x5mm_P0.65mm_EP3.15x3.15mm_ThermalViasU11
1TPS7A4701xRGWPackage_DFN_QFN:Texas_RGW0020A_VQFN-20-1EP_5x5mm_P0.65mm_EP3.15x3.15mm_ThermalViasU10

Similar boards

  • 2 layers33 × 46.4 mmFeather swd adapter, the printed circuit board in 3D

    Feather swd adapter

    jtdc-ca/feather_swd_adapter

    SWD Adapter with Breakout for Northern Mechatronics Feather Board (NM180310)

    9 partsMIT
  • 4 layers130 × 115 mm4ch Strain Gauge Collector, the printed circuit board in 3D

    4ch Strain Gauge Collector

    EERNINUO/4ch-Strain-Gauge-Collector

    4通道应变信号同步采集模块

    308 partsGPL-3.0
  • 4 layers68 × 45 mmInterface DAC, the printed circuit board in 3D

    Interface DAC

    nonameCCC/PHASE-1

    A compact modularized audio DAC & Headphone Amplifier.

    146 partsGPL-3.0
  • 2 layers116 × 45 mmLowNoiseDual5W, the printed circuit board in 3D

    LowNoiseDual5W

    ulikoehler/PowerSupplies

    Power supply PCBs & documentation

    63 partsCC0-1.0
  • 2 layers62.5 × 61.5 mmJeden board, the printed circuit board in 3D

    Jeden board

    Wojtekb30/Jeden-board

    KiCad hardware project. A ATMega328P-based development board with Arduino Uno's functionality.

    29 parts2
  • 4 layers26.4 × 49.4 mmRP2040 Dev, the printed circuit board in 3D

    RP2040 Dev

    CafeAsh/DevBoards

    Development board based on the ATmega32U4 microcontroller, designed for USB-enabled embedded projects, rapid prototyping, and firmware experimentation.

    40 parts
  • 2 layers74.1 × 16.6 mmLED Board, the printed circuit board in 3D

    LED Board

    lfras01/lume-led-board-pcb

    25 parts

Questions

How big is the TM MUX Board REV B PCB?

It measures 87.4 × 175.5 mm and has 4 copper layers, 1.6 mm thick.

What parts does the TM MUX Board REV B use?

183 parts, built around the LPC1114FBD48/301:1, PGA849RGTR, ADG1409YRUZ and TLV76133DCY. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the TM MUX Board REV B KiCad files?

From the emilefarine/redpitaya-afm repository on GitHub, at the commit this page was made from: the board is hardware/TM_MUX_Board_REV_B/TM_MUX_Board_REV_B.kicad_pcb and its schematic hardware/TM_MUX_Board_REV_B/MCU.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the TM MUX Board REV B design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).