Menu:



Version:

Dec 06, 2019:
Revision: v1.0

The Sweeter Upgraded ZL2PD SugarCube Si5351 VFO

Major improvements including user-programmable parameters! Just how much sweeter can the tiny compact ZL2PD SugarCube VFO get?  At time of writing this, just prior to Christmas 2019, perhaps you can call it my gift for you this festive season. And the New Year. A special kind of sweet treat that's actually good for the diet. 

Introduction

About six months ago, I released my latest Si5351a based VFO design, the SugarCube VFO. It's a tiny dual VFO controlled by a small 8-pin ATtiny85 microcontroller that can be built in a volume not much larger than a sugar cube.

It connects to  small graphical display, the widely available low-cost 0.91" 128x32 OLED LCD. All that's required to control it is a standard rotary  encoder for tuning, and three pushbuttons.

The software also supports a graphical bar meter for signal strength, RF power, battery volts etc.

Many users have found the SugarCube VFO to be a very compelling package for a wide range of ham radio applications. 


Figure 1 : The Sugarcube VFO's OLED display measures just 38mm x 12mm yet is very easy to read. The three status icons on the top right corner indicate VFO Lock, Transmit, and VFO A operating. The arrow points to the current tuning step size (100Hz) while the bar graph along the bottom edge shows signal strength or other analog values you may wish to select externally to display, such as battery voltage..

The SugarCube VFO has met with an amazing response. Lots of people have successfully built one all over the world. Subsequent requests for more features have been almost overwhelming.


BUT... there was an issue - Programming it to suit everyone's slightly different requirements. Not everyone had access to the easy to use Bascom-AVR software necessary to recompile the software.

So what could be done in a VFO already so small, there was simply no room to add anything more? Yes, I just squeezed, pushed, shoved, trimmed and worked away on the software until, finally, there was room to add...

Enhancements for the SugarCube VFO

Following a very useful suggestion from Eric ZL2BMI, and with his encouragement and support including  ‘beta’ testing of my software, I have now completed an improved version of the tiny SugarCube VFO software.

The good news: It’s still just as small as the original, and all of the software still (just!) fits into the 8-pin ATtiny85. A problem with a few 128x32 OLED displays failing to start properly with the original software has been traced to display quality issues. Their slow to start electronics have been addressed in the new software.

The better news:
The new software now has dual BFO/CIO oscillators, one per VFO, allowing interesting new possibilities such as USB/LSB selection. Tuning is silent, and quadrature remains standard.

The best news: You can now program your own VFO configuration WITHOUT having to recompile the BASCOM-AVR software. It’s even possible to calibrate your SugarCube VFO with the exact frequency of the crystal you are using to give enhanced VFO accuracy!

User Programmable Parameters

Here’s the full list of parameters that my new SugarCube VFO software allows you to change and program:

–    VFO A Rx
–    VFO B Rx
–    VFO A Tx, and
–    VFO B Tx

The ATtiny85 is about 38 bytes away from the capacity of the chip's 8k flash memory, and similarly close to SRAM capacity.
Phew! Just fits.


Technical Details of ATtiny85 Memories

