Friday, November 3, 2023

Brick Buddy ONE Upgrade


For some unknown reason, I started upgrading the firmware on the Brick Buddy ONE. Since I had done all of this software work on consolidation and refactoring, I thought lets do it.  Plus I need a 4 motor controller and Brick Buddy TWO is still a long way from being ready.  Thus during the road trip, I started working on upgrading and refactoring.

Brick Buddy ONE was done over five years ago and was written using the C18 compiler.  First task was to transition to the XC8 compiler.  Most of this went fairly smooth as I don't try to rewrite the whole thing and then start compiling.  I stripped it down to just the startup code and worked on it until it compiled without error.  This is the main loop

    while(1)
    {
        ProcessIO();
        PWMCtrl_Tasks();
        SCRIPT_Tasks();
        BT_Tasks();
        USB_AppTasks();
        APP_Tasks();
        BlinkStatus();
    }//end while

So what I do is comment all of these out and then start adding them in one at a time.  Solve the compile issues and move on to the next.  By the end of the road trip, I had left to do Script and Bluetooth.

Before proceeding on adding the remainder in, I connected to the USB port and started testing out the USB interface to the PC program.   Once the LEDs and Motors worked, it was time to get back including the remainder of the code.

One interesting thing that happened was that uint16_t type could not be found.  I got around it by using uint32_t since I was only compiling and not actually running at the time.  Eventually to solve this error I had to delete the project and start over again.  There must have been something in the project file from C18 that was getting in the way.  Once I built the new project, uint16_t no longer caused issues.

Next issue was FLASH size.  The PIC18F45K50 only has 32K of program FLASH, compared to the 64K of better in all the other controllers.  Changing the controller is not an option for the simple reason that the 18F45K50 is the only crystal less USB PIC.  There are multiple larger USB PICs, but all require a crystal for USB 2.0.  At optimization level 0, I exceeded the memory towards the end of the BT implementation and before the Script implementation.  At optimization level 1, I have about 7K left after BT implementation,  Hopefully that will be enough, else I will have to buy a monthly XC8 license to compile this.  Also means that the bootloader may not fit any more, but we shall see.  I also need to make a pass through the code and see if there is any compaction I can do.

Right now I have basic USB interface working and some of the BTLE interface working.  Maybe another week to finish this.

What do I get out of this.  Well a common User Interface for both the PC and Android.  Right now, the Android Interface only works on the new designs and I have limited control over all of the Brick Buddy ONEs I am using.  




No comments:

Post a Comment