Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: MM Edit/ Backpack Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
carlm
Newbie
Newbie


Joined: 31 May 2018
Location: Australia
Online Status: Offline
Posts: 9
Posted: 21 June 2018 at 9:15am | IP Logged Copy link to clipboard   Quote carlm

Hi,
I have been putting some code for a project together for a Micromite LCD Backpack.
All was going well until I get the following message on a load and run


[55] Const DecWarning10 = 25
Error: Not Enough memory


There is nothing special about line 55 in my code.
I have cut my program right back until there is virtually nothing in it besides these declarations but the error does not seem to disappear.

I assume that this is something basic. Can anyone help?

Thanks in Advance.



Back to Top View carlm's Profile Search for other posts by carlm
 
panky
Guru
Guru
Avatar

Joined: 02 October 2012
Location: Australia
Online Status: Offline
Posts: 622
Posted: 21 June 2018 at 9:33am | IP Logged Copy link to clipboard   Quote panky

@carlm

Can you type in the MEMORY command at the prompt and report back on what it says?

panky


__________________
... all the Maximites, almost all of the MicromMites, all the MM Extremes, all the ArmMites, and loving it!
Back to Top View panky's Profile Search for other posts by panky
 
Azure
Guru
Guru
Avatar

Joined: 09 November 2017
Location: Australia
Online Status: Offline
Posts: 446
Posted: 21 June 2018 at 9:36am | IP Logged Copy link to clipboard   Quote Azure

If the code is small then you might need the check the size of your variables and usually multidimensional arrays can use up a lot.

You will need to provide some more information to get useful help.

Which LCD Backpack are you using and what version of MM Basic are you running. you can PRINT the variables MM.VER and MM.DEVICE$ if you are not sure.

You can execute the MEMORY command to see how much memory is being used.


Let us know how you go or if you need more help.


Edited by Azure on 21 June 2018 at 9:36am
Back to Top View Azure's Profile Search for other posts by Azure
 
carlm
Newbie
Newbie


Joined: 31 May 2018
Location: Australia
Online Status: Offline
Posts: 9
Posted: 21 June 2018 at 9:37am | IP Logged Copy link to clipboard   Quote carlm

Hi Panky,

I quickly did this on my cutdown code.
The result follows:
> RUN
Flash:
2K ( 3%) Program (82 lines)
17K (29%) Library
41K (68%) Free

RAM:
0K ( 0%) 0 Variables
0K ( 0%) General
50K (100%) Free
[56] Const DecWarning10 = 25
Error: Not enough memory

I am no expert but this seems to be OK.

Carl
Back to Top View carlm's Profile Search for other posts by carlm
 
panky
Guru
Guru
Avatar

Joined: 02 October 2012
Location: Australia
Online Status: Offline
Posts: 622
Posted: 21 June 2018 at 9:43am | IP Logged Copy link to clipboard   Quote panky

Carl,

Can you post the entire program you ran above - you are right re the memory, that should not be the issue.

panky


__________________
... all the Maximites, almost all of the MicromMites, all the MM Extremes, all the ArmMites, and loving it!
Back to Top View panky's Profile Search for other posts by panky
 
carlm
Newbie
Newbie


Joined: 31 May 2018
Location: Australia
Online Status: Offline
Posts: 9
Posted: 21 June 2018 at 9:50am | IP Logged Copy link to clipboard   Quote carlm

Hi, this is the entire code!


'Options
memory
option explicit
option default none
option autorun on

'Flags
const True = 1
const False = 0

'IO
const bFuelPulse = 17
CONST bFuelSolenoid = 16

'Pins
setpin bFuelPulse, din ' pullup or pulldown
setpin bFuelSolenoid, dout

'Globals used by Sub DrawButton
CONST NumberOfButtons = 30
Dim Integer key_coord(150, 5)
Dim String key_caption(150)
Dim integer key_state(150), key_pulse(150)

dim integer iMinWarning = 400
dim integer iMaxEmpty = 2000
dim integer iMinDiff = 100
dim integer iPulseCountSinceLastDose
dim integer iDoseCountWarning
dim integer iDoseCountEmpty
dim integer iLitresPerDose = 10
dim integer iDosesSinceRefill

dim string StandbyTitleA = "Standby"

dim integer iTemp

'GUI Controls (Main) - 1 > 10
Const MainNavtoEmpty = 1
Const MainNavtoWarning = 2
Const MainNavtoStandby = 3
Const MainNavtoValues = 4

'GUI Controls (Standby) - 11 > 20
const DosesReset = 11
Const StandbyNavToEmpty = 12
const StandbyNavtoStandby = 13
Const StandbyNavtoHome = 14
const StandbyNavtoValues = 15

