ConfigurableFirmata RAM usage
Opened this issue · 0 comments
From @soundanalogous on August 12, 2013 3:35
I've been looking into the RAM usage by the various feature classes (utility directory) in ConfigurableFirmata. Here's what I found.
With all features included:
Available RAM ~ 625 bytes (on an Arduino Uno). My test sketch reports 598 bytes but that includes a 25 char string to send the free ram message.
RAM usage by feature (including any dependencies) on an Arduino Uno:
Feature class(s) | RAM usage | Note |
---|---|---|
DigitalInputFirmata + DigitalOutputFirmata | 41 bytes | |
AnalogInputFirmata | 18 bytes | |
AnalogOutputFirmata | 14 bytes | |
ServoFirmata | 40 bytes | + 5 bytes per servo instance |
I2CFirmata | 215 bytes | 140 of the bytes are error strings |
OneWireFirmata | 234 bytes | likely due to large lookup table in OneWire.cpp |
StepperFirmata | 28 bytes | + 68 bytes per stepper instance |
FirmataExt | ? | was unable to isolate - may be a bug |
FirmataScheduler | 20 bytes |
ServoFirmata, StepperFirmata and OneWireFirmata each use dynamic memory allocation. A stepper instance (create a new stepper in a client application) is fairly large... memory fragmentation may be an issue if using all firmata features and multiple stepper motors. The Servo ram usage is so small (5 bytes per instance) that there's little risk of issues due to memory fragmentation. I'll see if I can make any improvements to the stepper implementation.
I was not able to test the RAM usage per OneWire device instance. @ntruchsess is this something you can look into?
My process for obtaining the RAM usage was to include the FreeMemory class (pulled out of the ArduinoUnit library) with the ConfigurableFirmata sketch and send the free ram amount via sendString to a client application. I then reduced the included features to the bare minimum (FirmataReporting) and then added a single feature class at a time, recorded it's memory usage the removed the feature and repeated for each feature class. I've uploaded my ConfigurableFirmataMemCheck sketch. If you want to run it make sure you install the latest configurable
branch from this repo. Then copy ConfigurableFirmataMemCheck to your Arduino Sketch directory, upload and run. You'll need a Firmata client library that implements the FirmataString protocol.
Copied from original issue: firmata/arduino#81