Multichannel Pulse Height Analyzer

Some interesting links on radiation spectroscopy:


The basic blocks of the system are shown on the following diagram:

Multichannel Pulse Height Analyzer

The projects/mcpha directory contains five Tcl files: block_design.tcl, pha.tcl, hst.tcl, osc.tcl, gen.tcl. The code in these files instantiates, configures and interconnects all the needed IP cores.

The source code of the R script used to calculate the coefficients of the FIR filter can be found in projects/mcpha/filters/fir_0.r.


The projects/mcpha/server directory contains the source code of the TCP server (mcpha-server.c) that receives control commands and transmits the data to the control program running on a remote PC.

The projects/mcpha/client directory contains the source code of the control program (mcpha.tcl).

MCPHA client

Getting started with MS Windows

Getting started with GNU/Linux

sudo apt-get install tk8.6 tk8.6-blt2.5
git clone
cd red-pitaya-notes/projects/mcpha/client
wish8.6 mcpha.tcl

Building from source

The installation of the development machine is described at this link.

The structure of the source code and of the development chain is described at this link.

Setting up the Vivado environment:

source /opt/Xilinx/Vivado/2018.3/

Cloning the source code repository:

git clone
cd red-pitaya-notes

Building mcpha.bit:

make NAME=mcpha bit

Building mcpha-server and pha-server:

arm-linux-gnueabihf-gcc -static -O3 -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard projects/mcpha/server/mcpha-server.c -o mcpha-server -lm -lpthread
arm-linux-gnueabihf-gcc -static -O3 -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard projects/mcpha/server/pha-server.c -o pha-server -lpthread

Building SD card image zip file:

source helpers/