Some time ago I attempted to create physical controls for SDRSharp using the excellent SDRSharp Net Remote plugin for SDRSharp created by Al Brown (https://github.com/EarToEarOak/SDRSharp-Net-Remote). This plugin allows an external device to send commands over a USB serial connection to control the SDRSharp software. My prototype worked with a low resolution rotary encoder but not with a higher resolution 360 pulses-per-rotation rotary encoder because the Arduinos I had at my disposal were not fast enough and as a result dropped / could not notice pulses being generated by the encoder. Due to this I ended up abandoning the project.
Recently I acquired my first Raspberry Pi Pico and with its much faster clock rate wondered if it would be up to the job, and, sure enough, it is more than up to the job!
My next hurdle was the SDRSharp Net Remote plugin. I wanted to be able to send simple "turn the volume up one notch" and "turn the volume down one notch" commands and not have to keep track of what the current volume setting is in SDRSharp. However, this plugin does not support these types of commands so I decided to create my own SDRSharp plugin in C# which I have called SDRSharp Controller and is available here.
IMPORTANT: You will need to install and use this SDRSharp Controller plugin for this project.
FunctionalityEach push button is labeled with its primary function. Whenever you want to adjust the volume, for example, press the Volume button and then turn the rotary encoder CW and CCW to adjust the SDRSharp volume. Pressing a second time on most buttons will allow you to adjust a second setting. Here are the primary and secondary functions for each button:
Volume
Primary: Adjust the volume / audio gain
Secondary: Adjust the squelch threshold
Tuning
Primary: Adjust the tuning / frequency
Secondary: Adjust the tuning step
Mode
Primary: Change the filter type / demodulation mode (FM, AM, LSB, etc.)
Secondary: Adjust the filter bandwidth
Zoom
Primary: Adjust the zoom of the FFT
No secondary function assigned to this button
Memory
Short press and release within a second: Memory recall
Longer press of between 1 and 4 seconds: Memory set
...more about this memory function: Whenever you perform a long press of this Memory button, the SDRSharp Controller plugin in SDRSharp will remember the frequency, mode and filter bandwidth of what is currently playing (memory set). This allows you to explore other frequencies and return to this stored frequency with a simple short press of this same Memory button (memory recall). Only one "memory slot" is available so performing a second long press will simply overwrite what was stored before with what is now playing. When setting the memory (long press) the LED of the Memory button will blink 5 times. Whenever recalling the memory (short press) the LED will blink 2 times.
Except for the Memory button, whenever you press one of the other buttons, the LED next to the button will light up to indicate that you are now adjusting this setting when you turn the rotary encoder. When you press the button a second time to access the secondary function, the LED next to the button will blink to indicate that you are in the secondary function.
ResponsivenessThe 360 pulses-per-revolution rotary encoder will generate many pulses when it is turned fast. If we were to send each pulse as an adjustment command to SDRSharp this would cause a serial connection bottleneck and also issues on the SDRSharp end which would crash or freeze, unable to keep up with the frequency of adjustments being requested. For this reason, pulses are "cached" and the net change of the position of the rotary encoder is sent to SDRSharp every 100 milliseconds. If the rotary encoder is not being turned then nothing is being sent to SDRSharp.
This 100 millisecond setting is on line 329 of the Pico sketch. Tests using a standard Windows 10 desktop with a USB 2 connection were successful with smooth operation and SDRSharp never freezing up or lagging. However, if you experience issues you should try using a longer period between rotary encoder commands being sent to SDRSharp - for example, change from 100 to every 200 milliseconds.
Btw, the rotary encoder in the parts list is advertised to work using 5 to 24 volts but works just fine with the 3.3 volts supplied by the Pico.
BuildI chose to build a wooden enclosure because I have the tools and woodworking skills but obviously many other types of enclosures could be used. Also, the arrangement of the push buttons in a semi-circle around the rotary encoder seemed visually appealing and ergonomically appropriate but other layouts could be explored.
In this second picture you can see the USB cable connected to the Pico. The other end of the cable is connected to the PC which is running SDRSharp with the SDRSharp Controller plugin installed and configured with the serial port that the Pico is connected to.
Comments