Reprogramming a Audio Knob to build a SDR VFO Knob
I recently wanted to get a VFO knob to be able to better adjust the Frequency of my SDRs for SSB Signals on Shortwave or QO100 for example. You can use the Mouse Wheel on a PC, but on a Notebook or Tablet you are out of luck. After a quick Google Search i wasn't able to find anything like i wanted for a reasonable price, but i found a Audio Dial for only 15€ including Shipping on Ebay. I thought that for the price it was worth a try, even when there is no chance of changing the Audio control to something else, i at least will have a nice looking USB Knob with a metal Case and a Long micro USB Cable.
After it arrive i first gave it a try on Controling the Audio on my PC and it worked nicely. The Base is quite heavy and has some rubber pads, so it stays in place very nicely. The Knob also turns okayish, the one on my Yaesu Radio is a lot nicer of course, but it's more then good enough for a SDR Frequency Adjust. Sadly there is no Software included to change the Buttons Mapping, so what now?
Well let's Tear it Apart and see what is inside, maybe there is a way to modify it. After Removing two Screws i was able to seperate the base and take a look at the PCB inside.The Knob seems to be Glued so i can't ge the Board out completely. It is build quite simple and has only one interestng Chip on it, a STM32 Microcontroller that seems to do everything needed. The first thing i thought next was if it was Write locked or if we can reprogramm it.
After i searched for the Datasheet, looked at the Pinout and read a lot about STM32 Micros i figured that it should be possible to just solder a few cables onto the PCB and communicate with it over Serial. After a bit of fiddeling with Software and Soldering up to the Serial Interface as well as adding a Jumper to enable DFU Mode i was able to connect to it, unfortunately the Code Protection was enabled, so on my first try to dump the firmware it got erased and didn't do anything then DFU mode after That.
UPDATE: You can also programm the Chip directly over USB, thanks to Dale 2W0ODS for the Instructions. Install Dfuse including the Driver, bridge the Boot Pin as stated below and plug your Knob into your PC over USB. It should appear as a "STM32 in DFU Mode" Device that you can select in DFuse. Select the .dfu file and Upload it with dfuse to the Knob and you are done.
Pinout STM32 Serial (to USB to Serial Adapter):
- 5v -> 5v
- (USB_DM / PA11 / TX) - -> RX
- (USB_DP / PA12 / RX) + -> TX
- GND -> GND
(Note: The Pinheaders / Black Components are optional but practical for flashing multiple times)
(Programming the Knob without using Pinheaders, just a Jumper Cable and a FTDI Adapter pressed against the contacts)
Well, now i need to write a Program to get it Working again in any way or form. I never worked with a STM32 before, so it was quite a steep learning curve. Also figuring out what pins on the Chip connect to which part of the Knob also took some measuring with a multimeter and somewhat reversengeneering the PCB. But after a while i got the IDE for the Chip working and was able to make a glorius Blink Programm for it that uses the Blue LED on the Knob.
I was so happy that i got the Chip reprogrammed, but i wasn't anything close to the Functionality i wanted. After a few more hours i also was able to read the Knobs Rotation and Button function but i still needed USB Functionality. So i dove down the Rabbit hole that is HID Implementation on STMs....at least i think it is just not described good enough anywhere online. Just getting the USB Descriptor Right is a Nightmare, even with decent tutorials online, i really wished it would have been as easy as on a ATTiny over the Arduino Libaries, but i got it working after a lot of tinkering.
So here we are, i got the Knob reprogrammed so it simulates the Mouse wheel including three different scroll Speeds and it doesen't need any driver. It can be used by any Device that supports a Mouse over HID. I also added a Audio mute Function that could be useful, it'S activated with a long press of the Knob.
You can Download a HEX File for the STM32 found on my Dial (could be different on yours!) below if you want to flash such a Audio knob as well as the Source Code for anyone that want's to maybe add functionality. I don't want't to invest more Time into this Poject, but if anyone knows a lot about STM32 and Hid a MIDI implementation would be nice to integrade with SDR Programs without having to have the Software in Focus.