Tuesday, April 4, 2023

Building a Scintillator, using CsI(Na) crystal and Hamamatsu R6231 PMT

 This scintillator build is not much different than the others except for using a CsI(Na) crystal and 2" / 51mm PMT.

 I understand that people use these posts as a guide when building their own scintillators so I decided to document it as it might provide additional information, which I might have missed in previous posts.

Using Gamma Spectacular PCB for R6231. This PCB is designed for both, single wire (HV Bias + Signal) and 2 wire (HV Bias and a separate Signal line) interface. I populated the PCB for the Single wire interface using R value of 5.6M for the voltage divider. Had to improvise a bit with the 2R resistors between K-G and G-D1 as there was only one footprint per resistor but there are no 11.2M resistors.
Total resistance of the VD is 67.2M.

Voltage-Divider impedance is not a super-critical parameter, but it is important to consider based on the application. For example, with many battery-powered counters and meters where the HV Bias supply can't take much load, high-impedance is preferred as the lower current will reduce the voltage drop. Some low-current PS will drop the output voltage significantly with impedance as low as 60M. In these cases, a total impedance of 120M will work well. High-impedance divider on the other hand will have poor SNR (Signal-to-Noise Ratio) and linearity could suffer as well - for Gamma Spectroscopy with benchtop / lab-grade power supplies, VD impedance of 12M or even lower should work quite well.
For this detector I went "in the middle of the road" with VD around 70M.

Machined PMT rear cap, completed PCB and the PMT ready for the final assembly.

The PMT is a 2" Hamamatsu R6231 - the little brother of R6233. The only difference between the two is really the size - all other specs are the same.
R6233 is one of the best all-around PMTs - I've built more than a dozen detectors with it and absolutely love it - the R6231 should be just as good!

VD PCB installed on the back of the PMT with the two silver-plated, Teflon insulated lead wires. 

Installing the MIL-grade BNC connector (Amphenol UG-625 B/U). 
There is a wire fed thru a small hole in the cap for grounding the electrostatic shield. Heat shrink tubing is added for extra insulation of the Anode lead and both wires are coiled into "springs" and away from each-other before closing the PMT cap so they don't press on the board and stay away from the components.

The photocathode window was thoroughly cleaned with Acetone and any dust particles were removed using micro-fiber cloth and sticky tape until the glass is absolutely spotless. 


The crystal is a "Soviet Era" 40mm x 40mm CsI(Na). Datecode is June, 1991.

