Wednesday, 3 January 2018

BITX40 Software Modification

This is my third post in a series about building and hacking a BIT40 radio. The previous post may be found here.

For future reference links to all the Arduino software, articles and discussions I write about can be found on the Arduino Links Page which is listed in the Pages and Links gadget to the right.

In post one I built the radio. In post two I employed some hardware hacking to correct an unfortunate property of my radio. You may have to do something similar, or maybe your radio works well out of the box. Now it is time to look at how we can modify the radio operating software.


Installing Arduino Integrated Development Environment (IDE).


I could write a lot about installing the Arduino IDE, but it would be difficult to come close to what the Arduino folks have already written. So follow that link and read up about programing the boards and install the IDE on the system(s) you want to use. If the system you want to use is a Raspberry Pi, don't worry. Installing the IDE on a Pi is very easy and the people at MagPi have you covered. Actually even if you aren't going to use a Raspberry Pi that article is still a recommended read.




There are a number of choices of available software:
  1. Farhan's original code, with updates since your Raduino was programmed.
  2. Munters mods which support a series of hardware mods and provide some attractive features.
  3. Costa's fork of Farhan's original and his own Si5351 library. This supports some of Munter's mods and adds some others.
  4. Your own mashup taking pieces from these or other sources and adding your own features.
All of these are possible. I will walk through option 2 in this post. Of all the options this is the one I recommend starting out from. It is feature rich and has ongoing development and support. You will want to implement at least the function button hardware mod.


 A Word About GitHub


The git program is a very advanced source code control system that allows multiple developers to work on a body of code and manage the issues which arise therefrom. The use of git tools is beyond the scope of this post so I will be showing you the simplest way to get the code. If you want to contribute back with your own work, or even if you just want to be able to get the latest updates easily you should look into using git and GitHub.

 Munters Mods


The source code for Munters sketch is on a GitHub repository.
Munters GitHub repository
To download the latest release of the code click on the green "Clone or Download" button and select "Download ZIP":
Use your favorite ZIP management tool to extract the contents to the sketches directory you created when you installed the Arduino IDE. Because I am working with three (or more) options and each will have a sketch called bitx40 I also created a sub-directory for each option, in this case Munters:

As you can see the extracted directory is called bitx40-master. This is a feature of GitHub encoding the branch on into the ZIP file. Double click on the raduino_v1.27.3 Arduino file to open the sketch in the Arduino IDE. The IDE will complain about the sketch name not matching the directory name. Just click "OK" and the IDE will sort it out for you. Open the Tools menu and set the Bord to "Arduino Nano".

Before we can compile the sketch we need to ensure we have access to a library. In the readme file for the code starting at version 1.27 the PinChangeInterrup library is required. The Arduino IDE manages well know libraries very well. From the Sketch menu go to Include Library and select Manage Libraries... Enter PinChangeInterrup where is says filter your search:
Select the entry for the PinChangeInterrupt library and click Install.

You can now Verify and Compile the sketch by selecting "Verify/Compile" from the Sketch menu. This should compile without warnings or errors. Now the sketch is ready to be uploaded. Connect the Raduino to your development machine with an appropriate USB cable. If the radio is off this will power up the Raduino and start running whatever sketch was previously loaded. Using the Tools menu make sure the correct Port is selected. Consult the Arduino getting started guide if you have to. Now you can upload the sketch by selecting "Upload" from the sketch menu.

Enjoy your updated BITX40 software. Make some of the hardware modes as well. If you want a quick and easy taste of what making software mods can do try this. Somewhere around line 460 you will find the printLine function. The original looks like this:

   Display Routine
   This display routine prints a line of characters to the upper or lower line of the 16x2 display
   linenmbr = 0 is the upper line
   linenmbr = 1 is the lower line

void printLine(char linenmbr, char *c) {
  if (strcmp(c, printBuff[linenmbr])) {     // only refresh the display when there was a change
    lcd.setCursor(0, linenmbr);             // place the cursor at the beginning of the selected line
    strcpy(printBuff[linenmbr], c);

    for (byte i = strlen(c); i < 16; i++) { // add white spaces until the end of the 16 characters line is reached
      lcd.print(' ');

Change the function prototype (the first line of the function) by adding const in front of char *c like this:

void printLine(char linenmbr, const char *c) {

Then add these three lines immediately after the function prototype:

  if (linenmbr == 1 && strlen(c) == 0) {
    c = "your callsign";

This is a kludge, there is a much better way but it involves changes scattered around the source code. I have created a request to have the code included in Munters' repository. In the mean time you can get the updated source from my repository. These changes are now incorporated in Munters' repository.


No comments:

Post a Comment