Skip to content

Memory_Consumption_Infos

elral edited this page Mar 15, 2023 · 5 revisions

Device Buffer, usage per device

Fast IO Normal IO
analog device 29 byte 29 byte
button 6 byte 4 byte
digital input MUX 9 byte 6 byte
encoder 35 byte 31 byte
input shifter 17 byte 11 byte
lcdDisplay 18 byte 18 byte
output 2 byte 2 byte
Output Shifter 15 byte 9 byte
Led Segment 28 byte 22 byte
Servos 23 byte 23 byte
Stepper 14 byte 14 byte

Memory consumption

Mega:

NormalIO

RAM:   [======    ]  55.3% (used 4528 bytes from 8192 bytes)
Flash: [=         ]  10.8% (used 27534 bytes from 253952 bytes)

-> 226.418 bytes left

FastIO

RAM:   [======    ]  55.4% (used 4540 bytes from 8192 bytes)
Flash: [=         ]  11.2% (used 28354 bytes from 253952 bytes)

-> 225.598 bytes left

Device Buffer 1496 byte

Name Buffer with 1000 byte can be freed up

Bytes which are requested from the device buffer

Device FastIO NormalIO
40 Outputs: 80 byte 80 byte
68 Buttons: 408 byte 272 byte
4 LEDSegment: 112 byte 88 byte
20 Encoder: 700 byte 620 byte
10 Stepper: 140 byte 140 byte
10 Servos: 230 byte 230 byte
2 LCD: 36 byte 36 byte
16 AnalogIn: 464 byte 464 byte
4 OutputShifter: 60 byte 36 byte
4 InputShifter: 68 byte 44 byte
4 MUX: 36 byte 24 byte

Micro:

NormalIO

RAM:   [========  ]  76.6% (used 1960 bytes from 2560 bytes)
Flash: [==========]  97.4% (used 27916 bytes from 28672 bytes)

-> 756 bytes left

FastIO

RAM:   [========  ]  77.0% (used 1972 bytes from 2560 bytes)
Flash: [==========]  100.2% (used 28718 bytes from 28672 bytes)

-> exceeds Flash!!!

Device Buffer 440 byte

Name Buffer with 350 byte can be freed up

Bytes which are requested from the device buffer

Device FastIO NormalIO
18 Outputs: 36 byte 36 byte
18 Buttons: 108 byte 72 byte
1 LEDSegment: 28 byte 22 byte
9 Encoder: 315 byte 279 byte
3 Stepper: 42 byte 32 byte
3 Servos: 69 byte 69 byte
2 LCD: 36 byte 36 byte
5 AnalogIn: 145 byte 145 byte
2 OutputShifter: 30 byte 18 byte
2 InputShifter: 34 byte 22 byte
3 MUX: 27 byte 18 byte

Uno/Nano:

NormalIO

RAM:   [========= ]  86.6% (used 1773 bytes from 2048 bytes)
Flash: [========  ]  83.3% (used 25598 bytes from 30720 bytes)

-> 5.122 bytes left

FastIO

RAM:   [========= ]  87.2% (used 1785 bytes from 2048 bytes)
Flash: [========= ]  86.0% (used 26418 bytes from 30720 bytes)

-> 4.302 bytes left

Device Buffer 286 byte

Name Buffer with 220 byte can be freed up

Bytes which are requested from the device buffer

Device FastIO NormalIO
18 Outputs: 36 byte 36 byte
18 Buttons: 108 byte 72 byte
1 LEDSegment: 22 byte 22 byte
9 Encoder: !!!315 byte 279 byte
2 Stepper: 28 byte 28 byte
2 Servos: 46 byte 46 byte
2 LCD: 36 byte 36 byte
6 AnalogIn: 174 byte 174 byte
2 OutputShifter: 30 byte 18 byte
2 InputShifter: 34 byte 22 byte
3 MUX: 27 byte 18 byte

