How do you recycle VAR I need to free up some RAM in a Basic Stamp (Resloved)
Hi EveryOne
This is a project that I have been ·ask to do·by employer
As of right now I can not give all of the details.......................
................·but when the Project is done I will share with all of you on the Forum
I know that I have·This a another Post but this is a different question
http://forums.parallax.com/showthread.php?p=804156
http://forums.parallax.com/showthread.php?p=804554
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·that you may have and all of your time finding them ![smile.gif](http://forums.parallax.com/images/smilies/smile.gif)
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/5/2009 2:09:55 AM GMT
This is a project that I have been ·ask to do·by employer
As of right now I can not give all of the details.......................
................·but when the Project is done I will share with all of you on the Forum
I know that I have·This a another Post but this is a different question
http://forums.parallax.com/showthread.php?p=804156
http://forums.parallax.com/showthread.php?p=804554
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
![idea.gif](http://forums.parallax.com/images/smilies/idea.gif)
![smile.gif](http://forums.parallax.com/images/smilies/smile.gif)
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/5/2009 2:09:55 AM GMT
Comments
Use workVal in all your routines where the value does not need to be saved. Even when it does need to be saved you can copy it.
importantValue = workVal
Aside from optimizing your code or using a different Stamp, I don't know what else you could do.
Rich H
importantValue = workVal
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
workVal VAR word
Rich H
See
http://forums.parallax.com/showthread.php?p=696777
phil
Thank For sharing that post link
Time···· ·VAR· ·WORD
S_Time·· VAR·· Time
There is one thing about using this is that
1·· You have to have them neat to each other or you get an error need a·label· for one of them ·S_Time or Time
··· ·I can not remember which gave the error
2 You can only use this if that VAR is not need in two places at one time
This will work if let say that you want to set a CON on the fly and use a switch to set the CON· and you go back to you main routine then this will
work
Time· VAR used in one place then you want use the S_Time VAR two command line down from the first one
·· I found out the Hard Way· this dose not work
·It also warn you about this in the on-line help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/5/2009 2:18:15 AM GMT
Perhaps I mislead you. You can't free up RAM in the BS2. The use
of aliasing (giving the same memory location two names) is of more
use with the multi-slot Stamps such as BS2P, BS2x, and BS2Pe.
Zoot was trying to demonstrate two things:
1) create a Byte array named Time
2) Using an alias to access the first byte in that array:
The variable Time must be defined first. The alias secs does not have
to be defined next. It may be defined anywhere later in the code.
Multi-slot Stamps have much more program space, but they still have
only 26 bytes of RAM. However, they also have a scratchpad memory
which can be used to gain space for your variables, but the process
isn't straight forward.
Tracy Allen has an excellent discussion of how to make use of the
scratchpad memory at:
www.emesystems.com/BS2SX.htm
phil
In my case I have a routine that has two routine one routine runs when the switch =·1
the other runs when the swich·= 0
This allow me·to set a value that is need in the main routine
This is not·ALL of the code routines and not all of the VAR are listed in this Demo code and as you can see that these two·routines use this much RAM··the SET·routine ·take 5 WORDs and 1 BYTE
To add the SET routine with the compled code routine that I am using it put me 3 WORDs over so now what am I going·to do is reuse some VAR
that are not need in the SET routine that are only need in the main routine
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/5/2009 3:48:00 AM GMT
You can divide seconds by 60, if no remainder then one minute has passed. Same with dividing by 3600, then one hour has passed.
It looks like PD is the same as SL which is the same as RC_set
Does X always equal f ** 1000, if so, you don't need x.
It seems really difficult to me to try to reduce you VAR space without knowing how those VARs are used in other parts of your code.
Rich H
The main code should start off, when in0=1, with a READ of x,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
·Reusing·these·two·variables·temporarily,·alias·name·them·if·it·makes·you·feel·better
I would feel better if I used· alias·name·it would be easyer for to know what VAR ·I am using and what it is·for
·I did think about just using what VAR not being used at that with out changing the name
Thanks for sharing this the way you have this help me·understand more about what is happing when
···PD·=·PD·-·RC_min·MAX·RC_diff·················································· '·Make·sure·PD·falls·within·range·of·the·CONstants
··················································· '·----·binary·division·loop·----
····FOR·J=15·TO·0····································································· ·'·16·bits···NOTE:··J·only·needs·to·be·a·NIB
······PD=PD//RC_diff<<1··························································· · ·'·remainder*2·<---·note·the·divisor·is·constant,·PD·dividend·is·reduced·directly
······x.BIT0(J)=PC/RC_diff·····························································'·next·bit···<-·using·x·for·the·quotient
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
I'm glad our forum gurus took good care of you! Just FYI for others who read this post:
Two techniques to save variable space are introduced in the Stamps in Class text Applied Robotics with the SumoBot·(a free download). One is·the use of a multipurpose·"temp" variable, and the other is the use of a single byte·variable as a flag register·to quickly·evaluate and act upon the state of·6 sensors.
Have fun,
-Steph Lindsay
Editor, Parallax Inc.