Comparing the Grand Central to ItsyBitsy M4, CircuitBrains Deluxe - Program Space Questions

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
xanatos
 
Posts: 110
Joined: Thu Jun 18, 2009 3:09 pm

Comparing the Grand Central to ItsyBitsy M4, CircuitBrains Deluxe - Program Space Questions

Post by xanatos »

I'm trying to compare the ItsyBitsy M4 Express (IBM4E), CircuitBrains Deluxe (CBD), and Grand Central (GC), in terms of space for user code.

The IBM4E:

ATSAMD51 M4
2MB SPI Flash
120 MHz
512kb flash, 192kb RAM

The CBD:

ATSAMD51 M4
8 MB SPI Flash
120 MHz
512kb flash, 192kb RAM

Those two have a different listed "SPI Flash" (2MB vs 8MB), but the same "512kb flash, 192kb RAM"

The GC:

ATSAMD51 M4
8 MB SPI Flash
120 MHz
1MB Flash, 256kb RAM

This also has "8 MB SPI Flash", but shows "1 MB Flash, 256kb RAM"

My issue is that with all the sensors, displays, etc that I am running on the IBM4E, I am nearly out of space. I have a few CircuitBrains Deluxe. But I am not sure if those actually have more space for user programs than the IBM4E. It *looks* like the Grand Central does indeed have more space (twice as much?), but I want to be sure before I order.

Thanks for clarification!

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Comparing the Grand Central to ItsyBitsy M4, CircuitBrains Deluxe - Program Space Questions

Post by dastels »

The first question is what programming language are you using. How memory is used depends on that.

Independent of that, "1 MB Flash, 256kb RAM" (in the case of the GC) is what's on the MCU. The SPI flash is an external to the MCU. The big advantage of having external flash is for file storage, especially when it's exposed as a USB drive.

Dave

User avatar
xanatos
 
Posts: 110
Joined: Thu Jun 18, 2009 3:09 pm

Re: Comparing the Grand Central to ItsyBitsy M4, CircuitBrains Deluxe - Program Space Questions

Post by xanatos »

Apologies, yes, should have stated I am using CircuitPython. Not exactly sure of how much of the stated memory that takes up. Thanks!

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Comparing the Grand Central to ItsyBitsy M4, CircuitBrains Deluxe - Program Space Questions

Post by dastels »

OK. With CircuitPython, RAM is the key to a running program. CircuitPython (the C program that's in the UF2) is stored in flash (like any C/C++ program) but CircuitPython code is stored in RAM once it's compiled to bytecode (either as a precompiled MPY file or a PY file compiled when loaded). Flash not used by the CircuitPython runtime is used for the CIRCUITPY flash drive. Additional SPI/external flash gives you a bigger flash drive, which means more library code and/or data files (bitmaps, sounds, fonts, etc).

So if you want to write larger CircuitPython program (or with a lot of libraries) you need more RAM. If you have lots of library code and/or data files, you need more flash. The GrandCentral has plenty of both. Other MCUs/boards have more or less of each.

My rule of thumb is to use a board with as much of both as fits budget, space, etc.

At the same time consider clock frequency: the fast it is the better performance you'll get. This isn't usually a big deal with C/C++ code, but is far more relevant for CircuitPython code. Basically CircuitPython loves speed and memory.

Dave

User avatar
xanatos
 
Posts: 110
Joined: Thu Jun 18, 2009 3:09 pm

Re: Comparing the Grand Central to ItsyBitsy M4, CircuitBrains Deluxe - Program Space Questions

Post by xanatos »

Thanks, that confirms my throughts I'll need the GC. I get allocation errors once I add more stuff... here's my current list of includes - and I have at least six more to go:

Code: Select all

import board
import busio
import time
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogOut, AnalogIn
from adafruit_display_text import label
import microcontroller  # for uP temp measurements
import gc # For memory space checks
import adafruit_ds3231 # RTC, Hi Precision  I2C 0x68
import adafruit_mmc56x3 #I2C 0x30
import adafruit_scd4x # Temp, Humid, True CO2 ppm  I2C 0x62 (12 bit DAC?)
import adafruit_bme680 # Pressure (hPa), Temp, Humid, VOC+ 0x5e
import adafruit_tlv493d # 3-Axis Magnetometer, I2C 0x5e
import DFRobot_EOxygenSensor as ox
import adafruit_focaltouch  # I2C 0x38
import adafruit_ili9341 # SPI (Display)
import math
import terminalio
import displayio
from adafruit_rgb_display import color565
import sdcardio
import storage
import pwmio
import rotaryio
I'm displaying free space to keep tabs on what's left:

Code: Select all

gc.collect()
freeS = str(gc.mem_free())
And my current script length is 670 lines.... There's a LOT of stuff going on in this project lol

Thanks for the info & clarification!

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Comparing the Grand Central to ItsyBitsy M4, CircuitBrains Deluxe - Program Space Questions

Post by dastels »

The GrandCentral is a great choice for large projects. See https://learn.adafruit.com/Memory-savin ... cuitPython for advice on reducing memory (RAM) use if you run into the problem again (probably not on the GrandCentral).

Dave

User avatar
xanatos
 
Posts: 110
Joined: Thu Jun 18, 2009 3:09 pm

Re: Comparing the Grand Central to ItsyBitsy M4, CircuitBrains Deluxe - Program Space Questions

Post by xanatos »

Thanks for that link, great stuff especially turning my script into a .mpy file. I'm not using any fonts other than the default built-in, and no bitmaps - it's just all code with some text labels - just a lot of it. For a microcontroller, it's a huge bunch of stuff. The GC will handle it I'm pretty sure, although I'll have to increase the size of my enclosure a little bit to accommodate... fortunately it's easy in FreeCAD to edit what I have to work, and re-print overnight.

Thanks again for all, as usual! :)

Dave

PS, ordered two GCs :)

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”