Shop OBEX P1 Docs P2 Docs Learn Events
3000 lines of code? — Parallax Forums

3000 lines of code?

ArchiverArchiver Posts: 46,084
edited 2002-05-24 03:11 in General Discussion
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

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 01:11
    For Steve

    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]
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 01:33
    Dude, what kind of controller? What are you trying to do?


    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/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 01:52
    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/
    > >
    > >
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 01:54
    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/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 02:08
    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]
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 03:09
    Seriously look into purchasing the Nuts and Volts of Basic Stamps books.
    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.
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 04:20
    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@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
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 11:56
    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]
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 16:27
    I have some info on cross-bank calls posted at

    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
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 19:18
    When I write a program I often include many DEBUG commands for
    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
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 23:47
    Hi Steve,

    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
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-24 03:07
    That did the trick!

    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
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-24 03:11
    Hi David,

    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
Sign In or Register to comment.