CsI is a higher density (4.51g/cm3) scintillation material which makes it more efficient at detecting gamma (better stopping power due to Cesium's higher Z). 
Its light output is 85% when referenced to NaI(Tl) but one big advantage of CsI(Na) when compared to CsI(Tl) is that the emission peak matches perfectly the response of Bialkali PMT photocathode at 420nm wavelength. 
CsI(Tl) on the other hand is better suited for use with SiPM as its peak is at 550nm and cutoff at 320nm.
CsI(Na) is also much faster scintillator with decay time of 630ns compared to CsI(Tl) at 3.5us which allows for higher rate detection. Not as fast as the NaI(Tl) with 250ns decay.

Comparison of the emission peak wavelength and temperature response of both types CsI materials. 
The light yield is slightly lower with 41 photons/keV Gamma for CsI(Na) compared to 54 photons per keV Gamma for CsI(Tl) but greater than NaI(Tl) with 38 photons/keV Gamma.

My crystal is absolutely pristine - no significant blemishes, no yellowing, no cloudiness. It is crystal-clear (no pun intended).
 The glass of the optical interface window was cleaned in the same manner as the PMT's photocathode.

Due to the small difference in diameters between the crystal canister (45mm) and the PMT (51mm), I added a short sleeve from EVA foam around the window area, which will center the crystal during assembly, preventing it from sliding off-center to the PMT. The size difference is very small (~5mm) and there was no need to 3D print a centering collar.

A drop of high-viscosity (100K cSt) silicone fluid is added as optical interface between the two glass surfaces to minimize reflections and refractions by eliminating the air gap between the two glass windows. The silicone oil's refractive index is around 1.41 which is close to the 1.46 refractive index of the borosilicate glass of the PMT.

PMT and crystal are put together and the silicone fluid interface is distributed evenly between the two glass surfaces with repeated, overlapping, wide, circular motion until it becomes a very thin and even layer. The extremely high viscosity of this layer and surface tension prevents it from "running" and it will stay permanently in place.

Strips of vertical electrical tape are used to pull together both, PMT and Crystal with some tension. The tape is stretched during application, and it exerts constant pressure between the two parts ensuring a firm contact. With this small diameter PMT 4 long strips (which loop under the crystal) are sufficient.
Both, crystal and PMT are then wrapped multiple times, around, with special focus on the interface zone so it becomes one tight package.

After completely wrapping the assembly with multiple layers of electrical tape, I added a sleeve of EVA (Ethylene-Vinyl Acetate) foam to serve as mechanical shock protection and thermal insulation for the assembly. EVA foam is a very dense closed-cell foam and does great job for both applications.
The front face of the crystal is also protected by a disk of EVA foam, glued to the crystal's foam sleeve. 
Needless to say, the assembly is 100% light-proof.

The magnetic / electrostatic shield is added as a two-turns sleeve of special Mu-Metal sheet, spot-soldered closed, and the grounding wire is then soldered to the sleeve. The sleeve overlaps the photocathode area and into the crystal canister by about 5-7 mm.

Second EVA foam layer for even more shock protection of the glass-envelope PMT goes on top of the magnetic shield.

After completing the entire assembly, the final protective layer of heat-shrink tubing is applied. 

This is probably the most critical and dangerous part of the assembly process as overheating the crystal can easily cause it to crack. Crystal temperature should not be increased too rapidly. Heat was applied in short burst (with cooling time between them), which allowed the heat-shrink to heat up rapidly but not to transfer a lot of heat at once to the crystal.

Heat-shrinking is not "a must" but provides a nice finish, serves as an additional protective, abrasion / scratch resistant layer and keeps both components - crystal and PMT firmly together.

Just as expected, the resolution is not bad at all and spectrum looks pretty good! 

Running the detector on 600V PMT Bias. For Cs-137 at 662keV resolution is 6.2% FWHM. 

Theremino's algorithm for automatic estimation of the FWHM resolution seems to be a bit on the conservative side so a more realistic value would be actually around 6.0% - not too shabby for a 30-year-old, Soviet Era crystal I must say.

Tuesday, March 7, 2023

Complete DIY XRF Setup

My DIY XRF setup is finally complete - it is comprised of an Amptek X-123 detector using the proprietary Amptek 25 mm2 / 500 μm Si-PIN X-Ray detector element (model FSJ32MD-G3SP), Amptek Pre-Amplifier and DP5 DPP /MCA.

Details about the detector are in THIS post.

On the exciter side, in the past, I have used X-Rays from an Am-241 source (59.54keV). Unfortunately, there is no exempt quantity or a way to obtain high activity, pure Am-241. The ones used in modern household smoke detectors are only 0.9 uCi (unless obtained from the old Pyrotronics industrial smoke detectors with up to 80uCi) but still have the Am-241 mixed and pressed into Gold and Silver foil which has parasitic emissions of the said metals in addition to the Am-241 decay product - usually a fairly strong Np La line emission (from Np-237 decay product). The Neptunium La-line is observed even with recently created Am-241) La at 13.95keV.

I decided to switch over to an X-Xay Tube where the emission can be controlled precisely, the spectrum is uniform with the exception of the XRF emissions from the target material (Tungsten in my case) but this is normally a single element and easy to remove from the spectra.

 I am using Moxtek Magnum series transmission X-Ray tube with Tungsten target - 10W total electrical power (-50kV / 200 uA) controlled by an X-ray source controller of my own design my own design.

The X-Ray tube is placed inside a Lead shield. The aluminum box on the right-top in this picture is the detector enclosure, housing the detector element, preamp, power supply and the Amptek DP5 Digital Pulse Processor.

This is my test setup while doing XRF on a piece of copper foil for initial Energy Calibration.