(Feel free to skip around this section unless you are interested in what'sgoing on "under the hood")

To achieve this new functionality, and following Eric ZL2BMI’s suggestion, I took a close look at using the ATtiny85’s EEPROM memory to store key user parameters. The useful thing about the EEPROM is that it is easily changed by users without the need to change the compiled operating software stored in the chip’s flash memory.

For those unfamiliar with the ATtiny85, the device actually contains four types of programmable memory:

Most programmers simply program their software into the flash memory, and use the volatile SRAM memory for variables and other functions during software operation. EEPROM memory is generally ignored. One reason is its relatively limited functionality - You can read and write to it, but it's a relatively solow process. EEPROM is also often perceived to being more difficult to use. Finally, EEPROM memory locations also have a limited write lifetime.

In this context, ‘limited’ means, at least according to Atmel/Microchip, that after you write to the same EEPROM location about 100,000 times, it's possible for that byte location to just ‘wear out’. It may not retain new data after that. Of course, it's important to note there is NO limit on the number of times you can read from an EEPROM location.

In practice, tests have understandably shown that 100,000 writes is a very conservative limit. Nonetheless, this can be a problem in many applications. For example, it is a factor mentioned in my Aviation Receiver Channel Controller design described elsewhere on this website.

Using EEPROM in the SugarCube

The original SugarCube software stored all the variables and program flags in SRAM. A set of constants was stored in non-volative flash memory. These constants included, for example, the crystal frequency and start-up frequencies for the two VFOs.

By duplicating many of the key parameters into the EEPROM in this new software, I was able to minimize potential EEPROM issues such as the write cycle issue. It’s just not a problem that would be encountered with the approach used in my software. Usefully, this approach now allows users to change these parameters any time using almost any cheap (Less than $US2 at the time of writing) USB programmer and one of the many (freeware) programmer applications which can be run on a laptop or computer.

You need a programmer and the programming application anyway to program the SugarCube software in order to build the SugarCube.

This change means that my upgraded SugarCube software allows you to change the key SugarCube user parameters now stored in EEPROM, any time you like.

The downside? Well, when you first build the SugarCube for the first time, you must program the flash memory (as usual), the EEPROM (that’s a new step), and the fuses (as usual). After this, at any time, or even during this initial programming procedure, you can edit the example SugarCube parameters I've supplied and reprogram the EEPROM with your preferred values. And that's what allows you to change the complete functionality of the SugarCube to suit your requirements.

And I've managed to fit it all in the tiny 8-pin ATtiny85. Along with the little
0.91" 128x32 OLED display, this ensures the size of the VFO is kept down to an absolute minimum.

Let's look at some ways these features can be used. 

Example 1

The new SugarCube software comes with a SugarCube configuration example file ready for programming the EEPROM. You can install this initially to try out the VFO. It’s a somewhat unusual configuration provided to demonstrate the functionality available in this design rather than, say, for use in a specific transceiver. I’ll give a better and more realistic example of that later.

The two files you need to download to program your ATtiny85 include the SugarCubeV10.hex HEX file which must be written into the flash memory, and the SugarCubeV10.eep EEP file which must be writen into the ATtiny85's EEPROM. This latter file contains the following configuration data saved in Intel hex format:


where:

All of the information shown here has been saved in the
SugarCubeV10.eep which is available for download below.

Closer examination of this example configuration will quickly show  that the mixing scenario included in this file is very unlikely to be encountered in practice. However, the idea behind providing this unusual example is that it shows the values for each of these modes as well as illustrating the values to be expected in the various EEPROM locations for each of those parameters and modes.

Now, let's look at a more realistic example.

Example 2

This second example is for my new homebrew SSB transceiver. It has an IF with a nominal centre frequency of 12.0 MHz. I've decided to build my transceiver for use on 40m (7.0 – 7.3MHz) and 15m (21.0 – 21.45 MHz). It requires a VFO output = IFoffset – Frequency (Low-side injection) for 40m and a VFO output = Frequency – IFoffset (High-side injection) for 15m.

The VFO A output will be (12.0 – 7.0) to (12.0 – 7.3) = 5.0000 to 4.7000 MHz. I decide I want to start VFO A at power-up at 7.080 MHz. After testing my IF crystal filter, I want the BFO for VFO A set for LSB, in this case on 12.003100MHz.

For 15m, the VFO B output will be (12+21.0) to (12+21.45) = 33.0000 to 33.4500 MHz. I decide to start VFO B at power-up at 21.125 MHz. I also decide the BFO for VFO B, for USB, should be set to 11.998700MHz.

Finally, let's also demonstrate calibrating the SugarCube VFO to match the vagaries of the Si5351a's crystal. In this example, let's say I also measure the Si5351a reference crystal I am using and find it is oscillating a little above its nominal 25MHz frequency. I decide to calibrate that value at the same time. In this example, I determine the value of the Crystal parameter should be 25.001735 MHz.

The resulting configuration required is therefore:



Calculating the EEPROM Data

I’m sure your eyes are starting to glaze over by now. Honestly, the entire process is incredibly easy to do, and it takes much much longer to describe. I can completely update my SugarCube in less than a minute now. 

Back to the detail. The EEPROM must have this parameter data entered in the right place and in the right format. The decimal values above must be converted to HEX (hexadecimal, or base 16) and the resulting values arranged in the right order in the EEPROM.

To help you with this procedure, I’ve developed a small Excel spreadsheet tool. (It's available for download in  the section at the end of this page)

To use my spreadsheet, begin by entering the VFO parameters you want for your VFO into the spreadsheet. (There are two worked examples in the spreadsheet, the second of which can be over-written with your values) The required EEPROM bytes are then automagically generated by the spreadsheet and summarized in the correct arrangement in the last section of the worksheet.

These values should then be transferred to your programmer application.

If you program your SugarCube initially with the HEX software and EEP EEPROM files with the files below in the Download section, then, when you examine the EEPROM with a typical programmer application, the contents of the SugareCube’s EEPROM will look like this:



in some Atmel/Micrchip devices, it’s possible for the first byte in EEPROM (at address 0000) to be erased under some circumstances. To avoid this problem, I have placed two “dummy” bytes at the start of the EEPROM. Just leave these two bytes alone (i.e. &39h and &30h). I’ve shown these shaded in the above table.

The unused EEPROM locations which we do not need are also shown shaded in the table above. These contain the value &FFh and can also be left just as they are. If you change the VFO settings from the ones I've entered, just remember that you only need to change the
bytes in the EEPROM that differ from the original EEPROM contents. You can ignore everything else.

For example, using the configuration parameters from my second example described above, the EEPROM contents should be programmed like this:



The EEP file from the website can be programmed into the ATtiny85. Alternately, you can simply prepare your own data using my spreadsheet tool and the EEPROM tab in EB and then directly program that data into your SugarCube EEPROM. It's quite easy to use. Here is a screenshot of that tab for one of my SugarCube VFOs:
 


Programming the ATtiny85

After you have built your SugarCube hardware (See my original SugarCube VFO website page for details), the ATtiny85 should be programmed in this order:

1.    Program the ATtiny85 flash memory with the HEX file
2.    Program the ATtiny85 EEPROM with the EEP file
3.    Program the ATtiny85 fuses.

I use the well-known USBasp programmer and Extreme Burner ("EB") programming software. Assuming the USBasp has been set up and the two files downloaded from here, start EB.

To program the flash memory with the HEX file,  use File - Open Flash - Select the HEX file - Click on OK. (Wait while following the progress bar)

To program the EEPROM with the EEP file, use
File - Open EEPROM - Select the EEP file type using the pulldown button - Select the EEP file - Click on OK. (Wait briefly for this to be completed)

To program the fuses, select the Fuse Bits/Settings tab in the main window. Set Low Byte and High Byte values. Click  the Write boxes for both fuses, then click on Write to set the fuses. (Follow progress using the dialog that appears on screen)

Here are the recommended fuse settings:



IMPORTANT!!

Once you program the HIGH Fuse byte with &H5F, and specifically the RSTDISBL fuse bit in that byte with 0, you can only use a special HV programmer to reset the chip if you wish to change the EEP settings again. Therefore, I recommend you INITIALLY programming the HIGH fuse byte with the value &DFh (i.e. RSTDISBL=1) while you try out the SugarCube and experiment with the various EEPROM values to configure the VFO to your specific requirement. FINALLY, once you are satisfied with the EEPROM parameters, program the HIGH fuse byte with the recommended &5Fh value.

The LCD will not display the bar meter input value correctly until the HIGH fuse byte has been programmed to &5Fh, but that is a small inconvenience during the time you are setting up and initially testing your SugarCube VFO parameters.


Conclusions

I hope you enjoy these new features for my SugarCube VFO. Please, let me know if you find innovative ways to use these settings which allow the SugarCube to be used in unexpected ways. I'm sure others will want to share the sweetness.

Enjoy!



Downloads


Upgraded SugarCube VFO Software: This SugarCubeV10.zip ZIP file containing the new enhanced SugarCube VFO software in HEX program code ready to program your ATtiny85 flash memory (*.hex) and an example EEPROM software for the EEPROM (*.EEP).

SugarCube EEPROM Calculation Tool: An Excel® spreadsheet to help you determine the values to program in the EEPROM for your application.

Note: You can find all of the other files and details you need to build the VFO (Schematic, PCB layout, wiring details etc) over on the main SugarCube VFO page.





Questions? Send me an email. I'll try my best to answer as soon as I can. Just remember my (paid) work takes priority so it may take a couple of days to reply....or longer if I'm travelling or working in some weird out of the way location.




Want to go back to the main page? Click here to return directly.