You are on page 1of 5
Ea Technical Feature A soundcard-less SDR panadapter based on the Arduino Live spectrum and waterfall display without a PC INTRODUCTION. Over the years, | have experimented with several types of software defined radio receivers including the SoftRock series and the Finningley SOR. ‘These provide | and Q output signais that are usually processed and displayed using 2 PC and its associated soundcard, the software to do this being freely available (on the web [1]. Having recently purchased ‘a KX3, | sought an inexpensive route to ‘acquiring an accompanying standalone ppanadapter and so firs looked at the design by AAGBE, which is based on the Raspberry ror Beagletione boards (21. This design ‘again follows the traditional route of using ‘a soundcard, withthe Pi or Beaglebone dealing mainly with information display. ‘though Ihave been developing computer software for 50 years (I wrate my fist code in 1964, using Ferranti Mercury Autocode), | ound the Pi route frustrating, to say the least! Having worked my way through an eleven page guide to setting up the ABE softwere, | found that it didn’t run because the P's OS has been changed and there was now a missing dependency between the various software libraies. A search Of the P's Forum pages did not reveal 2 solution to this problem so I decided instead to-see what | could do with an Arduino based system that was entirely sotware- based, leit did not require a soundcard, Itis worth pointing out thatthe resulting hardware will only cisplay signals; unlike some PC and soundeard-based systems, it will nat demodulate them, primarily because (of processor and memory limitations, Nevertheless, it can still provide useful information to an operator in terms of band ‘occupancy and may also be capable of use 28a data logger for propagation monitoring HARDWARE. The success ofa project such as this depends crucially on the choice of computer board and displey module. Superficialy, the Raspberry Pi might seem to win hands down over the Arduino because of its much faster processor; however, Pi software is normally written in an interpretive language, Python, whereas the Arduino uses @ compiled version of C++. When feferrng to the Arduino, ‘most people normally think ofthe ubiquitous Uno board but its performance is inadequate for this project, not only in terms of processor speed (16MHz2) and working memory (2k8 SRAM) but also in terms of available 10 pins (14). Instead, | used an Arduino Due board, which has an Atmel SAM3XBE ARM Cortex-M3 32 bit processor running at 84MbHz, together with 96kb of SRAM and a tolal of 54 10 pins. A Due board can also do 12 bit ADC sampling, yet is available on eBay for less than £20. The 5 inch TFT colour display merule used in the panadapter has 800x480 RGB pixels, a touch screen and even a SD card port, Nevertheless, it too is available via eBay for less than £20. The module has a standard 40 pin header that is also used on several smaller and cheaper displays advertised on eBay but these typically hhave only 320x240 pine’. inital software evelopment was done using one of the PHOTO 1: Breadboard prototype of Arduino based panadapter. we cay wae LT Le Dusted x, cel fr ne Power FAURE 1: lek aga debs pret smaller displays but because of the common pinout ofthe header, it was 2 simple matter to upgrade the display when the feasibility ofthe project was confirmed. A block ciagram of the panadapter is shown in Figure 1. As well asthe Due board and TFT display, the only other hardware needed comprises single stage high gain audio amplifiers for each ofthe | and Q channels and their associated software-switchable active low pass filters The latter are needed to reduce aliasing errors in the sampled | and Q data Figure 2 shows the circuit ofthe | and Q input ampiters, each of which provides 2 nominal gain of about 50. Figure 3 shows the generic circuit of one ofthe 8 pole active low pass fiters. In total, four ofthese are needed: two for the I data channel and two for the Q data channel ‘The wideband its have a nominal cut-off frequency of about 20kH2, the narrowband ‘ones about 4kH2, The cutoff frequencies are set by changing the values of several Capacitors and resistors (3] and the appropriate values for each filter are listed in Table 1. The signal paths through the aporopriat filers are switched by software Controlled relays using the circuit shown in Figure 4. If required, the individual | and Q channel gains can be set by multi-turn potentiometers connected between the ‘outputs ofthe active low pass filters and 23 2a Technical Feature PHOTO 2: The panadapter displaying signals from the KX3 receiver tuned to 10.1407 5MH2 (bandwidth set at =5 the I and Q ADC inputs on the Due boar. ‘The connections between the latter and the TFT display are shown in Table 2. The display backlight is powered via the LED A connection, pin 19, on the 40 pin header. Preferably this should be connected toa separate 3.3V supply, but in practice the on-board Due 3.3V regulator seems able to cone with the required current demand. As supplied, the TFT display has {wo options for controling the backlight brightness and these can be selected by bridging appropriate pais of pads on the display board. However, | have only tried the option in which the backlight is fully on all the time. ‘SOFTWARE. Arduino programming is facilitated by the fact that there are many tutorials and code examples that can be ddownlcaded from the web, together with code libraries to door interface with almost anything. Inthe interest of brevity, I will discuss in detall only a few of the more important parts ofthe panadapter code, but the full isting contains many comments to-enable a fuller understanding for those readers wishing to make mosifications, The full code listing is available from me Since the | and Q data samples are each represented by a 12 bit ‘wor (specifying one of are then converted into ‘two numbers each lying within the range 21; thus the polarity of the original sampled AC waveforms is preserved. Although this code fragment looks simple, ‘two further factors need to be considered and these are to do with the rate at ‘hich the incoming | and data is sampled, since according to the Nyquist criterion, a signal with a bandwidth (of B Hz needs to be sampled at arate of at least 2B samples/sec. Thus the maximum signal bandwiath that can be displayed by the panadapter will depend on how fast the Due's ADC can acquire samples. There Is also another requirement for fast sampling ‘and this isto do with the fact thatthe I and Q data are not sampled simultaneously but rather sequentially since only a single ADC is used, together with a multiplexer. ‘The resulting time delay between sampling first the I channel and then the Q channel will give rise to a phase error for the Q Cchennel sample and this, together with ‘any unbalance in the amplitude of the | ‘and Q channel samples will give rise to an unwanted mirtor image on the spectrum display, The code fragment in Listing 1 tries to minimise the phase eror by frst sampling the land Q channels and then doing any processing that is requited before saving the data inthe array (@datal J, Tne second way in which the phase error can be reduced is by fine tuning certain, Constants that control the way the ADC operates. By default, a single anafogRead) 2). 4096 voltage levels), these ‘command takes about 39us to implement but by manipulating the CortecM3 ADC MR (Mode Register) constants in software, this time can be reduced to about 4us. The ‘code to do tis is shown in Listing 2. Further details on this technique can be found in the Atmel SAM3XBE ARM Cortex-MI3 CPU datasheet (4. The time taken to acquire the desired number of samples of I data and Q data Is noted and from this an estimate of the ‘equivalent sampling frequency can be calculated. This fs then trimmed to the required figure using additional delay inserted into the sampling loop using the ‘commend delayMicraseconds (Delay). The integer number Delay associated with this ‘command must be determined empirically but, 2s a guide, a value of 65 in my code ‘gave an effective sampling frequency of 13kH2 (equivalent to a displayed spectrum of ++5kHz) and a value of 4 gave a sampling frequency of 62kHz (equivalent to a displayed spectrum of +:24kH2). It will be noted that the displayed spectrum width is less than might be expected from the quoted sampling frequencies. The reason for this willbe discussed later Before further discussion of the software, we fist need to consider what information will be displayed to the user. | chose to make both a spectrum display and a ‘waterfall available simultaneously, but it would be a simple matter to ater the software to choose either one or the other. Irrespective of this, we should lm to utilise the TFT display pixels as effectively as possible. Hence I chose to use the display in landscape mode, ie the display axis ‘corresponding to 800 pixels was used for the frequency axis. The TFT display can display up to 480 pixels of infomation along the other ais, o I chose to use 200 ‘of these forthe spectrum display amplitude axis, 200 for the waterfall display time axis and the remaining 80 for axis labels (on request via e-mail The fist part of the code is concerned with sampling the incoming low frequency | and Q data from the receiver. This data will be in the form of two AC wavetorms but the ADC inputs on the Due board can only deal with uri-rectional signals The Solution is thus to DC bias the AADC input pins at their midway point of 1.65V via a potential divider and to feed in the | or @ signal via a DC blocking capacitor. By default, the Due's ADC is configured to output 10 bits of data to represent each data sample, but this can be extended to 12 bits using the command analogReadResolution (12); ‘Samples ofthe incoming | and @ data are acquired using the code loop shown in Listing 1. ae phy By -oeaue FIGURE 2:1 and @ channel amps and soft keys. ‘A decision now has to be made about how many | and Q samples, are to be processed each time 2 frequency spectrum or waterfall line Is displayed. The | and Q samples represent snapshos of voltage waveforms in the ime domain and these need to be transforned into information about the amplitudes of the individual frequency components ‘making up the spectrum display. The ‘most efficient way of doing this is by sing the fast Fourier transform (FFT) but this can only deal with data sets made up of 2" pais of numbers. N is an integer, so for example N= 10, a data set would consist of 1024 | data samples and 1024 Q data samples, thus giving rise to 1024 frequency components. The TFT display, 26 Technical Feature Sheffield. ac. uk FIGURE 3: Generic low pass fier (see Table 1) however, can only display 800 frequency Components ata time so we either have to.chaose a value of N=9 (equivalent to 512 frequency points) or N= 10. In the first case, not all the available pels (on the display will be used (512 out of '800) whereas in the second case, we can only display 800 out ofthe available 1024 frequency components. There are advantages in choosing the second of these alternatives; firstly, by using 1024 rather than 512 points in the FFT algorithm, the frequency resolution of the displayed spectrum is increased, even though we cannot display the full spectrum that a given sampling frequency provides. Also, the displayed | and Q data is effectively bbeing oversampled and this will ease the task ofthe | and Q low pass filters; hence the reason why in the earlier discussion, it was mentioned that the displayed frequency spectrum did not seem to match up with the quoted sampling frequency. So for ‘example, if the nominal sampling frequency were SDH, this would ordinarily result in a potential spectrum display of tumed into powers by squaring and are normalised with respect to the maximum signal power that could be measured by the Due's ADC. This maximum power is that resulting from an ADC reading of +2048. Finally, since a logarithmic amplitude display is required, each data point is processed accordingly. A simplified code to carry out these operations is shown in Listing 3. ‘Tuming now to the TFT display, the software for driving this is handled by a library called UTFT that can be downloaded from {6}. The library can dive a large number of different displays and contains routines for drawing text, figures, lines, Circles ete as well as full control of colour {and font. Since the TFT display also has an integrated touch screen, provision has been made to incorporate a numberof soft keys to-contret such things as displayed spectrum width and display amplitude range. The handling ofthe soft heys is controlled by another library called UTouch that can also be downloaded irom [6] SOFTWARE REFINEMENTS. Ifthe software and hardware are used as described thus ‘ar, ‘wo artefacts will be evidert on the display Firstly, a large spike will aways be seen at the centre of the display and this corresponds toa signal a DC. This arises from the fact thatthe | and Q waveform voltages will most probably have some associated DC shift ‘associated with them, If this is not removed in the data processing then it will show as 2 central frequency spike. ‘The other artefact on the display will ‘manifest itself as a mirtor image of a wanted spectral component, which appears in the ‘other half ofthe display. So for example, ifa real frequency component appears at frequency +f in the right hand half of the displey, an unwanted image of this may ‘appear at ~f inthe left hand side of the display, or vice versa. This effect is caused by amplitude and phase errors occurring in an | and Q data pair. The amplitude ‘error arises when the gains of the | and @ signal paths are unequal; the phase erors aise because the | and Q data channels are not sampled simultaneously but :25kHz (the left and right hand sides sequentially: Both the amplitude ofthe spectrum are independent since eH and phase errors will vary with the ‘we have sampled both the | and Q frequency being displayed so a data at BOKH2). In practice, the actual | 'ewegamp Lety ay gS g IehelADC | correction at one frequency will not displayed spectrum width would then = = hold exactly at another. There are be (800/1024) x 50kHz ~ 39kH2. nw schemes that can provide correction Having finaly decided on the at all displayed frequencies but these number of| and Q data sampies to be take up far more computing resources acquired, 1024, these are assembled a than we have at our disposal; hence into an array of complex numbers | adapted 2 correction scheme that ofthe form real part=/Qdatal0I, admgiane Lott r29] aammniac | uses the received spectral component imagiascy part-chistet, rel Hgy gaa Fee with the largest amplitude at any given part=IQdatal2}, etc. This array is ™ " time asa test signal (71. The suing then processed using the FFT to ew amplitude and phase corrections to find the frequency spectrum of the the displayed spectrum and waterfall sampled | and Q time waveforms. The sav are thus oniy valid, in theory, ata resulting data is an array of complex voltage amplitudes for each frequency Point in the spectrum. Conveniently, the Arduino IDE for the Due board contains a set of DSP algorithms specially writen for the Due's ARM Cortex M3 processor, (51, and $0 these are utilised wherever possible in the panadapter code. Further details, are given in the first sidebar. The FIGURE 4: Relay diver for switching low pass fers. single frequency but in practice the results are quite acceptable over the full displayed frequency range. Furthermore, the corections are made automatically and are dynamic, ie they change from one data set to the next. Because the mathematics of the error cortection process is rather involved, it will not be discussed further here but Interested readers will find fuller details complex voltage amplitudes are then inthe box on page 30. IMPLEMENTATION. A breadboard prototype ofthe complete panadapter is shown in Photo 1. The | and Q chennel amplifrs, low pass filters and relay ‘switching circuits were all built on single- Sided printed circuit boards using wire- tended components. As can be seen from the photo, the resulting boards are rather large and would benefit from a redesign using SMD parts. ‘The panadapter needs voltage supplies (of 8V, 3.3V and 2.5V, The frst two of these can be oblained from the Arduino board itself and the third is provided from the 5V supply via a simple potential divider, as shown in Figure 2. Photo 2 shows a close up view of the TFT screen when the panadapler was connected to my KX3 and the latter was being used to monitor signal activity around L0.14MHE. In this case, the bandwidth of the dispiay was set at :5kHz. From left to right, the soft keys atthe top ofthe display can be used to change the amplitude range of the displayed spectrum and waterfall displays and the displayed bandwidth (toggled Dbetwoen :1.2kHz and 4:5kH2). The Curent value of the former is displayed to the left ofthe soft keys CONCLUSIONS. When | started this project, | totaly underestimated the time and effort it would consume but the end result has made it worthwhile. Although not yet boxed-up, the panedaptr is already proving to be a useful addition to my KX3. Possible modifications might include increasing or decreasing the displayed frequency bandwidth, adding ‘mote soft keys for inceased functionality oF utilisation of the SD card slot on the TFT display. The latter would then enable the panadapter to be used as a beacon ‘monitor and data logger for propagation studies. ‘TABLE 1: Component values for low-pass fiters (all other values are common to both filter types) Component Namow band 4kHz Wide band 20kHz RO, R3, R7, RB, RI2,R13,R17, RIB BK ak (62, €8, 65, 05, 8, €3, C11, C12 4n7 1n0 ‘TABLE 2: Connections between the Arduino Due board and the TFT display. TFT pin TFT function ‘Arduino Due pin 1 ov 2 veos.av 3 4 RS 38. 5 wR 39) 6 RD Connect 3.3 7 DBs 22 8 59 23. 9 B10 2a 10 ett 25, 1 B12 26. 2 Bis: 27 13 B14 28. 4 B15: 29. 15 cs Dao. 1s 7 RST pat 38 19 LED A Connect to 3.3, Link ‘always on’ pads on back side of TFT module 20 2. 80 37 22 Bl 36: 23 B2 35, 24 es. 34 25 Dea 33. 25 DBS 32. 27 86 31 28 87, 30. 28 Tok D6 30 Tes Ds 31 TDN Da 32 33 1 DOUT D3 34 IRQ be Technical Feature WeBseanch U1 Roeky SOR software vdeo comfochy [2LATiay Python Panaptes, Martin Ewing, ABE, sr Api 2018 [31 Act Low Pats Fiter Bese, Toasters wr comtSt0%049 [Al Atmel SAMSXBE ARM Corer MS CPU datasheet orto conmagesdoc1 1057p ISI CMSIS DS trary fr ARM Cortex M3 processor worl comsekeeMSISOSPimlinge Nin [61 UTFT and UTovch ates itp heningasen.comidectonibran phd 52 (U1 eorecion Churchill FE OgarGW an Thompson B J, The coneten of ard Q ars in ‘a cabret proses, IEEE Tan Aaspce and ectone Systems, ES 17, No, la 198, post 137 [61 Enabing tte oun Gatex M3 OSP functors np tum arulnacendox prprPHPSESSIO=taesiol ‘elon aour phic Atope=140107.0 Enabling the Cortex M3 DSP functions The folowing information has ben taken from 1. Find the tet le platform. tt at CulProgram Files (85)/Arduinonardware/ ‘duinofsamiplatfrm.t 2. Using Notepad, amend the fle section called ‘#4 Combine ge sections, archives, and objects 0 Itnow includes a reference to fle called Liborm_cortexM3l_math.2 ‘## Combine ge sections, archives, and objects ‘recipe.c.combinepatter="{compiler path }{compier.c.eltemd}” {compilerc.et flags) mepu={build.mcu} * T{buil. variant path) {buldJescript}" * Wl, Mop {ouil.pathy/(ouité. project name). ‘map” 0 “{build,path) {build project_ rname}.elf” * L{build pathy” Im lgce ‘mthumb W, cref Wl, check sections Wi, gc sections Wi, entry=Reset_Hon ler Wl, unresolved symbols=report all WI, warn commen WI, warm section align Wh, war unresolved symbols WI, start group “(build pathsyscals_ ‘sam3.c.0" {object fies) “(ouildvariant. path {ould variant system ib)" "(bile variant path) libarm_cortexM3/_matha” {build path\farchive_fle}” WI, end aroun 3, Navigate tothe IDE folder Ci/Program Files (#86)/Arduinonardware/ _ardunjsam/system/CMSIS/OMSIS/Lby ccc In that folder, you should finda le called Iibarm _cortexM3! math 2 Make a copy ofthis fie and place itn the IDE folder CulProgram Files (85)/Arduinolhardware/ _arduinoysam/rariantsfarduino_due_x! The Cortex M3 DSP functions should now be accessible, 27 30 Technical Feature Conection oft and @ errors This escussion isan abridged version of that found in (71 [A simplified and ero ree version ofthe | and @ data being passed Into the panadapter can be writen as I(t) =A cost and Q(t) = Asin ot This pair of signals canbe thought of esa complex sinal 1) +jQ@ = Aelot In proce the recive | and @ data wil contain eros such that ©) = (1. +e)A cost +a and Q,(¢) =Asin@we-+ 9) +b where € isthe fractional amplitude imbalance isthe phase imbalance 2 isthe DC ofset in the I channe., and is the OC offset in the @ chanel 1 and b can be coecte by subtracting the average level from the signal in each channel Then we have I(2) = (1 +e)A cosaat and Qp(¢) = Asin(ot +9) The | and Q, signals ae treated as vectors and two comection coefcents P and E, are required, P for rotating one vetor and E, fr scaling the oer Then the conected signa |, and Q, are related to, and Q, by I= Eyl and Qs =P hh + Q Itcan be shown thatthe required form for E, and Ps cosy A tee) =n ae ter application ofthe correction proces, the fnal signals are BO = ‘An amplitue scaling factor ens has been introduced but since tis common to bath |, and Q, this is nat af importance, cospcoswt and Q3(¢) = Acosg sinwt The procature to obtain the conection cosets isa follows: The | and Q signals are each sampled 1024 times ard the dat stored in aray IQdata1[J. The 2048 data values are also store in ray IQdata2] fo future use. The data in JQdata is next FFTed as Outined in the previous discussion ofthe panadaptersotware. Now the fQdata11 array contains 1024 complex frequency values arranged in pairs (eal part, imaginary pat, eal part, imaginary pat...) inary locations (01 to 12047, ‘The DC ofse's i the orignal | and Q sampled time waveforms re obtained from Ledata10} ang p= #2éetany ‘and these values wiE later be subtracted from all he data contained in aay IQdat2217. To obiain the comecton coecintsE, and P we need to locate the complex equency component in array fAdataI( whic has the largest ‘magrituce and to note is location within the array as a par of indies, eg lQdated(2*1] real part of fequency, Qdstal (24/+4 imaginary pa of frequency. This frequency component can be thought of as our teat signal and let us assume that te values of ts eal and imaginary parts aro IQdatal(2 + i] = W and 1Qdatal|2 +i + 1] ‘Thon the unwanted image ofthis test signal wil be located within the array 1ddatatL) at adata112048 2*i) 10a pat of image frequency ana qdata1£2048 2414-1) imaginary part of image frequency. ‘Theo associated data values are 1Qdatai [2048 ~ 2 i] = ¥ and 1Qdatai[2048— 2+ +1) =z Itcen be shown that te corection coefficients E, and P are related 10 W, X,Y and Z by demom = 2/(W-41)%W +) +0 210K 2); ol = 1. YHW+Y) 240 Z)4donom; Bm ZHWHI+Y"0 2))*denom; Finally, we can apply these correction factors to the copy ofthe eriginal sampled | and Q data which was previously stored in array data? 111Q correction to copy oferiginal sampled and Q data for (uinti6_t1 = 0; 1 < ftSize; ++) { {/1emove DC shit /Qct0212" 2; This data is now FFTed to obtain the coracted frequency spectum which will subsequently be displayed, Listing 1: Simple code loop to sample | and REG_ADC_MR = (REG_ADC_MR & to implement FFT *) Qdata ‘OxFFFOFFFF) | 0100020000; arm_efflradixa_£32(8S, 1Qdata); Const uint32_t ftize = 1024 change PRESCAL from 2 to 1 1° Process the data through the Complex const float weight = 1. /2047.; ‘REG _ADCMR = (REG_ADC_MR & Magnitude Module for fofuintt6.t ‘OxFFFFFOFF) | 0100000100; cafeulatig the magnitude at each bin. FRetum data in array Spectrum; This flootrew! 2047) * weight; 1Qdatal2%i+ 1) = foatrawQ 2047) “weight; ¥ Listing 2: Reducing the ADC read time. i modify 3DC_MR register to make ADC read faster {change STARTUP from 8 to 2 (S12 to 15 ‘periods of ADC clock) Listing 3: Converting the sampled | and Q ‘data toa frequency spectrum, const uint32_¢ 1tSize = 1024; ‘const uint32_tifFlag = 0; const uint32_t doBitReverse = 1; (Unitiaize the CFFTICIFFT module ‘arm ct radhx4 init 132188, fice, ifFlag, oBltReverse); 1° Process the complex 10 data in array ‘1Qdatal] through the CFFT/CIFFT module arm_emplx_mag_f32(IQdata, Spectrum, 1" Normalise the frequency data and convert for (uint 16. i=0; f

You might also like