The aluminum box in the center of the picture is the X-Ray tube's high-voltage power supply module. It is a high-frequency switching supply with a very easy to work interface - 3 output channels (2 analog and 1 digital) and 3 input channels (2 analog and 1 digital) + 12V main power. The supply is very efficient and the current draw is around 1.5A at maximum power.

The X-Ray source aperture and detector at almost 90 degrees so the X-Rays are skimming the surface of the specimen.

This is the first XRF of Copper foil with the new source - the Ka line is at 8.05keV and to the right the Kb-line is at 8.90keV. 
I still need to adjust the detector Peaking Time and Flat Top Time as well as the Slow and Fast detector thresholds - currently I have over 99% of Dead time due to the current settings intended for low X-Ray flux source and too much of primary beam getting into the detector. Revising the geometry of the setup - the placement of the detector, exciter and sample should resolve this issue.

My X-Ray Source Controller works flawlessly, and I am really happy with the end-result.

Saturday, February 25, 2023

X-Ray Source Controller for MOXTEK and AMPTEK Mini X-Ray tubes (Part 2)

A follow up on this post this post

 I needed controller for the Magnum series 50kV / 10W MOXTEK X-Ray source and as it turns out the FTC-200 controller, once sold by MOXTEK is no longer available - it was discontinued due components availability and the Moxtek sales engineer told me - "We expect customers to develop their own solutions." 

This was not a big deal - their FTC-200 controller has very basic functionality anyways, and it is lacking some features that I really needed, so I went ahead and developed my own design to control the MOXTEK X-Ray tube.

Currently, MOXTEK tubes are available in one of 3 configuration - built-in USB controller, I2C interface and Analog Interface. The MAGNUM tube I am using is equipped with the analog interface, but it should be quite easy to add the I2C control capabilities to the controller design as well.

One of my design goals is to have a stand-alone unit with no PC required. I don't want to fumble with numerous PC applications while doing XRF and prefer to have a piece of hardware with actual buttons and dials to adjust the X-ray tube parameters and to operate it. For the fairly simple functionality the controller affords, there is no real benefit from running it with a PC.

I was pleasantly surprised to find out that the AMPTEK Mini-X2 tube uses the same electrical interface as the MOXTEK Magnum series of X-Ray tubes so my controller will work for AMPTEK Mini-X2 just as well which makes it even more versatile.

Update: As it turns out Newton Scientific X-Ray tubes are also equipped with the same analog interface or at least have a connector option for it. (thanks Matteo!) 

Simplified block-diagram of XTC-2000

My source controller is based on the nRF52840 System-on-a-Chip (SoC) using Cortex M4F processor and employs 6 control channels as required by the x-ray source interface - 4 Analog and 2 digital channels. Of these 6 channels, there are 2 Analog outputs (driven by precision 12-bit DACs), used for setting up tube's High Voltage and Emission Current parameters and 1 digital output (5V TTL signal) to turn the source ON / OFF. There are also 2 Analog inputs (sampled with a multiplexed 12-bit ADC) to monitor the x-ray tube's working parameters as they are returned by the Moxtek HV module and a digital input (5V TTL signal) to report when the beam is ON and stable (The filament is fully heated and ready). 

I had to employ Logic Level shifters as the nRF52840 is a 3.3V chip and the MOXTEK module has standard 5V TTL levels for the digital signals. Furthermore, the voltage ranges on the Analog output channels range 0-to-4VDC and I have to use the 4.096V internal DAC reference voltage which means the DAC must be powered with a 5V rail. In reality, the reference is 2.048V and the output op-amp buffer of the DAC is switched to 2X GAIN mode, but still 5VDC DAC power is required. 

