Shop OBEX P1 Docs P2 Docs Learn Events
Run 2 Program in BS2 — Parallax Forums

Run 2 Program in BS2

irivineirivine Posts: 18
edited 2008-11-04 05:52 in BASIC Stamp
it is possible to run 2 different programn on the same BS2 ?

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-10-31 06:10
    irivine -

    You haven't given us quite enough information to give you a proper answer to your question. Let me try rephrasing your question if I may. If you were to ask:

    Can I have two separate programs within a BS-2, the sum of the sizes of which do not exceed the 2K memory limit, and have them operate independently of each other, with some external event determining which one would be operational?

    The answer to that question is YES. Moreover, if you ask the same question of a BS-2sx or any other of the larger Stamp platforms, you can change the 2K limit mentioned above to an 8 x 2K limit (8 times larger) due to the banked memory feature which they contain. Just be aware that the 8 x 2K banked storage is not linear.

    I hope that answers your question. If not, we'll give it another shot with more information from you.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • irivineirivine Posts: 18
    edited 2008-11-03 08:15
    yes , i am refering to running 2 programn that does not exceed the memory space

    hw will i be about to do it ?

    i am also using the Board of Education Development Board - Serial Version , is there anyway that when i press the reset button , it will switch between the 2 programn



    thanks for the help
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-11-03 09:23
    irivine -

    Let's just look at the original question, and save any use of RESET until you understand the concept here. Here is an overview in pseudo-code:

    - - - - - - - - - - - - - - -

    Condition Pin 1

    Begin:

    If (Condition = 0) THEN GOTO RoutineOne ELSE GOTO RoutineTwo

    RoutineOne:

    DO

    'one set of instructions

    LOOP

    RoutineTwo:

    DO

    'a different set of instructions

    LOOP

    END

    - - - - - - - - - - - - - -

    Does that makes sense to you? There are many ways to accomplish what you asked, this is just one way.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • ArnoNLArnoNL Posts: 15
    edited 2008-11-03 09:54
    Hello,

    as I was looking for a solution to use full EEPROM memory of the BSpx I found the BSp manual with an example how to store 2 or more different programs in a BS2p (it will work for all BS with 8x2k memory). Find the link below:
    http://www.parallax.com/Portals/0/Downloads/docs/prod/book/bs2pCommnFeat.pdf

    Pages 25 to 28.

    Hope this helps you.

    Kind regards,

    Arno
  • irivineirivine Posts: 18
    edited 2008-11-03 10:45
    ya i know the concept u mention
  • irivineirivine Posts: 18
    edited 2008-11-03 14:32
    hi Bruce

    the following is the code that i have for my school project

    i have tried what u mention and understand the concept of using the IF...ELSE , GOTO Command

    but i still cannot get the actual condition i need to have to allow the 2 program to switch when i need either 1 of them

    Thanks for the time

    Best Regard
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-11-03 15:31
    irivine -

    I changed a few things in the method by which you get to each of the routines. Instead of GOTO we're now going to use GOSUB which is a concept with which I trust you are familiar.

    Please realize I'm not exactly sure what the expected outcome is to be (practically) of switching between the two programs. I set it up to dump to the LCD when the button is pressed. If that's not correct, it's easy enough to change it to meet your criteria.

    I also massaged some of the indents, removed a few lines of white space and added a few lines of white space in. I hope I didn't screw up the way your professor expects to see it. If so, my apologies, I just wanted to make it just that much more readable. It looks real good from a readability standpoint, and I do hope he takes that into consideration!

    The new "Mod1" version is attached to this message.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • irivineirivine Posts: 18
    edited 2008-11-03 16:21
    Hi Bruce

    i have try the mod code u uploaded . It does not switch to the other program when i press the reset button on the Development board

    do u know anyway that i could solve that part ?

    Thanks



    just a mention , i am currently using the ping sensor , 2x16 serial LCD[noparse][[/noparse]Backlit] and the Board of Education Development Board - Serial Version

    this whole project was to
    1)detect a object that is moving towards and away from the sensor , measuring its distance from the sensor·and spd its moving at
    2)detect the number of people that passby the sensor

    Thanks for helping

    Best Regards
  • irivineirivine Posts: 18
    edited 2008-11-04 01:31
    Help needed , need this urgently

    Ant help will be appreciate !

    Thanks !
  • SRLMSRLM Posts: 5,045
    edited 2008-11-04 02:23
    You need to add in some of your own code. Condition is always 0, so it always goes to subroutine 2.
  • irivineirivine Posts: 18
    edited 2008-11-04 04:04
    Hi SRLM

    which code will u be refering to ?
    I have got the code for my project , currently i just hope to get the switching of the program when i press the reset button of the Development Board

    is there any pin i have to assign that will trigger the condition into switching the 2 programs

    thanks
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-11-04 04:19
    irivine -

    Is there some reason why you NEED to use the RESET line? If the answer is YES it makes the program about 10 to 100 times more difficult and complex. That's not to say it can't be done but it's usually only attempted by seasoned Stamp programmers, not students with a deadline to meet.

    If you would merely use a standard pushbutton this program would have been done yesterday! Is that a problem?

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • SRLMSRLM Posts: 5,045
    edited 2008-11-04 05:30
    I was referring to the code posted by Bruce Bates.
  • irivineirivine Posts: 18
    edited 2008-11-04 05:52
    thanks

    i have figure out how to get the program to switch by adding a push button that is at pin 1 which will go with the code of mine

    Thanks for the help render =)
Sign In or Register to comment.