Not a tube project, version 1.1

This is just a brief update to last week’s post about the 3 band VFO sketch for the Si5351 breakout board and Arduino. Software never stands still….

Working with Joel Caulkins, KB6QVI, who generously expressed an interest in the sketch last week, we discovered that although it sure looked like it would run on an Uno, it didn’t.

I did all my testing on an Arduino Mega 2560, the 800 pound gorilla of Arduinos, which has significantly more flash memory and SRAM than the gold standard, the Uno R3. Although compilation reported that there would still 300 bytes or so of SRAM available on the Uno (with 2kb SRAM), it probably wasn’t enough to support the stack needed to run. The sketch just hung on the Uno.

A little investigation revealed the culprit: the Adafruit display libraries I was using consume rather a lot of SRAM. Really a lot. Lots. The clear choice was to switch over to the popular Google U8glib display libraries for 8bit processors.

The Google code seemed a little daunting at first, but only because it supports every display ever built (and possibly some that are only being thought of at this time), so the most difficult step is choosing the correct constructor for the display you are using. Luckily for me, the little 0.96″ OLED display I chose is very popular, and I quickly found several tutorials which cleared up the matter of the constructor and initialization quickly.

The structure of the Google code is a little different that that of the Adafruit – a little less linear in that the actual displaying of the screen runs in its own loop. At first I thought you needed to do this once per Arduino processing loop – that is not correct at all. Actually, instead of calling a “show” method once, you just implement the little display loop at the point where you want the display to change.  A little refactoring of the classes I had written for the Adafruit library, and U8glib slid neatly into place.

Another difference is that U8glib is more pixel oriented. There is a drawStr() method to allow printing text to the display, but it didn’t seem to support a newline. Instead I had to explicitly position each line of text using the setPrintPos(x,y) method. Not a big deal once I got used to the idea, just different. The library also supports the familiar print() and write() methods, similar to those of the Serial object, but I suspect these are just wrappers around drawStr().

In addition to being much more economical in its use of SRAM, U8glib offers a staggering number of fonts, sizes and styles of print to choose from. Check the font wiki page for more information on this – I am quite pleased with the resulting print which looks much better than the Adafruit display in my opinion.

To verify the new sketch, I slapped an Uno on my breadboard, disconnecting the Mega

Now with Uno R3 support!

Now with Uno R3 support!

A little messy, but effective.

Code for the new is uploaded to github, and can be found here.

The Google U8glib, in all its glory, resides here.

And I am going outside to build a wire antenna for 17 meters, it’s a beautiful day.
Enough software for now.

73,
de N2HTT

 

 

 

 

Advertisements
This entry was posted in Arduino, Ham Radio and tagged , , , , , , , . Bookmark the permalink.

One Response to Not a tube project, version 1.1

  1. g4ydmone says:

    Reblogged this on G4YDM and commented:
    The core principals learned from building are worth their weight in gold…JOHN G4YDM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s