(I am playing with the idea to dynamically switch DAC's output buffer op-amp GAIN based on the needed DAC output, using 1X GAIN when output less than 2.024V is required (up to 25kV and 100uA) and automatically switching to 2X GAIN for higher DAC output. This should make the output even more precise.)

For the Analog inputs, I used precision voltage dividers to bring down the Monitor / Return channel voltages in the range of 0-to-3VDC and then used the built-in ADC reference of 0.6V with gain of 5x.

There is also a 5th Analog Input channel, internal to the controller, with its own voltage divider, used to monitor the Low-Voltage Main Input Power and to inhibit controller operation if the controller's and / or tube's input voltage is not within the nominal range. 

OSH Park service delivered again beautiful, high-quality PCBs. The ordering process is very simple and a pure joy - I almost feel sorry I don't have more PCB projects to order. 
The PCB design was done with Autodesk Eagle but I am not big fan of what Autodesk is doing with Eagle (it used to be my favorite PCB app) and very likely to switch over to KiCad in the near future.

The assembled and ready X-Ray Source controller - XTC-2000 (a.k.a. "X-Ray Tube Commander 2000" :-) 
(Chat GPT suggestion :-)

Using a rotary encoder with a pushbutton makes the UI really quick and intuitive. The button (knob-press) is used to enter adjustment mode, and the user can dial first the whole number and then the tenths after the decimal point for each parameter separately.
After entering Set mode, the encoder's push-button scrolls through different digit positions, indicated by a blinking cursor and spinning the knob changes the value. 
The rotary encoder is equipped with its own microcontroller (Atmel SAM D09) which takes care of all of the quadrature input stuff - counts, phase-detection, timing, etc. and just reports the actual tick count, delta, etc. over I2C bus to the MCU. This makes the Encoder really fast and easy to use and I can reset the tick counter with a command if needed. The encoder breakout can also generate interrupt on button press or encoder rotation.

The complete and working controller during bench-testing and DAC/ADC non-linearity compensation and alignment. 
Testing was done by looping the DAC outputs to the ADC inputs and monitoring the loop with a calibrated 6 1/2 digits benchtop DMM. The linearity corrections made sure that both, output and input agree with the voltmeter thru the entire range.
The white (unpopulated in this picture) 4-pin JST connector near the encoder is AUX I2C expansion connector, used for the X-ray tube's temperature sensor or controlling a tube with I2C interface.

Currently, the code is complete and mature, the core functionality is all done and bug-free thus "Version 1.0" release
In the unlikely event of some commercial interest, I might write a more elaborate menu system for setting up various tube types, internal parameters and calibration values, but even at this stage, XTC-2000 has a lot more features, better functionality and better ergonomics than both, the discontinued Moxtek FTC-200 controller and the entirely software-controlled Amptek solution. It also has more safety features and should take better care of the tube's health and operating conditions.

As for the user-interface, in a nutshell - there are 3 modes of operation - MOMENTARY (X-Ray is emitted only while the OPERATE button is pressed), TOGGLE (X-Ray beam is latched, on/off with each press of the OPERATE button) and COUNTDOWN (the user can dial duration in seconds for the beam and start the Timer)

There are many safety features implemented - hardware lockout, software lockout, preventing accidental exposure, emergency beam shutdown, control voltages power-down, tube shut-off watchdog and so on.

In addition, there is a number of features looking after the tube's health as minimum emission time, cooling timeout, temperature alerts, isopower curve ensuring maximum power is never exceeded, mains voltage drop and many more.


When the working parameters are dialed in, the calculated power is immediately displayed on-screen. If the calculated output power exceeds tube's maximum permissible output power for the particular type of tube, the controller will scale the Emission Current to the edge of the permissible power curve and will indicate the change in the calculated power display. This will prevent the tube from being operated at excessive power levels.
While the X-Ray tube is powered on, the controller will also display the actual power level calculated from the Tube's return channels.

As part of the safety and tube's health features, I added external temperature sensing and monitoring using MCP9809 chip.

While designing the PCB, I added an extra I2C bus connector for future expansion such as temperature sensing and control of an I2C tube.

The temperature sensor I am using is MCP9808 - a very accurate and precise chip with I2C interface. Resolution is actually much better than 0.25°C but for my purpose 1° Celsius is completely sufficient and allows faster sample time.

The controller constantly monitors the temperature of the tube, and it will shut it off if temperature exceeds +60°C. The tube will not be re-enabled until it cools down to below +55°C.  With 10W of total electrical power and a massive brass housing this is unlikely to occur, but it offers another level of safety.
The temperature sensor presence is auto-detected on startup - if the I2C cable is not plugged in, the controller will work normally, just without any temperature related features.

The critical part of attaching the sensor is the connection cable between the controller and the MCP9808 breakout board - the cable must be fully shielded due to the proximity to the tube's HV cables and must be of very low capacitance as the I2C bus does not tolerate high capacitance on the signal lines or the useable bus speed will begin to drop.  At 70cm cable length the sensor works perfectly well. The cable I used was foil-shielded 4-conductor USB cable.

The last thing, currently pending on my development list is a suitable enclosure.

Update: As part of the tube's diagnostics, I added a check for deviation from the requested parameters - if the controller detects a difference between what is requested from the tube and what is returned, it will generate "Tube Error" message with a 3-digit error code - each digit represents one of the 3 critical parameters (Filament ready, High Voltage and Emission Current) and the value represents the type of deviation. This makes it really easy and quickly to understand what is going on with the x-ray tube. The check begins 2 seconds after the tube is turned on, allowing time for all parameters to stabilize. There is an option for the user to turn off temporarily this check if needed.

Thursday, January 19, 2023

XRF Exciter source using a Moxtek or Amptek Miniature X-Ray Tube (Part 1)

 I am working on a new XRF Exciter source, employing a pretty cool miniature, ceramic, 10W X-Ray tube with Tungsten transmission target by Moxtek (MAGNUM series). This source will deliver an immensely higher X-Ray flux compared to the Am-241 source I've been using, thus cutting down on the integration time during XRF analysis and bringing out peaks hiding in the noise.

The Moxtek X-Ray tube comes with a High-Voltage Power Supply module which allows for control of both, the tube voltage (-10kV to -50kV range) and the tube's emission current (0 to 200 uA). The maximum electrical power is 10W into the tube - here are the specs.

The brass housing of the X-Ray tube with the beryllium window aperture and the two high-voltage supply cables. The tube is in a Grounded Anode configuration and the two cables deliver both, High-Voltage to the Cathode and power to the filament. The brass housing is massive enough to dissipate plenty of heat. In its final configuration, the tube will mounted inside of 1+" thick lead shielding as some X-rays are generated in all directions besides the collimated main beam. These X-Rays are much attenuated but still a radiation hazard so proper shielding is mandatory.

My test setup. The HV PS has a very neat and straight-forward interface for controlling the tube's operational parameters of the tube. It is also very efficient when it comes to power - it requires 9V to 12V DC and about 1A of current. The efficiency is a little over 80% - around 12W input power which is fantastic.


While I am designing and prototyping the X-Ray tube controller (more on this later), just for a quick test I was driving the tube with my 3-channel power supply in a rather "manual" mode - Ch.1 is the main power, Ch.2 controls the HV - 0.8V to 4V are scaled to -10kV to -50kV range and Ch.3 sets the beam's emission current - 0 to 4V are scaled to the 0-200uA range.

The tube's module returns monitor signals - voltages with the same exact scaling factors as the control voltages in order to monitor the actual HV and Current straight from the HV module. A TTL level signal controls the beam state - ON/OFF and there is a FILAMENT READY return signal from the HV PS going HIGH when the filament is heated, and the beam is ON and stable.

One important requirement is that the beam should not be turned ON sooner than 2 seconds after it has been turned OFF to prevent damage to the tube's filament. For the same reason the tube should be turned ON for a minimum of 1 second and no less than that - all these requirements will be part of my design for the controller.

Prototyping the X-Ray tube controller on a breadboard, using nRF52840 MCU with ARM Cortex M4F, 24LC32 EEPROM for storing configurations, 12-bit MCP4728 Quad DAC for Tube control voltages, large high-contrast SHARP Memory display (400x240 pixels), bi-directional logic level shifter, Non-Latching Relay, MCP 9808 temperature sensor and a nifty I2C Rotary Encoder breakout.
There are various other components - voltage dividers, voltage regulator, power conditioning, piezo buzzer, pull-up and pull-down resistors, etc. located on the controller board - I designed the board with some thru-hole components so I can easily continue the development once I have the boards in hand and swap components as needed. 
If I ever make another version of the PCB it will be all SMD based to reduce size and cost.

Controller's User Interface
Top of the screen is the Status display, temperature reading (when sensor is plugged in) and the current timer display.
 Second section, below, is the Mode Selector and Timer Selector display - it also shows the Last Run Log, calculated X-Ray tube power, Tube Temperature while running and selected memory preset. 
Third section is the X-Ray tube's Parameter Set (S) configuration where the user can dial in the tube's High Voltage (-5kV to -50kV range (0.1kV steps)) and Tube's Emission Current (1uA to 200uA (0.1uA steps)).
 Bottom part is the Tube's Return Monitor (M) display, showing the measured return signals from the tube's power supply module - sampled with a 12-bit ADC.
 
All set parameters are persistent - Once dialed, they are stored in EEPROM and automatically loaded on startup. There are also two user-configurable Memory Presets with Tube parameters and Timers for quick switching between different sets of values for different experiments. I might eventually increase the number of presets to 3.

There are 3 Operational Modes - MOMENTARY when beam is ON while the OPERATE button is pressed and turned OFF when the button is released. 
The second mode is TOGGLE - pressing the OPERATE button turns ON the beam and starts a count-up timer. Second press of the OPERATE button turns OFF the beam and logs the elapsed time. Sequential ON/OFF will integrate the beam time in the "Last Run time" until a RESET action is executed. 
The third mode is COUNTDOWN timer - the user can dial desired beam time and OPERATE button STARTS/PAUSES the countdown. The X-Ray beam is turned OFF when the timer expires but it can be PAUSED, STOPPED or CANCLED at any time. The user can also spin the rotary encoder to add or remove time from the initial timer setting while the beam is ON in 5 seconds steps.

I have added many safety features!
 When the beam is turned OFF there is a 2 seconds blackout period while the filament is cooling. During this time the beam cannot be re-engaged. It is not possible also to run the tube for less than 1 second - if any such attempt is made, the controller will automatically "pad" the time for a total of 1 second. 
This is a requirement by the x-ray tube to maintain filament health.

There is an INTERLOCK detection feature which inhibits any operation unless the interlock switch on the door/lid of the XRF enclosure is closed or overridden with a key. 
In COUNTDOWN and TOGGLE mode, pressing on the TIMER RESET / MODE button or the Rotary Encoder button acts as an EMERGENCY SHUT-OFF.

 In TOGGLE mode there is also a Timeout feature which will turn OFF the tube after a period of time if left unattended. 
The controller also constantly monitors the Low Voltage power supply and disables the tube if under-voltage / over-voltage condition occurs. 
Tube temperature is monitored with an external sensor attached to the tube housing and the tube is disabled if temperature reaches 60C.

Control voltages for the HV and the Emission Current are always kept at 0VDC when the tube is OFF to prevent the tube from firing up due to a transient on the TTL "tube enable" signal during controller power-up and shut-down. These control voltages go up to the programmed levels just before the X-ray tube is turned ON and are dropped again to 0VDC shortly after (200ms) the tube is turned OFF.

Another safety feature is a "parameter watchdog" - 2 seconds after the x-ray tube is turned ON, and the beam is stable, the controller will start actively monitoring for a difference between the set control voltages and the return monitor voltages - if a specified tolerance between what is requested and what is received is exceeded, the controller will turn OFF the tube and will report the Tube error detected.

External device control is available via a relay with NO/NC contacts used for control of various types of external equipment - X-Ray ON warning indicator, beam shutter system, XRF acquisition system, etc

The nRF52840 BLE will allow me to implement a Bluetooth connection to another host device (Smart phone for example) and control everything remotely. 

 The PCB design for the controller board.
 Critical modules are socketed and can be replaced easily. There is a terminal block and a DB-9 connector directly compatible with the Moxtek DB-9 on the Magnum series tubes and auxiliary 2-pin power connector used for tubes with higher than 4W power. The Tube module plugs in directly with the supplied Moxtek control cable.

For testing, I looped the DAC outputs used to Set the x-ray tube control parameters (the "S" display line on the display) to the ADC inputs for monitoring the tube's return (the bottom, "M" display line) and whatever is programmed as SET tracks perfectly on the MONITOR. The ADCs exhibit a small non-linearity up to about 1.2V (they run with 3.00V reference). I plotted voltage set vs. voltage read and created a curve in the firmware to correct it, which improved the measurement accuracy quite a bit.


The internal ADC inputs of nRF52840 are configured for 12-bit resolution and using the built-in 3.0V (0.6V at 5X Gain) voltage reference. The ADC noise is very typical for these chips - around ~3mV swing as seen on the plot. 
To improve on the noise, I use Interquartile Mean (IQM) when sampling, tossing out the Min and Max values for each data set, while averaging the samples in an attempt to get a more stable readout and this aproach works quite well - now the least significant digit on the readout exhibits some infrequent ADC noise of +/- 1 digit but overall it is fairly stable, also due to the over-sampling conversation I am performing. 

Tuesday, October 18, 2022

Gamma Dog - Volume Control

One thing that was really bugging me with the Gamma Dog circuit was the original analog audio volume adjustment. 

The MCU swings a digital output pin, driving the amplifier input between 0V and 3.3V. This output is connected directly to a linear (class D) 1W audio amplifier which employs a tiny trimmer-potentiometer for gain adjustment.

To adjust the audio level in the field, first I have to remove the screw plugging the adjustment access hole (everything on the front panel is dust-proof) and then use a small flathead screwdriver to turn the internal trimmer-pot - hardly a convenient thing to do every time I needed to change the volume.

I normally keep the audio level pretty loud (3/4 of full power) as it helps during windy conditions but when it is quiet and one is kneeling right in front of the instrument, digging a hole or trying to pinpoint specimens, the loud tone in your face can get a bit annoying. Sometimes there will be a couple of us using Gamma Dogs near each-other and becomes a pretty loud "concert" so quick volume control is a "plus". Not to mention the "dirty looks" I was getting at indoor mineral shows from ladies looking for "healing crystals" who didn't like the loud, variable pitch tone produced by the instrument. (I guess it wasn't "resonant to their aura" :-)

