
Feather swd adapter
jtdc-ca/feather_swd_adapter
SWD Adapter with Breakout for Northern Mechatronics Feather Board (NM180310)

master project, low cost solution for afm acquisition
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.
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.

The system is organised in four layers:
| Layer | Description | Location |
|---|---|---|
| FPGA datapath | Custom programmable-logic design on the Zynq: excitation generation and acquisition around a single shared BRAM, with adaptive decimation | fpga/ |
| Analog board | Custom conditioning board: programmable gain (×1/8 to ×16), input multiplexer, ±10 V range, analog sum/difference outputs, LPC1114 control microcontroller, OLED IP display | hardware/, ElectronicBoard/ |
| Embedded C++ server | Single-client TCP server running on the Red Pitaya's Linux, exposing an SCPI-inspired command language over the network | cpp/ |
| Python clients | Client library, interactive CLI, PyQt6 desktop GUI with routing schematic dialog, and deployment tooling | python/ |
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.
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 BOMhardware/). Without it the
server runs in Red Pitaya-only mode and the BOARD:* commands are unavailable.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+ imagegit 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.txtAll 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.
A prebuilt bitstream is included, so you do not need Vivado:
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 operatingBy 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.
The C++ code is compiled on the Red Pitaya (not cross-compiled). rp_deploy.py mirrors
the sources over SSH, then build with make:
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/:
make test_host # build and run the unit tests
make coverage # unit tests + HTML report at out/host/coverage/index.htmlThe 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):
./out/afm_server --no-boardConnect 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.
Interactive CLI:
python python/afm_cli.py 192.168.1.100Desktop GUI (PyQt6, real-time magnitude/phase plots):
python python/afm_gui.pyGUI 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:
python python/afm_schematic.pyPython library:
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)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.
ERR_PARAM: ADC overdrive: ... with a
suggested gain or amplitude.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.BOARD:ADC:PROTECT OFF (CLI adc_protect off, GUI "ADC protection"
checkbox). *RST and a restart re-enable it and reset the sample gain.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.
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:
python python/afm_hil_check.py 192.168.1.100The 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.
The custom FPGA modules have testbenches for the Vivado simulator (Vivado 2025.1 in its
default folder, or the install named by XILINX_VIVADO):
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 waveformstb_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.
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.
| Command | Description |
|---|---|
*IDN? / *RST / *OPC? | IEEE 488.2 common commands |
SYSTEM:INIT / SYSTEM:DEINIT / SYSTEM:STATUS? | Hardware lifecycle and status |
SYSTEM:PING / SYSTEM:VERSION? / SYSTEM:SHUTDOWN | Connectivity 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:RESET | Query board routing/gains, reset board to defaults |
BOARD:ADC:LOOP AUTO / <excite>,<return> / OFF | ADC protection loop: from the routing (default), by hand, or off |
BOARD:ADC:PROTECT ON / OFF | Refuse 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.
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:
cr_startup_lpc11xx startup and crp.c code-read-protection files).ElectronicBoard/src/ into the project's source folder.The analog MUX board (REV B) is designed in KiCad 10, under
hardware/TM_MUX_Board_REV_B/:
TM_MUX_Board_REV_B.kicad_pro, or read the exported PDFsTM_MUX_Board_REV_B.kicad_pcbTM_MUX_Board_REV_B.stepbom/ibom.html (open in a browser)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.
| Qty | Value | Footprint | References |
|---|---|---|---|
| 35 | 100nF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C3, C10, C11, C12, C13, C14, C15, C16, C17, C20, C21, C22, C25, C26, C27, C30 +19 |
| 19 | TestPoint_Small | TestPoint:TestPoint_Loop_D1.80mm_Drill1.0mm_Beaded | TP1, TP2, TP3, TP4, TP5, TP6, TP10, TP11, TP12, TP13, TP14, TP15, TP17, TP18, TP19, TP20 +3 |
| 12 | 3kR | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | R5, R7, R9, R10, R11, R12, R13, R14, R27, R28, R29, R30 |
| 11 | 1uF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C44, C49, C51, C59, C60, C61, C62, C63, C64, C65, C66 |
| 10 | SD12_SOD323 | Diode_SMD:D_SOD-323 | D2, D3, D4, D5, D6, D7, D8, D9, D10, D11 |
| 8 | 100pF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C1, C2, C18, C19, C23, C24, C28, C29 |
| 6 | 0R | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | R3, R6, R8, R21, R23, R25 |
| 6 | Conn_Coaxial | Connector_Coaxial:BNC_Amphenol_B6252HB-NPP3G-50_Horizontal | J5, J6, J7, J8, J10, J12 |
| 6 | OPA828IDR | Package_SO:SOIC-8_3.9x4.9mm_P1.27mm | U2, U3, U4, U5, U6, U7 |
| 4 | 0R | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R2, R22, R24, R26 |
| 4 | 100R | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R31, R32, R33, R34 |
| 4 | 1MR | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R4, R15, R17, R19 |
| 4 | 47R | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R1, R16, R18, R20 |
| 4 | 47pF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C50, C53, C54, C55 |
| 4 | ADG1409YRUZ | PCB_Library:SOP65P640X120-16N | IC1, IC6, IC7, IC8 |
| 4 | Conn_Coaxial | Connector_Coaxial:SMA_Amphenol_132289_EdgeMount | J2, J3, J4, J9 |
| 4 | MountingHole_Pad | MountingHole:MountingHole_3.2mm_M3_Pad_Via | H1, H2, H3, H4 |
| 4 | PGA849RGTR | PCB_Library:QFN50P300X300X100-17N-D | IC2, IC3, IC4, IC5 |
| 3 | 10uF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C6, C45, C46 |
| 2 | 470R | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R44, R47 |
| 2 | 47uF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C48, C58 |
| 1 | 100kR | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | R35 |
| 1 | 10kR | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R49 |
| 1 | 10kR | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | R38 |
| 1 | 10nF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C47 |
| 1 | 12kR | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | R42 |
| 1 | 150kR | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | R43 |
| 1 | 1M5R | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | R40 |
| 1 | 220R | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | R37 |
| 1 | 220uF 16V | Capacitor_THT:CP_Radial_D6.3mm_P2.50mm | C57 |
| 1 | 2u2F | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C52 |
| 1 | 330kR | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | R36 |
| 1 | 660R | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R48 |
| 1 | Conn_01x04_Pin | Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_Vertical | J13 |
| 1 | Conn_02x13_Odd_Even | Connector_IDC:IDC-Header_2x13_P2.54mm_Vertical | J11 |
| 1 | Fuse_Small | Fuse:Fuse_1812_4532Metric | F1 |
| 1 | Jumper_2_Bridged | Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical | JP1 |
| 1 | LED_ARGB | LED_SMD:LED_ASMB-KTF0-0A306 | D1 |
| 1 | LPC1114FBD48-301 | Package_QFP:LQFP-48_7x7mm_P0.5mm | U1 |
| 1 | M50-3600542R | PCB_Library:HUSSP10W40P127_2X5_635X340X420P | J1 |
| 1 | MCP120-300TT | Package_TO_SOT_SMD:SOT-23 | U8 |
| 1 | PTVS5V0Z1USKP | Diode_SMD:Nexperia_DSN1608-2_1.6x0.8mm | D13 |
| 1 | SW_Omron_B3FS | Button_Switch_SMD:SW_SPST_Omron_B3FS-100xP | SW1 |
| 1 | Screw_Terminal_01x02 | TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2_1x02_P5.00mm_Horizontal | J15 |
| 1 | Screw_Terminal_01x03 | TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-3-5.08_1x03_P5.08mm_Horizontal | J14 |
| 1 | TLV76133DCY | Package_TO_SOT_SMD:SOT-223-3_TabPin2 | U9 |
| 1 | TPS7A3301RGW | Package_DFN_QFN:Texas_RGW0020A_VQFN-20-1EP_5x5mm_P0.65mm_EP3.15x3.15mm_ThermalVias | U11 |
| 1 | TPS7A4701xRGW | Package_DFN_QFN:Texas_RGW0020A_VQFN-20-1EP_5x5mm_P0.65mm_EP3.15x3.15mm_ThermalVias | U10 |

jtdc-ca/feather_swd_adapter
SWD Adapter with Breakout for Northern Mechatronics Feather Board (NM180310)



nonameCCC/PHASE-1
A compact modularized audio DAC & Headphone Amplifier.


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

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

It measures 87.4 × 175.5 mm and has 4 copper layers, 1.6 mm thick.
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.
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.
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).