Encoder-Tuned Software Descriptions


You can download the listing PDF here.

Like the simpleST.ino sketch, this version has no monitoring, no CW, just replacing the original tuning method. A straightforward simple and basic SSB transceiver. Unlike the Shuttle-Tuned rig, this program requires a physical modification: The tuning potentiometer is replaced by a switch-type rotary encoder with a SPST push-button section. Where the original Raduino was tuned using the A7 pin, this method will use three digital pins, D2 through D4. A 5 volt regulated reference voltage is not needed but it still requires a ground return. Thus the new encoder will have 4 wires going to it from the Raduino.

Wire one terminal of the SPST switch to the common of the encoder switches and then ground this connection. The remaining terminal of that push switch is then connected to the Nanos D4 pin which appears on plug 3 pin 4. Encoder terminal B is connected to the Nanos D3 pin (plug 3 pin 5). The remaining encoder terminal (A) is connected to D2, plug 3 pin 6.

Be sure to buy a rotary encoder that has a threaded shaft. It will then fit the same sized hole that the original control used. It makes for a very clean installation. The knob should be mounted far enough out on the shaft so that it can be pressed inward that 1/32”, not flush to the panel.

As with my other BITX Raduino sketches, I use the Etherkit Si5351 library found here. The rotary encoder libraries that I use can be found here. These library packages also have examples and explanations that are priceless (in both senses of the word!) and well worth the time exploring.

This sketch begins with the inclusion of the new rotary encoder library “Rotary.h” and the initialization of it.

An unsigned character type variable (“ result “) is designated to hold the result of the encoder operation and an integer variable (“ ind “) is declared to store the tuning indicator position (where the cursor appears). The amount that the tuning is changed, incremented or decremented, is stored in a long integer variable and is assigned to initially 1,000 Hz ( 1 KHz ).

For the ultimate in frequency accuracy you should measure the BFO frequency with a frequency counter where it would least likely disturb the signal. I suggest using the output of the buffer amplifier, Q11. Probably at the junction of R105 and C106 would be best. It will be in the vicinity of 12 MHz on the BITX40. Use that number to initialize The BFO variable. The example shown is 11999855, just 145 Hz lower than the stated 12 MHz.

The next variable in this block is the Local Oscillator frequency, the workhorse of the tuning. The initial starting value is calculated by subtracting the desired frequency (in this case, 7.2 MHz) from the BFO variable. This shortcut method simplifies the assignment, making it easier and less prone to error. Win..win!

To make it easy to detect a change in the LO frequency the “oldLO” variable holds the number for future comparison. The current operating frequency is kept in a floating point variable for display and for cursor calculations. Finally, an extremely long variable (“post”) is established for timing the display updates.

In the “setup()” function we establish that interrupt and use the encoder library to decode the change. It uses an ingenious method to reliably determine the change in state without using additional hardware for de-bouncing the contacts. All of the core rotary encoder operations are within the interrupt service routine and are handled quickly and efficiently enough that they are transparent to the rest of the radio operation.

Setup continues with optioning the Si5351 synthesizer. Again, for accuracy, the reference oscillator frequency needs to be measured and the result placed on the “si5351.init...” line where the example shows “25005200L”. Don’t forget the “L” or the following comma and zero. That measurement can be done using the calibration method.

Pin D4 is optioned as an input with pull-up voltage for the tuning push switch and then the “Splash” screen is displayed so that you can tell which version of software is loaded.

The main program ( yes, all so far as been merely prelude ) consists of very few lines that continues to loop through its cycle. It’s named “loop()” appropriately! The first thing on the agenda is to calculate the cursor position using the length of the frequency number, the position of the decimal place, and the tuning increment at the time. Next, if there has been any changes, the display function is called to display them. Finally, if a change in frequency has been requested, then the operation jumps to the “ program() “ function where the command is sent to the synthesizer and the display called to place it on the screen.


You can download the listing PDF here.

This is my latest build, in use for several weeks now and appears quite stable. In addition to the rotary encoder tuning this sketch includes support for the following:

I am starting out from a new board and so abandoned my previous pin assignments to allow a more convenient (to me) cabling arrangement. So, be very careful with your adaptation: Make sure that your wiring matches the software assignments, or vice versa. Note, for instance, that I am using two pins for which the Raduino does not have header pin connections: D0 and D1. Those pins are used in serial communications. In other sketches (including the one that comes native in the Raduino) the serial port is used as a trouble-shooting tool. They are also used when re-programming. Otherwise, they just sit there, unused. I needed more control pins for some of the extra features. It works.

The batch of 1N34a diodes that I recently purchased and put to use in my new BITX modifications appear to have significantly different forward conduction values. Perhaps they are not actually 1N34a. Nonetheless, this provides a good example of how to compensate for different results when calibrating your software.

The first statement in the “ loop() “ function is “ FP=analogRead(A1)/(27e3/analogRead(A1)+1); “ where the forward power measurement is read from the RF monitor circuit by the analog to digital converter on pin A1. In previous builds, the voltages were higher and the “27e3” (that’s 27000) was instead “3e4” (that is 30,000). That value had to be discovered by testing. The BITX was connected to a power meter and dummy load, the results then compared with the actual power. The voltage/power response curve remained the same, just the voltages were proportionally less. Changing that one constant made the change linear. Varying the supply voltage to the test BITX made verification of other power levels possible.

Since the reflected power is done the same way, that formula is identical. This can be checked by reversing the bridge and measuring.

The S meter is now derived from the new AGC board. That modification is documented here. The amplifier section on it provides a nice full range from S3 to S9+50 dB. Instead of a formula to display the signal level, it was more convenient to individually map each display level.

The T/R clicks are almost completely eliminated by using the "ClickFix" modification found here.

As with the Shuttle Tuned sketches, the display replaces the S meter readout, when forward RF power is detected, by the power and SWR values. The RF monitor is only activated in CW mode if a straight key is held for one second or more. This is to avoid having it “hang” for a few milliseconds in transmit. That would be annoying. I prefer a clean “fist” than a power monitor, but it is there if you need it.

Return to Home