Shop OBEX P1 Docs P2 Docs Learn Events
out of variable on BS2p — Parallax Forums

out of variable on BS2p

ArchiverArchiver Posts: 46,084
edited 2003-05-09 13:30 in General Discussion
Hi, how do i deal with this problem,
i know it's not the first time someone ask, but i'm new
thanks
John

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-05-03 01:13
    John,

    Eventually we all run out of variable space as our projects get more bloated.
    There are two different things I do when this occurs. I either use some
    external eeprom or if this is not an option I will try to make a few of the
    variables non committed. As in I will use a few that change to accomodate the
    value for that instance.

    TEMP_1 VAR BYTE
    TEMP_2 VAR BYTE
    TEMP_3 VAR BYTE
    TEMP_4 VAR BYTE

    I'm sure if you analyze your code you will be able to find a way of
    implementing some temp variables that can be used for more then one instance.


    Hope this helps,


    In a message dated 5/2/2003 4:49:53 PM Pacific Daylight Time,
    johneck790@s... writes:

    > Subj: [noparse][[/noparse]basicstamps] out of variable on BS2p
    > Date: 5/2/2003 4:49:53 PM Pacific Daylight Time
    > From: <A HREF="mailto:johneck790@s...">johneck790@s...</A>
    > Reply-to: <A
    HREF="mailto:basicstamps@yahoogroups.com">basicstamps@yahoogroups.com</A>
    > To: <A
    HREF="mailto:basicstamps@yahoogroups.com">basicstamps@yahoogroups.com</A>
    > Sent from the Internet
    >
    >
    >
    > Hi, how do i deal with this problem,
    > i know it's not the first time someone ask, but i'm new
    > thanks
    > John
    >
    >

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-03 01:26
    Is your data truly variable, or can will it be constant numbers, values etc.

    If constant, you may want to try something suggested to me by the Guru
    himself, Jon Williams...

    Jon writes:

    Since there's not much RAM in the Stamp, I wonder if you know it advance what
    your patterns will be....· If this is the case, I would recomend storing your
    patterns in EEPROM and use a general-purpose routine to send them out.· I had
    a similar problem and Jon suggested storing the data in EEProm Something
    like this:


    PatternA····· DATA··· %00000000, %00000010, ....
    PatternB····· DATA··· %10000000, %01000000, ...

    Test:
    · eeAddr = PatternA
    · GOSBU Show_Leds
    · PAUSE 1000
    · eeAddr = PatternB
    · GOSBU Show_Leds
    · END

    Show_Leds:
    · FOR idx = 0 TO 22
    ··· READ eeAddr + idx, ledData
    ··· SHIFTOUT Dpin, Cpin, [noparse][[/noparse]ledData]
    · NEXT
    · ' latch out if using 74x595
    · RETURN


    -- Jon Williams



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-03 01:34
    Thanks,

    i appreciate your help, i just bought the bs2p plus pack and in it the is an
    24LC32 ic in it.
    could you give me an example how to used it for my extra variable.
    thanks in advance

    John
    Original Message
    From: <electronguy@a...>
    To: <basicstamps@yahoogroups.com>
    Sent: Friday, May 02, 2003 8:13 PM
    Subject: Re: [noparse][[/noparse]basicstamps] out of variable on BS2p


    > John,
    >
    > Eventually we all run out of variable space as our projects get more
    bloated.
    > There are two different things I do when this occurs. I either use some
    > external eeprom or if this is not an option I will try to make a few of
    the
    > variables non committed. As in I will use a few that change to accomodate
    the
    > value for that instance.
    >
    > TEMP_1 VAR BYTE
    > TEMP_2 VAR BYTE
    > TEMP_3 VAR BYTE
    > TEMP_4 VAR BYTE
    >
    > I'm sure if you analyze your code you will be able to find a way of
    > implementing some temp variables that can be used for more then one
    instance.
    >
    >
    > Hope this helps,
    >
    >
    > In a message dated 5/2/2003 4:49:53 PM Pacific Daylight Time,
    > johneck790@s... writes:
    >
    > > Subj: [noparse][[/noparse]basicstamps] out of variable on BS2p
    > > Date: 5/2/2003 4:49:53 PM Pacific Daylight Time
    > > From: <A
    HREF="mailto:johneck790@s...">johneck790@s...</A>
    > > Reply-to: <A
    HREF="mailto:basicstamps@yahoogroups.com">basicstamps@yahoogroups.com</A>
    > > To: <A
    HREF="mailto:basicstamps@yahoogroups.com">basicstamps@yahoogroups.com</A>
    > > Sent from the Internet
    > >
    > >
    > >
    > > Hi, how do i deal with this problem,
    > > i know it's not the first time someone ask, but i'm new
    > > thanks
    > > John
    > >
    > >
    >
    > [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/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-03 01:43
    Better planning is probably going to be the key, especially since you're new
    to Stamps. Keep in mind that the BASIC Stamp has four variable types (sizes)
    -- make sure you don't declare a variable with a size bigger than it needs to
    be:

    Bit - 1 bit ... 0 to 1
    Nib - 4 bits ... 0 to 15
    Byte - 8 bits ... 0 to 255
    Word - 16 its ... 0 to 65535

    Also remember that you can reuse variable space by aliasing -- giving the
    same RAM location so your program "reads" nicely. You just have to make sure
    that aliased variables aren't used at the same time -- a change in one
    affects the other.

    -- Jon Williams
    -- Parallax

    In a message dated 5/2/2003 6:49:40 PM Central Standard Time,
    johneck790@s... writes:

    > Hi, how do i deal with this problem,
    > i know it's not the first time someone ask, but i'm new
    > thanks
    > John



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-03 01:46
    Again, check your program design. In over nine years of working with BASIC
    Stamps, only ONE time have I every "run out" of variables. As it turned out,
    the program had a second mode so I could alias a bunch of vars and reset
    everything after that mode ended, which made sense because the mode had to do
    with reporgraming the data statements used by the project.

    In the BS2 series, all Stamps except the stock BS2 have a Scratchpad RAM area
    that can be used to hold data. You can't use it for variable space, per se,
    you can use it to store information temporarily and retrieve it later.

    Look up PUT and GET in the help file or manual to learn how to use the
    Scratchpad RAM.

    -- Jon Williams
    -- Parallax

    In a message dated 5/2/2003 7:37:04 PM Central Standard Time,
    johneck790@s... writes:

    > Thanks,
    >
    > i appreciate your help, i just bought the bs2p plus pack and in it the is
    > an
    > 24LC32 ic in it.
    > could you give me an example how to used it for my extra variable.
    > thanks in advance
    >
    > John



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-09 08:07
    Thanks Jon,

    You did it again with your good advice.
    I used PUT and GET and with 3 extra BYTE var i save 9 WORD var
    space...great!!!!!
    my robot program used 56% of the internal EEPROM and it's not finish.
    now i got to find what to do with my external EEPROM.
    anybody got any ideas...

    John

    ps: keep up the good work
    Original Message
    From: <jonwms@a...>
    To: <basicstamps@yahoogroups.com>
    Sent: Friday, May 02, 2003 8:46 PM
    Subject: Re: [noparse][[/noparse]basicstamps] out of variable on BS2p


    > Again, check your program design. In over nine years of working with
    BASIC
    > Stamps, only ONE time have I every "run out" of variables. As it turned
    out,
    > the program had a second mode so I could alias a bunch of vars and reset
    > everything after that mode ended, which made sense because the mode had to
    do
    > with reporgraming the data statements used by the project.
    >
    > In the BS2 series, all Stamps except the stock BS2 have a Scratchpad RAM
    area
    > that can be used to hold data. You can't use it for variable space, per
    se,
    > you can use it to store information temporarily and retrieve it later.
    >
    > Look up PUT and GET in the help file or manual to learn how to use the
    > Scratchpad RAM.
    >
    > -- Jon Williams
    > -- Parallax
    >
    > In a message dated 5/2/2003 7:37:04 PM Central Standard Time,
    > johneck790@s... writes:
    >
    > > Thanks,
    > >
    > > i appreciate your help, i just bought the bs2p plus pack and in it the
    is
    > > an
    > > 24LC32 ic in it.
    > > could you give me an example how to used it for my extra variable.
    > > thanks in advance
    > >
    > > John
    >
    >
    >
    > [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/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-09 13:30
    Since you're using a BS2p I would suggest looking into the many I2C devices,
    both RAM and EEPROMs are available and very easy to use. You get a
    double-whammy with the PCF8583 in that it's a real-time-clock with 240 extra
    bytes of RAM.

    The I2C buss has become one of my personal technology favorites lately. It's
    very easy to use (even with a stock BS2), and there are thousands of devices
    available -- many that will probably serve your robotics project well.

    -- Jon Williams
    -- Parallax

    In a message dated 5/9/2003 2:10:19 AM Central Standard Time,
    johneck790@s... writes:

    > Thanks Jon,
    >
    > You did it again with your good advice.
    > I used PUT and GET and with 3 extra BYTE var i save 9 WORD var
    > space...great!!!!!
    > my robot program used 56% of the internal EEPROM and it's not finish.
    > now i got to find what to do with my external EEPROM.
    > anybody got any ideas...
    >
    > John
    >
    > ps: keep up the good work
    >



    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.