'GUI Controls (Warning) - 21 > 30
const IncWarning1 = 21
const IncWarning10 = 22
const IncWarning100 = 23
const DecWarning1 = 24
const DecWarning10 = 25
const DecWarning100 = 26
const WarningNavToEmpty = 27
const WarningNavtoStandby = 28
Const WarningNavtoHome = 29
' = 30

'GUI Controls (Empty) - 31 > 40
const IncEmpty1 = 31
const IncEmpty10 = 32
const IncEmpty100 = 33
const DecEmpty1 = 34
const DecEmpty10 = 35
const DecEmpty100 = 36
const EmptyNavToWarn = 37
const EmptyNavtoStandby = 38
Const EmptyNavtoHome = 39
' = 40

'GUI Controls (Values) - 41 > 50
const IncMinDiff1 = 41
const DecMinDiff1 = 42
const IncMinWarn1 = 43
const DecMinWarn1 = 44
const IncMaxEmpty1 = 45
const DecMaxEmpty1 = 46
Const ValuesNavtoHome = 47

Back to Top View carlm's Profile Search for other posts by carlm
 
Grogster
Guru
Guru
Avatar

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 6648
Posted: 21 June 2018 at 9:52am | IP Logged Copy link to clipboard   Quote Grogster

Hmmmmm.....very interesting. I agree - this should not be an issue.
I'm with Panky and Azure - please post your entire code, so we can examine it.

EDIT: Ha! Beat me!

EDIT:

Dim Integer key_coord(150, 5)
Dim String key_caption(150)
Dim integer key_state(150), key_pulse(150)


Your single string DIM is sucking up most of the memory. Each string reserves 256 bytes of memory, so 256 x 150 = 38,400 - 38K of RAM right there in that one single command.

Try adding LENGTH commands to your strings. Lets say you KNOW the strings will be no more then 50 bytes: Dim String key_caption(150) LENGTH 50

That will create a single array of 150 elements, but each one will only be 50-bytes long.

Edited by Grogster on 21 June 2018 at 10:00am


__________________
Smoke makes things work. When the smoke gets out, it stops!
Back to Top View Grogster's Profile Search for other posts by Grogster Visit Grogster's Homepage
 
Azure
Guru
Guru
Avatar

Joined: 09 November 2017
Location: Australia
Online Status: Offline
Posts: 446
Posted: 21 June 2018 at 10:08am | IP Logged Copy link to clipboard   Quote Azure

Depending on what chip you are using those arrays especially the string will take up a lot of the available memory.

You need to execute the memory command after you get the error.


@Grogster We are typing at the same time

Edited by Azure on 21 June 2018 at 10:09am
Back to Top View Azure's Profile Search for other posts by Azure
 
panky
Guru
Guru
Avatar

Joined: 02 October 2012
Location: Australia
Online Status: Offline
Posts: 622
Posted: 21 June 2018 at 10:53am | IP Logged Copy link to clipboard   Quote panky

Carl,

Grogster/Azure certainly have the problem right - your variables use up 51K and the MM2 chip only has 50K available.

Even with the suggestions above of using the LENGTH modifier in your DIM statement, your program looks to be moderately complex and if you want to take advantage of using the GUI commands, you might consider moving to the MM+ Backpack (Silicon Chip Nov 2016). With your program as is, you only use about half the variable memory of an MM+ so with some tidying as suggested by others, you will have tons of room for expansion.

panky


__________________
... all the Maximites, almost all of the MicromMites, all the MM Extremes, all the ArmMites, and loving it!
Back to Top View panky's Profile Search for other posts by panky
 
carlm
Newbie
Newbie


Joined: 31 May 2018
Location: Australia
Online Status: Offline
Posts: 9
Posted: 21 June 2018 at 11:09am | IP Logged Copy link to clipboard   Quote carlm

Thanks Guys,
I through some smaller values straight into my original code arrays and it seems to
be working again.



Back to Top View carlm's Profile Search for other posts by carlm
 
Grogster
Guru
Guru
Avatar

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 6648
Posted: 21 June 2018 at 11:15am | IP Logged Copy link to clipboard   Quote Grogster

String arrays are a real memory gobbler.
Geoff added the LENGTH option to the DIM command for this reason. Earlier versions of MMBASIC did not have that option, and......well.....you just found out why it is a good thing to have in the language.

__________________
Smoke makes things work. When the smoke gets out, it stops!
Back to Top View Grogster's Profile Search for other posts by Grogster Visit Grogster's Homepage
 


If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Search the forums using Google.
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1406 seconds.
Privacy Policy     Process times : 0.03, 0, 0, 0.11