Solving the issue entirely on the software side without re-wiring the audio circuit and using push-pull between two PWM digital outputs was going to be pretty intrusive, and also I didn't want to use additional timers and CPU cycles just to control the volume, so I decided to implement a simple hardware solution - digital potentiometer control.

The two main candidates - Analog Devices AD5171 (6-bit resolution) and Analog Devices AD5243 (8-bit resolution) digital potentiometers - 10K resistance. Most digi-pots out there, unfortunately are using SPI interface for control.
I, on the other hand, have a number of I2C devices in my Gamma Dog, so I wanted to stick with the microcontroller's I2C interface bus - this saves me the use of an additional digital output for Chip Select (CS) signal needed with the SPI interface.

I mounted the chips on SMD-to-thru-hole adapter boards - Mouser #535-LCQT-MSOP10 from Aries Electronics for the MSOP-10 component (AD5243) and Mouser #485-121210 from Adafruit for the SOT-23-8 packaged (this one was a bit tricky to install as the MSOP-8 footprint on the board is larger and the leads were not overlapping the solder pads but rather just reaching the very edge of each pad)

At the end, I focused on the AD5243 chip - it is an 8-bit potentiometer - this means 256 positions, and the chip has two independent, addressable potentiometers / channels which gives me a lot more flexibility for future expansion. With the 10K version, each step is 39 Ohms.
This IC is also using very low power - drawing about 6uA. 
Here is the Analog Devices Datasheet.

 Prototyping the solution. Added benefit was that I didn't have to write an Arduino library "from scratch" to control it - Rob Tillaart already did this. His library was written for AD5241 and AD5242 but works just as well with the AD5243 as it uses the same command set - only the I2C device address of the chip had to be changed to 0x2F. The I2C bus signals SDA and SCL require pull-up resistors.

