View Single Post
  #3   Spotlight this post!  
Unread 24-06-2002, 02:20
archiver archiver is offline
Forum Archival System
#0047 (ChiefDelphi)
 
Join Date: May 2001
Location: Pontiac, MI
Posts: 21,214
archiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond repute
Re: Anyone looking for more program space?

Posted by Travis Hoffman at 03/15/2001 11:27 AM EST


Engineer on team #48, Delphi E.L.I.T.E., from Warren G. Harding High School and Delphi Automotive Systems .


In Reply to: Re: Anyone looking for more program space?
Posted by Stephen on 03/14/2001 9:10 PM EST:



: Hey,
: you were right next to us in the pits (team 122) - great job at VCU.

Thanks. I think. You and I were watching the same regional, right?

: any way, our code is 1300 + (comments included) lines of code, and the other day, it literally ran out of memory at "stop" so I just took "stop" out of the code, since the program never reaches it. With 4 potentiometers, 16 digital inputs, a y-cable for the joysticks, and 6 pre-defined positions, our code is just about as compressed as it can get. I would greatly appreciate any information on this feature - I have talked about it with the other programmers, and we just didn't have (well, at least I didn't have) information on how to use it. I mean, do you have multiple serin and serout commands (1 in each program), can the programs share common variables, do you get 26 bytes in each of the programs, or 26 total, to be shared amongst the programs, etc.

You still only get 26 total bytes of variable space. Variable and scratchpad RAM is shared by all the programs you download to the Basic Stamp.

At the beginning of your main control program listing (program 0), you should see a directive that looks something like the following:

' {$STAMP BS2SX}

Well, to break up your program into multiple programs, modify the directive to read

' {$STAMP BS2SX,program1,program2,...,program7}

Where programs 1-7 are the names of your subprograms stored in the same directory as program 0. Note that you don't have to have seven subprograms; you can break up your program however you like. You can also call the subprograms whatever you want.

Once you have modified the directive, create new programs using the names specified in the directive and save them to the same directory as your base program. For each subprogram, copy your ENTIRE variable declaration listing from the main program into every subprogram you create. I believe this would include everything in your program listed before the DEFINE CONSTANTS FOR INITIALIZATION section. Now you are ready to break apart your main program.

Assuming you want to break your control program into a main program (program 0) and two subprograms (programs 1 and 2), break your program up according to the following:

For Program 0:

(EVERYTHING IN YOUR PROGRAM UP TO AND INCLUDING THE "PBASIC - MASTER uP INITIALIZATION ROUTINE". This includes your custom variable initialization stuff.)

RUN 1 'Call Subprogram 1. Jump completely out of
'program 0, never to return until you reset

SUBROUTINES RELATED TO PROGRAM 0

**************END PROGRAM 0**********************

For Program 1:

VARIABLE DECLARATIONS

CONSTANT DECLARATIONS

SERIN Statement 'The first thing after the "MainLoop:"
'label in your original program.
'This is important.

(WHATEVER ELSE YOU WANT TO INCLUDE IN THIS SUBPROGRAM)

RUN 2 'Jump out of this program and into program 2

SUBROUTINES RELATED TO PROGRAM 1

******************END PROGRAM 1***********************

For Program 2:

VARIABLE DECLARATIONS

CONSTANT DECLARATIONS

(THE REST OF YOUR ORIGINAL CODE)

RUN 1 'Analogous to "GOTO MainLoop" in original code

STOP

SUBROUTINES RELATED TO PROGRAM 2

******************END PROGRAM 2**********************

That should be it. Make sure you individually save all your programs. Click on program 0 and download in the same manner as you have always done. Multiple progress bars will track the download status of each subprogram into the uP's EEPROM. To open your project in the future, just open program 0 and the rest will automatically open in the programming software.

Please test your new code thoroughly to make sure it does the same thing as your original program. In the future, if you make any changes to variable declarations or constants, YOU MUST MAKE CERTAIN you make these changes in ALL of your subprograms.

If you need more information, or I have confused you to the point of extreme annoyance, download the BASIC Stamp Windows 95/98/NT4.0 Interface Manual version 1.3 from the Parallax website using the link listed below.

Good Luck!

Travis

: : For all I know, this may already be common knowledge,
: : but does anyone need or want to know how to take advantage of the Basic Stamp II SX's ability to store and execute up to 8 2K-sized programs "at the same time"? After getting a headache trying to cram all the features of Xtremachen4's control program into a thimble sized 2K program, I got fed up and, darnit, I did something about it. I broke up the program into six separate subprograms, downloaded them to our backup control system, ran our Labview dashboard, and everything appeared to function correctly. I will have to wait to test the new setup on the actual control system at the Great Lakes regional, but for now, I feel that a great weight has been lifted off my shoulders. Huzzah!

: : Travis Hoffman, Controls Captain, Team #48
: : Beware of "The Claw"


__________________
This message was archived from an earlier forum system. Some information may have been left out. Start new discussion in the current forums, and refer back to these threads when necessary.