Open-source two channel Total Power Meter with network interface (TPM Server)
This is description and set-up information of Total Power Meter (TPM Server) based on AD8362 RMS detector, AD7176 24-bit ADC, and Raspberry PI. Main motivation of this project is fast and compact two channel total power indicator with high resolution, good dynamic range and network access for use at VIRAC Irbene radio telescopes. Main uses includes: on-source power increase (receiver performance checks) and antenna pointing verification, measurements of antenna pattern, sky raster scanning, and general purpose IF power vs. time monitoring.
The operation of TMP Server is simple. TCP server runs on RPI and listens for client connections and total power reading requests. After receiving request, server reads both ADC channels and then answers with data string. At time of writing this, two clients are developed: Windows plotting application and Irbene radio telescope system specific logging software. Windows application is provided below. Windows client and TPM Server source is available at GitHub.A Little bit about hardware
Detector and ADC hardware design follows all the standard guidelines published in IC data sheets. Schematics of both modules can be found at end of this page. MiniCircuits TC4-19LN+ 4:1 balun transformer is used at input of AD8362 for optimum dynamic range and input match - by paper it sets frequency range of detector to about 10...1900 MHz, but it can be pushed beyond these values of course. In our case, there is no need for it. Optional temperature sensor is added in case if need for temperature compensation arises in future.
ADC has fully differential input interface, so analog conditioning circuit is used to convert single ended detector signal to differential. AD8362 linear output voltage ranges from 0.5 to 3.5 V (actually many similar detectors have such output range), so signal is shifted and amplified to fully use ADC differential input range. It this case 4.096 V reference source is used, so detector voltage swing of 0.5 to 3.5 V causes differential voltage swing from -4.096 to +4.096 or 8.192 Vp-p. At the same time common mode voltage is set to +2.5 V (at middle of analog power supply voltage), so ADC and analog front-end linearity errors are minimized. See more detailed calculations at schematic PDF file.
One general conclusion: Analog Devices gives its ENOB ratings at differential inputs shorted together - I was able to easily reproduce data sheet published ENOB with such condition (ENOB can be calculated with help of standard deviation of many samples). In practice with this setup, including analog conditioning stage and open inputs, ENOB of 16...17 bits can be achieved at 1 KSPS. With further averaging (no need for 1 KSPS in practice in indicator application) at client side resolution is greatly improved. Current ENOB at 1 KSPS is printed out at start of TPM server software - it should not be lower than 15...16 bits with open ADC module inputs. If it is lower - there must by external noise issue somewhere (PSU most likely). Currently TPM server samples at 1 KSPS and averages 32 values for each channel before sending a response string. I could sample with lower speed at the first place to get same noise performance, but 32 value array allows to calculate standard deviation, which can be valuable additional information for example in case if there are signal with fast changing power and would otherwise be missed if sample rate was lower (see example of such case below). As result, by default effective maximum sample or "request" rate from client perspective is ~15 SPS without taking software/network delays into account. It should be noted that AD7176 is capable of 250 KSPS, so server code can be easily modified if such rates are needed. AD7176 may also be directly replaced with AD7172 or AD7175.
You can see prototype of hardware in Fig. 1. It can be noticed that I chose to use separate power supplies for RPI and analog part. I have not carried out any rigorous tests to prove that it is really necessary, but why not reduce potential noise sources of which I am at least aware. It is the first time I used one of these nice through hole SMPSU modules from VIGORTRONIX (available at Farnell) - saved me a lot of time and all modules can be mounted in same case without additional external power adapters or other hacks.
Fig. 1. Prototype of TMP server
TPM plotter for Windows
Main purpose of this application is plotting values of both channels versus time. It is implemented in form of "lightweight" chart recorder with automatic scrolling to the left. Additional features includes optional standard deviation plotting, moving average, measurement unit selection (right now user can select between dBm, uW and Raw ADC counts), measurement relative to cursor position and easy zooming. At this time calibration coeficients are hard-coded and if change is needed, recompilation is required.
Following pictures shows application in field action with TP server connected to RT-32 radiotelescope C band IF outputs. Fig 2. shows relative cursor functionality. It is handy way of measuring power level increase. Deltas for both channels are calculated. Because single cursor is used, one can also easely measure relative level between channels.
Fig. 2. Measurement of power relative to cursor.
Fig 3. shows averaging. It can be noticed that in this case relative level on order of 0.00X dB can be measured. With more averaging, it will be even smaller. User also can clear averaging buffer in case if step response takes too much time (in case of large average count).
Fig. 3. Measurement of power relative to cursor.
As it was mentioned, standard deviation can give additional information. In this case deviation is calculated for each value which at the source is 32 values sampled with 1 KSPS, so it can give indication of fast changing events, which otherwise may be missed (in case of slow sample rate) or averaged out. Also in case of large average count, user can still monitor dynamic changes of signal. For example the other day I noticed some RFI spikes at RT-32 which were much easier detected with std plotting on (don't pay attention to older version of software):
Fig. 4. Example: In this case RFI are more pronounced in standard deviation plot. Some spikes are averaged out almost completely.
Unfortunately at this stage, settings are not saved when quiting application. Ask me if you need version compiled with your settings (IP address for example).
RPI Server connection and setup
First You need to connect ADC board to Raspberry PI pin header as shown in Fig. 5. Notice, that DOUT/RDY pin of ADC board is connected to two pins on RPI (on RPI its not easy to conveniently switch between SPI and GPIO functionality on the run), so "Y" type connection wire must be made.
Fig. 4. ADC board connection with Raspberry PI
TPM server software requires PIGPIO library for SPI and IO pins. Library download and setup information can be found here. After PIGPIO setup, download and copy tpm_server files in same folder for exampe in home directory of RPI. You can use SSH/SFFT client sofware, for exampe MobaXterm or similar to easely copy files and create folders. Then compile source (for example if you copied files in RPI home dir folder called "tpm_server"):
Then from same the folder run the server (assuming that ADC board is already connected):
Server should recognize AD7176-2, and show initial raw readings, standard deviation and ENOB for both channels and then start listening for client requests. At each ADC use and/or client request, LED on ADC board should blink - it is wired to one of AD7176 GPIO and is set via SPI registers. It is good indication that SPI interface and AD7176 is working properly. By default, server listens to port 7176 (make sure You fill in the correct IP address of Your RPI in windows client "Settings" menu). After receiving "tpm" command (without "", of course), server responds with four Raw 24 bit unsigned integer string in form:
Server is thread based, so more than one client can connect in parallel. Of course only one client can access ADC at the same time, so other clients need to wait their turn.
TPM plotter version 1.01 is now available (see below for exe file). Config settings can now be saved for next time loading. Open "Settings" and press "Save" and file "tpm_config.txt" will be generated in same directory as exe file. This file also contains crude cal coefficients for both channels, so You can use Your own coefficients if You like. Displayed power is calculated using these simple linear functions:
TPM in final enclosure. Open collector buffer (based on ULN2003V12) PCB was added to interface few GPIOs of Raspberry Pi to outside world. It is used to control some equipment over a LAN.