The two SMD 10K pull-up resistors and a ceramic 100nF filter capacitor mounted on the converter PCB.

On the board I connected Ch.1 pot's B1 pin to ground and added also 10uF / 16V tantalum capacitor across the power supply rail to minimize any transient disturbance and low frequency ripple.

I designed the digital potentiometer volume control as an add-on board which is inserted inline between the speaker / amp board and the main board's speaker connector. This connector provides signal and power to both, the digi-pot and the audio amplifier. The I2C bus is connected to the I2C bus on the Latching Relay FeatherWing shield with a separate line. 
JST connectors allow for an easy, no-soldering install in the units.

The complete add-on volume control module. The board was placed inside a heat-shrink tube for electrical and mechanical protection. On the left side are the output to the amplifier board pigtail and the input connector. On the right side is the I2C bus connector. The 3-pin input/output JST connectors deliver power to the board and to the audio amplifier.

The add-on board installed in the Gamma Dog. Visible on the right is the I2C bus line going to the FeatherWing Relay pins which are basically a signal feed-through to the MCU board.

 Adding these volume control modules to my fleet of Gamma Dogs was effortless and looks as elegant as an inline add-on board can be. I made 3 such modules.

Crude schematics I sketched while developing the volume control. 
The digital potentiometer acts as an adjustable voltage divider for the output signal. The "wiper" is connected to the input of the audio amplifier. 
Ch. 2 potentiometer is currently unused. 


