3000 lines of code?
Archiver
Posts: 46,084
Hello.
I'm writing a controller using the BS2SX stamp. My
code, so far, is about 350 lines long and yet I'm
running out of code space! I think maybe I'm doing
something fundimentally wrong here but I'm clueless as
to what it could be.
Any suggestions?
Steve
__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
I'm writing a controller using the BS2SX stamp. My
code, so far, is about 350 lines long and yet I'm
running out of code space! I think maybe I'm doing
something fundimentally wrong here but I'm clueless as
to what it could be.
Any suggestions?
Steve
__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
Comments
Ifg I'm not mistaken, the BS2SX has 8 2k byte memory banks. Go to Parallax
site and look for the Stamp Manual and it explains how to run programs in the
different slots.
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
Original Message
From: "Steve Kershaw" <steve_kershaw@y...>
To: <basicstamps@yahoogroups.com>
Sent: Wednesday, May 22, 2002 6:21 PM
Subject: [noparse][[/noparse]basicstamps] 3000 lines of code?
> Hello.
>
> I'm writing a controller using the BS2SX stamp. My
> code, so far, is about 350 lines long and yet I'm
> running out of code space! I think maybe I'm doing
> something fundimentally wrong here but I'm clueless as
> to what it could be.
>
> Any suggestions?
>
> Steve
>
>
>
> __________________________________________________
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
I'm writing a controller for my 180 gallon aquarium.
--- In basicstamps@y..., "David Wright" <dwright3@a...> wrote:
> Dude, what kind of controller? What are you trying to do?
>
>
>
Original Message
> From: "Steve Kershaw" <steve_kershaw@y...>
> To: <basicstamps@y...>
> Sent: Wednesday, May 22, 2002 6:21 PM
> Subject: [noparse][[/noparse]basicstamps] 3000 lines of code?
>
>
> > Hello.
> >
> > I'm writing a controller using the BS2SX stamp. My
> > code, so far, is about 350 lines long and yet I'm
> > running out of code space! I think maybe I'm doing
> > something fundimentally wrong here but I'm clueless as
> > to what it could be.
> >
> > Any suggestions?
> >
> > Steve
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > LAUNCH - Your Yahoo! Music Experience
> > http://launch.yahoo.com
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@y...
> > from the same email address that you subscribed. Text in the
Subject and
> Body of the message will be ignored.
> >
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
was the coolest. 350 lines? Wow : ) You must be using it to check ph,
salinity,....etc. I remember my aquarium was pretty labor intensive. That
would have been cool to set up a controller to do all that stuff, but that
does sound like a lot of code for that. Tell me what you are trying to do.
Original Message
From: "steve_kershaw" <steve_kershaw@y...>
To: <basicstamps@yahoogroups.com>
Sent: Wednesday, May 22, 2002 7:52 PM
Subject: [noparse][[/noparse]basicstamps] Re: 3000 lines of code?
> Dude,
> I'm writing a controller for my 180 gallon aquarium.
>
> --- In basicstamps@y..., "David Wright" <dwright3@a...> wrote:
> > Dude, what kind of controller? What are you trying to do?
> >
> >
> >
Original Message
> > From: "Steve Kershaw" <steve_kershaw@y...>
> > To: <basicstamps@y...>
> > Sent: Wednesday, May 22, 2002 6:21 PM
> > Subject: [noparse][[/noparse]basicstamps] 3000 lines of code?
> >
> >
> > > Hello.
> > >
> > > I'm writing a controller using the BS2SX stamp. My
> > > code, so far, is about 350 lines long and yet I'm
> > > running out of code space! I think maybe I'm doing
> > > something fundimentally wrong here but I'm clueless as
> > > to what it could be.
> > >
> > > Any suggestions?
> > >
> > > Steve
> > >
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > LAUNCH - Your Yahoo! Music Experience
> > > http://launch.yahoo.com
> > >
> > > To UNSUBSCRIBE, just send mail to:
> > > basicstamps-unsubscribe@y...
> > > from the same email address that you subscribed. Text in the
> Subject and
> > Body of the message will be ignored.
> > >
> > >
> > > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
> > >
> > >
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
... but it will depend on what you're doing. The big thing to look for are
opportunities to eliminate HIGH and LOW statements. Not that these use a lot
of code space, but they can be redundant in that they affect Dirs [noparse][[/noparse]redundant]
and Outs register as well -- this takes code.
I see this kind of thing a lot:
HIGH 0
LOW 1
HIGH 2
HIGH 3
... Long sequences like this sprinkled through the program. You can save
code by setting the Dirs register once:
DirA = %1111
... then:
OutA = %1011
This is the most common code-space consumer that I see, and there are others.
It would seem to me that you could easily build a nifty fish-tank controller
with a BS2sx -- using just one code bank. But then, I don't know what
features you're attempting to program into it.
-- Jon Williams
-- Applications Engineer, Parallax
In a message dated 5/22/02 7:04:40 PM Central Daylight Time,
steve_kershaw@y... writes:
> I'm writing a controller using the BS2SX stamp. My
> code, so far, is about 350 lines long and yet I'm
> running out of code space! I think maybe I'm doing
> something fundimentally wrong here but I'm clueless as
> to what it could be.
>
>
[noparse][[/noparse]Non-text portions of this message have been removed]
They cover a whole bunch of articles on the various Stamp models including
some very unique, space-saving code examples. Jon Williams, who works for
Parallax and authored a good portion of the articles is the supreme expert
on compressing programs into their smallest possible form.
> I'm writing a controller using the BS2SX stamp. My
> code, so far, is about 350 lines long and yet I'm
> running out of code space! I think maybe I'm doing
> something fundimentally wrong here but I'm clueless as
> to what it could be.
The controller is pretty extensive and I'm going to
need much more than 300-450 lines of code (more like
1000 lines). I've been looking online at the Basic
Stamp manual 2.0 and it has some information on how I
can load different "slots" with code, but I haven't
yet figured out how I can call code in (say) slot 1
from code in slot 0. Any suggestions?!
Steve
--- jonwms@a... wrote:
> You can usually expect to get "about" 450 - 500
> lines of code in a 2K bank
> ... but it will depend on what you're doing. The
> big thing to look for are
> opportunities to eliminate HIGH and LOW statements.
> Not that these use a lot
> of code space, but they can be redundant in that
> they affect Dirs [noparse][[/noparse]redundant]
> and Outs register as well -- this takes code.
>
> I see this kind of thing a lot:
>
> HIGH 0
> LOW 1
> HIGH 2
> HIGH 3
>
> ... Long sequences like this sprinkled through the
> program. You can save
> code by setting the Dirs register once:
>
> DirA = %1111
>
> ... then:
>
> OutA = %1011
>
> This is the most common code-space consumer that I
> see, and there are others.
> It would seem to me that you could easily build a
> nifty fish-tank controller
> with a BS2sx -- using just one code bank. But then,
> I don't know what
> features you're attempting to program into it.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
>
>
>
>
> In a message dated 5/22/02 7:04:40 PM Central
> Daylight Time,
> steve_kershaw@y... writes:
>
>
> > I'm writing a controller using the BS2SX stamp. My
> > code, so far, is about 350 lines long and yet I'm
> > running out of code space! I think maybe I'm doing
> > something fundimentally wrong here but I'm
> clueless as
> > to what it could be.
> >
> >
>
>
>
>
> [noparse][[/noparse]Non-text portions of this message have been
> removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
columns is helpful in this situation. Briefly, it looks like this:
Init:
GET 0, task
Main:
' do stuff that happens every iteration of main loop
BRANCH task, [noparse][[/noparse]Task_0, Task_1, .... Task_n]
task = 0
GOTO Main
Task_0:
' do task 0 stuff; update task variable
GOTO Main
Task_1:
' do task 1 stuff; update task variable
GOTO Main
Task_n:
' call code in slot 1
PUT 0, x ' start with task x on return from slot 1
PUT 1, y ' run task y in slot 1
RUN 1
When you need to "call" a routine in Slot 1, you PUT your next task and the
task to run in Slot 1 into the SPRAM, then run the program in Slot 1.
Structurally, the code is similar in both slots except that Slot 1 GETs its
task value from SPRAM address 1 and ends each of its tasks with RUN 0
(instead of GOTO Main) to cause it to "return."
Using this technique is the closest I've come to having subroutines in
another slot.
Good luck with your project.
-- Jon Williams
-- Applications Engineer, Parallax
In a message dated 5/22/02 10:22:59 PM Central Daylight Time,
steve_kershaw@y... writes:
> The controller is pretty extensive and I'm going to
> need much more than 300-450 lines of code (more like
> 1000 lines). I've been looking online at the Basic
> Stamp manual 2.0 and it has some information on how I
> can load different "slots" with code, but I haven't
> yet figured out how I can call code in (say) slot 1
>
[noparse][[/noparse]Non-text portions of this message have been removed]
http://www.owlogic.com/BS2SX.htm
-- Tracy
>Thanks Jon,
>The controller is pretty extensive and I'm going to
>need much more than 300-450 lines of code (more like
>1000 lines). I've been looking online at the Basic
>Stamp manual 2.0 and it has some information on how I
>can load different "slots" with code, but I haven't
>yet figured out how I can call code in (say) slot 1
>from code in slot 0. Any suggestions?!
>
>Steve
>
troubleshooting purposes. When the program is running properly I
eliminate these and available eeprom space increases, sometimes
dramatically. Maybe you are doing the same thing.
--- In basicstamps@y..., Steve Kershaw <steve_kershaw@y...> wrote:
> Hello.
>
> I'm writing a controller using the BS2SX stamp. My
> code, so far, is about 350 lines long and yet I'm
> running out of code space! I think maybe I'm doing
> something fundimentally wrong here but I'm clueless as
> to what it could be.
>
> Any suggestions?
>
> Steve
>
>
>
> __________________________________________________
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com
with that many lines you may have some duplicate proceedures.
if you are doing math on raw sensor inputs there may be some way to
save space. if you are doing a pre-filter, filter, smoothing, data-
logging and a PID loop.....
If you are duplicating things like a PID loop, you might be able to
use the same loop for different processes.
Another thought would be to go over your code and see what process
takes the most code. Then toss that section to the wolves (this
group) and the chances are pretty good there will be some suggestions
on how to streamline it.
of course you would take the new biggest section and see if you can
make it tighter.
hope that helps.
Dave
--- In basicstamps@y..., Steve Kershaw <steve_kershaw@y...> wrote:
> Thanks Jon,
> The controller is pretty extensive and I'm going to
> need much more than 300-450 lines of code (more like
> 1000 lines). I've been looking online at the Basic
> Stamp manual 2.0 and it has some information on how I
> can load different "slots" with code, but I haven't
> yet figured out how I can call code in (say) slot 1
> from code in slot 0. Any suggestions?!
>
> Steve
>
> --- jonwms@a... wrote:
> > You can usually expect to get "about" 450 - 500
> > lines of code in a 2K bank
> > ... but it will depend on what you're doing. The
> > big thing to look for are
> > opportunities to eliminate HIGH and LOW statements.
> > Not that these use a lot
> > of code space, but they can be redundant in that
> > they affect Dirs [noparse][[/noparse]redundant]
> > and Outs register as well -- this takes code.
> >
> > I see this kind of thing a lot:
> >
> > HIGH 0
> > LOW 1
> > HIGH 2
> > HIGH 3
> >
> > ... Long sequences like this sprinkled through the
> > program. You can save
> > code by setting the Dirs register once:
> >
> > DirA = %1111
> >
> > ... then:
> >
> > OutA = %1011
> >
> > This is the most common code-space consumer that I
> > see, and there are others.
> > It would seem to me that you could easily build a
> > nifty fish-tank controller
> > with a BS2sx -- using just one code bank. But then,
> > I don't know what
> > features you're attempting to program into it.
> >
> > -- Jon Williams
> > -- Applications Engineer, Parallax
> >
> >
> >
> >
> > In a message dated 5/22/02 7:04:40 PM Central
> > Daylight Time,
> > steve_kershaw@y... writes:
> >
> >
> > > I'm writing a controller using the BS2SX stamp. My
> > > code, so far, is about 350 lines long and yet I'm
> > > running out of code space! I think maybe I'm doing
> > > something fundimentally wrong here but I'm
> > clueless as
> > > to what it could be.
> > >
> > >
> >
> >
> >
> >
> > [noparse][[/noparse]Non-text portions of this message have been
> > removed]
> >
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@y...
> > from the same email address that you subscribed.
> > Text in the Subject and Body of the message will be
> > ignored.
> >
> >
> > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com
Thank you.
Steve
--- jonwms@a... wrote:
> Using the task switching design I've described in
> several of my Nuts & Volts
> columns is helpful in this situation. Briefly, it
> looks like this:
>
> Init:
> GET 0, task
>
> Main:
> ' do stuff that happens every iteration of main
> loop
>
> BRANCH task, [noparse][[/noparse]Task_0, Task_1, .... Task_n]
> task = 0
> GOTO Main
>
> Task_0:
> ' do task 0 stuff; update task variable
> GOTO Main
>
> Task_1:
> ' do task 1 stuff; update task variable
> GOTO Main
>
> Task_n:
> ' call code in slot 1
> PUT 0, x ' start with task x on return from slot
> 1
> PUT 1, y ' run task y in slot 1
> RUN 1
>
> When you need to "call" a routine in Slot 1, you PUT
> your next task and the
> task to run in Slot 1 into the SPRAM, then run the
> program in Slot 1.
> Structurally, the code is similar in both slots
> except that Slot 1 GETs its
> task value from SPRAM address 1 and ends each of its
> tasks with RUN 0
> (instead of GOTO Main) to cause it to "return."
>
> Using this technique is the closest I've come to
> having subroutines in
> another slot.
>
> Good luck with your project.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
>
>
> In a message dated 5/22/02 10:22:59 PM Central
> Daylight Time,
> steve_kershaw@y... writes:
>
>
> > The controller is pretty extensive and I'm going
> to
> > need much more than 300-450 lines of code (more
> like
> > 1000 lines). I've been looking online at the Basic
> > Stamp manual 2.0 and it has some information on
> how I
> > can load different "slots" with code, but I
> haven't
> > yet figured out how I can call code in (say) slot
> 1
> >
>
>
>
>
> [noparse][[/noparse]Non-text portions of this message have been
> removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
No, I'm not checking ph or anything like that. I'm
just turining on/off lights, main pump, UV, Protein
skimmer, etc. The on/off part isn't what's killing me
code length wise. It's the human-controller interface
that's doing me in, but now that I have the ability to
use the slots, I'm OK!
Steve
--- David Wright <dwright3@a...> wrote:
> Cool, I bet its a salt water, right? I used to have
> a saltwater aquarium. It
> was the coolest. 350 lines? Wow : ) You must be
> using it to check ph,
> salinity,....etc. I remember my aquarium was pretty
> labor intensive. That
> would have been cool to set up a controller to do
> all that stuff, but that
> does sound like a lot of code for that. Tell me what
> you are trying to do.
>
>
>
Original Message
> From: "steve_kershaw" <steve_kershaw@y...>
> To: <basicstamps@yahoogroups.com>
> Sent: Wednesday, May 22, 2002 7:52 PM
> Subject: [noparse][[/noparse]basicstamps] Re: 3000 lines of code?
>
>
> > Dude,
> > I'm writing a controller for my 180 gallon
> aquarium.
> >
> > --- In basicstamps@y..., "David Wright"
> <dwright3@a...> wrote:
> > > Dude, what kind of controller? What are you
> trying to do?
> > >
> > >
> > >
Original Message
> > > From: "Steve Kershaw" <steve_kershaw@y...>
> > > To: <basicstamps@y...>
> > > Sent: Wednesday, May 22, 2002 6:21 PM
> > > Subject: [noparse][[/noparse]basicstamps] 3000 lines of code?
> > >
> > >
> > > > Hello.
> > > >
> > > > I'm writing a controller using the BS2SX
> stamp. My
> > > > code, so far, is about 350 lines long and yet
> I'm
> > > > running out of code space! I think maybe I'm
> doing
> > > > something fundimentally wrong here but I'm
> clueless as
> > > > to what it could be.
> > > >
> > > > Any suggestions?
> > > >
> > > > Steve
> > > >
> > > >
> > > >
> > > >
> __________________________________________________
> > > > Do You Yahoo!?
> > > > LAUNCH - Your Yahoo! Music Experience
> > > > http://launch.yahoo.com
> > > >
> > > > To UNSUBSCRIBE, just send mail to:
> > > > basicstamps-unsubscribe@y...
> > > > from the same email address that you
> subscribed. Text in the
> > Subject and
> > > Body of the message will be ignored.
> > > >
> > > >
> > > > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> > > >
> > > >
> >
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> > from the same email address that you subscribed.
> Text in the Subject and
> Body of the message will be ignored.
> >
> >
> > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
> >
> >
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com