Reduction of Dynamic Memory Usage

By: Tate McGeary

As stated in a previous blog, one of the immediate issues that was evident was the lack of resources on the smaller micro-controllers. The micro-controller that was chosen the Arduino Micro has the following resources:

32 kb of flash (4kb for the bootloader): 28 kb flash available for programming

2.5 kb of SRAM (dynamic memory)

While the program will require around:

14 kb of flash

4.7 kb of SRAM

That means the program uses a little under 200% of the dynamic memory. The first task was to go through the code and reduce the variable footprint. All variables that were constant where pushed into flash memory with the PROGMEM, but this did not reduce the SRAM usage enough. It was determined that a majority of the SRAM was used due to the tables that stored the movement of the BiPed. These tables could not be stored in flash in the original code due to the modification the tables went through. In the original code the tables had to be modified through the use of a calibration sub function because the frames are usually different BiPed to BiPed.

Using Robot Poser  from Dr. Dowdall, a servo calibration table is created and inserted into the original code. From there the sub-function called calibration(), will then map the servo calibration table to the proper frames used for the BiPed locomotion phase. The calibration() function is what uses a majority of the SRAM simply because it is actively modifying the tables stored on the Arduino which are rather large.

To overcome this two methods were thought of.  One is to separate the calibration() code and have an Arduino MEGA output the data to a text file on a computer. Another method is to use Processing 2.21 (a JAVA type language) or MATLAB. By looking at a flowchart of the calibration code ( see below) one can see how it can be applied or modified to fit a different platform other then the original code.

applycalibrate

Right now, the group is working on the calibration() code for the Arduino MEGA outputting data to a computer and a MATLAB code. However, a version for Processing 2.21 is being tested and completed using Dr. Dowdall’s logic, variable declarations,  and method. The project chose Processing 2.21 in case an individual wanted to reduce the footprint of the code, but didn’t have access to an Arduino MEGA or MATLAB. As Processing is a free compiler and anyone can access it, the group decided to try and get Processing to do the calibration. Here is a link to the current Processing code.