Sunday, July 6, 2014

Minima - Alternate Tuning Method - Cont'd

I have been working on Software for the Minima Transceiver. As posted before, my plan was to provide an Alternate Tuning Method for the Minima.

 In the Beginning

The original tuning method was provided via a standard POT that had a center position that did not change the frequency of the radio. When turned off center to the left the frequency would go down in different steps depending on how far from center the POT was turned. Once near the desired frequency, turning the POT back toward the center would decrease the steps size so that tuning could be stopped on the desired frequency. The same is necessary to increase the frequency, but in the opposite direction. The original Driver for the Si570 did not have 1Hz resolution and therefore the preprogrammed tuning steps was a reasonable, or an acceptable solution.

New Direction

I desired higher resolution and a more natural way of tuning the Minima Transceiver, within the limits of using the existing Minima hardware as much as possible. And I wanted to add some additional features to the software, see below. A method of adding additional push buttons switches was found, thanks to Minima e-mail contributors.The button circuit can be found here. Note: most of the wiring can be done on the front panel, next to the switches.

With a lot of work Jeff - KO7M, rewrote the Si570 Driver to provide better than 1Hz resolution. He did so by, rewriting the original floating point algorithms using fast 64bit interger math. His Driver is a plug-and-play replacement for the original. Jeff's Si570 Driver can be found here.

Writing replacement software to implement my Alternate Tuning Method started as a simple modification and grew into a major rewrite of the Minima program sketch. Many people around the world provided inspiration, testing, and ideas that were eventually included in what it has become today.  

Jeff - KO7M, Wayne - NB6M, and John - MI0DFG are major contributors.

The functionality of this program will continue to grow; to include menus, beacon modes and several other interesting ideas. Programming space is limited, but some things can be carefully added.

But, Program Modifications and Additions have Costs

One major cost, hassle, or headache was how to minimize the use of Variable Space to stay within the 1K bytes (RAM) available on the ATMEGA328P microprocessor.

So far, the Program Space has not been an issue, currently the program uses only about 20K bytes of the available 32K bytes (FLASH).

Free Memory from the Variable Space (RAM) is necessary for proper program execuiton as the "stack" used by each programmed function consumes and releases it as they are called. There are NO reported run-time errors if ALL of the Free space is used, the program just become erratic or fails (crashes). Using ALL of Free Memory is NOT a good thing. At one point, there were only 322 bytes of available Free Space at program reboot (way too little), program crash was inevitable.

An analyses of Variable Space of the modified Sketch indicate that most of it was used by String Constants within the program. A method was needed to move the String Constants to FLASH Memory, and out of RAM. With lots of research and putting disconnected ideas together, a method was concocted that provided the solution. The problem is discussed, but no-where on the web could I find a suggested cut-n-paste integrated solution.

Arduino String Constant Moved to FLASH Memory

The solution that I came up with is implemented via a set of Macros. The macros uses the PSTR construct in conjunction with a "strcpy_P" function. My simple solution is implemented as a buffer and two simple macro. This solution is not as fast as it could be, because it copies the String Constants back to RAM before it's used. But in doing so, the String Constants can be used anywhere within the program as normal, by wrapping it in a simple "FLASH( ... )" programming construct.



char buf[60];
// ERB - Force format stings into FLASH Memory
#define FLASH(x) strcpy_P(buf, PSTR(x))
// FLASH2 can be used where Two small (1/2 size) Buffers are needed.
#define FLASH2(x) strcpy_P(buf + sizeof(buf)/2, PSTR(x))


A few examples from the Minima Sketch as used:



debug(FLASH("Register[%i] = %02x"), i, dco_reg[i]);

sprintf(c, FLASH("%-16.16s"), FLASH2("VFO swap!"));
printLine2(c);



These examples are saved here for my future reference, and hopefully saved where other programmers may find it, and find it as useful.

After moving the String Constants to FLASH Memory, it has grown from 20K to about 21.5K bytes, but still with lots of room for careful additions.

This solution has changed Free Memory from 322 bytes to 1070 bytes for this Minima Program Sketch. With 1070 bytes of Free Space the program will not (should not) fail for lack of stack resources.

The Alternate Tuning Method

The Alternate Tuning Method implements the following, which are not found in the original sketch.

  • High resolution, plus/minus 1Hz Tuning (thanks to Jeff).
  • Near Normal Dial Tuning as found on most Dial Radio system.
  • Tuning Cursor positioning via Left/Right push buttons
  • Automatic (original) or Manual Selection of Sideband via push button
  • Nine Ham Band Memories, with Frequency and Sideband Save via Up and Down push buttons
  • RF386 Power Amplifier Filter Selection via generated clock pulses (Note: Not a lot of testing has been done on this yet)

Thanks to the people on the web and Minima e-mail list, the current Alternate Minima Tuning software is working very smooth and provides some very desirable functions.

The GitHub Repository where this software is available, is:


As the software continues to be developed, the GitHub Repository will be updated, check back often.

A complete dynamic list of my Minima Project posts are available via this search link (which will include this post):




UPDATE: July 14, 2014 12:16
After much more research, I found the use of "PSTR" used in a similar context as I have suggested documented, at:

http://electronics4dogs.blogspot.com/2010/12/simple-way-how-to-use-progmem.html

I wished I have found this link long ago.


--

2 comments:

  1. Hi Eldon,

    Great work.

    Just one thought, Instead of 100K pot can we use encoder? This will give the complete commercial feel for Minima tuning.

    Regards,
    Raurs

    ReplyDelete
  2. There are people working on an Encoder Based Tuning. My efforts have so far been to minimize changes to Farhan's hardware.

    I know of one implementation of a Encoder that use pins abandoned when the LCD Display was converted to I2C.

    I am sure you will see this working soon.

    Thanks for the comment !

    ReplyDelete