Pico:

NormalIO

RAM:   [=         ]   7.1% (used 18504 bytes from 262144 bytes)
Flash: [          ]   3.6% (used 74892 bytes from 2093056 bytes)

-> 2.018.164 bytes left

FastIO

RAM:   [=         ]   7.1% (used 18536 bytes from 262144 bytes)
Flash: [          ]   3.6% (used 75220 bytes from 2093056 bytes)

-> 2.017.836 bytes left

Device Buffer 1496 byte

Name Buffer with 1000 byte can be freed up

Bytes which are requested from the device buffer

Device FastIO NormalIO
26 Outputs: 52 byte 52 byte
26 Buttons: 156 byte 104 byte
4 LEDSegment: 112 byte 88 byte
8 Encoder: 280 byte 248 byte
6 Stepper: 84 byte 84 byte
8 Servos: 184 byte 184 byte
2 LCD: 36 byte 36 byte
3 AnalogIn: 87 byte 87 byte
4 OutputShifter: 60 byte 36 byte
4 InputShifter: 68 byte 44 byte
4 MUX: 36 byte 24 byte

Time consumption

Atmega | Pico (measurements from month ago)

Atmega NormalIO Atmega FastIO Pico NormalIO Pico FastIO Remark
Outputs 11 us 11 us only writing one output, analogWrite(), no changes
Buttons 9 us 3 us 2 us only reading one input
224 us 220 us (??) reading AND evaluating one input, must be wrong for the Pico
LEDSegment 6.3 ms 1.3 ms 1.3 ms 2x8 daisy chained
Encoder 23 us 10 us 3 us only reading one encoder
290 us 22 us reading AND evaluating one
Stepper 23 ms 23 ms 3 us not changed to FastIO
Servos
LCD 12 ms 12 ms 9.7 ms limited by I2C
AnalogIn 122 us 122 us 11 us calculating average value
OutputShifter 0.74 ms 0.16 ms 4x8bit daisy chained
InputShifter 0.5 ms 0.14 ms 4x8bit daisy chained
MUX 2.4 ms 0.9 ms 4 x 16 bit
Pico (measurements from month ago)

Readin time for Encoders:

  • 1ms: actual status, works with only very very less detection of wrong direction for fast turning
  • 2ms: very less detection of wrong direction for fast turning -> OK
  • 3ms: less detection of wrong direction for fast turning
  • 4ms: same as 3ms
  • 5ms: slow turning is OK, fast turning with multiple detection of wrong direction
  • 10ms: even slow turning does not work

Summary:

  • Mega does not have any Flash or RAM limitations for now.

  • ProMicro has 756 bytes in Flash and 600 bytes in RAM left

    • very likely that no additional device will fit into the Flash
  • Uno/Nano has 5.122 bytes in Flash and 275(263) bytes in RAM left

    • at least the name buffer of 220 bytes are required for additional devices
    • 506 bytes could be used -> 16(14) encoder can be used. 6 are available on I/O's (18 pins - 5 pins from MUX device) so 10(8) encoders could be connected to an MUX
  • Pico has plenty Flash and RAM, no limitations for now.

    (numbers in() are for FastIO)

Consequences for encoders:

  • Encoders on MUX are possible for Mega and Pico, Fast IO could be used from sight of memory and is usefull at least for the Mega (8Mhz!) due to the amount of possible devices. For now 20 encoders can be defined for the Mega, if really more encoders are required the maximum could be increased (connected to I/O's).
  • for SimVim users (using a Mega) encoders on MUX are helping to move to Mobiflight
  • for Pico users (very limited for now) it could be a requirement in the future
  • Encoders on MUX for the Uno/Nano is limited (due to RAM consumption and available pins) to one MUX with 8 encoders and 6 encoders connected to I/O's.
  • Encoders should be read in within 2ms, delays due to output devices are acceptable but the main loop time should not be exceeded