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.

2 comments:

Anonymous said...

Is the gamma dog firmware and the board layouts and schematics proprietary or open source?

If the latter, where can it be found?

It looks quite interesting.

Andrey E. Stoev said...

Currently, the firmware code and schematics are not open - this, of course could change at some point.
I also need to work on a new board layout in order to integrate the volume control instead of using an add-on module and also a change is needed due to the fact that the vendor for the 12-bit DAC module changed the dimensions of their PCB and their current version will not fit with the existing main PCB layout.
Keep an eye on the blog - if we choose to open the source code and design, this will be published here.

Meanwhile, a simpler version of this instrument but with more or less the same core functionality when it comes to mineral detection (sans the "bells & whistles" - no display, no digitally adjustable peak-height threshold, no configuration menu with persistent settings, etc) is built and sold by Charles Young on eBay - search for "GammaDog radioactive mineral detector". As far as I know only a few units are left and probably there will be no more. Currently there is a world-wide electronic components shortage and the MCU boards are also difficult to procure.