Writing the firmware support, I implemented two ways to adjust the Audio Volume using the Gamma Dog's user-interface. 
A menu item in the Configuration Menu can select one of 6 volume levels - from a very soft sound suitable for a quiet room to maximum loudness for windy conditions. 6 Volume Levels seems to cover the entire range nicely and I see no need for the "classic" 0 to 10 volume range. This adjustment sets the default volume level of the instrument, and it is persistent (saved in the EEPROM and then loaded on startup).

If the user needs only a quick, temporary adjustment - double-click on the BLUE/UP button will switch the instrument to Constantly Open (Latched) Squelch Mode and the current volume level will be displayed right next to "#" symbol. 
The Constantly Open squelch Mode will produce naturally a continuous tone that can be used as audio level feedback. The user then can press the GREEN/DOWN button to cycle thru the available 6 volume levels. Once a selection is made, same BLUE/UP Double-Click action will turn off the Constantly Open Squelch Mode and return the instrument to normal squelched mode with the new audio volume level. 
The volume adjustment in this case is not persistent, and the instrument will revert to the default volume level set thru the Config Menu System on the next restart.

The add-on volume control board bumped up the firmware code version to 4.0.  The board is backwards compatible with older firmware versions - if the AD5243 code is missing, the pot will automatically set the "wiper" to the "middle position" (127) during power-on (which actually equates to MAX volume when 10K chip is used). The useful adjustment range with a 10K potentiometer chip is approx. 0 to ~64 steps (1/4 of the 8-bit range or 0 to 2.5K) in my circuit - anything above 70 and all the way to 255 is really MAX volume.
Ideally, I should have probably picked a lower resistance value (2.5K) but I don't need such fine adjustments with only 6 volume steps to spread across an 8-bit range and 10K is useful for some other ideas I have for the unused pot on the chip.

