Questions about abdrive lib
Rsadeika
Posts: 3,837
What is it about the abdrive library, that when added it pushes the program size by ~10K? I have been trying to create a program that would drive the ActivityBot using the least amount of code size, but it seems like the abdrive lib is responsible for a lot of the code size increase.
After looking at the abdrive lib itself, I cannot determine if it is this:
In a very basic abdrive program, it shows "Code Size 13,000 bytes (16,820 total)", so has there been another 3,820 bytes added making even less room for program expansion? I am still trying to figure out how much RAM is really being used. Other than that ...
Ray
After looking at the abdrive lib itself, I cannot determine if it is this:
#include"simpletext.h" #include "fdserial.h" #include <string.h>that pushes up the code size. Another large library, code size, is the use of the SD lib, when you combine the SD lib with the abdrive lib you really do not have very much room left to develop an exciting ActivityBot. It almost seems that the availability of XMMC should be mandatory, or we revert to programming in PASM.
In a very basic abdrive program, it shows "Code Size 13,000 bytes (16,820 total)", so has there been another 3,820 bytes added making even less room for program expansion? I am still trying to figure out how much RAM is really being used. Other than that ...
Ray
Comments
If you use Project Manager you can right-click on a file-name and use Show Map File to see what's eating memory.
libabdrive is using 0x12b0 or 4784 bytes.
Ray
I am not really sure what this comment means, I thought the problem was that using cogs in XMMC resulted in some very sluggish run times? If you create a COGC or PASM version and then run it in XMMC mode you would get the same sluggish response, correct. So I am not sure why you would not just have the availability of writing all your cog(s) necessary code in XMMC to begin with?
It looks like there is a very heavy reliance on CMM mode, but with the hefty libraries that have to be used, that is starting to fall short of being a good remedy. Just my thoughts, I am sure that I am probably the only one that sees this as a problem.
Ray
The comment is "XMMC does not support launching LMM/CMM code into other cogs, which is what the abdrive library does...."
Propeller GCC supports running a function in a separate COG just like Spin does. This is only available at the moment in CMM/LMM modes in the release. In a future release, we will also be able to run a function in a separate COG in XMM modes.
Hope that helps.
--Steve
I am sorry for leaving abdrive in such a state. I am just about done with my other tasks and will post a smaller memory footprint version immediately after that.
The encoder counting, feedback control system, servo control, and trim compensation are all stuffed into one function named encoders that runs in a separate CMM cog. You will see the values of PHSA and PHSB set near the end of abdrive.c. Those get started as servo pulses that the A and B counter modules complete while the cog's code moves on to rechecking the encoders, recalculating distance, correcting for distance errors, etc.
Andy
Ray
My first pass at reducing abdrive's footprint in Main RAM program memory reduced typical navigation programs by 6.5 k.
I still have lots of updates to do, but figured you might be interested in testing it since it makes lots of extra room for the applications you seem to be interested in writing. So a slightly modified example of your app from MyActivityBot Post #51 is attached.
19.8 kB - With current abdrive
13.3 kB - With abdrive in attached zip
6.5 kB - Net savings from first edit
Keep the Footprint Small
To take advantage of the whole 6.5 kB, avoid print, dprint, sprint and scan unless you actually have to print floating point values. So far, all I see are decimal values in the app, so use printStr and printDec instead. You are already using writeStr and readStr in place of dprint, which also saves space. For more info on these functions, click Help in SimpleIDE, select Simple Library Reference, then follow the simpletext.h link.
Andy
Alright, let's start with the downsized abdrive library and your app from MyActivityBot Post #51. Then, we can add SD card datalogging of IR remote key presses to this mix. That should make a decent example because your app is already using lots of library features:
- abdrive uses another cog to monitor encoders, feedback system calculations, and servo control
- abdrive also uses I2C and EEPROM libraries to load linear interpolation tables to improve responses to drive_speed and other calls
- fdserial for communication in another cog + simpletext for communication with PC terminal through XBee radio
- ping for simplifying Ping))) Ultrasonic Sensor measurements
- sonyremote for monitoring and processing IR remote button presses
...and the application is also already doing a number of tasks, including:- Processing TV remote commands and making the ActivityBot respond accordingly
- Processing commands from PC sent wirelessly to an XBee on the ActivityBot, which also makes the ActivityBot respond accordingly
- Reporting status wirelessly to PC via XB
- Reporting status wired to SimpleIDE Terminal (when connected)
- On command, switch into autonomous mode and roam with Ping))) Ultrasonic Distance Sensor
The example is attached, and again, it uses the downsized abdrive, and following the rules from my previous post, it takes 24.4 kB. This leaves 8 kB for further expanding your application. Given everything it's already doing, I think you'll be able to use that space to significantly expand the program's feature set.We'll also continue to make the Simple Libraries more compact. The second and third passes through abdrive should free up more space, and we'll look into a lighter SD option as well.
Ray