Out of RAM Space on Custom Program

Posted by Frank Wang.

Student on team #115, Monta Vista Robotics Team, from Monta Vista High School and NASA Ames and 3COM.

Posted on 2/10/2000 10:11 PM MST

Is any one else experiencing lack of RAM space on their custom program? We are wondering if there is a way to optimize our code so we can declare more variables. We used most of our electronic kit parts, and we lack variable space to control two more speed controllers.

Posted by Nate Smith.

Other on team #66, GM Powertrain/Willow Run HS, from Eastern Michigan University and GM Powertrain.

Posted on 2/10/2000 11:55 PM MST

In Reply to: Out of RAM Space on Custom Program posted by Frank Wang on 2/10/2000 10:11 PM MST:

: Is any one else experiencing lack of RAM space on their custom program? We are wondering if there is a way to optimize our code so we can declare more variables. We used most of our electronic kit parts, and we lack variable space to control two more speed controllers.

In an earlier version of our program, I removed some of the variables that I wasn’t using(mainly the wheel variables for the ports), in order to have room to declare more. Just be sure to remove all references to the variables, as well as setting the c values for those variables to 0…

Nate

Posted by Mike Gray.

Engineer on team HOT from Huron Valley Schools sponsored by GM Milford Proving Ground.

Posted on 2/11/2000 5:44 AM MST

In Reply to: Out of RAM Space on Custom Program posted by Frank Wang on 2/10/2000 10:11 PM MST:

: Is any one else experiencing lack of RAM space on their custom program? We are wondering if there is a way to optimize our code so we can declare more variables. We used most of our electronic kit parts, and we lack variable space to control two more speed controllers.

Here’s a few possibilities, short of deleteing variables in the intialization routine:

  1. Reuse local variables. If they don’t need to be global, use them again in other routines.
  2. Can some of your new variables be constants instead? Constants don’t use any RAM.
    3 Declare variables only as big as they truly need to be. If a variable value will never exceed 255, make
    sure its declared as a byte variable. If all you need is a nibble or a bit, declare them respectively. In short, don’t use a bigger bucket than you really need.
  3. Use one of the other seven programs available on the SX. Pass variables from one program to another using the ‘scratchpad RAM’. You will take a throughput hit, but its not that bad.

Posted by Mike Sperber.

Engineer on team #175, Buzz, from Enrico Fermi High School and UTC/Hamilton Sundstrand Space Systems.

Posted on 2/11/2000 6:00 AM MST

In Reply to: Out of RAM Space on Custom Program posted by Frank Wang on 2/10/2000 10:11 PM MST:

You could also look at the hardware side of things. See if there are some places where you could ‘Y’ 2 PWMs together.

Good Luck
-mike

Posted by Innovation First, Inc.

Engineer on team #883 from Texas.

Posted on 2/11/2000 4:19 PM MST

In Reply to: Re: Out of RAM Space on Custom Program posted by Mike Sperber on 2/11/2000 6:00 AM MST:

The BS2SX chip in the Robot Controller has a 64 byte ‘scratchpad’ that you can use to store and retrieve variables from. This should help solve any RAM problems you have. The Parallax document ‘The BASIC Stamp IIsx documentation v1.3’ on the Parallax web site has the details on the new ‘GET’ and ‘PUT’ commands used to access the scratchpad.

http://www.parallaxinc.com/