Another future possibility is to use a digi-pot control for the HV bias power supply for the detector - currently this is done with another trimmer-pot on the HV board and requires the removal of 3 screws to access it.

I am quite happy with the volume control implementation, and it works just as expected!

Firmware version 4.4 marks the end of the current development efforts for my branch of Gamma Dog - the instrument at this stage is mature and polished, performance is excellent, firmware is clear of bugs.
The last added feature in ver. 4.4 is "Gesture Control" for the Squelch Auto-Set. When this option is enabled in the menu system, the GD monitors its orientation and if it is inverted (upside-down, detector pointing to the sky) for more than 4 seconds it will activate Squelch Auto-Set. This allows for one-handed operation in the field - instead of pressing and holding the BLUE button to set the current squelch level, the user just changes the orientation of the instrument.

Hardware version 4 is already developed as a new PCB layout and adds small layout improvements, the incorporation of the digital potentiometer and a couple of new features - "Charge Complete" LED indicator as part of the GREEN button and a circuit for measuring and displaying the HV Bias for the PMT (up to 1.25kV). The built-in HV voltmeter can be used for diagnostics and voltage adjustments in the field, for example when switching to a different detector. 
If I decide to fabricate more PCBs, all these will be ver. 4 and firmware will go to ver. 4.5, adding support for the new features.

In my free time I'll work on documentation, schematics and source code, pending a decision whether to open it and make the project public.
Unfortunately, given the niche application of this instrument, the general interest has been rather sparse, but I would love to hear feedback.