Redpitaya ADC characterization
, January 18, 20211 Connecting to the Redpitaya
The ssh serverdropbearis currently not functional on the Redpitaya, so thatsshandscpcannotbe used ! Please connect to the Redpitaya withminicomand transfer files through NFS as the home directory on the host computer can be exported to the Redpitaya.
2 Data acquisition
Two bitstreams are provided,adcChanADmaDirect single.bit.binandadcChanADmaDirect dual.bit.binfor single chan- nel measurement or dual channel synchronous measurements. The devicetree overlay requires that the bitstream is called adcChanADmaDirect wrapper.bit.binso rename (cp) the wanted bitstream accordingly.
Launch onceadcChanADmaDirect us.shto initialize the Redpitaya, namely by loading the kernel moduledata dma direct core.ko, copying the bitstream to the right location in the GNU/Linux tree structure, and loading the bitstream in the FPGA. All
these steps are automated thanks to theadcChanADmaDirect.dtbodevicetree overlay.
Once the Redpitaya has been initialized, the application adcChanADmaDirect uswill acquire data through the DMA, 1 Msamples for a single channel or 500 ksamples/channel interleaved for two channels. The output filename isdump.bin, to be copied to the host PC through NFS.
3 Data processing
The data are stored in binary format, signed 16-bit integers. With GNU/Octave: for a single channel acquisition
f=f o p e n(’ d u m p . bin ’) ; d=f r e a d( f ,’ i n t 1 6 ’) ; f=l i n s p a c e(−1 2 5 / 2 , 1 2 5 / 2 ,l e n g t h( d ) ) ; p l o t( f ,a b s(f f t s h i f t(f f t( d−mean( d ) ) ) ) )
and for a dual channel acquisition
f=f o p e n(’ d u m p . bin ’) ; d=f r e a d( f ,’ i n t 1 6 ’) ; d1=d ( 1 : 2 :end) ;
d2=d ( 2 : 2 :end) ;
f=l i n s p a c e(−1 2 5 / 2 , 1 2 5 / 2 ,l e n g t h( d1 ) ) ; p l o t( f ,a b s(f f t s h i f t(f f t( d1−mean( d1 ) ) ) ) )
4 Time v.s frequency
Energy must be conserved, whether data are displayed in the time domain or the frequency domain (Parseval theorem analyzed from its energy conservation perspective by Rayleigh). Indeed, as found in Lord Rayleigh, On the character of the complete radiation at a given temperature, The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science27(169), 460–469 (1889),
...
The energy of the signal in the time domain in P
x2k computed in GNU/Octave assum(x.^2)
The challenge in the frequency domain lies in properly normalizing the spectra. Many presentations on the web explain how to correctly normalize power spectra1, so we will use the readily signal processing toolpwelch2 here
1e.g. S. Hageman, Real spectrum analysis with Octave and MATLAB, EDN (2015) at https://www.edn.com/
real-spectrum-analysis-with-octave-and-matlab/
2O.M. Solomon,PSD Computations Using Welch’s Method, Sandia Report (1991) athttps://www.osti.gov/servlets/purl/5688766/
1
pkg l o a d s i g n a l N=32768;
f s =1;
x=rand(N, 1 ) ; x=x−mean( x ) ; window=r e c t w i n (N) ;
% d e f a u l t i s f o r p w e l c h t o REMOVE t h e mean v a l u e [ pxx , f ]= p w e l c h ( x , window , 0 , N, f s , [ ] ,’ no - s t r i p ’) ; % W/Hz s u b p l o t( 1 2 1 ) ;p l o t( f , 1 0∗l o g 1 0( pxx ) ) ; y l a b e l(’ dBW / Hz ’) s u b p l o t( 1 2 2 ) ;p l o t( f , 1 0∗l o g 1 0( pxx∗f s /N) ) ; y l a b e l(’ dBW / bin ’) sum( pxx )
demonstrates that indeedsum(pxx)is equal tosum(x.^2). Notice thatpwelchis also available for SciPy asscipy.signal.pwelch For plotting histograms, hist() can be used. The excellent peakfit.m at https://terpconnect.umd.edu/~toh/
spectrum/InteractivePeakFitter.htm is used for Gaussian peak fitting. After recording the bin index and number of samples per bin, peak fitting is achieved with
pkg l o a d s i g n a l
f=f o p e n(’ d u m p . bin ’) ; d=f r e a d( f ,’ i n t 1 6 ’) ; d1=d ( 1 : 2 :end) ; d1=d1−mean( d1 ) ;
d2=d ( 2 : 2 :end) ; d2=d2−mean( d2 ) ;
f=l i n s p a c e(−1 2 5 / 2 , 1 2 5 / 2 ,l e n g t h( d1 ) ) ; [ hh , xx ]=h i s t( d1 ,f l o o r(max( d1 )−min( d1 ) ) ) ; s i g n a l =[ xx ’ hh ’ ] ;
[ F i t R e s ,GOF, b l , c o e f f , r e s , x i , y i , BootRes ]= p e a k f i t ( s i g n a l , 0 , 0 , 1 , 1 , 0 , 0 , [ 0 max( xx ) ] , 0 , 0 , 0 ) ;
whereFitResholds the mean value and width of the peak in its second and fourth attributes respectively, and the result of the fit is in(xi,yi).
Fig. 1 displays an example of such a processing on experimental data with the ADC loaded by a 50 Ω resistor. The case of a sine wave is shown in Fig. 2
0 10000 20000 30000 40000 50000
-30 -20 -10 0 10 20 30
number of samples
bin number
mean=-0.45 width=11.1
data fit
Figure 1: Fit of the bit value distribution of the ADC loaded on a 50 Ω resistor (noise).
bin count
bin number 0
50 100 150 200
-15000 -10000 -5000 0 5000 10000 15000
hist(d(1:2:1e5),1024)
bin count
bin number 0
50 100 150 200 250 300
-1500 -1000 -500 0 500 1000 1500
hist(d(1:2:1e5),1024)
Figure 2: Histogram of an undersampled 250 MHz (left) and 850 MHz (right) sine wave sampled at 122.88 S/s with the 16-bit Redpitaya.
2