[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 

Reduce RAM usage RSS feed
Forum Index » IoAbstraction & TaskManagerIO
Author Message
TheTomRom


Joined: Mar 26, 2020
Messages: 10
Offline
Hi Dave,

I have finally continued with a little hobby project (we talked back in 2020 I think) and I ran into problems with RAM during runtime, using a pro micro (2560 bytes of RAM, 28672 bytes of Flash) with IoAbstraction version 1.4.11

The Situation: After compiling, I have about 400 bytes of free RAM - not a lot, but everything works fine. But I have to add some more code and as soon as I add that code and initial free RAM is lower than 370 bytes, the program stops at runtime. This seems to happen during encoder initializing (found out by "debugging" via Serial.print).

What I have tried: I am aware of the F-macro and putting stuff into the EPROM via PROGMEM. I have used that whereever possible, I think.

My questions are:
1) Is there any documentation how to deactivate parts / methods of the IoAbstraction library or is this even possible?
2) Is there documentation on the size for every switch or encoder object needed? I think I read somewhere that it is 6 bytes per switch but I am not sure about the encorders. I am using about 40 switches and 8 rotary encoders.
3) Should I upgrade the IoAbstraction library or stay with my version (1.4.11)? Which one is likely to use less RAM?

Thanks in advance,
Tom
TheTomRom


Joined: Mar 26, 2020
Messages: 10
Offline
Hi Dave,

I have updated to the latest version of ioAbstraction and I was super happy that everything worked out of the box - many thanks and congrats to an apparently super well-written and maintained code!!!!

Also, available RAM increased a lot with the new version (84% usage down to 54%) which is great. However, it also uses more flash memory which is at 99% with the current code - even without some of the things I still need to put in. I used to see the memory limitations of my pro micro as a challenge but either I am just wanting too much or I am not skilled enough to code more effienciently. Regardless, I am thinking about upgrading the board. I could not find an arduino board with more flash and RAM that can also work as HID (I am sending keystrokes to the PC with it).

Do you have a recommendation? I was looking at the newer teensy - seems overkill but prices are similar to most arduino boards. Obviously, I would like to continue using your library but I have no chance of estimating whether that would work or not. Can you give me a hint? List of teensys is here: https://www.pjrc.com/teensy/techspecs.html
davetcc


Joined: Jan 19, 2019
Messages: 637
Offline
Each key takes 10 bytes these days, the documentation should be updated, but it has been that way for a long time, ever since the onRelease functionality was added; when two extra bytes were needed for the pointer. So with 40, you'd need around 1600 bytes to store all those key states. I mean if the old version works for you, you could just stick with it.

I've noticed that one thing that was missed when moving to simple collections to do the allocations (which should have a very modest memory overhead) was the ability to set the number of switches upfront, meaning it will reallocate each time you exceed the current array, default start is 5 for AVR. I'll add MAX_KEYS back in the next version.

It is possible on such a small board that even 10 bytes per switch is too much, as even without the other overheads of the library that is already 1600 bytes out of 2500. To be honest, we've moved on and would not really consider an AVR in a production system these days, I keep the boards for testing with as I know many still rely on it. The power usage and price of much more capable devices have leveled out, and they are available in small pacakge configurations ready to put into a product. In terms of HID I think many STM32 devices can act as a HID using Stm32Duino. I also think ESP32-S2 does so too.

In terms of code being compiled out, the linker does that by default, only compiling in the parts you are using. It is probably simple-collections list accounting for the difference.
davetcc


Joined: Jan 19, 2019
Messages: 637
Offline
So from a quick look around:

* at least some STM32 boards have HID capability
* some Teensy boards have HID capability
* some Seeed studio SAMD boards seem to have HID capability
* probably most mbed based Arduinos (EG Nano 33 BLE)
* ESP32-S2 has HID capability
* [EDIT] Most SAMD based Arduino including MKR boards use cortex-0 with the ability to enter very low power states, even have an example for task-manager low power integration.


[EDIT] I wouldn't think of it as overkill, a cortex-0 is probably close to the same power requirement, with enough flash and memory to comfortably fit a large sketch. They are also all fairly inexpensive (some dirt cheap) and work with the Arduino framework.
 
Forum Index » IoAbstraction & TaskManagerIO
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.